1
0
Fork 0
forked from OpenNeo/impress
impress/app/helpers/outfits_helper.rb

72 lines
2.3 KiB
Ruby
Raw Normal View History

2010-11-05 15:45:05 -07:00
module OutfitsHelper
def destination_tag(value)
hidden_field_tag 'destination', value, :id => nil
end
def latest_contribution_description(contribution)
user = contribution.user
contributed = contribution.contributed
2013-01-09 16:40:35 -08:00
t 'outfits.new.latest_contribution.description_html',
:user_link => link_to(user.name, user_contributions_path(user)),
:contributed_description => contributed_description(contributed, false)
end
def link_to_edit_outfit(content_or_outfit, outfit_or_options, options={})
if block_given?
content = capture_haml(&Proc.new)
outfit = content_or_outfit
options = outfit_or_options
else
content = content_or_outfit
outfit = outfit_or_options
end
query = outfit.to_query
query << "&outfit=#{outfit.id}" if user_signed_in? && outfit.user_id == current_user.id
link_to content, wardrobe_path(:anchor => query), options
end
2012-12-29 22:56:58 -08:00
def search_helper(filter)
key = translate("#{filter}.key")
default_value = translate("#{filter}.default_value")
content_tag :span, default_value, :class => 'search-helper',
'data-search-filter' => key
end
def search_query_description(base)
translate "#{base}.description_html",
:default_value => search_helper("#{base}.filter")
end
def search_query_with_helper(base)
translate "#{base}.query_html",
:filter_key => content_tag(:span, translate("#{base}.filter.key")),
:filter_value => search_helper("#{base}.filter")
end
2012-12-29 22:56:58 -08:00
def outfit_creation_summary(outfit)
user = outfit.user
user_link = link_to(user.name, user_contributions_path(user))
created_at_ago = content_tag(:abbr, time_ago_in_words(@outfit.created_at),
:title => @outfit.created_at)
translate 'outfits.show.creation_summary_html',
:user_link => user_link,
:created_at_ago => created_at_ago
end
def outfit_li_for(outfit)
class_name = outfit.starred? ? 'starred' : nil
content_tag :li, :class => class_name, &Proc.new
end
2010-11-05 15:45:05 -07:00
def pet_attribute_select(name, collection, value=nil)
select_tag name,
options_from_collection_for_select(collection, :id, :human_name, value)
end
def pet_name_tag(options={})
options = {:spellcheck => false, :id => nil}.merge(options)
text_field_tag 'name', nil, options
2010-11-05 15:45:05 -07:00
end
end