<%= content_tag :div, data: { **@resource.stimulus_data_attributes } do %> <%= render Avo::PanelComponent.new(name: title, description: description, data: { component: 'resources-index' }, display_breadcrumbs: @reflection.blank?) do |c| %> <% c.tools do %> <% if can_attach? %> <%= a_link attach_path, icon: 'heroicons/outline/link', color: :primary, style: :text, 'data-turbo-frame': 'attach_modal', 'data-target': 'attach' do %> <%= t('avo.attach_item', item: singular_resource_name).capitalize %> <% end %> <% end %> <% if can_see_the_actions_button? %> <%= render Avo::ActionsComponent.new actions: @actions, resource: @resource, view: @view %> <% end %> <% if can_see_the_create_button? %> <%= a_link create_path, icon: 'heroicons/outline/plus', 'data-target': 'create', style: :primary, color: :primary do %> <%= t('avo.create_new_item', item: singular_resource_name.downcase ) %> <% end %> <% end %> <% end %> <% c.body do %>
<% unless hide_search_input %>
<%= render partial: 'avo/partials/resource_search', locals: {resource: @resource.route_key, via_reflection: via_reflection} %>
<% else %> <%# Offset for the space-y-2 property when the search is missing %>
<% end %> <% if @filters.present? || available_view_types.count > 1 %>
<%= render Avo::FiltersComponent.new filters: @filters, resource: @resource, applied_filters: @applied_filters, parent_model: @parent_model %> <%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: view_type, turbo_frame: @turbo_frame } if available_view_types.count > 1 %>
<% end %>
<% if view_type.to_sym == :table %> <% if @resources.present? %>
<%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model, parent_resource: @parent_resource, pagy: @pagy, query: @query)) %>
<% else %> <%= helpers.empty_state resource_name: @resource.name.downcase.pluralize, related_name: params[:related_name], view_type: view_type, add_background: true %> <% end %> <% end %> <% end %> <% c.bare_content do %> <% if view_type.to_sym == :table %> <% if @models.present? %>
<%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame || 'none', index_params: @index_params, resource: @resource, parent_model: @parent_model, discreet_pagination: field&.discreet_pagination %>
<% end %> <% end %> <% if view_type.to_sym == :grid %> <%= render Avo::Index::ResourceGridComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_model: @parent_model) %>
<%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame || 'none', index_params: @index_params, resource: @resource, parent_model: @parent_model, discreet_pagination: field&.discreet_pagination %>
<% end %> <% end %> <% end %> <% end %>