<% absolutely_abstract_creative_concept = @absolutely_abstract_creative_concept || @creative_concept %>
<% context ||= absolutely_abstract_creative_concept %>
<% collection ||= :completely_concrete_tangible_things %>
<% hide_actions ||= false %>
<% hide_back ||= false %>

<% tangible_things = tangible_things.order(:id) unless has_order?(tangible_things) %>
<% pagy, tangible_things = pagy(tangible_things, page_param: :tangible_things_page) %>

<%= action_model_select_controller do %>
  <%= updates_for context, collection do %>
    <%= render 'account/shared/box', pagy: pagy do |p| %>
      <% p.content_for :title, t(".contexts.#{context.class.name.underscore}.header") %>
      <% p.content_for :description do %>
        <%= t(".contexts.#{context.class.name.underscore}.description#{"_empty" unless tangible_things.any?}") %>
      <% end %>

      <% p.content_for :table do %>
        <% if tangible_things.any? %>
          <table class="table">
            <thead>
              <tr>
                <%= render "shared/tables/select_all" %>
                <%# 🚅 skip this section when scaffolding. %>
                <th><%= t('.fields.text_field_value.heading') %></th>
                <th><%= t('.fields.boolean_button_value.heading') %></th>
                <th><%= t('.fields.button_value.heading') %></th>
                <th><%= t('.fields.multiple_button_values.heading') %></th>
                <%# 🚅 stop any skipping we're doing now. %>
                <%# 🚅 super scaffolding will insert new field headers above this line. %>
                <th><%= t('.fields.created_at.heading') %></th>
                <th class="text-right"></th>
              </tr>
            </thead>
            <tbody>
              <% tangible_things.each do |tangible_thing| %>
                <% with_attribute_settings object: tangible_thing do %>
                  <tr data-id="<%= tangible_thing.id %>">
                    <%= render "shared/tables/checkbox", object: tangible_thing %>
                    <%# 🚅 skip this section when scaffolding. %>
                    <td><%= render 'shared/attributes/text', attribute: :text_field_value, url: [:account, tangible_thing] %></td>
                    <td><%= render 'shared/attributes/boolean', attribute: :boolean_button_value %></td>
                    <td><%= render 'shared/attributes/option', attribute: :button_value %></td>
                    <td><%= render 'shared/attributes/options', attribute: :multiple_button_values %></td>
                    <%# 🚅 stop any skipping we're doing now. %>
                    <%# 🚅 super scaffolding will insert new fields above this line. %>
                    <td><%= render 'shared/attributes/date_and_time', attribute: :created_at %></td>
                    <td class="buttons">
                      <% unless hide_actions %>
                        <% if can? :edit, tangible_thing %>
                          <%= link_to t('.buttons.shorthand.edit'), [:edit, :account, tangible_thing], class: 'button-secondary button-smaller' %>
                        <% end %>
                        <% if can? :destroy, tangible_thing %>
                          <%= button_to t('.buttons.shorthand.destroy'), [:account, tangible_thing], method: :delete, data: { confirm: t('.buttons.confirmations.destroy', model_locales(tangible_thing)) }, class: 'button-secondary button-smaller' %>
                        <% end %>
                        <%# 🚅 super scaffolding will insert new action model buttons above this line. %>
                      <% end %>
                    </td>
                  </tr>
                <% end %>
              <% end %>
            </tbody>
          </table>
        <% end %>
      <% end %>

      <% p.content_for :actions do %>
        <% unless hide_actions %>
          <% if context == absolutely_abstract_creative_concept %>
            <% if can? :create, Scaffolding::CompletelyConcrete::TangibleThing.new(absolutely_abstract_creative_concept: absolutely_abstract_creative_concept) %>
              <%= link_to t('.buttons.new'), [:new, :account, absolutely_abstract_creative_concept, :completely_concrete_tangible_thing], class: "#{first_button_primary(:completely_concrete_tangible_thing)} new" %>
            <% end %>
          <% end %>

          <% unless hide_back %>
          <%# 🚅 super scaffolding will insert new bulk action model buttons above this line. %>
          <%= render "shared/bulk_action_select" %>
            <%= link_to t('global.buttons.back'), [:account, context], class: "#{first_button_primary(:completely_concrete_tangible_thing)} back" %>
          <% end %>
        <% end %>
      <% end %>

      <% p.content_for :raw_footer do %>
        <%# 🚅 super scaffolding will insert new action model index views above this line. %>
      <% end %>
    <% end %>
  <% end %>
<% end %>