- <%= f.label :percentage %>
+ <%= f.label :percentage, nil, id: "percentage_label" %>
<%= f.text_field :percentage, { type: :range,
id: "percentage_range",
label: false,
+ "aria-labelledby": "percentage_label",
class: "column" }.merge(progress_options) %>
diff --git a/app/components/admin/progress_bars/form_component.rb b/app/components/admin/progress_bars/form_component.rb
new file mode 100644
index 000000000..a93f6c0fb
--- /dev/null
+++ b/app/components/admin/progress_bars/form_component.rb
@@ -0,0 +1,15 @@
+class Admin::ProgressBars::FormComponent < ApplicationComponent
+ include TranslatableFormHelper
+ include GlobalizeHelper
+ attr_reader :progress_bar
+
+ def initialize(progress_bar)
+ @progress_bar = progress_bar
+ end
+
+ private
+
+ def progress_options
+ { min: ProgressBar::RANGE.min, max: ProgressBar::RANGE.max, step: 1 }
+ end
+end
diff --git a/app/components/admin/site_customization/images/index_component.html.erb b/app/components/admin/site_customization/images/index_component.html.erb
index 3ff4a6eae..9b9c21dd0 100644
--- a/app/components/admin/site_customization/images/index_component.html.erb
+++ b/app/components/admin/site_customization/images/index_component.html.erb
@@ -12,7 +12,7 @@
<% images.each do |image| %>
|
- <%= image.name %> (<%= image.required_width %>x<%= image.required_height %>)
+ <%= image_description(image) %>
|
<%= render Admin::SiteCustomization::Images::TableActionsComponent.new(image) %>
diff --git a/app/components/admin/site_customization/images/index_component.rb b/app/components/admin/site_customization/images/index_component.rb
index 14648cc9b..41c5b0585 100644
--- a/app/components/admin/site_customization/images/index_component.rb
+++ b/app/components/admin/site_customization/images/index_component.rb
@@ -11,4 +11,17 @@ class Admin::SiteCustomization::Images::IndexComponent < ApplicationComponent
def title
t("admin.site_customization.images.index.title")
end
+
+ def image_description(image)
+ safe_join([
+ tag.strong(image.name),
+ tag.span(image_hint(image), id: dom_id(image, :hint))
+ ], " ")
+ end
+
+ def image_hint(image)
+ t("admin.site_customization.images.index.dimensions",
+ width: image.required_width,
+ height: image.required_height)
+ end
end
diff --git a/app/components/admin/site_customization/images/table_actions_component.html.erb b/app/components/admin/site_customization/images/table_actions_component.html.erb
index 3957d23ad..bcc963292 100644
--- a/app/components/admin/site_customization/images/table_actions_component.html.erb
+++ b/app/components/admin/site_customization/images/table_actions_component.html.erb
@@ -2,7 +2,10 @@
<%= form_for([:admin, image], html: { id: "edit_#{dom_id(image)}" }) do |f| %>
<%= image_tag image.image if image.persisted_attachment? %>
- <%= f.file_field :image, label: false %>
+ <%= f.file_field :image,
+ label: false,
+ "aria-label": image.name,
+ "aria-describedby": dom_id(image, :hint) %>
<%= f.submit(t("admin.site_customization.images.index.update"), class: "button hollow") %>
diff --git a/app/components/admin/site_customization/information_texts/form_component.html.erb b/app/components/admin/site_customization/information_texts/form_component.html.erb
index b8f8b6444..044bd1019 100644
--- a/app/components/admin/site_customization/information_texts/form_component.html.erb
+++ b/app/components/admin/site_customization/information_texts/form_component.html.erb
@@ -6,7 +6,7 @@
<% end %>
<% contents.each do |group| %>
<% group.each do |content| %>
- <%= content.key %>
+ <%= hidden_field_tag "contents[content_#{content.key}][id]", content.key %>
<% (content.globalize_locales & enabled_locales.map(&:to_sym)).each do |locale| %>
<%= render Admin::SiteCustomization::InformationTexts::FormFieldComponent.new(content, locale: locale) %>
<% end %>
diff --git a/app/components/admin/site_customization/information_texts/form_field_component.html.erb b/app/components/admin/site_customization/information_texts/form_field_component.html.erb
index 1852afba0..1e546cf19 100644
--- a/app/components/admin/site_customization/information_texts/form_field_component.html.erb
+++ b/app/components/admin/site_customization/information_texts/form_field_component.html.erb
@@ -1,9 +1,6 @@
<% globalize(locale) do %>
- <%= hidden_field_tag "contents[content_#{i18n_content.key}][id]", i18n_content.key %>
- <%= text_area_tag "contents[content_#{i18n_content.key}]values[value_#{locale}]",
- text,
- rows: 5,
- class: "js-globalize-attribute",
- style: site_customization_display_translation_style,
- data: { locale: locale } %>
+
+ <%= label_tag html_id, i18n_key %>
+ <%= text_area_tag html_name, text, id: html_id, rows: 5 %>
+
<% end %>
diff --git a/app/components/admin/site_customization/information_texts/form_field_component.rb b/app/components/admin/site_customization/information_texts/form_field_component.rb
index 69ce896ef..046630722 100644
--- a/app/components/admin/site_customization/information_texts/form_field_component.rb
+++ b/app/components/admin/site_customization/information_texts/form_field_component.rb
@@ -20,10 +20,22 @@ class Admin::SiteCustomization::InformationTexts::FormFieldComponent < Applicati
end
def i18n_text
- I18n.translate(i18n_content.key, locale: locale)
+ I18n.translate(i18n_key, locale: locale)
end
- def site_customization_display_translation_style
+ def i18n_key
+ i18n_content.key
+ end
+
+ def html_id
+ html_name.tr("[", "_").tr("]", "")
+ end
+
+ def html_name
+ "contents[content_#{i18n_key}]values[value_#{locale}]"
+ end
+
+ def display_style
site_customization_enable_translation?(locale) ? "" : "display: none;"
end
end
diff --git a/app/views/admin/shared/_budget_investment_search.html.erb b/app/components/management/budgets/investments/search_component.html.erb
similarity index 52%
rename from app/views/admin/shared/_budget_investment_search.html.erb
rename to app/components/management/budgets/investments/search_component.html.erb
index 7e9d3d082..932304916 100644
--- a/app/views/admin/shared/_budget_investment_search.html.erb
+++ b/app/components/management/budgets/investments/search_component.html.erb
@@ -1,25 +1,29 @@
-<%= form_for(Budget::Investment.new, url: url, as: :budget_investment, method: :get) do |f| %>
+<%= form_tag(url, options) do |f| %>
+ <%= label_tag :search, search_label_text %>
<%= text_field_tag :search, "" %>
+ <%= label_tag :heading_id, attribute_name(:heading_id) %>
<%= select_tag :heading_id,
- options_for_select(budget_heading_select_options(@budget),
+ options_for_select(budget_heading_select_options(budget),
params[:heading_id]),
include_blank: true %>
-
- <%= check_box_tag :unfeasible, "1", params[:unfeasible].present? %>
- <%= t("admin.budget_investments.search_unfeasible") %>
+
+ <%= label_tag :unfeasible, class: "checkbox-label" do %>
+ <%= check_box_tag :unfeasible, "1", params[:unfeasible].present? %>
+ <%= t("admin.budget_investments.search_unfeasible") %>
+ <% end %>
- <%= f.submit t("shared.search"), class: "button" %>
+ <%= submit_tag t("shared.search"), class: "button" %>
<% end %>
diff --git a/app/components/management/budgets/investments/search_component.rb b/app/components/management/budgets/investments/search_component.rb
new file mode 100644
index 000000000..8244a2e9b
--- /dev/null
+++ b/app/components/management/budgets/investments/search_component.rb
@@ -0,0 +1,26 @@
+class Management::Budgets::Investments::SearchComponent < ApplicationComponent
+ attr_reader :budget, :url
+ use_helpers :budget_heading_select_options
+
+ def initialize(budget, url:)
+ @budget = budget
+ @url = url
+ end
+
+ private
+
+ def options
+ {
+ method: :get,
+ class: "management-investments-search"
+ }
+ end
+
+ def search_label_text
+ t("management.budget_investments.search.label")
+ end
+
+ def attribute_name(attribute)
+ Budget::Investment.human_attribute_name(attribute)
+ end
+end
diff --git a/app/components/shared/globalize_locales_component.html.erb b/app/components/shared/globalize_locales_component.html.erb
index 664d298db..d173c76ba 100644
--- a/app/components/shared/globalize_locales_component.html.erb
+++ b/app/components/shared/globalize_locales_component.html.erb
@@ -6,9 +6,9 @@
<%= selected_languages_description %>
+ <%= label_tag :select_language, t("shared.translations.current_language") %>
<%= select_tag :select_language,
options_for_select_language,
- prompt: t("shared.translations.select_language_prompt"),
class: "js-select-language" %>
<%= select_language_error %>
@@ -24,9 +24,10 @@
<% if manage_languages %>
+ <%= label_tag :add_language, t("shared.translations.add_language") %>
<%= select_tag :add_language,
options_for_add_language,
- prompt: t("shared.translations.add_language"),
+ prompt: "",
class: "js-add-language" %>
<% end %>
diff --git a/app/controllers/admin/admin_notifications_controller.rb b/app/controllers/admin/admin_notifications_controller.rb
index f76a4a756..484326942 100644
--- a/app/controllers/admin/admin_notifications_controller.rb
+++ b/app/controllers/admin/admin_notifications_controller.rb
@@ -69,8 +69,4 @@ class Admin::AdminNotificationsController < Admin::BaseController
def allowed_params
[:link, :segment_recipient, translation_params(AdminNotification)]
end
-
- def resource
- AdminNotification.find(params[:id])
- end
end
diff --git a/app/controllers/admin/banners_controller.rb b/app/controllers/admin/banners_controller.rb
index 72b085a5d..dee4fab2d 100644
--- a/app/controllers/admin/banners_controller.rb
+++ b/app/controllers/admin/banners_controller.rb
@@ -3,8 +3,6 @@ class Admin::BannersController < Admin::BaseController
has_filters %w[all with_active with_inactive], only: :index
- before_action :banner_sections, only: [:edit, :new, :create, :update]
-
respond_to :html, :js
load_and_authorize_resource
@@ -46,12 +44,4 @@ class Admin::BannersController < Admin::BaseController
translation_params(Banner),
web_section_ids: []]
end
-
- def banner_sections
- @banner_sections = WebSection.all
- end
-
- def resource
- @banner ||= Banner.find(params[:id])
- end
end
diff --git a/app/controllers/admin/legislation/draft_versions_controller.rb b/app/controllers/admin/legislation/draft_versions_controller.rb
index 5cb6fc88e..7dae29334 100644
--- a/app/controllers/admin/legislation/draft_versions_controller.rb
+++ b/app/controllers/admin/legislation/draft_versions_controller.rb
@@ -45,8 +45,4 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
def allowed_params
[:status, :final_version, translation_params(Legislation::DraftVersion)]
end
-
- def resource
- @draft_version
- end
end
diff --git a/app/controllers/admin/legislation/homepages_controller.rb b/app/controllers/admin/legislation/homepages_controller.rb
index 68d10285c..d0c8fd51c 100644
--- a/app/controllers/admin/legislation/homepages_controller.rb
+++ b/app/controllers/admin/legislation/homepages_controller.rb
@@ -26,8 +26,4 @@ class Admin::Legislation::HomepagesController < Admin::Legislation::BaseControll
def allowed_params
[:homepage, :homepage_enabled, translation_params(::Legislation::Process)]
end
-
- def resource
- @process || ::Legislation::Process.find(params[:id])
- end
end
diff --git a/app/controllers/admin/legislation/processes_controller.rb b/app/controllers/admin/legislation/processes_controller.rb
index d35b7ca52..17c18b794 100644
--- a/app/controllers/admin/legislation/processes_controller.rb
+++ b/app/controllers/admin/legislation/processes_controller.rb
@@ -77,8 +77,4 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
image_attributes: image_attributes
]
end
-
- def resource
- @process || ::Legislation::Process.find(params[:id])
- end
end
diff --git a/app/controllers/admin/legislation/questions_controller.rb b/app/controllers/admin/legislation/questions_controller.rb
index 4c285e7ab..bab3c81d2 100644
--- a/app/controllers/admin/legislation/questions_controller.rb
+++ b/app/controllers/admin/legislation/questions_controller.rb
@@ -55,8 +55,4 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
translation_params(::Legislation::QuestionOption)]
]
end
-
- def resource
- @question || ::Legislation::Question.find(params[:id])
- end
end
diff --git a/app/controllers/admin/site_customization/information_texts_controller.rb b/app/controllers/admin/site_customization/information_texts_controller.rb
index 4a8591b24..54c4078e1 100644
--- a/app/controllers/admin/site_customization/information_texts_controller.rb
+++ b/app/controllers/admin/site_customization/information_texts_controller.rb
@@ -15,10 +15,6 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
private
- def resource
- I18nContent.find(content_params[:id])
- end
-
def content_params
params.require(:contents).values
end
diff --git a/app/controllers/admin/site_customization/pages_controller.rb b/app/controllers/admin/site_customization/pages_controller.rb
index 7721da3f6..11a69b9d9 100644
--- a/app/controllers/admin/site_customization/pages_controller.rb
+++ b/app/controllers/admin/site_customization/pages_controller.rb
@@ -43,8 +43,4 @@ class Admin::SiteCustomization::PagesController < Admin::SiteCustomization::Base
[*attributes, translation_params(SiteCustomization::Page)]
end
-
- def resource
- SiteCustomization::Page.find(params[:id])
- end
end
diff --git a/app/helpers/admin_budget_investments_helper.rb b/app/helpers/admin_budget_investments_helper.rb
deleted file mode 100644
index 014118fd5..000000000
--- a/app/helpers/admin_budget_investments_helper.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-module AdminBudgetInvestmentsHelper
- def advanced_menu_visibility
- if params[:advanced_filters].empty? &&
- params["min_total_supports"].blank? &&
- params["max_total_supports"].blank?
- "hide"
- else
- ""
- end
- end
-
- def init_advanced_menu
- params[:advanced_filters] = [] unless params[:advanced_filters]
- end
-
- def admin_select_options(budget)
- budget.administrators.with_user.map { |v| [v.description_or_name, v.id] }.sort_by { |a| a[0] }
- end
-
- def valuator_or_group_select_options(budget)
- valuator_group_select_options + valuator_select_options(budget)
- end
-
- def valuator_select_options(budget)
- budget.valuators.order("description ASC").order("users.email ASC").includes(:user)
- .map { |v| [v.description_or_email, "valuator_#{v.id}"] }
- end
-
- def valuator_group_select_options
- ValuatorGroup.order("name ASC").map { |g| [g.name, "group_#{g.id}"] }
- end
-
- def investment_tags_select_options(budget, context)
- budget.investments.tags_on(context).order(:name).pluck(:name)
- end
-end
diff --git a/app/views/admin/banners/edit.html.erb b/app/views/admin/banners/edit.html.erb
index 26b4f49b0..a3d17da83 100644
--- a/app/views/admin/banners/edit.html.erb
+++ b/app/views/admin/banners/edit.html.erb
@@ -5,6 +5,6 @@
<%= t("admin.banners.edit.editing") %>
- <%= render "form" %>
+ <%= render Admin::Banners::FormComponent.new(@banner) %>
diff --git a/app/views/admin/banners/new.html.erb b/app/views/admin/banners/new.html.erb
index 1174fc81c..27df19519 100644
--- a/app/views/admin/banners/new.html.erb
+++ b/app/views/admin/banners/new.html.erb
@@ -5,6 +5,6 @@
<%= t("admin.banners.new.creating") %>
- <%= render "form" %>
+ <%= render Admin::Banners::FormComponent.new(@banner) %>
diff --git a/app/views/admin/budget_investments/_search_form.html.erb b/app/views/admin/budget_investments/_search_form.html.erb
deleted file mode 100644
index 8b78a8f73..000000000
--- a/app/views/admin/budget_investments/_search_form.html.erb
+++ /dev/null
@@ -1,71 +0,0 @@
-<% init_advanced_menu %>
-<%= form_tag(admin_budget_budget_investments_path(budget: @budget), method: :get, enforce_utf8: false) do %>
-
- <%= link_to "#advanced_filters_content",
- data: { toggle: "advanced_filters" },
- class: "advanced-filters float-right clear" do %>
- <%= t("admin.budget_investments.index.advanced_filters") %>
- <% end %>
-
-
-
-
-
- <%= select_tag :administrator_id,
- options_for_select(admin_select_options(@budget), params[:administrator_id]),
- { prompt: t("admin.budget_investments.index.administrator_filter_all") } %>
-
-
- <%= select_tag :valuator_or_group_id,
- options_for_select(valuator_or_group_select_options(@budget), params[:valuator_or_group_id]),
- { prompt: t("admin.budget_investments.index.valuator_filter_all") } %>
-
-
- <%= select_tag :heading_id,
- options_for_select(budget_heading_select_options(@budget), params[:heading_id]),
- { prompt: t("admin.budget_investments.index.heading_filter_all") } %>
-
-
- <%= select_tag :tag_name,
- options_for_select(investment_tags_select_options(@budget, "valuation_tags"), params[:tag_name]),
- { prompt: t("admin.budget_investments.index.tags_filter_all") } %>
-
-
-
- <%= select_tag :milestone_tag_name,
- options_for_select(investment_tags_select_options(@budget, "milestone_tags"), params[:milestone_tag_name]),
- { prompt: t("admin.budget_investments.index.milestone_tags_filter_all") } %>
-
-
-
-
- <%= text_field_tag :title_or_id, params["title_or_id"], placeholder: t("admin.budget_investments.index.placeholder") %>
-
-
-
-
- <%= submit_tag t("admin.budget_investments.index.buttons.filter"), class: "button expanded" %>
-
-<% end %>
diff --git a/app/views/admin/budget_investments/index.html.erb b/app/views/admin/budget_investments/index.html.erb
index 7a8e46741..7c9f0db3c 100644
--- a/app/views/admin/budget_investments/index.html.erb
+++ b/app/views/admin/budget_investments/index.html.erb
@@ -8,7 +8,7 @@
<%= @budget.name %> - <%= t("admin.budget_investments.index.title") %>
-<%= render "search_form" %>
+<%= render Admin::BudgetInvestments::SearchFormComponent.new(@budget) %>
<%= render "/shared/filter_subnav", i18n_namespace: "admin.budget_investments.index" %>
diff --git a/app/views/admin/legislation/processes/edit.html.erb b/app/views/admin/legislation/processes/edit.html.erb
index 372792e7e..2d2f148f0 100644
--- a/app/views/admin/legislation/processes/edit.html.erb
+++ b/app/views/admin/legislation/processes/edit.html.erb
@@ -9,5 +9,5 @@
<%= render "subnav", process: @process, active: "info" %>
- <%= render "form" %>
+ <%= render Admin::Legislation::Processes::FormComponent.new(@process) %>
diff --git a/app/views/admin/legislation/processes/new.html.erb b/app/views/admin/legislation/processes/new.html.erb
index 3efb091f6..aff4002b7 100644
--- a/app/views/admin/legislation/processes/new.html.erb
+++ b/app/views/admin/legislation/processes/new.html.erb
@@ -7,5 +7,5 @@
<%= t("admin.legislation.processes.new.title") %>
- <%= render "form" %>
+ <%= render Admin::Legislation::Processes::FormComponent.new(@process) %>
diff --git a/app/views/admin/progress_bars/edit.html.erb b/app/views/admin/progress_bars/edit.html.erb
index 21dd27d9a..c7f280a63 100644
--- a/app/views/admin/progress_bars/edit.html.erb
+++ b/app/views/admin/progress_bars/edit.html.erb
@@ -12,4 +12,4 @@
<%= bar_title %>
-<%= render "form" %>
+<%= render Admin::ProgressBars::FormComponent.new(@progress_bar) %>
diff --git a/app/views/admin/progress_bars/new.html.erb b/app/views/admin/progress_bars/new.html.erb
index 8c379ac3a..81c76b920 100644
--- a/app/views/admin/progress_bars/new.html.erb
+++ b/app/views/admin/progress_bars/new.html.erb
@@ -6,4 +6,4 @@
<%= t("admin.progress_bars.new.creating") %>
-<%= render "form" %>
+<%= render Admin::ProgressBars::FormComponent.new(@progress_bar) %>
diff --git a/app/views/management/budgets/investments/index.html.erb b/app/views/management/budgets/investments/index.html.erb
index 4dfc94848..73dd86f89 100644
--- a/app/views/management/budgets/investments/index.html.erb
+++ b/app/views/management/budgets/investments/index.html.erb
@@ -1,5 +1,5 @@
- <%= render "admin/shared/budget_investment_search", url: management_budget_investments_path(@budget) %>
+ <%= render Management::Budgets::Investments::SearchComponent.new(@budget, url: management_budget_investments_path(@budget)) %>
diff --git a/app/views/management/budgets/investments/print.html.erb b/app/views/management/budgets/investments/print.html.erb
index 4b5de991d..11fcb59ba 100644
--- a/app/views/management/budgets/investments/print.html.erb
+++ b/app/views/management/budgets/investments/print.html.erb
@@ -1,5 +1,5 @@
- <%= render "admin/shared/budget_investment_search", url: print_management_budget_investments_path(@budget) %>
+ <%= render Management::Budgets::Investments::SearchComponent.new(@budget, url: print_management_budget_investments_path(@budget)) %>
diff --git a/app/views/management/user_invites/new.html.erb b/app/views/management/user_invites/new.html.erb
index 826e6115d..2d47b6d55 100644
--- a/app/views/management/user_invites/new.html.erb
+++ b/app/views/management/user_invites/new.html.erb
@@ -1,7 +1,7 @@
<%= t("management.user_invites.new.title") %>
<%= form_tag management_user_invites_path do %>
-
+ <%= label_tag :emails, t("management.user_invites.new.label") %>
<%= t("management.user_invites.new.info") %>
<%= text_area_tag "emails", nil, rows: 5,
aria: { describedby: "emails-help-text" } %>
diff --git a/app/views/moderation/budgets/investments/index.html.erb b/app/views/moderation/budgets/investments/index.html.erb
index 4d81e5b98..cef7b9426 100644
--- a/app/views/moderation/budgets/investments/index.html.erb
+++ b/app/views/moderation/budgets/investments/index.html.erb
@@ -27,7 +27,11 @@
|
- <%= check_box_tag "budget_investment_ids[]", investment.id, nil, id: "#{dom_id(investment)}_check" %>
+ <%= check_box_tag "budget_investment_ids[]",
+ investment.id,
+ nil,
+ id: "#{dom_id(investment)}_check",
+ "aria-label": investment.title %>
|
<% end %>
diff --git a/app/views/moderation/comments/index.html.erb b/app/views/moderation/comments/index.html.erb
index 2381ce886..d6586313e 100644
--- a/app/views/moderation/comments/index.html.erb
+++ b/app/views/moderation/comments/index.html.erb
@@ -12,7 +12,9 @@
<% end %>
diff --git a/app/views/moderation/debates/index.html.erb b/app/views/moderation/debates/index.html.erb
index a3f666764..2691c3ba4 100644
--- a/app/views/moderation/debates/index.html.erb
+++ b/app/views/moderation/debates/index.html.erb
@@ -24,7 +24,11 @@