Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 23 additions & 66 deletions app/views/administrate/application/_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,22 @@ to display a collection of resources in an HTML table.

[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
%>
<%# locals: (collection_presenter:, collection_field_name:, page:, resources:, table_title:, resource_class: nil) %>

<table aria-labelledby="<%= table_title %>" data-controller="table" data-action="click->table#visitDataUrl keydown->table#visitDataUrl">
<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) %>
cell-label--<%= "#{collection_presenter.resource_name}_#{attr_name}" %>"
scope="col"
<% if attr_type.sortable? %>
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>"
<% end %>
>
<% if attr_type.sortable? %>
<%= link_to(params: 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: resource_class.human_attribute_name(attr_name).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">
<use xlink:href="#icon-up-caret" />
</svg>
</span>
<% end %>
<% end %>
<% else %>
<%= t(
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
default: resource_class.human_attribute_name(attr_name).titleize,
) %>
<% end %>
</th>
<% end %>
<%= render(
partial: 'collection_header_item',
layout: 'collection_header_item_layout',
collection: collection_presenter.attribute_types.to_a,
as: :attribute_type,
locals: {
collection_presenter: collection_presenter,
collection_field_name: collection_field_name,
page: page
}
) %>
<%= render(
"collection_header_actions",
collection_presenter: collection_presenter,
Expand All @@ -66,37 +44,16 @@ to display a collection of resources in an HTML table.
</thead>

<tbody>
<% resources.each do |resource| %>
<tr class="js-table-row"
<% if accessible_action?(resource, :show) %>
<%= %(tabindex=0 data-url=#{polymorphic_path([namespace, resource])}) %>
<% end %>
>
<% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="cell-data cell-data--<%= attribute.html_class %>">
<% if accessible_action?(resource, :show) -%>
<a href="<%= polymorphic_path([namespace, resource]) -%>"
tabindex="-1"
class="action-show"
>
<%= render_field attribute %>
</a>
<% else %>
<%= render_field attribute %>
<% end -%>
</td>
<% end %>

<%= render(
"collection_item_actions",
collection_presenter: collection_presenter,
collection_field_name: collection_field_name,
page: page,
namespace: namespace,
resource: resource,
table_title: "page-title"
) %>
</tr>
<% end %>
<%= render(
partial: "collection_item",
layout: "collection_item_layout",
collection: resources,
as: :resource,
locals: {
collection_presenter: collection_presenter,
collection_field_name: collection_field_name,
page: page
}
) %>
</tbody>
</table>
12 changes: 12 additions & 0 deletions app/views/administrate/application/_collection_field_item.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%# locals: (collection_presenter:, collection_field_name:, page:, resource:, attribute:, attribute_counter: nil, attribute_iteration: nil) %>

<% if accessible_action?(resource, :show) -%>
<a href="<%= polymorphic_path([namespace, resource]) -%>"
tabindex="-1"
class="action-show"
>
<%= render_field attribute %>
</a>
<% else %>
<%= render_field attribute %>
<% end -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<%# locals: (collection_presenter:, collection_field_name:, page:, resource:, attribute:, attribute_counter: nil, attribute_iteration: nil) %>

<td class="cell-data cell-data--<%= attribute.html_class %>">
<%= yield %>
</td>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<%# locals: (collection_presenter:, collection_field_name:, page:, attribute_type:, attribute_type_counter: nil, attribute_type_iteration: nil) %>
<% attr_name = attribute_type.first %>
<% attr_type = attribute_type.second %>

<% if attr_type.sortable? %>
<%= link_to(params: 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: resource_class.human_attribute_name(attr_name).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">
<use xlink:href="#icon-up-caret" />
</svg>
</span>
<% end %>
<% end %>
<% else %>
<%= t(
"helpers.label.#{collection_presenter.resource_name}.#{attr_name}",
default: resource_class.human_attribute_name(attr_name).titleize,
) %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<%# locals: (collection_presenter:, collection_field_name:, page:, attribute_type:, attribute_type_counter: nil, attribute_type_iteration: nil) %>
<% attr_name = attribute_type.first %>
<% attr_type = attribute_type.second %>

<th class="cell-label
cell-label--<%= attr_type.html_class %>
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
cell-label--<%= "#{collection_presenter.resource_name}_#{attr_name}" %>"
scope="col"
<% if attr_type.sortable? %>
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>"
<% end %>
>
<%= yield %>
</th>
14 changes: 14 additions & 0 deletions app/views/administrate/application/_collection_item.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<%# locals: (collection_presenter:, collection_field_name:, page:, resource:, resource_counter:, resource_iteration:) %>

<%= render(
partial: "collection_field_item",
layout: "collection_field_item_layout",
collection: collection_presenter.attributes_for(resource),
as: :attribute,
locals: {
collection_presenter: collection_presenter,
collection_field_name: collection_field_name,
page: page,
resource: resource
}
) %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<%# locals: (collection_presenter:, collection_field_name:, page:, resource:, resource_counter:, resource_iteration:) %>

<tr class="js-table-row"
<% if accessible_action?(resource, :show) %>
<%= %(tabindex=0 data-url=#{polymorphic_path([namespace, resource])}) %>
<% end %>
>

<%= yield %>

<%= render(
"collection_item_actions",
collection_presenter: collection_presenter,
collection_field_name: collection_field_name,
page: page,
namespace: namespace,
resource: resource
) %>
</tr>
19 changes: 1 addition & 18 deletions app/views/administrate/application/_index_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,7 @@
resource_name: display_resource_name(page.resource_name)
) %>

<% if filters.any? %>
<div data-controller="tooltip">
<button data-tooltip-target="tooltip" popovertarget="search-tooltip" class="button--tooltip search__tooltip">
<svg role="img">
<use xlink:href="#icon-question-mark" />
</svg>
</button>

<div data-tooltip-target="popover" popover id="search-tooltip" role="tooltip" class="search__tooltip-popover search__tooltip-popover-positioning">
<p><strong>Use filters to refine your search</strong></p>
<ul>
<% filters.keys.each do |filter_key| %>
<li><%= filter_key %>:<span class="search__tooltip-popover-value">&lt;value&gt;</span></li>
<% end %>
</ul>
</div>
</div>
<% end %>
<%= render "search_tooltip", page: page, filters: filters %>
<% end %>

<div>
Expand Down
19 changes: 19 additions & 0 deletions app/views/administrate/application/_search_tooltip.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<%# locals: (page:, filters:) %>
<% return if filters.empty? %>

<div data-controller="tooltip">
<button data-tooltip-target="tooltip" popovertarget="search-tooltip" class="button--tooltip search__tooltip">
<svg role="img">
<use xlink:href="#icon-question-mark" />
</svg>
</button>

<div data-tooltip-target="popover" popover id="search-tooltip" role="tooltip" class="search__tooltip-popover search__tooltip-popover-positioning">
<p><strong>Use filters to refine your search</strong></p>
<ul>
<% filters.keys.each do |filter_key| %>
<li><%= filter_key %>:<span class="search__tooltip-popover-value">&lt;value&gt;</span></li>
<% end %>
</ul>
</div>
</div>
Loading