mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Add select/deselect all checkbox
There's A Controller For That. (But I think it makes the HTML ugly..)
This commit is contained in:
@@ -12,13 +12,18 @@
|
||||
= form.hidden_field :enterprise_id, value: @enterprise.id
|
||||
= form.hidden_field :catalog_json, value: @catalog_json
|
||||
|
||||
%table
|
||||
%table{"data-controller": "checked" }
|
||||
%thead
|
||||
%tr
|
||||
%th
|
||||
%input{ type: 'checkbox', title: t('.select_all'), 'aria-label': t('.select_all'), data: { "checked-target": "all", action: "change->checked#toggleAll" } }
|
||||
%th
|
||||
%tbody
|
||||
- @items.each do |supplied_product, existing_product|
|
||||
%tr{id: supplied_product.semanticId }
|
||||
%td
|
||||
%label
|
||||
= form.check_box 'semanticIds[]', { checked: true }, supplied_product.semanticId, ""
|
||||
= form.check_box 'semanticIds[]', { checked: true, data: { "action" => "change->checked#toggleCheckbox", "checked-target" => "checkbox" } }, supplied_product.semanticId, ""
|
||||
= supplied_product.name
|
||||
%td
|
||||
- if existing_product.present?
|
||||
|
||||
@@ -851,6 +851,7 @@ en:
|
||||
title: "DFC product catalog"
|
||||
catalog_url: "%{count} products to be imported from: %{catalog_url}"
|
||||
enterprise: "Import to enterprise: %{enterprise_name}"
|
||||
select_all: "Select/deselect all"
|
||||
update: Update
|
||||
new: New
|
||||
import: Import
|
||||
|
||||
@@ -65,7 +65,13 @@ RSpec.describe "DFC Product Import" do
|
||||
expect(page).to have_content "Beans - Case, 12 x 400g (can) New"
|
||||
expect(page).to have_content "Chia Seed, Organic - Retail pack, 300g"
|
||||
|
||||
uncheck "Chia Seed, Organic - Case, 8 x 300g" # don't import this one
|
||||
# I can select all
|
||||
uncheck "Chia Seed, Organic - Case, 8 x 300g"
|
||||
check "Select/deselect all"
|
||||
expect(page).to have_checked_field "Chia Seed, Organic - Case, 8 x 300g"
|
||||
|
||||
# And deselect one
|
||||
uncheck "Chia Seed, Organic - Case, 8 x 300g"
|
||||
|
||||
expect {
|
||||
click_button "Import"
|
||||
|
||||
Reference in New Issue
Block a user