<%# # Collection This partial is used on the `index` and `show` pages to display a collection of resources in an HTML table. ## Local variables: - `collection_presenter`: An instance of [Administrate::Page::Collection][1]. The table presenter uses `ResourceDashboard::COLLECTION_ATTRIBUTES` to determine the columns displayed in the table - `resources`: An ActiveModel::Relation collection of resources to be displayed in the table. By default, the number of resources is limited by pagination or by a hard limit to prevent excessive page load times [1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection %> <% collection_presenter.attribute_types.each do |attr_name, attr_type| %> <% end %> <% [existing_action?(collection_presenter.resource_name, :edit), existing_action?(collection_presenter.resource_name, :destroy)].count(true).times do %> <% end %> <% resources.each do |resource| %> <%= %(role=link data-url=#{polymorphic_path([namespace, resource.becomes(User)])}) %> <% end %> > <% collection_presenter.attributes_for(resource).each do |attribute| %> <% end %> <% if existing_action? collection_presenter.resource_name, :edit %> <% end %> <% if existing_action? collection_presenter.resource_name, :destroy %> <% end %> <% end %>
<%= link_to(sanitized_order_params(page, collection_field_name).merge( collection_presenter.order_params_for(attr_name, key: collection_field_name) )) do %> <%= t( "helpers.label.#{collection_presenter.resource_name}.#{attr_name}", default: attr_name.to_s, ).titleize %> <% if collection_presenter.ordered_by?(attr_name) %> <% end %> <% end %>
<% if authorized_action? resource, :show -%> <%= render_field attribute %> <% end -%> <%= link_to( t("administrate.actions.edit"), [:edit, namespace, resource.becomes(User)], class: "action-edit", ) if authorized_action? resource, :edit%><%= link_to( t("administrate.actions.destroy"), [namespace, collection_presenter.resource_name == 'account_user' ? resource : resource.becomes(User)], class: "text-color-red", method: :delete, data: { confirm: t("administrate.actions.confirm") } ) if authorized_action? resource, :destroy %>