Use latest admin page views from administrate gem (#1351)

This commit is contained in:
Andy Zhao 2018-12-17 16:45:12 -05:00 committed by Mac Siri
parent 28736cda20
commit 651a26a514
2 changed files with 19 additions and 12 deletions

View file

@ -28,14 +28,13 @@ to display a collection of resources in an HTML table.
scope="col"
role="columnheader"
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
<%= link_to(sanitized_order_params.merge(
collection_presenter.order_params_for(attr_name)
<%= 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) %>
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
<svg aria-hidden="true">
@ -63,11 +62,13 @@ to display a collection of resources in an HTML table.
>
<% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="cell-data cell-data--<%= attribute.html_class %>">
<a href="<%= polymorphic_path([namespace, resource]) -%>"
class="action-show"
>
<%= render_field attribute %>
</a>
<% if show_action? :show, resource -%>
<a href="<%= polymorphic_path([namespace, resource]) -%>"
class="action-show"
>
<%= render_field attribute %>
</a>
<% end -%>
</td>
<% end %>
@ -76,7 +77,7 @@ to display a collection of resources in an HTML table.
t("administrate.actions.edit"),
[:edit, namespace, resource],
class: "action-edit",
) %></td>
) if show_action? :edit, resource %></td>
<% end %>
<% if valid_action? :destroy, collection_presenter.resource_name %>
@ -86,7 +87,7 @@ to display a collection of resources in an HTML table.
class: "text-color-red",
method: :delete,
data: { confirm: t("administrate.actions.confirm") }
) %></td>
) if show_action? :destroy, resource %></td>
<% end %>
</tr>
<% end %>

View file

@ -31,6 +31,7 @@ It renders the `_table` partial to display details about the resources.
<h1 class="main-content__page-title" id="page-title">
<%= content_for(:title) %>
</h1>
<% if show_search_bar %>
<%= render(
"search",
@ -41,10 +42,13 @@ It renders the `_table` partial to display details about the resources.
<div>
<%= link_to(
"#{t("administrate.actions.new")} #{page.resource_name.titleize.downcase}",
t(
"administrate.actions.new_resource",
name: page.resource_name.titleize.downcase
),
[:new, namespace, page.resource_path],
class: "button",
) if valid_action? :new %>
) if valid_action?(:new) && show_action?(:new, new_resource) %>
</div>
</header>
@ -52,6 +56,8 @@ It renders the `_table` partial to display details about the resources.
<%= render(
"collection",
collection_presenter: page,
collection_field_name: resource_name,
page: page,
resources: resources,
table_title: "page-title"
) %>