From 4cb1b0a48ecb997e86934330fa00770ca5e4ce66 Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 20 Feb 2025 12:09:41 +1100 Subject: [PATCH] Add total count of selected items I noticed there's a controller for that too, so might as well make use of it. The orders page has it at the top, because that's where the bulk action menu is. But on this page, the action is the import button so I put it there. --- app/views/admin/dfc_product_imports/index.html.haml | 7 +++++-- config/locales/en.yml | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/views/admin/dfc_product_imports/index.html.haml b/app/views/admin/dfc_product_imports/index.html.haml index 80f780cff2..720705d373 100644 --- a/app/views/admin/dfc_product_imports/index.html.haml +++ b/app/views/admin/dfc_product_imports/index.html.haml @@ -8,12 +8,12 @@ %p= t('.enterprise', enterprise_name: @enterprise.name) %br - = form_with url: main_app.import_admin_dfc_product_imports_path do |form| + = form_with url: main_app.import_admin_dfc_product_imports_path, html: { "data-controller": "checked" } do |form| -# This is a very inefficient way of holding a json blob. Maybe base64 encode or store as a temporary file = form.hidden_field :enterprise_id, value: @enterprise.id = form.hidden_field :catalog_json, value: @catalog_json - %table{"data-controller": "checked" } + %table %thead %tr %th @@ -33,5 +33,8 @@ - else = t(".new") + %span{ "data-controller": "checked-feedback", "data-checked-feedback-translation-value": "admin.dfc_product_imports.index.selected" } + = t(".selected", count: @items.count) + %br = form.submit t(".import") diff --git a/config/locales/en.yml b/config/locales/en.yml index 0a739cb660..f43f8667b2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -854,6 +854,10 @@ en: select_all: "Select/deselect all" update: Update new: New + selected: + zero: "0 selected" + one: "1 selected" + other: "%{count} selected" import: Import import: title: "DFC product catalog import"