diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index 441cf51bc..9b500b6af 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -956,34 +956,6 @@ table { // 10. Budgets // ----------------- -.advanced-filters { - margin: $line-height 0; - - @include breakpoint(medium) { - margin: calc(#{$line-height} / 2) 0 0; - } -} - -.advanced-filters-content { - background: $highlight; - clear: both; - margin: $line-height 0; - padding: calc(#{$line-height} / 2); - - .filter { - display: inline-block; - margin: 0 calc(#{$line-height} / 2); - - label { - font-weight: normal; - margin: 0; - } - } - - .button { - margin-top: calc(#{$line-height} / 2); - } -} .columns-selector { diff --git a/app/assets/stylesheets/admin/budget_investments/search_form.scss b/app/assets/stylesheets/admin/budget_investments/search_form.scss new file mode 100644 index 000000000..1849f7f2e --- /dev/null +++ b/app/assets/stylesheets/admin/budget_investments/search_form.scss @@ -0,0 +1,54 @@ +.admin-budget-investments-search-form { + .advanced-filters { + @include link; + float: $global-right; + margin: $line-height 0; + + @include breakpoint(medium) { + margin: calc(#{$line-height} / 2) 0 0; + } + } + + .advanced-filters-content { + background: $highlight; + clear: both; + margin: $line-height 0; + padding: calc(#{$line-height} / 2); + + .filter { + display: inline-block; + margin: 0 calc(#{$line-height} / 2); + + label { + font-weight: normal; + margin: 0; + } + } + + .button { + margin-top: calc(#{$line-height} / 2); + } + } + + .basic-filters { + align-items: flex-end; + clear: both; + display: flex; + flex-wrap: wrap; + + > * { + @include grid-column-gutter; + width: 100%; + + @include breakpoint(medium) { + width: 25%; + } + } + + > .title-or-id-filter { + @include breakpoint(medium) { + width: 50%; + } + } + } +} diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index b2badb487..e949d2e61 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -47,6 +47,7 @@ @import "documents/**/*"; @import "layout/**/*"; @import "machine_learning/**/*"; +@import "management/**/*"; @import "moderation/**/*"; @import "polls/**/*"; @import "proposals/**/*"; diff --git a/app/assets/stylesheets/management/budgets/investments/search.scss b/app/assets/stylesheets/management/budgets/investments/search.scss new file mode 100644 index 000000000..ed7561cf5 --- /dev/null +++ b/app/assets/stylesheets/management/budgets/investments/search.scss @@ -0,0 +1,5 @@ +.management-investments-search { + .checkbox-label { + font-weight: normal; + } +} diff --git a/app/views/admin/banners/_form.html.erb b/app/components/admin/banners/form_component.html.erb similarity index 77% rename from app/views/admin/banners/_form.html.erb rename to app/components/admin/banners/form_component.html.erb index cd82e3f37..a3d5c3d83 100644 --- a/app/views/admin/banners/_form.html.erb +++ b/app/components/admin/banners/form_component.html.erb @@ -1,8 +1,8 @@ -<%= render "shared/globalize_locales", resource: @banner %> +<%= render "shared/globalize_locales", resource: banner %> -<%= translatable_form_for [:admin, @banner] do |f| %> +<%= translatable_form_for [:admin, banner] do |f| %> - <%= render "shared/errors", resource: @banner %> + <%= render "shared/errors", resource: banner %>
@@ -36,7 +36,7 @@
<%= t("admin.banners.banner.sections_label") %> - <%= f.collection_check_boxes(:web_section_ids, @banner_sections, :id, :name) do |b| %> + <%= f.collection_check_boxes(:web_section_ids, sections, :id, :name) do |b| %> <%= b.label do %> <%= b.check_box + t("admin.banners.banner.sections.#{b.text}") %> <% end %> @@ -45,12 +45,12 @@
-
- <%= f.label :background_color, nil, for: "background_color_input" %> +
+ <%= f.label :background_color, nil, for: "background_color_input", id: "background_color_label" %>

<%= t("admin.shared.color_help") %>

- <%= f.text_field :background_color, label: false, type: :color %> + <%= f.text_field :background_color, label: false, type: :color, "aria-labelledby": "background_color_label" %>
<%= f.text_field :background_color, label: false, id: "background_color_input" %> @@ -58,12 +58,12 @@
-
- <%= f.label :font_color, nil, for: "font_color_input" %> +
+ <%= f.label :font_color, nil, for: "font_color_input", id: "font_color_label" %>

<%= t("admin.shared.color_help") %>

- <%= f.text_field :font_color, label: false, type: :color %> + <%= f.text_field :font_color, label: false, type: :color, "aria-labelledby": "font_color_label" %>
<%= f.text_field :font_color, label: false, id: "font_color_input" %> @@ -79,6 +79,6 @@
- <%= render Shared::BannerComponent.new(@banner) %> + <%= render Shared::BannerComponent.new(banner) %>
<% end %> diff --git a/app/components/admin/banners/form_component.rb b/app/components/admin/banners/form_component.rb new file mode 100644 index 000000000..26c51f9ba --- /dev/null +++ b/app/components/admin/banners/form_component.rb @@ -0,0 +1,15 @@ +class Admin::Banners::FormComponent < ApplicationComponent + include TranslatableFormHelper + include GlobalizeHelper + attr_reader :banner + + def initialize(banner) + @banner = banner + end + + private + + def sections + WebSection.all + end +end diff --git a/app/components/admin/budget_investments/search_form_component.html.erb b/app/components/admin/budget_investments/search_form_component.html.erb new file mode 100644 index 000000000..00ff3ec5e --- /dev/null +++ b/app/components/admin/budget_investments/search_form_component.html.erb @@ -0,0 +1,78 @@ +<%= form_tag(admin_budget_budget_investments_path(budget), method: :get, enforce_utf8: false, class: "admin-budget-investments-search-form") do %> +
+ <%= button_tag t("admin.budget_investments.index.advanced_filters"), + type: :button, + data: { toggle: "advanced_filters" }, + class: "advanced-filters" %> +
+ +
+
+
+ <% %w[feasible selected undecided unfeasible without_admin without_valuator under_valuation + valuation_finished winners].each do |filter| %> +
+ <%= check_box_tag "advanced_filters[]", filter, advanced_filters_params.index(filter), id: "advanced_filters_#{filter}" %> + <%= label_tag "advanced_filters[#{filter}]", t("admin.budget_investments.index.filters.#{filter}") %> +
+ <% end %> +
+
+ <%= label_tag :min_total_supports, t("admin.budget_investments.index.filters.min_total_supports") %> + <%= text_field_tag :min_total_supports, params["min_total_supports"] %> +
+
+ <%= label_tag :max_total_supports, t("admin.budget_investments.index.filters.max_total_supports") %> + <%= text_field_tag :max_total_supports, params["max_total_supports"] %> +
+
+
+
+
+ +
+
+ <%= label_tag :administrator_id, attribute_name(:administrator_id) %> + <%= select_tag :administrator_id, + options_for_select(admin_select_options, params[:administrator_id]), + { prompt: t("admin.budget_investments.index.administrator_filter_all") } %> +
+ +
+ <%= label_tag :valuator_or_group_id, t("admin.budget_investments.index.basic_filters.valuator_or_group") %> + <%= select_tag :valuator_or_group_id, + options_for_select(valuator_or_group_select_options, params[:valuator_or_group_id]), + { prompt: t("admin.budget_investments.index.valuator_filter_all") } %> +
+ +
+ <%= label_tag :heading_id, attribute_name(:heading_id) %> + <%= select_tag :heading_id, + options_for_select(budget_heading_select_options(budget), params[:heading_id]), + { prompt: t("admin.budget_investments.index.heading_filter_all") } %> +
+ +
+ <%= label_tag :tag_name, attribute_name(:valuation_tag_list) %> + <%= select_tag :tag_name, + options_for_select(investment_tags_select_options("valuation_tags"), params[:tag_name]), + { prompt: t("admin.budget_investments.index.tags_filter_all") } %> +
+ +
+ <%= label_tag :milestone_tag_name, attribute_name(:milestone_tag_list) %> + <%= select_tag :milestone_tag_name, + options_for_select(investment_tags_select_options("milestone_tags"), params[:milestone_tag_name]), + { prompt: t("admin.budget_investments.index.milestone_tags_filter_all") } %> +
+ +
+ <%= label_tag :title_or_id, t("admin.budget_investments.index.basic_filters.title_or_id") %> + <%= text_field_tag :title_or_id, params["title_or_id"] %> +
+ +
+ <%= submit_tag t("admin.budget_investments.index.buttons.filter"), class: "button expanded" %> +
+
+<% end %> diff --git a/app/components/admin/budget_investments/search_form_component.rb b/app/components/admin/budget_investments/search_form_component.rb new file mode 100644 index 000000000..daa5c222e --- /dev/null +++ b/app/components/admin/budget_investments/search_form_component.rb @@ -0,0 +1,49 @@ +class Admin::BudgetInvestments::SearchFormComponent < ApplicationComponent + attr_reader :budget + use_helpers :budget_heading_select_options + + def initialize(budget) + @budget = budget + end + + private + + def attribute_name(attribute) + Budget::Investment.human_attribute_name(attribute) + end + + def advanced_filters_params + params[:advanced_filters] ||= [] + end + + def advanced_menu_visibility + if advanced_filters_params.empty? && + params["min_total_supports"].blank? && + params["max_total_supports"].blank? + "hide" + else + "" + end + end + + def admin_select_options + budget.administrators.with_user.map { |v| [v.description_or_name, v.id] }.sort_by { |a| a[0] } + end + + def valuator_or_group_select_options + valuator_group_select_options + valuator_select_options + end + + def valuator_group_select_options + ValuatorGroup.order("name ASC").map { |g| [g.name, "group_#{g.id}"] } + end + + def valuator_select_options + budget.valuators.order("description ASC").order("users.email ASC").includes(:user) + .map { |v| [v.description_or_email, "valuator_#{v.id}"] } + end + + def investment_tags_select_options(context) + budget.investments.tags_on(context).order(:name).pluck(:name) + end +end diff --git a/app/components/admin/geozones/form_component.html.erb b/app/components/admin/geozones/form_component.html.erb index bd6a00ab9..ddf2a42d4 100644 --- a/app/components/admin/geozones/form_component.html.erb +++ b/app/components/admin/geozones/form_component.html.erb @@ -24,14 +24,14 @@ <%= f.text_area :geojson, rows: "10", hint: t("admin.geozones.geozone.geojson_help") %>
-
- <%= f.label :color, nil, for: "color_input", id: "color_input_label" %> +
+ <%= f.label :color, nil, for: "color_input", id: "color_label" %>

<%= t("admin.geozones.geozone.color_help", format_help: t("admin.shared.color_help")) %>

- <%= f.text_field :color, label: false, type: :color %> + <%= f.text_field :color, label: false, type: :color, "aria-labelledby": "color_label" %>
<%= f.text_field :color, label: false, id: "color_input" %> diff --git a/app/views/admin/legislation/processes/_form.html.erb b/app/components/admin/legislation/processes/form_component.html.erb similarity index 76% rename from app/views/admin/legislation/processes/_form.html.erb rename to app/components/admin/legislation/processes/form_component.html.erb index 0f461bfd7..6662148fc 100644 --- a/app/views/admin/legislation/processes/_form.html.erb +++ b/app/components/admin/legislation/processes/form_component.html.erb @@ -1,8 +1,8 @@ -<%= render "shared/globalize_locales", resource: @process %> +<%= render "shared/globalize_locales", resource: process %> -<%= translatable_form_for [:admin, @process], html: { class: "legislation-process-form" } do |f| %> +<%= translatable_form_for [:admin, process], html: { class: "legislation-process-form" } do |f| %> - <%= render "shared/errors", resource: @process %> + <%= render "shared/errors", resource: process %>
@@ -18,7 +18,7 @@ <%= f.date_field :draft_end_date, id: "draft_end_date" %>
- <%= f.check_box :draft_phase_enabled, checked: @process.draft_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> + <%= f.check_box :draft_phase_enabled, checked: process.draft_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
@@ -35,7 +35,7 @@ <%= f.date_field :end_date, id: "end_date" %>
- <%= f.check_box :published, checked: @process.published?, label: t("admin.legislation.processes.form.enabled") %> + <%= f.check_box :published, checked: process.published?, label: t("admin.legislation.processes.form.enabled") %>
@@ -52,7 +52,7 @@ <%= f.date_field :debate_end_date, id: "debate_end_date" %>
- <%= f.check_box :debate_phase_enabled, checked: @process.debate_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> + <%= f.check_box :debate_phase_enabled, checked: process.debate_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
@@ -69,7 +69,7 @@ <%= f.date_field :proposals_phase_end_date, id: "proposals_phase_end_date" %>
- <%= f.check_box :proposals_phase_enabled, checked: @process.proposals_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> + <%= f.check_box :proposals_phase_enabled, checked: process.proposals_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
@@ -86,7 +86,7 @@ <%= f.date_field :allegations_end_date, id: "allegations_end_date" %>
- <%= f.check_box :allegations_phase_enabled, checked: @process.allegations_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %> + <%= f.check_box :allegations_phase_enabled, checked: process.allegations_phase.enabled?, label: t("admin.legislation.processes.form.enabled") %>
@@ -95,7 +95,7 @@ <%= f.date_field :draft_publication_date, id: "draft_publication_date" %>
- <%= f.check_box :draft_publication_enabled, checked: @process.draft_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %> + <%= f.check_box :draft_publication_enabled, checked: process.draft_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %>
@@ -104,7 +104,7 @@ <%= f.date_field :result_publication_date, id: "result_publication_date" %>
- <%= f.check_box :result_publication_enabled, checked: @process.result_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %> + <%= f.check_box :result_publication_enabled, checked: process.result_publication.enabled?, label: t("admin.legislation.processes.form.enabled") %>
@@ -121,12 +121,12 @@

<%= t("admin.legislation.processes.form.banner_title") %>

-
- <%= f.label :background_color, nil, for: "background_color_input" %> +
+ <%= f.label :background_color, nil, for: "background_color_input", id: "background_color_label" %>

<%= t("admin.shared.color_help") %>

- <%= f.text_field :background_color, label: false, type: :color %> + <%= f.text_field :background_color, label: false, type: :color, "aria-labelledby": "background_color_label" %>
<%= f.text_field :background_color, label: false, id: "background_color_input" %> @@ -134,12 +134,12 @@
-
- <%= f.label :font_color, nil, for: "font_color_input" %> +
+ <%= f.label :font_color, nil, for: "font_color_input", id: "font_color_label" %>

<%= t("admin.shared.color_help") %>

- <%= f.text_field :font_color, label: false, type: :color %> + <%= f.text_field :font_color, label: false, type: :color, "aria-labelledby": "font_color_label" %>
<%= f.text_field :font_color, label: false, id: "font_color_input" %> @@ -182,7 +182,7 @@
- <%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(@process)}.submit_button")) %> + <%= f.submit(class: "button success expanded", value: t("admin.legislation.processes.#{admin_submit_action(process)}.submit_button")) %>
<% end %> diff --git a/app/components/admin/legislation/processes/form_component.rb b/app/components/admin/legislation/processes/form_component.rb new file mode 100644 index 000000000..b0525378b --- /dev/null +++ b/app/components/admin/legislation/processes/form_component.rb @@ -0,0 +1,11 @@ +class Admin::Legislation::Processes::FormComponent < ApplicationComponent + include TranslatableFormHelper + include GlobalizeHelper + + attr_reader :process + use_helpers :admin_submit_action + + def initialize(process) + @process = process + end +end diff --git a/app/views/admin/progress_bars/_form.html.erb b/app/components/admin/progress_bars/form_component.html.erb similarity index 76% rename from app/views/admin/progress_bars/_form.html.erb rename to app/components/admin/progress_bars/form_component.html.erb index 0a479245f..ea73f5f91 100644 --- a/app/views/admin/progress_bars/_form.html.erb +++ b/app/components/admin/progress_bars/form_component.html.erb @@ -1,6 +1,6 @@ -<%= render "shared/globalize_locales", resource: @progress_bar %> +<%= render "shared/globalize_locales", resource: progress_bar %> -<%= translatable_form_for @progress_bar, url: admin_polymorphic_path(@progress_bar) do |f| %> +<%= translatable_form_for progress_bar, url: admin_polymorphic_path(progress_bar) do |f| %>
@@ -16,13 +16,13 @@ <% end %>
- <% progress_options = { min: ProgressBar::RANGE.min, max: ProgressBar::RANGE.max, step: 1 } %> -
+
- <%= 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 %> -
- -
-
-
- <% %w[feasible selected undecided unfeasible without_admin without_valuator under_valuation - valuation_finished winners].each do |filter| %> -
- <%= check_box_tag "advanced_filters[]", filter, params[:advanced_filters].index(filter), id: "advanced_filters_#{filter}" %> - <%= label_tag "advanced_filters[#{filter}]", t("admin.budget_investments.index.filters.#{filter}") %> -
- <% end %> -
-
- <%= label_tag :min_total_supports, t("admin.budget_investments.index.filters.min_total_supports") %> - <%= text_field_tag :min_total_supports, params["min_total_supports"] %> -
-
- <%= label_tag :max_total_supports, t("admin.budget_investments.index.filters.max_total_supports") %> - <%= text_field_tag :max_total_supports, params["max_total_supports"] %> -
-
-
-
-
- -
- <%= 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 @@ <%= comment.commentable_type.constantize.model_name.human %> - - <%= link_to comment.commentable.title, commentable_path(comment) %> + <%= link_to comment.commentable.title, + commentable_path(comment), + id: dom_id(comment, :title) %>
<%= l comment.updated_at.to_date %>  •  @@ -25,7 +27,11 @@
- <%= check_box_tag "comment_ids[]", comment.id, nil, id: "#{dom_id(comment)}_check" %> + <%= check_box_tag "comment_ids[]", + comment.id, + nil, + id: "#{dom_id(comment)}_check", + "aria-labelledby": dom_id(comment, :title) %> <% 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 @@
- <%= check_box_tag "debate_ids[]", debate.id, nil, id: "#{dom_id(debate)}_check" %> + <%= check_box_tag "debate_ids[]", + debate.id, + nil, + id: "#{dom_id(debate)}_check", + "aria-label": debate.title %> <% end %> diff --git a/app/views/moderation/proposal_notifications/index.html.erb b/app/views/moderation/proposal_notifications/index.html.erb index 2c8a71ac6..39e1addaf 100644 --- a/app/views/moderation/proposal_notifications/index.html.erb +++ b/app/views/moderation/proposal_notifications/index.html.erb @@ -23,7 +23,8 @@ <%= check_box_tag "proposal_notification_ids[]", proposal_notification.id, nil, - id: "#{dom_id(proposal_notification)}_check" %> + id: "#{dom_id(proposal_notification)}_check", + "aria-label": proposal_notification.title %> <% end %> diff --git a/app/views/moderation/proposals/index.html.erb b/app/views/moderation/proposals/index.html.erb index 387ab60d8..e284d75bc 100644 --- a/app/views/moderation/proposals/index.html.erb +++ b/app/views/moderation/proposals/index.html.erb @@ -24,7 +24,11 @@
- <%= check_box_tag "proposal_ids[]", proposal.id, nil, id: "#{dom_id(proposal)}_check" %> + <%= check_box_tag "proposal_ids[]", + proposal.id, + nil, + id: "#{dom_id(proposal)}_check", + "aria-label": proposal.title %> <% end %> diff --git a/app/views/verification/residence/new.html.erb b/app/views/verification/residence/new.html.erb index a0d9b955e..c361d7d4c 100644 --- a/app/views/verification/residence/new.html.erb +++ b/app/views/verification/residence/new.html.erb @@ -38,7 +38,7 @@
- <%= f.label t("verification.residence.new.document_number") %> + <%= f.label :document_number, t("verification.residence.new.document_number") %>