2011-07-26 17:27:23 -07:00
|
|
|
module ClosetListsHelper
|
2011-07-29 07:52:04 -07:00
|
|
|
def closet_list_delete_confirmation(closet_list)
|
|
|
|
"Are you sure you want to delete \"#{closet_list.name}\"?".tap do |msg|
|
|
|
|
unless closet_list.hangers.empty?
|
|
|
|
msg << " Even if you do, we'll remember that you " +
|
2011-07-30 21:22:36 -07:00
|
|
|
ClosetHanger.verb(:you, closet_list.hangers_owned) +
|
2011-07-29 07:52:04 -07:00
|
|
|
" these items."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def closet_list_description_format(list)
|
|
|
|
md = RDiscount.new(list.description)
|
|
|
|
Sanitize.clean(md.to_html, Sanitize::Config::BASIC).html_safe
|
|
|
|
end
|
|
|
|
|
2011-07-26 17:27:23 -07:00
|
|
|
def hangers_owned_options
|
|
|
|
@hangers_owned_options ||= [true, false].map do |owned|
|
|
|
|
verb = ClosetHanger.verb(:i, owned)
|
|
|
|
["items I #{verb}", owned]
|
|
|
|
end
|
|
|
|
end
|
2011-07-29 07:52:04 -07:00
|
|
|
|
|
|
|
def render_sorted_hangers(list, show_controls)
|
|
|
|
render :partial => 'closet_hanger',
|
|
|
|
:collection => list.hangers.sort { |x,y| x.item.name <=> y.item.name },
|
|
|
|
:locals => {:show_controls => show_controls}
|
|
|
|
end
|
2011-07-26 17:27:23 -07:00
|
|
|
end
|
|
|
|
|