2010-11-05 15:45:05 -07:00
|
|
|
module OutfitsHelper
|
2024-09-06 11:47:17 -07:00
|
|
|
LAST_DAY_OF_ANNOUNCEMENT = Date.parse("2024-09-13")
|
|
|
|
def show_announcement?
|
|
|
|
Date.today <= LAST_DAY_OF_ANNOUNCEMENT
|
2024-05-02 13:28:37 -07:00
|
|
|
end
|
|
|
|
|
2010-11-05 15:45:05 -07:00
|
|
|
def destination_tag(value)
|
|
|
|
hidden_field_tag 'destination', value, :id => nil
|
|
|
|
end
|
2012-12-29 22:46:36 -08:00
|
|
|
|
|
|
|
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',
|
2012-12-29 22:46:36 -08:00
|
|
|
:user_link => link_to(user.name, user_contributions_path(user)),
|
|
|
|
:contributed_description => contributed_description(contributed, false)
|
|
|
|
end
|
2013-12-08 20:59:36 -08:00
|
|
|
|
2013-12-14 15:19:27 -08:00
|
|
|
def render_predicted_missing_species_by_color(species_by_color)
|
2013-12-30 07:55:49 -08:00
|
|
|
key_prefix = 'outfits.new.newest_items.unmodeled.content'
|
|
|
|
|
2014-01-01 07:15:58 -08:00
|
|
|
# Transform the Color => (Species => Int) map into an Array<Pair<Color's
|
|
|
|
# human name (empty if standard), (Species => Int)>>.
|
2013-12-14 15:19:27 -08:00
|
|
|
standard = species_by_color.delete(:standard)
|
|
|
|
sorted_pairs = species_by_color.to_a.map { |k, v| [k.human_name, v] }.
|
|
|
|
sort_by { |k, v| k }
|
|
|
|
sorted_pairs.unshift(['', standard]) if standard
|
2013-12-26 20:36:48 -08:00
|
|
|
species_by_color[:standard] = standard # undo parameter mutation
|
2013-12-14 15:19:27 -08:00
|
|
|
|
|
|
|
first = true
|
2014-01-01 07:15:58 -08:00
|
|
|
contents = sorted_pairs.map { |color_human_name, body_ids_by_species|
|
|
|
|
species_list = body_ids_by_species.keys.sort_by(&:human_name).map { |species|
|
|
|
|
body_id = body_ids_by_species[species]
|
|
|
|
content_tag(:span, species.human_name, 'data-body-id' => body_id)
|
|
|
|
}.to_sentence(
|
2013-12-30 07:55:49 -08:00
|
|
|
words_connector: t("#{key_prefix}.species_list.words_connector"),
|
|
|
|
two_words_connector: t("#{key_prefix}.species_list.two_words_connector"),
|
2014-01-01 07:15:58 -08:00
|
|
|
last_word_connector: t("#{key_prefix}.species_list.last_word_connector")
|
|
|
|
)
|
2013-12-30 07:55:49 -08:00
|
|
|
key = first ? 'first' : 'other'
|
|
|
|
content = t("#{key_prefix}.body.#{key}", color: color_human_name,
|
2014-01-01 07:15:58 -08:00
|
|
|
species_list: species_list).html_safe
|
2013-12-14 15:19:27 -08:00
|
|
|
first = false
|
|
|
|
content
|
|
|
|
}
|
2013-12-30 07:55:49 -08:00
|
|
|
contents.last << " " + t("#{key_prefix}.call_to_action")
|
2013-12-14 15:19:27 -08:00
|
|
|
content_tags = contents.map { |c| content_tag(:p, c) }
|
|
|
|
content_tags.join('').html_safe
|
|
|
|
end
|
2011-03-23 15:23:01 -07:00
|
|
|
|
2023-08-03 16:37:45 -07:00
|
|
|
def outfit_li_for(outfit, &block)
|
2011-03-23 15:23:01 -07:00
|
|
|
class_name = outfit.starred? ? 'starred' : nil
|
2023-08-03 16:37:45 -07:00
|
|
|
content_tag :li, :class => class_name, &block
|
2011-03-23 15:23:01 -07:00
|
|
|
end
|
|
|
|
|
2024-02-08 10:07:09 -08:00
|
|
|
def outfit_image_tag(outfit)
|
|
|
|
image_tag(
|
|
|
|
outfit.image.small.url,
|
|
|
|
srcset: [[outfit.image.medium.url, "2x"]],
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2010-11-05 15:45:05 -07:00
|
|
|
def pet_attribute_select(name, collection, value=nil)
|
2015-07-16 19:37:04 -07:00
|
|
|
options = options_from_collection_for_select(collection, :id, :human_name, value)
|
|
|
|
select_tag name, options, id: nil, class: name
|
2010-11-05 15:45:05 -07:00
|
|
|
end
|
2011-03-23 15:23:01 -07:00
|
|
|
|
2010-11-07 14:19:47 -08:00
|
|
|
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
|
2011-03-23 15:23:01 -07:00
|
|
|
|