Sha256: 1fbab9b8619133152acff92e030e814cc9c2a158bff6bbf69dd27bbd4905d99c

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

<%#
# HasMany Show Partial

This partial renders a has_many relationship,
to be displayed on a resource's show page.

By default, the relationship is rendered
as a table of the first few associated resources.
The columns of the table are taken
from the associated resource class's dashboard.

## Local variables:

- `field`:
  An instance of [Administrate::Field::HasMany][1].
  Contains methods to help display a table of associated resources.

[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/HasMany
%>

<% if field.resources.any? %>
  <% order = field.order_from_params(params.fetch(field.name, {})) %>
  <% page_number = params.fetch(field.name, {}).fetch(:page, nil) %>
  <%= render(
    "collection",
    collection_presenter: field.associated_collection(order),
    collection_field_name: field.name,
    page: page,
    resources: field.resources(page_number, order),
    table_title: field.name,
    resource_class: field.associated_class,
  ) %>
  <% if field.more_than_limit? %>
    <%= render("pagination", resources: field.resources(page_number), param_name: "#{field.name}[page]") %>
  <% end %>

<% else %>
  <%= t("administrate.fields.has_many.none", default: "–") %>
<% end %>

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
administrate-1.0.0.beta3 app/views/fields/has_many/_show.html.erb
administrate-1.0.0.beta2 app/views/fields/has_many/_show.html.erb
administrate-1.0.0.beta1 app/views/fields/has_many/_show.html.erb
administrate_tailwind_theme-0.0.3 app/views/fields/has_many/_show.html.erb
administrate_tailwind_theme-0.0.2 app/views/fields/has_many/_show.html.erb
administrate_tailwind_theme-0.0.1 app/views/fields/has_many/_show.html.erb
administrate-0.20.1 app/views/fields/has_many/_show.html.erb
administrate-0.20.0 app/views/fields/has_many/_show.html.erb
administrate-0.19.0 app/views/fields/has_many/_show.html.erb