adding admin erb templates
converted haml ones don’t work
This commit is contained in:
parent
d9157f1ea2
commit
58ba745a7e
|
@ -0,0 +1,92 @@
|
|||
<%#
|
||||
# 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
|
||||
%>
|
||||
|
||||
<table aria-labelledby="page-title">
|
||||
<thead>
|
||||
<tr>
|
||||
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
|
||||
<th class="cell-label
|
||||
cell-label--<%= attr_type.html_class %>
|
||||
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
|
||||
" scope="col">
|
||||
<%= link_to(sanitized_order_params.merge(
|
||||
collection_presenter.order_params_for(attr_name)
|
||||
)) do %>
|
||||
<%= t(
|
||||
"helpers.label.#{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_tag(
|
||||
"administrate/sort_arrow.svg",
|
||||
"sort_arrow",
|
||||
width: "13",
|
||||
height: "13"
|
||||
) %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</th>
|
||||
<% end %>
|
||||
<% [valid_action?(:edit), valid_action?(:destroy)].count(true).times do %>
|
||||
<th scope="col"></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% resources.each do |resource| %>
|
||||
<tr class="js-table-row"
|
||||
tabindex="0"
|
||||
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) if valid_action? :show -%>
|
||||
>
|
||||
<% 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>
|
||||
</td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :edit %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.edit"),
|
||||
[:edit, namespace, resource],
|
||||
class: "action-edit",
|
||||
) %></td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :destroy %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.destroy"),
|
||||
[namespace, resource],
|
||||
class: "text-color-red",
|
||||
method: :delete,
|
||||
data: { confirm: t("administrate.actions.confirm") }
|
||||
) %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
|
@ -0,0 +1,42 @@
|
|||
<%#
|
||||
# Form Partial
|
||||
|
||||
This partial is rendered on a resource's `new` and `edit` pages,
|
||||
and renders all form fields for a resource's editable attributes.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<%= form_for([namespace, page.resource], html: { class: "form" }) do |f| %>
|
||||
<% if page.resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= pluralize(page.resource.errors.count, "error") %>
|
||||
prohibited this <%= page.resource_name %> from being saved:
|
||||
</h2>
|
||||
|
||||
<ul>
|
||||
<% page.resource.errors.full_messages.each do |message| %>
|
||||
<li class="flash-error"><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% page.attributes.each do |attribute| -%>
|
||||
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
||||
<%= render_field attribute, f: f %>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1,36 @@
|
|||
<%#
|
||||
# Edit
|
||||
|
||||
This view is the template for the edit page.
|
||||
|
||||
It displays a header, and renders the `_form` partial to do the heavy lifting.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to help display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.edit")} #{page.page_title}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.show")} #{page.page_title}",
|
||||
[namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :show %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<%= render "form", page: page %>
|
||||
</section>
|
|
@ -0,0 +1,53 @@
|
|||
<%#
|
||||
# Index
|
||||
|
||||
This view is the template for the index page.
|
||||
It is responsible for rendering the search bar, header and pagination.
|
||||
It renders the `_table` partial to display details about the resources.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Collection][1].
|
||||
Contains helper methods to help display a table,
|
||||
and knows which attributes should be displayed in the resource's table.
|
||||
- `resources`:
|
||||
An instance of `ActiveRecord::Relation` containing the resources
|
||||
that match the user's search criteria.
|
||||
By default, these resources are passed to the table partial to be displayed.
|
||||
- `search_term`:
|
||||
A string containing the term the user has searched for, if any.
|
||||
- `show_search_bar`:
|
||||
A boolean that determines if the search bar should be shown.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
|
||||
%>
|
||||
|
||||
<% content_for(:title) do %>
|
||||
<%= display_resource_name(page.resource_name) %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:search) do %>
|
||||
<% if show_search_bar %>
|
||||
<%= render "search", search_term: search_term %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title" id="page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.new")} #{page.resource_name.titleize.downcase}",
|
||||
[:new, namespace, page.resource_path],
|
||||
class: "button",
|
||||
) if valid_action? :new %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body main-content__body--flush">
|
||||
<%= render "collection", collection_presenter: page, resources: resources %>
|
||||
<%= paginate resources %>
|
||||
</section>
|
|
@ -0,0 +1,32 @@
|
|||
<%#
|
||||
# New
|
||||
|
||||
This view is the template for the "new resource" page.
|
||||
It displays a header, and then renders the `_form` partial
|
||||
to do the heavy lifting.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to help display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.new")} #{page.resource_name.titleize}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to t("administrate.actions.back"), :back, class: "button" %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<%= render "form", page: page %>
|
||||
</section>
|
|
@ -0,0 +1,49 @@
|
|||
<%#
|
||||
# Show
|
||||
|
||||
This view is the template for the show page.
|
||||
It renders the attributes of a resource,
|
||||
as well as a link to its edit page.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Show][1].
|
||||
Contains methods for accessing the resource to be displayed on the page,
|
||||
as well as helpers for describing how each attribute of the resource
|
||||
should be displayed.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.show")} #{page.page_title}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.edit")} #{page.page_title}",
|
||||
[:edit, namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :edit %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<dl>
|
||||
<% page.attributes.each do |attribute| %>
|
||||
<dt class="attribute-label">
|
||||
<%= t(
|
||||
"helpers.label.#{resource_name}.#{attribute.name}",
|
||||
default: attribute.name.titleize,
|
||||
) %>
|
||||
</dt>
|
||||
|
||||
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
|
||||
><%= render_field attribute %></dd>
|
||||
<% end %>
|
||||
</dl>
|
||||
</section>
|
|
@ -0,0 +1,92 @@
|
|||
<%#
|
||||
# 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
|
||||
%>
|
||||
|
||||
<table aria-labelledby="page-title">
|
||||
<thead>
|
||||
<tr>
|
||||
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
|
||||
<th class="cell-label
|
||||
cell-label--<%= attr_type.html_class %>
|
||||
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
|
||||
" scope="col">
|
||||
<%= link_to(sanitized_order_params.merge(
|
||||
collection_presenter.order_params_for(attr_name)
|
||||
)) do %>
|
||||
<%= t(
|
||||
"helpers.label.#{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_tag(
|
||||
"administrate/sort_arrow.svg",
|
||||
"sort_arrow",
|
||||
width: "13",
|
||||
height: "13"
|
||||
) %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</th>
|
||||
<% end %>
|
||||
<% [valid_action?(:edit), valid_action?(:destroy)].count(true).times do %>
|
||||
<th scope="col"></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% resources.each do |resource| %>
|
||||
<tr class="js-table-row"
|
||||
tabindex="0"
|
||||
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) if valid_action? :show -%>
|
||||
>
|
||||
<% 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>
|
||||
</td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :edit %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.edit"),
|
||||
[:edit, namespace, resource],
|
||||
class: "action-edit",
|
||||
) %></td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :destroy %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.destroy"),
|
||||
[namespace, resource],
|
||||
class: "text-color-red",
|
||||
method: :delete,
|
||||
data: { confirm: t("administrate.actions.confirm") }
|
||||
) %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
|
@ -0,0 +1,42 @@
|
|||
<%#
|
||||
# Form Partial
|
||||
|
||||
This partial is rendered on a resource's `new` and `edit` pages,
|
||||
and renders all form fields for a resource's editable attributes.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<%= form_for([namespace, page.resource], html: { class: "form" }) do |f| %>
|
||||
<% if page.resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= pluralize(page.resource.errors.count, "error") %>
|
||||
prohibited this <%= page.resource_name %> from being saved:
|
||||
</h2>
|
||||
|
||||
<ul>
|
||||
<% page.resource.errors.full_messages.each do |message| %>
|
||||
<li class="flash-error"><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% page.attributes.each do |attribute| -%>
|
||||
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
||||
<%= render_field attribute, f: f %>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1,36 @@
|
|||
<%#
|
||||
# Edit
|
||||
|
||||
This view is the template for the edit page.
|
||||
|
||||
It displays a header, and renders the `_form` partial to do the heavy lifting.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to help display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.edit")} #{page.page_title}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.show")} #{page.page_title}",
|
||||
[namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :show %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<%= render "form", page: page %>
|
||||
</section>
|
|
@ -0,0 +1,53 @@
|
|||
<%#
|
||||
# Index
|
||||
|
||||
This view is the template for the index page.
|
||||
It is responsible for rendering the search bar, header and pagination.
|
||||
It renders the `_table` partial to display details about the resources.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Collection][1].
|
||||
Contains helper methods to help display a table,
|
||||
and knows which attributes should be displayed in the resource's table.
|
||||
- `resources`:
|
||||
An instance of `ActiveRecord::Relation` containing the resources
|
||||
that match the user's search criteria.
|
||||
By default, these resources are passed to the table partial to be displayed.
|
||||
- `search_term`:
|
||||
A string containing the term the user has searched for, if any.
|
||||
- `show_search_bar`:
|
||||
A boolean that determines if the search bar should be shown.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
|
||||
%>
|
||||
|
||||
<% content_for(:title) do %>
|
||||
<%= display_resource_name(page.resource_name) %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:search) do %>
|
||||
<% if show_search_bar %>
|
||||
<%= render "search", search_term: search_term %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title" id="page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.new")} #{page.resource_name.titleize.downcase}",
|
||||
[:new, namespace, page.resource_path],
|
||||
class: "button",
|
||||
) if valid_action? :new %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body main-content__body--flush">
|
||||
<%= render "collection", collection_presenter: page, resources: resources %>
|
||||
<%= paginate resources %>
|
||||
</section>
|
|
@ -0,0 +1,32 @@
|
|||
<%#
|
||||
# New
|
||||
|
||||
This view is the template for the "new resource" page.
|
||||
It displays a header, and then renders the `_form` partial
|
||||
to do the heavy lifting.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to help display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.new")} #{page.resource_name.titleize}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to t("administrate.actions.back"), :back, class: "button" %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<%= render "form", page: page %>
|
||||
</section>
|
|
@ -0,0 +1,49 @@
|
|||
<%#
|
||||
# Show
|
||||
|
||||
This view is the template for the show page.
|
||||
It renders the attributes of a resource,
|
||||
as well as a link to its edit page.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Show][1].
|
||||
Contains methods for accessing the resource to be displayed on the page,
|
||||
as well as helpers for describing how each attribute of the resource
|
||||
should be displayed.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.show")} #{page.page_title}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.edit")} #{page.page_title}",
|
||||
[:edit, namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :edit %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<dl>
|
||||
<% page.attributes.each do |attribute| %>
|
||||
<dt class="attribute-label">
|
||||
<%= t(
|
||||
"helpers.label.#{resource_name}.#{attribute.name}",
|
||||
default: attribute.name.titleize,
|
||||
) %>
|
||||
</dt>
|
||||
|
||||
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
|
||||
><%= render_field attribute %></dd>
|
||||
<% end %>
|
||||
</dl>
|
||||
</section>
|
|
@ -0,0 +1,92 @@
|
|||
<%#
|
||||
# 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
|
||||
%>
|
||||
|
||||
<table aria-labelledby="page-title">
|
||||
<thead>
|
||||
<tr>
|
||||
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
|
||||
<th class="cell-label
|
||||
cell-label--<%= attr_type.html_class %>
|
||||
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
|
||||
" scope="col">
|
||||
<%= link_to(sanitized_order_params.merge(
|
||||
collection_presenter.order_params_for(attr_name)
|
||||
)) do %>
|
||||
<%= t(
|
||||
"helpers.label.#{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_tag(
|
||||
"administrate/sort_arrow.svg",
|
||||
"sort_arrow",
|
||||
width: "13",
|
||||
height: "13"
|
||||
) %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</th>
|
||||
<% end %>
|
||||
<% [valid_action?(:edit), valid_action?(:destroy)].count(true).times do %>
|
||||
<th scope="col"></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% resources.each do |resource| %>
|
||||
<tr class="js-table-row"
|
||||
tabindex="0"
|
||||
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) if valid_action? :show -%>
|
||||
>
|
||||
<% 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>
|
||||
</td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :edit %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.edit"),
|
||||
[:edit, namespace, resource],
|
||||
class: "action-edit",
|
||||
) %></td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :destroy %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.destroy"),
|
||||
[namespace, resource],
|
||||
class: "text-color-red",
|
||||
method: :delete,
|
||||
data: { confirm: t("administrate.actions.confirm") }
|
||||
) %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
|
@ -0,0 +1,42 @@
|
|||
<%#
|
||||
# Form Partial
|
||||
|
||||
This partial is rendered on a resource's `new` and `edit` pages,
|
||||
and renders all form fields for a resource's editable attributes.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<%= form_for([namespace, page.resource], html: { class: "form" }) do |f| %>
|
||||
<% if page.resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= pluralize(page.resource.errors.count, "error") %>
|
||||
prohibited this <%= page.resource_name %> from being saved:
|
||||
</h2>
|
||||
|
||||
<ul>
|
||||
<% page.resource.errors.full_messages.each do |message| %>
|
||||
<li class="flash-error"><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% page.attributes.each do |attribute| -%>
|
||||
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
||||
<%= render_field attribute, f: f %>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1,36 @@
|
|||
<%#
|
||||
# Edit
|
||||
|
||||
This view is the template for the edit page.
|
||||
|
||||
It displays a header, and renders the `_form` partial to do the heavy lifting.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to help display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.edit")} #{page.page_title}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.show")} #{page.page_title}",
|
||||
[namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :show %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<%= render "form", page: page %>
|
||||
</section>
|
|
@ -0,0 +1,53 @@
|
|||
<%#
|
||||
# Index
|
||||
|
||||
This view is the template for the index page.
|
||||
It is responsible for rendering the search bar, header and pagination.
|
||||
It renders the `_table` partial to display details about the resources.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Collection][1].
|
||||
Contains helper methods to help display a table,
|
||||
and knows which attributes should be displayed in the resource's table.
|
||||
- `resources`:
|
||||
An instance of `ActiveRecord::Relation` containing the resources
|
||||
that match the user's search criteria.
|
||||
By default, these resources are passed to the table partial to be displayed.
|
||||
- `search_term`:
|
||||
A string containing the term the user has searched for, if any.
|
||||
- `show_search_bar`:
|
||||
A boolean that determines if the search bar should be shown.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
|
||||
%>
|
||||
|
||||
<% content_for(:title) do %>
|
||||
<%= display_resource_name(page.resource_name) %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:search) do %>
|
||||
<% if show_search_bar %>
|
||||
<%= render "search", search_term: search_term %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title" id="page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.new")} #{page.resource_name.titleize.downcase}",
|
||||
[:new, namespace, page.resource_path],
|
||||
class: "button",
|
||||
) if valid_action? :new %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body main-content__body--flush">
|
||||
<%= render "collection", collection_presenter: page, resources: resources %>
|
||||
<%= paginate resources %>
|
||||
</section>
|
|
@ -0,0 +1,32 @@
|
|||
<%#
|
||||
# New
|
||||
|
||||
This view is the template for the "new resource" page.
|
||||
It displays a header, and then renders the `_form` partial
|
||||
to do the heavy lifting.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to help display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.new")} #{page.resource_name.titleize}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to t("administrate.actions.back"), :back, class: "button" %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<%= render "form", page: page %>
|
||||
</section>
|
|
@ -0,0 +1,49 @@
|
|||
<%#
|
||||
# Show
|
||||
|
||||
This view is the template for the show page.
|
||||
It renders the attributes of a resource,
|
||||
as well as a link to its edit page.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Show][1].
|
||||
Contains methods for accessing the resource to be displayed on the page,
|
||||
as well as helpers for describing how each attribute of the resource
|
||||
should be displayed.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.show")} #{page.page_title}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.edit")} #{page.page_title}",
|
||||
[:edit, namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :edit %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<dl>
|
||||
<% page.attributes.each do |attribute| %>
|
||||
<dt class="attribute-label">
|
||||
<%= t(
|
||||
"helpers.label.#{resource_name}.#{attribute.name}",
|
||||
default: attribute.name.titleize,
|
||||
) %>
|
||||
</dt>
|
||||
|
||||
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
|
||||
><%= render_field attribute %></dd>
|
||||
<% end %>
|
||||
</dl>
|
||||
</section>
|
|
@ -0,0 +1,92 @@
|
|||
<%#
|
||||
# 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
|
||||
%>
|
||||
|
||||
<table aria-labelledby="page-title">
|
||||
<thead>
|
||||
<tr>
|
||||
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
|
||||
<th class="cell-label
|
||||
cell-label--<%= attr_type.html_class %>
|
||||
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
|
||||
" scope="col">
|
||||
<%= link_to(sanitized_order_params.merge(
|
||||
collection_presenter.order_params_for(attr_name)
|
||||
)) do %>
|
||||
<%= t(
|
||||
"helpers.label.#{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_tag(
|
||||
"administrate/sort_arrow.svg",
|
||||
"sort_arrow",
|
||||
width: "13",
|
||||
height: "13"
|
||||
) %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</th>
|
||||
<% end %>
|
||||
<% [valid_action?(:edit), valid_action?(:destroy)].count(true).times do %>
|
||||
<th scope="col"></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% resources.each do |resource| %>
|
||||
<tr class="js-table-row"
|
||||
tabindex="0"
|
||||
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) if valid_action? :show -%>
|
||||
>
|
||||
<% 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>
|
||||
</td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :edit %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.edit"),
|
||||
[:edit, namespace, resource],
|
||||
class: "action-edit",
|
||||
) %></td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :destroy %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.destroy"),
|
||||
[namespace, resource],
|
||||
class: "text-color-red",
|
||||
method: :delete,
|
||||
data: { confirm: t("administrate.actions.confirm") }
|
||||
) %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
|
@ -0,0 +1,42 @@
|
|||
<%#
|
||||
# Form Partial
|
||||
|
||||
This partial is rendered on a resource's `new` and `edit` pages,
|
||||
and renders all form fields for a resource's editable attributes.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<%= form_for([namespace, page.resource], html: { class: "form" }) do |f| %>
|
||||
<% if page.resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= pluralize(page.resource.errors.count, "error") %>
|
||||
prohibited this <%= page.resource_name %> from being saved:
|
||||
</h2>
|
||||
|
||||
<ul>
|
||||
<% page.resource.errors.full_messages.each do |message| %>
|
||||
<li class="flash-error"><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% page.attributes.each do |attribute| -%>
|
||||
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
||||
<%= render_field attribute, f: f %>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1,36 @@
|
|||
<%#
|
||||
# Edit
|
||||
|
||||
This view is the template for the edit page.
|
||||
|
||||
It displays a header, and renders the `_form` partial to do the heavy lifting.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to help display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.edit")} #{page.page_title}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.show")} #{page.page_title}",
|
||||
[namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :show %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<%= render "form", page: page %>
|
||||
</section>
|
|
@ -0,0 +1,53 @@
|
|||
<%#
|
||||
# Index
|
||||
|
||||
This view is the template for the index page.
|
||||
It is responsible for rendering the search bar, header and pagination.
|
||||
It renders the `_table` partial to display details about the resources.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Collection][1].
|
||||
Contains helper methods to help display a table,
|
||||
and knows which attributes should be displayed in the resource's table.
|
||||
- `resources`:
|
||||
An instance of `ActiveRecord::Relation` containing the resources
|
||||
that match the user's search criteria.
|
||||
By default, these resources are passed to the table partial to be displayed.
|
||||
- `search_term`:
|
||||
A string containing the term the user has searched for, if any.
|
||||
- `show_search_bar`:
|
||||
A boolean that determines if the search bar should be shown.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
|
||||
%>
|
||||
|
||||
<% content_for(:title) do %>
|
||||
<%= display_resource_name(page.resource_name) %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:search) do %>
|
||||
<% if show_search_bar %>
|
||||
<%= render "search", search_term: search_term %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title" id="page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.new")} #{page.resource_name.titleize.downcase}",
|
||||
[:new, namespace, page.resource_path],
|
||||
class: "button",
|
||||
) if valid_action? :new %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body main-content__body--flush">
|
||||
<%= render "collection", collection_presenter: page, resources: resources %>
|
||||
<%= paginate resources %>
|
||||
</section>
|
|
@ -0,0 +1,32 @@
|
|||
<%#
|
||||
# New
|
||||
|
||||
This view is the template for the "new resource" page.
|
||||
It displays a header, and then renders the `_form` partial
|
||||
to do the heavy lifting.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to help display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.new")} #{page.resource_name.titleize}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to t("administrate.actions.back"), :back, class: "button" %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<%= render "form", page: page %>
|
||||
</section>
|
|
@ -0,0 +1,49 @@
|
|||
<%#
|
||||
# Show
|
||||
|
||||
This view is the template for the show page.
|
||||
It renders the attributes of a resource,
|
||||
as well as a link to its edit page.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Show][1].
|
||||
Contains methods for accessing the resource to be displayed on the page,
|
||||
as well as helpers for describing how each attribute of the resource
|
||||
should be displayed.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.show")} #{page.page_title}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.edit")} #{page.page_title}",
|
||||
[:edit, namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :edit %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<dl>
|
||||
<% page.attributes.each do |attribute| %>
|
||||
<dt class="attribute-label">
|
||||
<%= t(
|
||||
"helpers.label.#{resource_name}.#{attribute.name}",
|
||||
default: attribute.name.titleize,
|
||||
) %>
|
||||
</dt>
|
||||
|
||||
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
|
||||
><%= render_field attribute %></dd>
|
||||
<% end %>
|
||||
</dl>
|
||||
</section>
|
|
@ -0,0 +1,92 @@
|
|||
<%#
|
||||
# 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
|
||||
%>
|
||||
|
||||
<table aria-labelledby="page-title">
|
||||
<thead>
|
||||
<tr>
|
||||
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
|
||||
<th class="cell-label
|
||||
cell-label--<%= attr_type.html_class %>
|
||||
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
|
||||
" scope="col">
|
||||
<%= link_to(sanitized_order_params.merge(
|
||||
collection_presenter.order_params_for(attr_name)
|
||||
)) do %>
|
||||
<%= t(
|
||||
"helpers.label.#{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_tag(
|
||||
"administrate/sort_arrow.svg",
|
||||
"sort_arrow",
|
||||
width: "13",
|
||||
height: "13"
|
||||
) %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</th>
|
||||
<% end %>
|
||||
<% [valid_action?(:edit), valid_action?(:destroy)].count(true).times do %>
|
||||
<th scope="col"></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% resources.each do |resource| %>
|
||||
<tr class="js-table-row"
|
||||
tabindex="0"
|
||||
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) if valid_action? :show -%>
|
||||
>
|
||||
<% 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>
|
||||
</td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :edit %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.edit"),
|
||||
[:edit, namespace, resource],
|
||||
class: "action-edit",
|
||||
) %></td>
|
||||
<% end %>
|
||||
|
||||
<% if valid_action? :destroy %>
|
||||
<td><%= link_to(
|
||||
t("administrate.actions.destroy"),
|
||||
[namespace, resource],
|
||||
class: "text-color-red",
|
||||
method: :delete,
|
||||
data: { confirm: t("administrate.actions.confirm") }
|
||||
) %></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
|
@ -0,0 +1,42 @@
|
|||
<%#
|
||||
# Form Partial
|
||||
|
||||
This partial is rendered on a resource's `new` and `edit` pages,
|
||||
and renders all form fields for a resource's editable attributes.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<%= form_for([namespace, page.resource], html: { class: "form" }) do |f| %>
|
||||
<% if page.resource.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2>
|
||||
<%= pluralize(page.resource.errors.count, "error") %>
|
||||
prohibited this <%= page.resource_name %> from being saved:
|
||||
</h2>
|
||||
|
||||
<ul>
|
||||
<% page.resource.errors.full_messages.each do |message| %>
|
||||
<li class="flash-error"><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% page.attributes.each do |attribute| -%>
|
||||
<div class="field-unit field-unit--<%= attribute.html_class %>">
|
||||
<%= render_field attribute, f: f %>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1,36 @@
|
|||
<%#
|
||||
# Edit
|
||||
|
||||
This view is the template for the edit page.
|
||||
|
||||
It displays a header, and renders the `_form` partial to do the heavy lifting.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to help display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.edit")} #{page.page_title}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.show")} #{page.page_title}",
|
||||
[namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :show %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<%= render "form", page: page %>
|
||||
</section>
|
|
@ -0,0 +1,53 @@
|
|||
<%#
|
||||
# Index
|
||||
|
||||
This view is the template for the index page.
|
||||
It is responsible for rendering the search bar, header and pagination.
|
||||
It renders the `_table` partial to display details about the resources.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Collection][1].
|
||||
Contains helper methods to help display a table,
|
||||
and knows which attributes should be displayed in the resource's table.
|
||||
- `resources`:
|
||||
An instance of `ActiveRecord::Relation` containing the resources
|
||||
that match the user's search criteria.
|
||||
By default, these resources are passed to the table partial to be displayed.
|
||||
- `search_term`:
|
||||
A string containing the term the user has searched for, if any.
|
||||
- `show_search_bar`:
|
||||
A boolean that determines if the search bar should be shown.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
|
||||
%>
|
||||
|
||||
<% content_for(:title) do %>
|
||||
<%= display_resource_name(page.resource_name) %>
|
||||
<% end %>
|
||||
|
||||
<% content_for(:search) do %>
|
||||
<% if show_search_bar %>
|
||||
<%= render "search", search_term: search_term %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title" id="page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.new")} #{page.resource_name.titleize.downcase}",
|
||||
[:new, namespace, page.resource_path],
|
||||
class: "button",
|
||||
) if valid_action? :new %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body main-content__body--flush">
|
||||
<%= render "collection", collection_presenter: page, resources: resources %>
|
||||
<%= paginate resources %>
|
||||
</section>
|
|
@ -0,0 +1,32 @@
|
|||
<%#
|
||||
# New
|
||||
|
||||
This view is the template for the "new resource" page.
|
||||
It displays a header, and then renders the `_form` partial
|
||||
to do the heavy lifting.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Form][1].
|
||||
Contains helper methods to help display a form,
|
||||
and knows which attributes should be displayed in the resource's form.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.new")} #{page.resource_name.titleize}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to t("administrate.actions.back"), :back, class: "button" %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<%= render "form", page: page %>
|
||||
</section>
|
|
@ -0,0 +1,49 @@
|
|||
<%#
|
||||
# Show
|
||||
|
||||
This view is the template for the show page.
|
||||
It renders the attributes of a resource,
|
||||
as well as a link to its edit page.
|
||||
|
||||
## Local variables:
|
||||
|
||||
- `page`:
|
||||
An instance of [Administrate::Page::Show][1].
|
||||
Contains methods for accessing the resource to be displayed on the page,
|
||||
as well as helpers for describing how each attribute of the resource
|
||||
should be displayed.
|
||||
|
||||
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
|
||||
%>
|
||||
|
||||
<% content_for(:title) { "#{t("administrate.actions.show")} #{page.page_title}" } %>
|
||||
|
||||
<header class="main-content__header" role="banner">
|
||||
<h1 class="main-content__page-title">
|
||||
<%= content_for(:title) %>
|
||||
</h1>
|
||||
|
||||
<div>
|
||||
<%= link_to(
|
||||
"#{t("administrate.actions.edit")} #{page.page_title}",
|
||||
[:edit, namespace, page.resource],
|
||||
class: "button",
|
||||
) if valid_action? :edit %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="main-content__body">
|
||||
<dl>
|
||||
<% page.attributes.each do |attribute| %>
|
||||
<dt class="attribute-label">
|
||||
<%= t(
|
||||
"helpers.label.#{resource_name}.#{attribute.name}",
|
||||
default: attribute.name.titleize,
|
||||
) %>
|
||||
</dt>
|
||||
|
||||
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
|
||||
><%= render_field attribute %></dd>
|
||||
<% end %>
|
||||
</dl>
|
||||
</section>
|
Loading…
Reference in New Issue