<% content_for :content do %> <% if @collection %>
<% if @collection.num_pages < 2 %> <% if @collection.size == 0 %> No <%= @interface.collection.titleize %> found <% elsif @collection.size == 1 %> Displaying 1 <%= @interface.member.titleize %> <% else %> Displaying all <%= @collection.size %> <%= @interface.collection.titleize %> <% end %> <% elsif @collection.size == 1 %> Displaying <%= @interface.member.titleize %>: <%= pretty_format(@collection.first) %>; <%= @collection.total_count %> in total <% else %> Displaying <%= @interface.collection.titleize %> <%= (@collection.current_page * (params[:per_page] || SimpleAdmin.default_per_page).to_i) - (params[:per_page] || SimpleAdmin.default_per_page).to_i + 1 %> - <%= (@collection.current_page * (params[:per_page] || SimpleAdmin.default_per_page).to_i) > @collection.total_count ? @collection.total_count : (@collection.current_page * (params[:per_page] || SimpleAdmin.default_per_page).to_i) %> of <%= @collection.total_count %> in total <% end %> <% editable = @interface.attributes_for(:index).any? {|a| a.editable} %> <% if editable %> | <%= link_to((params[:editing] ? 'Stop Editing' : 'Edit'), request.query_parameters.merge(:editing => (params[:editing] ? nil : 1))) %> | <%= link_to((params[:mode] == 'approvals' ? 'Rows' : 'Approvals'), request.query_parameters.merge( :mode => (params[:mode] == 'approvals' ? nil : 'approvals'), :per_page => (params[:mode] == 'approvals' ? nil : 1))) %> <% end %>
<% if params[:mode] == 'approvals' %>
<%= paginate(@collection) %> <% if @resource = @collection.first %> <%= send(SimpleAdmin.form_for_helper, @resource, :as => @interface.member.to_sym, :url => resource_path(@resource), :id => "#{@interface.member}_#{@resource.id}", :html => {:onsubmit => "return false", :class => "inline simple_form formtastic #{@interface.member}"}) do |form| %> <%= form_fields(form, @interface.attributes_for(:index, 'approvals')) %> <% end %> <% end %>
<% else %>
<% @interface.attributes_for(:index).each do |col| %> <% end %> <% @collection.each do |object| %> <% @interface.attributes_for(:index).each do |col| %> <% end %> <% end %>
<%= link_to(col.title, request.query_parameters.merge(:order => "#{col.sort_key}_#{order_for_sort_key(col.sort_key)}").except(:page)) %>  
<% if col.editable && params[:editing] %> <%= send(SimpleAdmin.form_for_helper, object, :as => @interface.member.to_sym, :url => resource_path(object), :id => "#{@interface.member}_#{object.id}", :html => {:class => "inline simple_form formtastic #{@interface.member}"}) do |form| %> <%= form_field(form, col) %> <% end %> <% elsif col.data %> <%= instance_exec(object, &col.data) %> <% else %> <%= pretty_format(object.send(col.attribute)) %> <% end %> <%= resource_actions(object) %>
<% end %>
<% if params[:mode] != 'approvals' %> <%= paginate(@collection) %> <% end %>
<% end %> <% end %> <% content_for :filters do %> <% filters = @interface.filters_for(:index) %> <% unless filters.blank? %> <% end %> <% end %> <% content_for :sidebar do %> <%= sidebars %> <% end %>