Group buttons to check all/none elements

Since they're related, we're making them part of the same list. Instead
of finding a way to have the `Select` prefix they had as a label for the
list, we're including the "prefix" they had inside their texts, so the
text of a button doesn't need any additional context.
This commit is contained in:
Javi Martín
2024-04-12 01:25:00 +02:00
parent 2dab8682d9
commit 673eb1358a
9 changed files with 28 additions and 22 deletions

View File

@@ -1,7 +1,17 @@
.check-all-none { .check-all-none {
float: $global-left; float: $global-left;
list-style-type: none;
margin-#{$global-left}: 0;
button { button {
@include link; @include link;
} }
li {
display: inline-block;
+ li::before {
@include vertical-separator;
}
}
} }

View File

@@ -9,12 +9,10 @@
<% end %> <% end %>
<%= form_tag form_path, method: :put do %> <%= form_tag form_path, method: :put do %>
<p class="check-all-none"> <ul class="check-all-none">
<%= t("shared.check") %>: <li><%= button_tag t("shared.check_all"), type: "button", data: { check_all: field_name } %></li>
<%= button_tag t("shared.check_all"), type: "button", data: { check_all: field_name } %> <li><%= button_tag t("shared.check_none"), type: "button", data: { check_none: field_name } %></li>
| </ul>
<%= button_tag t("shared.check_none"), type: "button", data: { check_none: field_name } %>
</p>
<%= content %> <%= content %>

View File

@@ -674,9 +674,8 @@ en:
author_deleted: User deleted author_deleted: User deleted
email_deleted: Email deleted email_deleted: Email deleted
back: Go back back: Go back
check: Select check_all: Select all
check_all: All check_none: Select none
check_none: None
collective: Collective collective: Collective
flag: Flag as inappropriate flag: Flag as inappropriate
follow: "Follow" follow: "Follow"

View File

@@ -674,9 +674,8 @@ es:
author_deleted: Usuario eliminado author_deleted: Usuario eliminado
email_deleted: Email eliminado email_deleted: Email eliminado
back: Volver back: Volver
check: Seleccionar check_all: Seleccionar todos
check_all: Todos check_none: Seleccionar ninguno
check_none: Ninguno
collective: Colectivo collective: Colectivo
flag: Denunciar como inapropiado flag: Denunciar como inapropiado
follow: "Seguir" follow: "Seguir"

View File

@@ -109,11 +109,11 @@ describe "Moderate budget investments" do
expect(page).to have_field type: :checkbox, count: 3 expect(page).to have_field type: :checkbox, count: 3
within(".check-all-none") { click_button "All" } within(".check-all-none") { click_button "Select all" }
expect(all(:checkbox)).to all(be_checked) expect(all(:checkbox)).to all(be_checked)
within(".check-all-none") { click_button "None" } within(".check-all-none") { click_button "Select none" }
all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked } all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked }
end end

View File

@@ -130,11 +130,11 @@ describe "Moderate comments" do
expect(page).to have_field type: :checkbox, count: 2 expect(page).to have_field type: :checkbox, count: 2
within(".check-all-none") { click_button "All" } within(".check-all-none") { click_button "Select all" }
expect(all(:checkbox)).to all(be_checked) expect(all(:checkbox)).to all(be_checked)
within(".check-all-none") { click_button "None" } within(".check-all-none") { click_button "Select none" }
all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked } all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked }
end end

View File

@@ -99,11 +99,11 @@ describe "Moderate debates" do
expect(page).to have_field type: :checkbox, count: 2 expect(page).to have_field type: :checkbox, count: 2
within(".check-all-none") { click_button "All" } within(".check-all-none") { click_button "Select all" }
expect(all(:checkbox)).to all(be_checked) expect(all(:checkbox)).to all(be_checked)
within(".check-all-none") { click_button "None" } within(".check-all-none") { click_button "Select none" }
all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked } all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked }
end end

View File

@@ -110,11 +110,11 @@ describe "Moderate proposal notifications" do
expect(page).to have_field type: :checkbox, count: 2 expect(page).to have_field type: :checkbox, count: 2
within(".check-all-none") { click_button "All" } within(".check-all-none") { click_button "Select all" }
expect(all(:checkbox)).to all(be_checked) expect(all(:checkbox)).to all(be_checked)
within(".check-all-none") { click_button "None" } within(".check-all-none") { click_button "Select none" }
all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked } all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked }
end end

View File

@@ -98,11 +98,11 @@ describe "Moderate proposals" do
expect(page).to have_field type: :checkbox, count: 3 expect(page).to have_field type: :checkbox, count: 3
within(".check-all-none") { click_button "All" } within(".check-all-none") { click_button "Select all" }
expect(all(:checkbox)).to all(be_checked) expect(all(:checkbox)).to all(be_checked)
within(".check-all-none") { click_button "None" } within(".check-all-none") { click_button "Select none" }
all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked } all(:checkbox).each { |checkbox| expect(checkbox).not_to be_checked }
end end