97 lines
3.3 KiB
ERB
97 lines
3.3 KiB
ERB
<%#
|
|
# 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 %>
|
|
|
|
<%
|
|
resource_icons = {
|
|
'account' => 'icon-building-4-line',
|
|
'user' => 'icon-user-follow-line',
|
|
'account_user' => 'icon-user-follow-line',
|
|
'agent_bot' => 'icon-robot-line',
|
|
'response_source' => 'icon-book-2-line',
|
|
'response_document' => 'icon-draft-line',
|
|
'response' => 'icon-reply-line'
|
|
}
|
|
current_icon = resource_icons[page.resource_name] || 'icon-apps-2-line'
|
|
%>
|
|
|
|
<section class="flex flex-col w-full h-full">
|
|
<header class="sticky top-0 z-10 bg-n-background border-b border-n-weak" role="banner">
|
|
<div class="flex items-center justify-between w-full h-16 mx-auto max-w-[60rem]">
|
|
<div class="flex items-center gap-3">
|
|
<div class="border border-n-weak p-2 rounded-full text-n-slate-11">
|
|
<svg width="24" height="24"><use xlink:href="#<%= current_icon %>" /></svg>
|
|
</div>
|
|
<div class="flex flex-col justify-center">
|
|
<h1 class="text-base font-medium tracking-tight text-n-slate-12" id="page-title">
|
|
<%= content_for(:title) %>
|
|
</h1>
|
|
<p class="text-xs text-n-slate-11 m-0">Manage all registered <%= page.resource_name.pluralize.downcase %></p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-3">
|
|
<% if show_search_bar %>
|
|
<%= render("filters", page: page) %>
|
|
<%= render(
|
|
"search",
|
|
search_term: search_term,
|
|
resource_name: display_resource_name(page.resource_name)
|
|
) %>
|
|
<% end %>
|
|
|
|
<% if accessible_action?(new_resource, :new) %>
|
|
<%= link_to(
|
|
t(
|
|
"administrate.actions.new_resource",
|
|
name: page.resource_name.titleize.downcase
|
|
),
|
|
[:new, namespace, page.resource_path.to_sym],
|
|
class: "inline-flex items-center justify-center h-8 px-3 text-sm font-medium text-white bg-woot-500 rounded-lg hover:bg-woot-600 transition-colors",
|
|
) %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="flex-1 px-6 overflow-y-auto">
|
|
<div class="w-full mx-auto max-w-[60rem] py-4">
|
|
<%= render(
|
|
"collection",
|
|
collection_presenter: page,
|
|
collection_field_name: resource_name,
|
|
page: page,
|
|
resources: resources,
|
|
table_title: "page-title"
|
|
) %>
|
|
|
|
<%= paginate resources, param_name: '_page'%>
|
|
</div>
|
|
</main>
|
|
</section>
|