app/views/headmin/table/_actions.html.erb in headmin-0.2.5 vs app/views/headmin/table/_actions.html.erb in headmin-0.2.6

- old
+ new

@@ -1,26 +1,52 @@ +<% + # headmin/table/actions + # + # The form action url is dynamically set when switching between actions. + # + # ==== Examples + # Basic version + # <%= render 'headmin/table/actions' do %#> + # <%= render 'headmin/table/actions/delete', url: destroy_admin_pages_path %#> + # <% end %#> + + selection_count = content_for(:collection_total_count).to_i || 0 +%> + <% content_for :table_actions do %> - <th class="h-table-actions d-none" data-controller="table-actions" data-table-target="actions"> - <form data-table-actions-target="form" method="post"> - <%= hidden_field_tag :_method, :post, 'data-table-actions-target': 'method' %> - <%= hidden_field_tag :authenticity_token, form_authenticity_token %> + <th class="h-table-actions d-none" data-controller="table-actions" data-table-actions-target="wrapper" data-table-target="actions"> + <%= form_with data: { 'table-actions-target': 'form' } do |form| %> + <%= form.hidden_field :authenticity_token, value: form_authenticity_token %> + <%= form.hidden_field :_method, value: 'POST', 'data-table-actions-target': 'method' %> + <%= query_parameter_fields(form) %> - <template data-table-target="idFieldTemplate"> - <%= hidden_field_tag('ids[]', 'ID', multiple: true, id: 'ids_ID') %> + <template data-table-actions-target="idInputTemplate"> + <%= form.hidden_field :ids, value: 'ID', multiple: true, 'data-table-actions-target': 'id' %> </template> <div class="row g-1"> <div class="col-6 col-sm-auto"> - <select class="form-select me-1" data-table-actions-target="select" data-action="change->table-actions#update"> - <option disabled selected="selected"><%= t('.selection') %></option> - <%= yield if block_given? %> - </select> + <div class="d-flex align-items-center gap-3"> + <label class="text-nowrap" + data-table-actions-target="counter" + data-total-count="<%= selection_count %>" + data-items-zero="<%= t('.items_html', count: 0) %>" + data-items-one="<%= t('.items_html', count: 1) %>" + data-items-other="<%= t('.items_html', count: 2) %>" + > + <%= t('.items_html', count: selection_count) %> + </label> + <select class="form-select me-1" data-table-actions-target="select" data-action="change->table-actions#update"> + <option disabled selected="selected"><%= t('.selection') %></option> + <%= yield if block_given? %> + </select> + </div> </div> <div class="col-6 col-sm-auto"> <button class="btn h-btn-outline-light w-100" type="submit" data-table-actions-target="button" disabled> <%= t('.apply') %> </button> </div> </div> - </form> + <% end %> </th> <% end %> \ No newline at end of file