<%= content_tag :div, data: { component_name: self.class.to_s.underscore, model_name: @resource.model_name.to_s, resource_name: @resource.class.to_s, **@resource.stimulus_data_attributes } do %> <%= render Avo::PanelComponent.new(name: title, description: description, data: { component: 'resources-index' }, display_breadcrumbs: @reflection.blank?) do |c| %> <% c.with_tools do %> <% @resource.render_index_controls(item: singular_resource_name.downcase).each do |control| %> <%= render_control control %> <% end %> <% end %> <% c.with_body do %>
<%= render scopes_list if can_render_scopes? %>
<% if show_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 %>
<%= render_dynamic_filters_button %> <%= render Avo::FiltersComponent.new filters: @filters, resource: @resource, applied_filters: @applied_filters, parent_record: parent_record %> <%= render partial: 'avo/partials/view_toggle_button', locals: { available_view_types: available_view_types, view_type: view_type, turbo_frame: turbo_frame } %>
<% if Avo.avo_filters_installed? && resource.has_filters? %> <%= render Avo::DynamicFilters::FiltersComponent.new resource: resource, turbo_frame: turbo_frame %> <% end %>
<% if view_type.to_sym == :table %> <% if @resources.present? %>
<%= render(Avo::Index::ResourceTableComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: parent_record, parent_resource: parent_resource, pagy: @pagy, query: query, actions: actions)) %>
<% else %> <%= helpers.empty_state by_association: params[:related_name].present?, view_type: view_type, add_background: true %> <% end %> <% end %> <% end %> <% c.with_bare_content do %> <% if view_type.to_sym == :map %> <% if @resources.present? %>
<%= render(Avo::Index::ResourceMapComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, pagy: @pagy, query: @query)) %>
<% else %> <%= helpers.empty_state by_association: params[:related_name].present?, view_type: view_type, add_background: true %> <% end %> <% end %> <% if view_type.to_sym == :table || view_type.to_sym == :map %> <% if @records.present? %>
<%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: turbo_frame || 'none', index_params: @index_params, resource: @resource, parent_record: parent_record, 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_record: parent_record, parent_resource: parent_resource, actions: actions) %>
<%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: turbo_frame || 'none', index_params: @index_params, resource: @resource, parent_record: parent_record, discreet_pagination: field&.discreet_pagination %>
<% end %> <% end %> <% end %> <% end %>