From 3484c6b7b8af9955af231cc59984049959a2525f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 23 Feb 2025 21:56:02 +0100 Subject: [PATCH 1/6] Use a list of links to change group in budgets wizard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The original implementation (which was never merged) had a ` Fix all of the following: - ARIA attribute is not allowed: aria-expanded="true" Selector: #dashboard_action_action_type_resource HTML: Fix all of the following: - ARIA attribute is not allowed: aria-expanded="true" ``` So we're using custom JavaScript instead. We're also making the `short_description` field act as intended; since the changes in commit 07fd5084f it was never shown because it had the `hide` HTML class and it didn't have a `data-toggler` attribute. --- .../admin/dashboard/actions/form.js | 21 +++++++++++++++++++ app/assets/javascripts/application.js | 1 + .../proposal_dashboard_actions_helper.rb | 4 ---- .../admin/dashboard/actions/_form.html.erb | 10 +++------ spec/system/admin/dashboard/actions_spec.rb | 10 +++++++++ 5 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 app/assets/javascripts/admin/dashboard/actions/form.js diff --git a/app/assets/javascripts/admin/dashboard/actions/form.js b/app/assets/javascripts/admin/dashboard/actions/form.js new file mode 100644 index 000000000..1ef7f4dc1 --- /dev/null +++ b/app/assets/javascripts/admin/dashboard/actions/form.js @@ -0,0 +1,21 @@ +(function() { + "use strict"; + App.AdminDashboardActionsForm = { + initialize: function() { + $("input[name='dashboard_action[action_type]']").on({ + change: function() { + switch ($(this).val()) { + case "proposed_action": + $("#request_to_administrators").hide(); + $("#short_description").hide(); + break; + case "resource": + $("#request_to_administrators").show(); + $("#short_description").show(); + } + } + }).filter("[checked]").trigger("change"); + } + }; +}).call(this); + diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index c2c3c8cfa..d1070d56a 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -169,6 +169,7 @@ var initialize_modules = function() { App.ColumnsSelector.initialize(); } App.AdminBudgetsWizardCreationStep.initialize(); + App.AdminDashboardActionsForm.initialize(); App.AdminMachineLearningScripts.initialize(); App.AdminPollShiftsForm.initialize(); App.AdminTenantsForm.initialize(); diff --git a/app/helpers/admin/proposal_dashboard_actions_helper.rb b/app/helpers/admin/proposal_dashboard_actions_helper.rb index 2b0cbddf2..17efbd100 100644 --- a/app/helpers/admin/proposal_dashboard_actions_helper.rb +++ b/app/helpers/admin/proposal_dashboard_actions_helper.rb @@ -8,8 +8,4 @@ module Admin::ProposalDashboardActionsHelper def default_actions %w[polls email poster] end - - def css_for_resource(action) - "hide" if action == "proposed_action" - end end diff --git a/app/views/admin/dashboard/actions/_form.html.erb b/app/views/admin/dashboard/actions/_form.html.erb index 3dd147172..a3a4301ea 100644 --- a/app/views/admin/dashboard/actions/_form.html.erb +++ b/app/views/admin/dashboard/actions/_form.html.erb @@ -5,9 +5,7 @@ <%= f.label :action_type %> <% ::Dashboard::Action.action_types.keys.each do |action_type_value| %> - <%= f.radio_button :action_type, - action_type_value, - data: { toggle: "request_to_administrators short_description" } %> + <%= f.radio_button :action_type, action_type_value %> <% end %> @@ -16,9 +14,7 @@ <%= f.check_box :active %> -
+
<%= f.check_box :request_to_administrators %>
@@ -28,7 +24,7 @@
<%= f.text_field :title %> -
+
<%= f.text_field :short_description %>
diff --git a/spec/system/admin/dashboard/actions_spec.rb b/spec/system/admin/dashboard/actions_spec.rb index 645ceea0a..302f2edc4 100644 --- a/spec/system/admin/dashboard/actions_spec.rb +++ b/spec/system/admin/dashboard/actions_spec.rb @@ -73,7 +73,17 @@ describe "Admin dashboard actions", :admin do end scenario "Updates the action" do + expect(page).to have_checked_field "Proposed action" + expect(page).to have_unchecked_field "Resource" + expect(page).not_to have_field "Short description" + expect(page).not_to have_field "Include in the resource a button to " \ + "request the resource from administrators" + + choose "Resource" + check "Include in the resource a button to request the resource from administrators" + fill_in "Title", with: "Great action!" + fill_in "Short description", with: "And awesome too!" click_button "Save" expect(page).to have_content "Great action!" From 224999a95fecdab7746da0042803b8b4fab1f920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 24 Feb 2025 01:17:25 +0100 Subject: [PATCH 6/6] Move tabs link list outside tabs content Just like we do everywhere else. We're also removing the wrong ARIA attributes that we added in commit c18479e3a, which caused an accessibility issue reported by Axe: ``` aria-required-children: Certain ARIA roles must contain particular children (critical) https://dequeuniversity.com/rules/axe/4.10/aria-required-children?application=axeAPI The following 1 node violate this rule: Selector: .tabs-content HTML:
Fix any of the following: - Element has children which are not allowed: ul[tabindex] ``` Although, in this case, it would probably be better to have different pages instead of tabs, so loading the page doesn't take too long. --- .../site_customization/information_texts/index.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/admin/site_customization/information_texts/index.html.erb b/app/views/admin/site_customization/information_texts/index.html.erb index c6a2fea43..39af0f84b 100644 --- a/app/views/admin/site_customization/information_texts/index.html.erb +++ b/app/views/admin/site_customization/information_texts/index.html.erb @@ -1,9 +1,9 @@

<%= t("admin.menu.site_customization.information_texts") %>

-
- <%= render "tabs" %> +<%= render "tabs" %> -