<% # Variables: # * container => ActiveRecord instance that owns the Proposal records to show, e.g., a User. REQUIRED. # * records => Array of Proposal instances to display. Optional, defaults to #proposals method on +container+. # * title => Title of the container, e.g., "user". Optional, leave blank to guess based on container's class. # * header_tag => HTML tag used to wrap the header, defaults to :h3 # * header_prefix => Prefix to add to the title, e.g., "Favorite" # * show_sorter => Display the sort toolbar? Optional, defaults to false. container = local_assigns[:container] title = local_assigns[:title] header_tag ||= :h3 header_prefix = local_assigns[:header_prefix] show_sorter = local_assigns[:show_sorter] cache_key = "proposals,sub_list,container_#{container.class.name}_#{container.id},title_#{title}_#{header_prefix},admin_#{admin?},order_#{params[:sort]},dir_#{params[:dir]}" include_user_favorites_javascript %> <%= cache(cache_key) do %> <% # Defer expensive operations so they run within the cached block. ## The +displayer+ provides an easier way to render the partials. displayer = lambda{|kind, my_records, is_archived| render :partial => "open_conference_ware/proposals/sub_list_for_kind", :locals => { :kind => kind, :records => my_records, :container => container, :title => title, :header_tag => header_tag, :header_prefix => header_prefix, :show_sorter => show_sorter, :is_archived => is_archived, } } ## Get records from variable or through an association. records = local_assigns[:records] || OpenConferenceWare::Proposal.populated_proposals_for(container) ## Get events to organize records. events_to_records = records.select(&:event).group_by(&:event) events_by_deadline = events_to_records.keys.sort_by(&:deadline).reverse many_events = events_by_deadline.size > 1 %> <% events_by_deadline.each do |event| %>
"> <% event_records = events_to_records[event] %> <% if many_events %>

<%=h event.title %>

<% end %> <% if event.proposal_status_published? %> <% event_records_by_confirmation = event_records.group_by(&:confirmed?) %> <%= displayer.call(:sessions, event_records_by_confirmation[true], false) %> <% unless container.kind_of?(OpenConferenceWare::Room) %> <%= displayer.call(:proposals, event_records_by_confirmation[false], true) %> <% end %> <% run_when_dom_is_ready "archive_proposals_sub_list(#{event.id})" %> <% else %> <%= displayer.call(:proposals, event_records, false) %> <% end %>
<% end %><%# END: events_by_deadline.each %> <% end %><%# END: cache %>