diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 56d9dc046..ffe4f4f4a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,6 +6,7 @@ class ApplicationController < ActionController::Base include HasOrders include AccessDeniedHandler + default_form_builder ConsulFormBuilder protect_from_forgery with: :exception before_action :authenticate_http_basic, if: :http_basic_auth_site? diff --git a/app/controllers/management/base_controller.rb b/app/controllers/management/base_controller.rb index 9f45fab39..78b0f7fc3 100644 --- a/app/controllers/management/base_controller.rb +++ b/app/controllers/management/base_controller.rb @@ -1,6 +1,7 @@ class Management::BaseController < ActionController::Base include GlobalizeFallbacks layout "management" + default_form_builder ConsulFormBuilder before_action :verify_manager before_action :set_locale diff --git a/app/controllers/management/sessions_controller.rb b/app/controllers/management/sessions_controller.rb index 5617c22fb..066fc6a9f 100644 --- a/app/controllers/management/sessions_controller.rb +++ b/app/controllers/management/sessions_controller.rb @@ -3,6 +3,7 @@ require "manager_authenticator" class Management::SessionsController < ActionController::Base include GlobalizeFallbacks include AccessDeniedHandler + default_form_builder ConsulFormBuilder def create destroy_session diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb index d8de03389..6403bd440 100644 --- a/app/helpers/documents_helper.rb +++ b/app/helpers/documents_helper.rb @@ -33,18 +33,15 @@ module DocumentsHelper def render_attachment(builder, document) klass = document.persisted? || document.cached_attachment.present? ? " hide" : "" - html = builder.label :attachment, - t("documents.form.attachment_label"), - class: "button hollow #{klass}" - html += builder.file_field :attachment, - label: false, - accept: accepted_content_types_extensions(document.documentable_type.constantize), - class: "js-document-attachment", - data: { - url: document_direct_upload_url(document), - nested_document: true - } - html + builder.file_field :attachment, + label: t("documents.form.attachment_label"), + label_options: { class: "button hollow #{klass}" }, + accept: accepted_content_types_extensions(document.documentable_type.constantize), + class: "js-document-attachment", + data: { + url: document_direct_upload_url(document), + nested_document: true + } end def document_direct_upload_url(document) diff --git a/app/helpers/images_helper.rb b/app/helpers/images_helper.rb index c865c6937..0fbe1dd2f 100644 --- a/app/helpers/images_helper.rb +++ b/app/helpers/images_helper.rb @@ -47,19 +47,15 @@ module ImagesHelper def render_image_attachment(builder, imageable, image) klass = image.persisted? || image.cached_attachment.present? ? " hide" : "" - html = builder.label :attachment, - t("images.form.attachment_label"), - class: "button hollow #{klass}" - html += builder.file_field :attachment, - label: false, - accept: imageable_accepted_content_types_extensions, - class: "js-image-attachment", - data: { - url: image_direct_upload_url(imageable), - nested_image: true - } - - html + builder.file_field :attachment, + label: t("images.form.attachment_label"), + label_options: { class: "button hollow #{klass}" }, + accept: imageable_accepted_content_types_extensions, + class: "js-image-attachment", + data: { + url: image_direct_upload_url(imageable), + nested_image: true + } end def render_image(image, version, show_caption = true) diff --git a/app/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index ff8659dd2..1310dfc1c 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -64,10 +64,6 @@ module ProposalsHelper proposals_current_view == "default" ? "minimal" : "default" end - def summary_help_text_id(translations_form) - "summary-help-text-#{translations_form.locale}" - end - def link_to_toggle_proposal_selection(proposal) if proposal.selected? button_text = t("admin.proposals.index.selected") diff --git a/app/helpers/translatable_form_helper.rb b/app/helpers/translatable_form_helper.rb index ecd0a16a1..92eff3d33 100644 --- a/app/helpers/translatable_form_helper.rb +++ b/app/helpers/translatable_form_helper.rb @@ -18,7 +18,7 @@ module TranslatableFormHelper "highlight" if translations_interface_enabled? end - class TranslatableFormBuilder < FoundationRailsHelper::FormBuilder + class TranslatableFormBuilder < ConsulFormBuilder attr_accessor :translations def translatable_fields(&block) @@ -94,31 +94,9 @@ module TranslatableFormHelper end end - class TranslationsFieldsBuilder < FoundationRailsHelper::FormBuilder - %i[text_field text_area cktext_area].each do |field| - define_method field do |attribute, options = {}| - custom_label(attribute, options[:label], options[:label_options]) + - help_text(options[:hint]) + - super(attribute, options.merge(label: false, hint: false)) - end - end - + class TranslationsFieldsBuilder < ConsulFormBuilder def locale @object.locale end - - def label(attribute, text = nil, options = {}) - label_options = options.dup - hint = label_options.delete(:hint) - - super(attribute, text, label_options) + help_text(hint) - end - - private - def help_text(text) - if text - content_tag :span, text, class: "help-text" - end - end end end diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb index b1fda5247..90ac292d5 100644 --- a/app/views/account/show.html.erb +++ b/app/views/account/show.html.erb @@ -32,82 +32,40 @@
- <%= f.label :public_activity do %> - <%= f.check_box :public_activity, title: t("account.show.public_activity_label"), label: false %> - - <%= t("account.show.public_activity_label") %> - - <% end %> + <%= f.check_box :public_activity, label: t("account.show.public_activity_label") %>
- <%= f.label :public_interests do %> - <%= f.check_box :public_interests, title: t("account.show.public_interests_label"), label: false %> - - <%= t("account.show.public_interests_label") %> - - <% end %> + <%= f.check_box :public_interests, label: t("account.show.public_interests_label") %>
<% if @account.email.present? %>

<%= t("account.show.notifications") %>

- <%= f.label :email_on_comment do %> - <%= f.check_box :email_on_comment, title: t("account.show.email_on_comment_label"), label: false %> - - <%= t("account.show.email_on_comment_label") %> - - <% end %> + <%= f.check_box :email_on_comment, label: t("account.show.email_on_comment_label") %>
- <%= f.label :email_on_comment_reply do %> - <%= f.check_box :email_on_comment_reply, title: t("account.show.email_on_comment_reply_label"), label: false %> - - <%= t("account.show.email_on_comment_reply_label") %> - - <% end %> + <%= f.check_box :email_on_comment_reply, label: t("account.show.email_on_comment_reply_label") %>
- <%= f.label :email_newsletter_subscribed do %> - <%= f.check_box :newsletter, title: t("account.show.subscription_to_website_newsletter_label"), label: false %> - - <%= t("account.show.subscription_to_website_newsletter_label") %> - - <% end %> + <%= f.check_box :newsletter, label: t("account.show.subscription_to_website_newsletter_label") %>
- <%= f.label :email_digest do %> - <%= f.check_box :email_digest, title: t("account.show.email_digest_label"), label: false %> - - <%= t("account.show.email_digest_label") %> - - <% end %> + <%= f.check_box :email_digest, label: t("account.show.email_digest_label") %>
- <%= f.label :email_on_direct_message do %> - <%= f.check_box :email_on_direct_message, title: t("account.show.email_on_direct_message_label"), label: false %> - - <%= t("account.show.email_on_direct_message_label") %> - - <% end %> + <%= f.check_box :email_on_direct_message, label: t("account.show.email_on_direct_message_label") %>
<% end %> <% if @account.official_level == 1 %>
- <%= f.label :official_position_badge do %> - <%= f.check_box :official_position_badge, - title: t("account.show.official_position_badge_label"), - label: false %> - - <%= t("account.show.official_position_badge_label") %> - - <% end %> + <%= f.check_box :official_position_badge, label: t("account.show.official_position_badge_label") %>
<% end %> @@ -116,23 +74,13 @@ <% if feature?("user.recommendations_on_debates") %>
- <%= f.label :recommended_debates do %> - <%= f.check_box :recommended_debates, title: t("account.show.show_debates_recommendations"), label: false %> - - <%= t("account.show.show_debates_recommendations") %> - - <% end %> + <%= f.check_box :recommended_debates, label: t("account.show.show_debates_recommendations") %>
<% end %> <% if feature?("user.recommendations_on_proposals") %>
- <%= f.label :recommended_proposals do %> - <%= f.check_box :recommended_proposals, title: t("account.show.show_proposals_recommendations"), label: false %> - - <%= t("account.show.show_proposals_recommendations") %> - - <% end %> + <%= f.check_box :recommended_proposals, label: t("account.show.show_proposals_recommendations") %>
<% end %> <% end %> diff --git a/app/views/admin/banners/_form.html.erb b/app/views/admin/banners/_form.html.erb index 0195d8e52..5e7d6e56b 100644 --- a/app/views/admin/banners/_form.html.erb +++ b/app/views/admin/banners/_form.html.erb @@ -7,9 +7,8 @@
<% date_started_at = @banner.post_started_at.present? ? I18n.localize(@banner.post_started_at) : "" %>
- <%= f.label :post_started_at, t("admin.banners.banner.post_started_at") %> <%= f.text_field :post_started_at, - label: false, + label: t("admin.banners.banner.post_started_at"), placeholder: t("admin.banners.banner.post_started_at"), value: date_started_at, class: "js-calendar-full", @@ -17,9 +16,8 @@
<% date_ended_at = @banner.post_ended_at.present? ? I18n.localize(@banner.post_ended_at) : "" %>
- <%= f.label :post_ended_at, t("admin.banners.banner.post_ended_at") %> <%= f.text_field :post_ended_at, - label: false, + label: t("admin.banners.banner.post_ended_at"), placeholder: t("admin.banners.banner.post_ended_at"), value: date_ended_at, class: "js-calendar-full", @@ -47,9 +45,8 @@
- <%= f.label :target_url, t("admin.banners.banner.target_url") %> <%= f.text_field :target_url, - label: false, + label: t("admin.banners.banner.target_url"), placeholder: t("admin.banners.banner.target_url") %>
diff --git a/app/views/admin/budget_headings/_form.html.erb b/app/views/admin/budget_headings/_form.html.erb index fd3c9bc58..827afed60 100644 --- a/app/views/admin/budget_headings/_form.html.erb +++ b/app/views/admin/budget_headings/_form.html.erb @@ -22,16 +22,12 @@ maxlength: 8, placeholder: t("admin.budget_headings.form.amount") %> - <%= f.label :population, t("admin.budget_headings.form.population") %> -

- <%= t("admin.budget_headings.form.population_info") %> -

<%= f.text_field :population, - label: false, + label: t("admin.budget_headings.form.population"), maxlength: 8, placeholder: t("admin.budget_headings.form.population"), data: { toggle_focus: "population-info" }, - aria: { describedby: "budgets-population-help-text" } %> + hint: t("admin.budget_headings.form.population_info") %> <%= f.text_field :latitude, label: t("admin.budget_headings.form.latitude"), diff --git a/app/views/admin/budget_investments/_search_form.html.erb b/app/views/admin/budget_investments/_search_form.html.erb index 80b722bed..b6c24b1a1 100644 --- a/app/views/admin/budget_investments/_search_form.html.erb +++ b/app/views/admin/budget_investments/_search_form.html.erb @@ -35,33 +35,28 @@
<%= select_tag :administrator_id, options_for_select(admin_select_options, params[:administrator_id]), - { prompt: t("admin.budget_investments.index.administrator_filter_all"), - label: false } %> + { prompt: t("admin.budget_investments.index.administrator_filter_all") } %>
<%= 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: false } %> + { 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"), - label: false } %> + { prompt: t("admin.budget_investments.index.heading_filter_all") } %>
<%= select_tag :tag_name, options_for_select(investment_tags_select_options(@budget), params[:tag_name]), - { prompt: t("admin.budget_investments.index.tags_filter_all"), - label: false } %> + { prompt: t("admin.budget_investments.index.tags_filter_all") } %>
<%= select_tag :milestone_tag_name, options_for_select(investment_milestone_tags_select_options(@budget), params[:milestone_tag_name]), - { prompt: t("admin.budget_investments.index.milestone_tags_filter_all"), - label: false } %> + { prompt: t("admin.budget_investments.index.milestone_tags_filter_all") } %>
diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb index 8051783c7..f8a51add9 100644 --- a/app/views/admin/budget_investments/edit.html.erb +++ b/app/views/admin/budget_investments/edit.html.erb @@ -29,10 +29,9 @@ <% end %>
- <%= f.label :tag_list, t("admin.budget_investments.edit.user_tags") %> <%= f.text_field :tag_list, value: @investment.tag_list.sort.join(","), - label: false %> + label: t("admin.budget_investments.edit.user_tags") %>
@@ -106,18 +105,16 @@ <% if @investment.incompatible? || @investment.winner? %>

<%= t("admin.budget_investments.edit.compatibility") %>

- <%= f.label :incompatible do %> - <%= f.check_box :incompatible, title: t("admin.budget_investments.edit.compatibility"), label: false %> - <%= t("admin.budget_investments.edit.mark_as_incompatible") %> - <% end %> + <%= f.check_box :incompatible, + title: t("admin.budget_investments.edit.compatibility"), + label: t("admin.budget_investments.edit.mark_as_incompatible") %>
<% end %>

<%= t("admin.budget_investments.edit.selection") %>

- <%= f.label :selected do %> - <%= f.check_box :selected, title: t("admin.budget_investments.edit.selection"), label: false %> - <%= t("admin.budget_investments.edit.mark_as_selected") %> - <% end %> + <%= f.check_box :selected, + title: t("admin.budget_investments.edit.selection"), + label: t("admin.budget_investments.edit.mark_as_selected") %>
diff --git a/app/views/admin/budget_phases/_form.html.erb b/app/views/admin/budget_phases/_form.html.erb index 4bb746219..5251b3254 100644 --- a/app/views/admin/budget_phases/_form.html.erb +++ b/app/views/admin/budget_phases/_form.html.erb @@ -6,50 +6,38 @@
- <%= f.label :starts_at, t("admin.budget_phases.edit.start_date") %> <%= f.text_field :starts_at, value: format_date_for_calendar_form(@phase.starts_at), class: "js-calendar-full", id: "start_date", - label: false %> + label: t("admin.budget_phases.edit.start_date") %>
- <%= f.label :ends_at, t("admin.budget_phases.edit.end_date") %> <%= f.text_field :ends_at, value: format_date_for_calendar_form(@phase.ends_at), class: "js-calendar-full", id: "end_date", - label: false %> + label: t("admin.budget_phases.edit.end_date") %>
<%= f.translatable_fields do |translations_form| %>
- <%= f.label :description, t("admin.budget_phases.edit.description") %> - - - <%= t("admin.budget_phases.edit.description_help_text") %> - -
<%= translations_form.cktext_area :description, maxlength: Budget::Phase::DESCRIPTION_MAX_LENGTH, - label: false %> + label: t("admin.budget_phases.edit.description"), + hint: t("admin.budget_phases.edit.description_help_text") %>
- <%= f.label :summary, t("admin.budget_phases.edit.summary") %> - - - <%= t("admin.budget_phases.edit.summary_help_text") %> - -
<%= translations_form.cktext_area :summary, maxlength: Budget::Phase::SUMMARY_MAX_LENGTH, - label: false %> + label: t("admin.budget_phases.edit.summary"), + hint: t("admin.budget_phases.edit.summary_help_text") %>
<% end %> diff --git a/app/views/admin/dashboard/actions/_form.html.erb b/app/views/admin/dashboard/actions/_form.html.erb index 59e74690a..f018bb1f2 100644 --- a/app/views/admin/dashboard/actions/_form.html.erb +++ b/app/views/admin/dashboard/actions/_form.html.erb @@ -5,9 +5,9 @@ <%= f.label :action_type %> <% ::Dashboard::Action.action_types.keys.each do |action_type_value| %> - <%= f.radio_button :action_type, action_type_value, label: false, - data: { toggle: "request_to_administrators short_description" } %> - <%= f.label "action_type_#{action_type_value}", t("admin.dashboard.actions.action_type.#{action_type_value}") %> + <%= f.radio_button :action_type, action_type_value, + label: t("admin.dashboard.actions.action_type.#{action_type_value}"), + data: { toggle: "request_to_administrators short_description" } %> <% end %>
@@ -26,12 +26,10 @@
- <%= f.label :title %> - <%= f.text_field :title, label: false %> + <%= f.text_field :title %>
- <%= f.label :short_description %> - <%= f.text_field :short_description, label: false %> + <%= f.text_field :short_description %>
@@ -49,21 +47,18 @@
- <%= f.label :day_offset %> -

<%= t("admin.dashboard.actions.form.help_text") %>

- <%= f.number_field :day_offset, label: false, step: 1, min: 0 %> + <%= f.number_field :day_offset, step: 1, min: 0, + hint: t("admin.dashboard.actions.form.help_text") %>
- <%= f.label :required_supports %> -

<%= t("admin.dashboard.actions.form.help_text") %>

- <%= f.number_field :required_supports, label: false, step: 1, min: 0 %> + <%= f.number_field :required_supports, step: 1, min: 0, + hint: t("admin.dashboard.actions.form.help_text") %>
- <%= f.label :order %> -

<%= t("admin.dashboard.actions.form.help_text") %>

- <%= f.number_field :order, label: false, step: 1, min: 0 %> + <%= f.number_field :order, step: 1, min: 0, + hint: t("admin.dashboard.actions.form.help_text") %>
diff --git a/app/views/admin/geozones/_form.html.erb b/app/views/admin/geozones/_form.html.erb index 0a1bde3d9..516ce7ef1 100644 --- a/app/views/admin/geozones/_form.html.erb +++ b/app/views/admin/geozones/_form.html.erb @@ -8,22 +8,16 @@
- <%= f.label :census_code %> -

<%= t("admin.geozones.geozone.code_help") %>

- <%= f.text_field :census_code, label: false %> + <%= f.text_field :census_code, hint: t("admin.geozones.geozone.code_help") %>
- <%= f.label :external_code %> -

<%= t("admin.geozones.geozone.code_help") %>

- <%= f.text_field :external_code, label: false %> + <%= f.text_field :external_code, hint: t("admin.geozones.geozone.code_help") %>
- <%= f.label :html_map_coordinates %> -

<%= t("admin.geozones.geozone.coordinates_help") %>

- <%= f.text_field :html_map_coordinates, label: false %> + <%= f.text_field :html_map_coordinates, hint: t("admin.geozones.geozone.coordinates_help") %>
diff --git a/app/views/admin/legislation/draft_versions/_form.html.erb b/app/views/admin/legislation/draft_versions/_form.html.erb index d0cf4f317..6e2395ebb 100644 --- a/app/views/admin/legislation/draft_versions/_form.html.erb +++ b/app/views/admin/legislation/draft_versions/_form.html.erb @@ -71,16 +71,14 @@
<%= f.label :status %> <% ::Legislation::DraftVersion::VALID_STATUSES.each do |status| %> - <%= f.radio_button :status, status, label: false %> - <%= f.label "status_#{status}", t("admin.legislation.draft_versions.statuses.#{status}") %> + <%= f.radio_button :status, status, label: t("admin.legislation.draft_versions.statuses.#{status}") %> <%= t("admin.legislation.draft_versions.form.hints.status.#{status}") %>
<% end %>
- <%= f.label :final_version %> - <%= f.check_box :final_version, label: false %> + <%= f.check_box :final_version %> <%= t("admin.legislation.draft_versions.form.hints.final_version") %>
diff --git a/app/views/admin/legislation/proposals/_form.html.erb b/app/views/admin/legislation/proposals/_form.html.erb index 19e0afe3a..536521187 100644 --- a/app/views/admin/legislation/proposals/_form.html.erb +++ b/app/views/admin/legislation/proposals/_form.html.erb @@ -16,10 +16,9 @@ <% end %>
- <%= f.label :custom_list, t("admin.legislation.proposals.form.custom_categories") %> - <%= t("admin.legislation.proposals.form.custom_categories_description") %> <%= f.text_field :custom_list, value: @process.tag_list_on(:customs).to_s, - label: false, + label: t("admin.legislation.proposals.form.custom_categories"), + hint: t("admin.legislation.proposals.form.custom_categories_description"), placeholder: t("admin.legislation.proposals.form.custom_categories_placeholder"), class: "js-tag-list", aria: { describedby: "tag-list-help-text" } %> diff --git a/app/views/admin/local_census_records/_form.html.erb b/app/views/admin/local_census_records/_form.html.erb index 959b365cd..5b1dcd9ea 100644 --- a/app/views/admin/local_census_records/_form.html.erb +++ b/app/views/admin/local_census_records/_form.html.erb @@ -15,17 +15,14 @@
- <%= f.label :date_of_birth, t("admin.local_census_records.form.date_of_birth") %> -
- <%= f.date_select :date_of_birth, - prompt: true, - start_year: 1900, end_year: minimum_required_age.years.ago.year, - label: false %> -
+ <%= f.date_select :date_of_birth, + prompt: true, + start_year: 1900, end_year: minimum_required_age.years.ago.year, + label: t("admin.local_census_records.form.date_of_birth") %>
-
+
<%= f.text_field :postal_code %>
diff --git a/app/views/admin/newsletters/_form.html.erb b/app/views/admin/newsletters/_form.html.erb index 37a153fab..c68d3cb37 100644 --- a/app/views/admin/newsletters/_form.html.erb +++ b/app/views/admin/newsletters/_form.html.erb @@ -4,8 +4,7 @@ <%= f.select :segment_recipient, options_for_select(user_segments_options, @newsletter[:segment_recipient]) %> <%= f.text_field :subject %> - <%= f.label :from, t("admin.newsletters.new.from") %> - <%= f.text_field :from, label: false %> + <%= f.text_field :from, label: t("admin.newsletters.new.from") %> <%= f.cktext_area :body, ckeditor: { language: I18n.locale } %>
diff --git a/app/views/admin/poll/shifts/_form.html.erb b/app/views/admin/poll/shifts/_form.html.erb index 726e0797f..c09f63d85 100644 --- a/app/views/admin/poll/shifts/_form.html.erb +++ b/app/views/admin/poll/shifts/_form.html.erb @@ -13,11 +13,9 @@
- <%= f.select :task, Poll::Shift.tasks.map { |k, v| [t("admin.poll_shifts.#{k}"), k] }, - { prompt: t("admin.poll_shifts.new.select_task"), - label: false }, + { prompt: t("admin.poll_shifts.new.select_task"), label: t("admin.poll_shifts.new.task") }, class: "js-poll-shifts" %>
@@ -25,13 +23,11 @@ <%= select "shift[date]", "vote_collection_date", options_for_select(shift_vote_collection_dates(@booth, @voting_polls)), - { prompt: @voting_polls.present? ? t("admin.poll_shifts.new.select_date") : t("admin.poll_shifts.new.no_voting_days"), - label: false }, + { prompt: @voting_polls.present? ? t("admin.poll_shifts.new.select_date") : t("admin.poll_shifts.new.no_voting_days") }, class: "js-shift-vote-collection-dates" %> <%= select "shift[date]", "recount_scrutiny_date", options_for_select(shift_recount_scrutiny_dates(@booth, @recount_polls)), - { prompt: t("admin.poll_shifts.new.select_date"), - label: false }, + { prompt: t("admin.poll_shifts.new.select_date") }, class: "js-shift-recount-scrutiny-dates", hidden: "hidden" %>
diff --git a/app/views/admin/signature_sheets/new.html.erb b/app/views/admin/signature_sheets/new.html.erb index bf88f1ca7..f851ebd0f 100644 --- a/app/views/admin/signature_sheets/new.html.erb +++ b/app/views/admin/signature_sheets/new.html.erb @@ -14,10 +14,8 @@ <%= f.text_field :signable_id %>
- <%= f.label :required_fields_to_verify %> -

<%= required_fields_to_verify_text_help %>

-

<%= example_text_help %>

- <%= f.text_area :required_fields_to_verify, rows: "6", label: false, aria: { describedby: "required-fields-to-verify-help-text" } %> + <%= f.text_area :required_fields_to_verify, rows: "6", + hint: sanitize("#{required_fields_to_verify_text_help}
#{example_text_help}") %> <%= f.submit(class: "button", value: t("admin.signature_sheets.new.submit")) %> <% end %> diff --git a/app/views/admin/site_customization/content_blocks/_form_content_block.html.erb b/app/views/admin/site_customization/content_blocks/_form_content_block.html.erb index 897558fe4..0753b075e 100644 --- a/app/views/admin/site_customization/content_blocks/_form_content_block.html.erb +++ b/app/views/admin/site_customization/content_blocks/_form_content_block.html.erb @@ -16,17 +16,14 @@ <% end %>
- <%= f.label :name %> - <%= f.select :name, options_for_select(valid_blocks, @selected_content_block), label: false %> + <%= f.select :name, options_for_select(valid_blocks, @selected_content_block) %>
- <%= f.label :locale %> - <%= f.select :locale, I18n.available_locales, label: false %> + <%= f.select :locale, I18n.available_locales %>
- <%= f.label :body %> - <%= f.text_area :body, label: false, rows: 10 %> + <%= f.text_area :body, rows: 10 %>
<%= f.submit class: "button success expanded" %>
diff --git a/app/views/admin/site_customization/content_blocks/_form_heading_content_block.html.erb b/app/views/admin/site_customization/content_blocks/_form_heading_content_block.html.erb index 3f9e8e4b8..f05f0c1e9 100644 --- a/app/views/admin/site_customization/content_blocks/_form_heading_content_block.html.erb +++ b/app/views/admin/site_customization/content_blocks/_form_heading_content_block.html.erb @@ -13,11 +13,11 @@
<%= label_tag :name %> - <%= select_tag :name, options_for_select(valid_blocks, @selected_content_block), label: false %> + <%= select_tag :name, options_for_select(valid_blocks, @selected_content_block) %>
<%= label_tag :locale %> - <%= select_tag :locale, options_for_select(I18n.available_locales, @content_block.locale.to_sym), label: false %> + <%= select_tag :locale, options_for_select(I18n.available_locales, @content_block.locale.to_sym) %>
<%= label_tag :body %> diff --git a/app/views/admin/site_customization/pages/_form.html.erb b/app/views/admin/site_customization/pages/_form.html.erb index c253798d8..7396b4cec 100644 --- a/app/views/admin/site_customization/pages/_form.html.erb +++ b/app/views/admin/site_customization/pages/_form.html.erb @@ -22,8 +22,8 @@

<%= t("admin.site_customization.pages.form.options") %>

<%= f.label :status %> <% ::SiteCustomization::Page::VALID_STATUSES.each do |status| %> - <%= f.radio_button :status, status, label: false %> - <%= f.label "status_#{status}", t("admin.site_customization.pages.page.status_#{status}") %> + <%= f.radio_button :status, status, + label: t("admin.site_customization.pages.page.status_#{status}") %>
<% end %> @@ -32,9 +32,8 @@
- <%= f.label :slug %> -

<%= t("admin.site_customization.pages.new.slug_help_html") %> - <%= f.text_field :slug, label: false, size: 80, maxlength: 80 %> + <%= f.text_field :slug, size: 80, maxlength: 80, + hint: t("admin.site_customization.pages.new.slug_help_html") %>

diff --git a/app/views/admin/tags/index.html.erb b/app/views/admin/tags/index.html.erb index b02959059..c40c113d0 100644 --- a/app/views/admin/tags/index.html.erb +++ b/app/views/admin/tags/index.html.erb @@ -3,8 +3,7 @@ <%= form_for(@tag, url: admin_tags_path, as: :tag) do |f| %>
- <%= f.label :name, t("admin.tags.name.placeholder") %> - <%= f.text_field :name, placeholder: t("admin.tags.name.placeholder"), label: false %> + <%= f.text_field :name, placeholder: t("admin.tags.name.placeholder"), label: t("admin.tags.name.placeholder") %>
<%= f.submit(t("admin.tags.create"), class: "button success") %> diff --git a/app/views/admin/valuator_groups/edit.html.erb b/app/views/admin/valuator_groups/edit.html.erb index b73095d2e..495750acc 100644 --- a/app/views/admin/valuator_groups/edit.html.erb +++ b/app/views/admin/valuator_groups/edit.html.erb @@ -2,8 +2,7 @@
<%= form_for [:admin, @group] do |f| %> - <%= f.label :name, t("admin.valuator_groups.form.name") %> - <%= f.text_field :name, label: false %> + <%= f.text_field :name, label: t("admin.valuator_groups.form.name") %> <%= f.submit t("admin.valuator_groups.form.edit"), class: "button success" %> <% end %>
diff --git a/app/views/admin/valuator_groups/new.html.erb b/app/views/admin/valuator_groups/new.html.erb index d79f22d85..044c626a7 100644 --- a/app/views/admin/valuator_groups/new.html.erb +++ b/app/views/admin/valuator_groups/new.html.erb @@ -2,8 +2,7 @@
<%= form_for [:admin, @group] do |f| %> - <%= f.label :name, t("admin.valuator_groups.form.name") %> - <%= f.text_field :name, label: false %> + <%= f.text_field :name, label: t("admin.valuator_groups.form.name") %> <%= f.submit t("admin.valuator_groups.form.new"), class: "button success" %> <% end %>
diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index f1b405cc5..d81a92b06 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -59,8 +59,7 @@ <% end %>
- <%= f.label :location, t("budgets.investments.form.location") %> - <%= f.text_field :location, label: false %> + <%= f.text_field :location, label: t("budgets.investments.form.location") %>
@@ -90,14 +89,11 @@ <% unless current_user.manager? %>
- <%= f.label :terms_of_service do %> - <%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %> - - <%= t("form.accept_terms", - policy: link_to(t("form.policy"), "/privacy", target: "blank"), - conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %> - - <% end %> + <%= f.check_box :terms_of_service, + title: t("form.accept_terms_title"), + label: t("form.accept_terms", + policy: link_to(t("form.policy"), "/privacy", target: "blank"), + conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
<% end %> diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 4841e6871..87b04c317 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -3,8 +3,11 @@ <% css_id = parent_or_commentable_dom_id(parent_id, commentable) %>
class="comment-form"> <%= form_for Comment.new, remote: true do |f| %> - <%= label_tag "comment-body-#{css_id}", leave_comment_text(commentable) %> - <%= f.text_area :body, id: "comment-body-#{css_id}", maxlength: Comment.body_max_length, label: false %> + <%= f.text_area :body, + id: "comment-body-#{css_id}", + maxlength: Comment.body_max_length, + label: leave_comment_text(commentable) %> + <%= f.hidden_field :commentable_type, value: commentable.class.name %> <%= f.hidden_field :commentable_id, value: commentable.id %> <%= f.hidden_field :parent_id, value: parent_id %> @@ -14,14 +17,16 @@ <% if can? :comment_as_moderator, commentable %>
- <%= f.check_box :as_moderator, title: t("comments.form.comment_as_moderator"), id: "comment-as-moderator-#{css_id}", label: false %> - <%= label_tag "comment-as-moderator-#{css_id}", t("comments.form.comment_as_moderator"), class: "checkbox" %> + <%= f.check_box :as_moderator, + label: t("comments.form.comment_as_moderator"), + id: "comment-as-moderator-#{css_id}" %>
<% end %> <% if can? :comment_as_administrator, commentable %>
- <%= f.check_box :as_administrator, title: t("comments.form.comment_as_admin"), id: "comment-as-administrator-#{css_id}", label: false %> - <%= label_tag "comment-as-administrator-#{css_id}", t("comments.form.comment_as_admin"), class: "checkbox" %> + <%= f.check_box :as_administrator, + label: t("comments.form.comment_as_admin"), + id: "comment-as-administrator-#{css_id}" %>
<% end %> diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index 87c559a62..69639fbb4 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -26,26 +26,21 @@ <%= f.invisible_captcha :subtitle %>
- <%= f.label :tag_list, t("debates.form.tags_label") %> -

<%= t("debates.form.tags_instructions") %>

- <%= f.text_field :tag_list, value: @debate.tag_list.to_s, - label: false, + label: t("debates.form.tags_label"), + hint: t("debates.form.tags_instructions"), placeholder: t("debates.form.tags_placeholder"), - aria: { describedby: "tag-list-help-text" }, data: { js_url: suggest_tags_path }, class: "tag-autocomplete" %>
<% if @debate.new_record? %> - <%= f.label :terms_of_service do %> - <%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %> - - <%= t("form.accept_terms", - policy: link_to(t("form.policy"), "/privacy", target: "blank"), - conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %> - - <% end %> + <%= f.check_box :terms_of_service, + title: t("form.accept_terms_title"), + label: t("form.accept_terms", + policy: link_to(t("form.policy"), "/privacy", target: "blank"), + conditions: link_to(t("form.conditions"), "/conditions", target: "blank") + ).html_safe %> <% end %>
diff --git a/app/views/devise/password_expired/show.html.erb b/app/views/devise/password_expired/show.html.erb index cf008fe35..ac3fd10ae 100644 --- a/app/views/devise/password_expired/show.html.erb +++ b/app/views/devise/password_expired/show.html.erb @@ -3,10 +3,7 @@ <%= form_for(resource, :as => resource_name, :url => [resource_name, :password_expired], :html => { :method => :put }) do |f| %> <%= f.password_field :current_password %>

- - <%= f.label t("devise.password_expired.new_password") %> - <%= f.password_field :password, label: false %>

- + <%= f.password_field :password, label: t("devise.password_expired.new_password") %>

<%= f.password_field :password_confirmation %>

<%= f.submit t("devise.password_expired.change_password") %>

diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index f6e62791d..cba9e6ec0 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -21,10 +21,7 @@ <% if devise_mapping.rememberable? -%>
- <%= f.label :remember_me do %> - <%= f.check_box :remember_me, title: t("devise_views.sessions.new.remember_me"), label: false %> - <%= t("devise_views.sessions.new.remember_me") %> - <% end %> + <%= f.check_box :remember_me, label: t("devise_views.sessions.new.remember_me") %>
<% end -%> diff --git a/app/views/direct_messages/new.html.erb b/app/views/direct_messages/new.html.erb index fef4d84dc..202dff6c8 100644 --- a/app/views/direct_messages/new.html.erb +++ b/app/views/direct_messages/new.html.erb @@ -23,11 +23,8 @@ <%= form_for [@receiver, @direct_message] do |f| %> <%= render "shared/errors", resource: @direct_message %> - <%= f.label :title, t("users.direct_messages.new.title_label") %> - <%= f.text_field :title, label: false %> - - <%= f.label :body, t("users.direct_messages.new.body_label") %> - <%= f.text_area :body, label: false, rows: "3" %> + <%= f.text_field :title, label: t("users.direct_messages.new.title_label") %> + <%= f.text_area :body, label: t("users.direct_messages.new.body_label"), rows: "3" %>
<%= f.submit t("users.direct_messages.new.submit_button"), class: "button expanded" %> diff --git a/app/views/legislation/annotations/_comments_box.html.erb b/app/views/legislation/annotations/_comments_box.html.erb index 7340f7e04..b9e8eea70 100644 --- a/app/views/legislation/annotations/_comments_box.html.erb +++ b/app/views/legislation/annotations/_comments_box.html.erb @@ -25,8 +25,11 @@ <% css_id = parent_or_commentable_dom_id(nil, annotation) %> diff --git a/app/views/legislation/proposals/_form.html.erb b/app/views/legislation/proposals/_form.html.erb index e48f149ec..b6d702c27 100644 --- a/app/views/legislation/proposals/_form.html.erb +++ b/app/views/legislation/proposals/_form.html.erb @@ -5,30 +5,33 @@
- <%= f.label :title, t("proposals.form.proposal_title") %> - <%= f.text_field :title, maxlength: Legislation::Proposal.title_max_length, placeholder: t("proposals.form.proposal_title"), label: false %> + <%= f.text_field :title, + maxlength: Legislation::Proposal.title_max_length, + placeholder: t("proposals.form.proposal_title"), + label: t("proposals.form.proposal_title") %>
<%= f.invisible_captcha :subtitle %>
- <%= f.label :summary, t("proposals.form.proposal_summary") %> -

<%= t("proposals.form.proposal_summary_note") %>

- <%= f.text_area :summary, rows: 4, maxlength: 200, label: false, - placeholder: t("proposals.form.proposal_summary"), - aria: { describedby: "summary-help-text" } %> + <%= f.text_area :summary, rows: 4, maxlength: 200, + label: t("proposals.form.proposal_summary"), + placeholder: t("proposals.form.proposal_summary"), + hint: t("proposals.form.proposal_summary_note") %>
- <%= f.label :description, t("proposals.form.proposal_text") %> - <%= f.cktext_area :description, maxlength: Legislation::Proposal.description_max_length, ckeditor: { language: I18n.locale }, label: false %> + <%= f.cktext_area :description, + maxlength: Legislation::Proposal.description_max_length, + ckeditor: { language: I18n.locale }, + label: t("proposals.form.proposal_text") %>
- <%= f.label :video_url, t("proposals.form.proposal_video_url") %> -

<%= t("proposals.form.proposal_video_url_note") %>

- <%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), label: false, - aria: { describedby: "video-url-help-text" } %> + <%= f.text_field :video_url, + placeholder: t("proposals.form.proposal_video_url"), + label: t("proposals.form.proposal_video_url"), + hint: t("proposals.form.proposal_video_url_note") %>
<% if feature?(:allow_images) %> @@ -42,8 +45,8 @@
- <%= f.label :geozone_id, t("proposals.form.geozone") %> - <%= f.select :geozone_id, geozone_select_options, { include_blank: t("geozones.none"), label: false } %> + <%= f.select :geozone_id, geozone_select_options, + include_blank: t("geozones.none"), label: t("proposals.form.geozone") %>
@@ -66,14 +69,12 @@
<% if @proposal.new_record? %> - <%= f.label :terms_of_service do %> - <%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %> - - <%= t("form.accept_terms", - policy: link_to(t("form.policy"), "/privacy", target: "blank"), - conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %> - - <% end %> + <%= f.check_box :terms_of_service, + title: t("form.accept_terms_title"), + label: t("form.accept_terms", + policy: link_to(t("form.policy"), "/privacy", target: "blank"), + conditions: link_to(t("form.conditions"), "/conditions", target: "blank") + ).html_safe %> <% end %>
diff --git a/app/views/management/users/new.html.erb b/app/views/management/users/new.html.erb index ce5b5a01a..8c8b4c5a4 100644 --- a/app/views/management/users/new.html.erb +++ b/app/views/management/users/new.html.erb @@ -13,11 +13,10 @@ label: t("management.users.email_optional_label"), placeholder: t("management.email_label") %>
- <%= f.label t("management.date_of_birth") %> <%= f.date_select :date_of_birth, prompt: true, start_year: 1900, end_year: 16.years.ago.year, - label: false %> + label: t("management.date_of_birth") %>
<%= f.submit t("management.users.create_user_submit"), class: "button success" %> <% end %> diff --git a/app/views/map_locations/_form_fields.html.erb b/app/views/map_locations/_form_fields.html.erb index f2292a42e..132c39a00 100644 --- a/app/views/map_locations/_form_fields.html.erb +++ b/app/views/map_locations/_form_fields.html.erb @@ -18,14 +18,8 @@ id: map_location_input_id(parent_class, "zoom") %>
- <%= form.label :skip_map do %> - <%= form.check_box :skip_map, - title: t("#{i18n_namespace}.form.map_skip_checkbox"), - label: false, - class: "js-toggle-map" %> - - <%= t("#{i18n_namespace}.form.map_skip_checkbox") %> - - <% end %> + <%= form.check_box :skip_map, + label: t("#{i18n_namespace}.form.map_skip_checkbox"), + class: "js-toggle-map" %>
<% end %> diff --git a/app/views/officing/ballot_sheets/new.html.erb b/app/views/officing/ballot_sheets/new.html.erb index a83c3a7d0..a715933d0 100644 --- a/app/views/officing/ballot_sheets/new.html.erb +++ b/app/views/officing/ballot_sheets/new.html.erb @@ -5,7 +5,7 @@ <%= select_tag :officer_assignment_id, booths_for_officer_select_options(@officer_assignments), - { prompt: t("officing.poll_budgets.new.select_booth"), label: false } %> + { prompt: t("officing.poll_budgets.new.select_booth") } %> <%= text_area_tag :data, nil, rows: 10 %> diff --git a/app/views/officing/results/new.html.erb b/app/views/officing/results/new.html.erb index 39cde8186..9b2855133 100644 --- a/app/views/officing/results/new.html.erb +++ b/app/views/officing/results/new.html.erb @@ -7,8 +7,7 @@ <%= select_tag :officer_assignment_id, booths_for_officer_select_options(@officer_assignments), - { prompt: t("officing.results.new.select_booth"), - label: false } %> + { prompt: t("officing.results.new.select_booth") } %>
diff --git a/app/views/organizations/registrations/new.html.erb b/app/views/organizations/registrations/new.html.erb index a8667127f..705f27fde 100644 --- a/app/views/organizations/registrations/new.html.erb +++ b/app/views/organizations/registrations/new.html.erb @@ -8,11 +8,10 @@ <%= f.fields_for :organization do |fo| %> <%= fo.text_field :name, autofocus: true, maxlength: Organization.name_max_length, placeholder: t("devise_views.organizations.registrations.new.organization_name_label") %> - <%= fo.label :responsible_name %> -

<%= t("devise_views.organizations.registrations.new.responsible_name_note") %>

- <%= fo.text_field :responsible_name, placeholder: t("devise_views.organizations.registrations.new.responsible_name_label"), - maxlength: Organization.responsible_name_max_length, label: false, - aria: { describedby: "responsible-name-help-text" } %> + <%= fo.text_field :responsible_name, + placeholder: t("devise_views.organizations.registrations.new.responsible_name_label"), + maxlength: Organization.responsible_name_max_length, + hint: t("devise_views.organizations.registrations.new.responsible_name_note") %> <% end %> <%= f.email_field :email, placeholder: t("devise_views.organizations.registrations.new.email_label") %> @@ -28,12 +27,14 @@ label: t("devise_views.organizations.registrations.new.password_confirmation_label"), placeholder: t("devise_views.organizations.registrations.new.password_confirmation_label") %> - <%= f.label :terms_of_service do %> - <%= f.check_box :terms_of_service, title: t("devise_views.users.registrations.new.terms_title"), label: false %> - - <%= t("devise_views.users.registrations.new.terms", - terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions", title: t("shared.target_blank_html"), target: "_blank")).html_safe %> - <% end %> + <%= f.check_box :terms_of_service, + title: t("devise_views.users.registrations.new.terms_title"), + label: t("devise_views.users.registrations.new.terms", + terms: link_to(t("devise_views.users.registrations.new.terms_link"), + "/conditions", + title: t("shared.target_blank_html"), + target: "_blank") + ).html_safe %>
<%= f.submit t("devise_views.organizations.registrations.new.submit"), class: "button expanded" %> diff --git a/app/views/proposal_notifications/new.html.erb b/app/views/proposal_notifications/new.html.erb index cee18f1d8..408be1404 100644 --- a/app/views/proposal_notifications/new.html.erb +++ b/app/views/proposal_notifications/new.html.erb @@ -20,12 +20,8 @@ <%= form_for @notification do |f| %> <%= render "shared/errors", resource: @notification %> - <%= f.label :title, t("proposal_notifications.new.title_label") %> - <%= f.text_field :title, label: false %> - - <%= f.label :body, t("proposal_notifications.new.body_label") %> - <%= f.text_area :body, label: false, rows: "3" %> - + <%= f.text_field :title, label: t("proposal_notifications.new.title_label") %> + <%= f.text_area :body, label: t("proposal_notifications.new.body_label"), rows: "3" %> <%= f.hidden_field :proposal_id, value: @proposal.id %>
diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index 415536e85..7e20272f9 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -17,15 +17,10 @@
- <%= translations_form.label :summary %> -

- <%= t("proposals.form.proposal_summary_note") %> -

<%= translations_form.text_area :summary, rows: 4, maxlength: 200, - label: false, placeholder: t("proposals.form.proposal_summary"), - aria: { describedby: summary_help_text_id(translations_form) } %> + hint: t("proposals.form.proposal_summary_note") %>
@@ -38,11 +33,9 @@ <%= f.invisible_captcha :subtitle %>
- <%= f.label :video_url, t("proposals.form.proposal_video_url") %> -

<%= t("proposals.form.proposal_video_url_note") %>

<%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), - label: false, - aria: { describedby: "video-url-help-text" } %> + label: t("proposals.form.proposal_video_url"), + hint: t("proposals.form.proposal_video_url_note") %>
<% if feature?(:allow_images) %> @@ -58,8 +51,8 @@ <% end %>
- <%= f.label :geozone_id, t("proposals.form.geozone") %> - <%= f.select :geozone_id, geozone_select_options, { include_blank: t("geozones.none"), label: false } %> + <%= f.select :geozone_id, geozone_select_options, + include_blank: t("geozones.none"), label: t("proposals.form.geozone") %>
<% if feature?(:map) %> @@ -99,23 +92,21 @@ <% if current_user.unverified? %>
- <%= f.label :responsible_name, t("proposals.form.proposal_responsible_name") %> -

<%= t("proposals.form.proposal_responsible_name_note") %>

- <%= f.text_field :responsible_name, placeholder: t("proposals.form.proposal_responsible_name"), label: false, - aria: { describedby: "responsible-name-help-text" } %> + <%= f.text_field :responsible_name, + placeholder: t("proposals.form.proposal_responsible_name"), + label: t("proposals.form.proposal_responsible_name"), + hint: t("proposals.form.proposal_responsible_name_note") %>
<% end %>
<% if @proposal.new_record? %> - <%= f.label :terms_of_service do %> - <%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %> - - <%= t("form.accept_terms", - policy: link_to(t("form.policy"), "/privacy", target: "blank"), - conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %> - - <% end %> + <%= f.check_box :terms_of_service, + title: t("form.accept_terms_title"), + label: t("form.accept_terms", + policy: link_to(t("form.policy"), "/privacy", target: "blank"), + conditions: link_to(t("form.conditions"), "/conditions", target: "blank") + ).html_safe %> <% end %>
diff --git a/app/views/proposals/retire_form.html.erb b/app/views/proposals/retire_form.html.erb index 9de4bd3ba..6c1e5e182 100644 --- a/app/views/proposals/retire_form.html.erb +++ b/app/views/proposals/retire_form.html.erb @@ -16,8 +16,9 @@ <%= render "shared/errors", resource: @proposal %>
- <%= f.label :retired_reason, t("proposals.retire_form.retired_reason_label") %> - <%= f.select :retired_reason, retire_proposals_options, { include_blank: t("proposals.retire_form.retired_reason_blank"), label: false } %> + <%= f.select :retired_reason, retire_proposals_options, + include_blank: t("proposals.retire_form.retired_reason_blank"), + label: t("proposals.retire_form.retired_reason_label") %>
diff --git a/app/views/shared/_map.html.erb b/app/views/shared/_map.html.erb index 499b1e47e..e2112e7a5 100644 --- a/app/views/shared/_map.html.erb +++ b/app/views/shared/_map.html.erb @@ -31,9 +31,8 @@ <%= form_for(@resource, url: new_url_path, method: :get) do |f| %>
- <%= f.label :geozone_id, t("map.select_district") %> <%= f.select :geozone_id, geozone_select_options, - { include_blank: t("geozones.none"), label: false } %> + include_blank: t("geozones.none"), label: t("map.select_district") %>
diff --git a/app/views/topics/_form.html.erb b/app/views/topics/_form.html.erb index 3ec5982d1..2119ee5b6 100644 --- a/app/views/topics/_form.html.erb +++ b/app/views/topics/_form.html.erb @@ -4,11 +4,8 @@
- <%= f.label :title, t("community.topic.form.topic_title") %> - <%= f.text_field :title, label: false %> - - <%= f.label :description, t("community.topic.form.topic_text") %> - <%= f.text_area :description, label: false, rows: "5" %> + <%= f.text_field :title, label: t("community.topic.form.topic_title") %> + <%= f.text_area :description, label: t("community.topic.form.topic_text"), rows: "5" %> <%= f.submit(class: "button", value: t("community.topic.form.#{action_name}.submit_button")) %>
diff --git a/app/views/tracking/milestones/_form.html.erb b/app/views/tracking/milestones/_form.html.erb index a6fd6687a..e56e69682 100644 --- a/app/views/tracking/milestones/_form.html.erb +++ b/app/views/tracking/milestones/_form.html.erb @@ -27,10 +27,9 @@
- <%= f.label :publication_date, t("tracking.milestones.new.date") %> <%= f.text_field :publication_date, value: @milestone.publication_date.present? ? l(@milestone.publication_date.to_date) : nil, - label: false, + label: t("tracking.milestones.new.date"), class: "js-calendar-full" %> <%= render "images/admin_image", imageable: @milestone, f: f %> diff --git a/app/views/tracking/progress_bars/_form.html.erb b/app/views/tracking/progress_bars/_form.html.erb index 4a66107d3..7606b17e8 100644 --- a/app/views/tracking/progress_bars/_form.html.erb +++ b/app/views/tracking/progress_bars/_form.html.erb @@ -19,8 +19,10 @@ <% progress_options = { min: ProgressBar::RANGE.min, max: ProgressBar::RANGE.max, step: 1 } %>
+ <%= f.label :percentage %> <%= f.text_field :percentage, { type: :range, id: "percentage_range", + label: false, class: "column" }.merge(progress_options) %>
diff --git a/app/views/users/registrations/edit.html.erb b/app/views/users/registrations/edit.html.erb index c4abc987d..eee748ec5 100644 --- a/app/views/users/registrations/edit.html.erb +++ b/app/views/users/registrations/edit.html.erb @@ -6,8 +6,10 @@ <%= render "shared/errors", resource: resource %>
- <%= f.label :email, t("devise_views.users.registrations.edit.email_label") %> - <%= f.email_field :email, label: false, autofocus: true, placeholder: t("devise_views.users.registrations.edit.email_label") %> + <%= f.email_field :email, + label: t("devise_views.users.registrations.edit.email_label"), + autofocus: true, + placeholder: t("devise_views.users.registrations.edit.email_label") %>
@@ -17,24 +19,26 @@
- <%= f.label :password, t("devise_views.users.registrations.edit.password_label") %> -

<%= t("devise_views.users.registrations.edit.leave_blank") %>

- <%= f.password_field :password, autocomplete: "off", label: false, - placeholder: t("devise_views.users.registrations.edit.password_label"), - aria: { describedby: "password-help-text" } %> + <%= f.password_field :password, + autocomplete: "off", + label: t("devise_views.users.registrations.edit.password_label"), + placeholder: t("devise_views.users.registrations.edit.password_label"), + hint: t("devise_views.users.registrations.edit.leave_blank") %>
- <%= f.label :password_confirmation, t("devise_views.users.registrations.edit.password_confirmation_label") %> - <%= f.password_field :password_confirmation, label: false, autocomplete: "off", placeholder: t("devise_views.users.registrations.edit.password_confirmation_label") %> + <%= f.password_field :password_confirmation, + label: t("devise_views.users.registrations.edit.password_confirmation_label"), + autocomplete: "off", + placeholder: t("devise_views.users.registrations.edit.password_confirmation_label") %>
- <%= f.label :current_password, t("devise_views.users.registrations.edit.current_password_label") %> -

<%= t("devise_views.users.registrations.edit.need_current") %>

- <%= f.password_field :current_password, label: false, autocomplete: "off", - placeholder: t("devise_views.users.registrations.edit.current_password_label"), - aria: { describedby: "current-password-help-text" } %> + <%= f.password_field :current_password, + label: t("devise_views.users.registrations.edit.current_password_label"), + autocomplete: "off", + placeholder: t("devise_views.users.registrations.edit.current_password_label"), + hint: t("devise_views.users.registrations.edit.need_current") %>
diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb index 9d3336178..c97b1befb 100644 --- a/app/views/users/registrations/new.html.erb +++ b/app/views/users/registrations/new.html.erb @@ -17,12 +17,9 @@ <%= f.hidden_field :use_redeemable_code %> <%= f.hidden_field :locale, value: I18n.locale %> - <%= f.label :username %> -

<%= t("devise_views.users.registrations.new.username_note") %>

<%= f.text_field :username, autofocus: true, maxlength: User.username_max_length, placeholder: t("devise_views.users.registrations.new.username_label"), - label: false, - aria: { describedby: "username-help-text" } %> + hint: t("devise_views.users.registrations.new.username_note") %> <%= f.invisible_captcha :address %> @@ -39,15 +36,14 @@ <%= f.text_field :redeemable_code, placeholder: t("devise_views.users.registrations.new.redeemable_code") %> <% end %> - <%= f.label :terms_of_service do %> - <%= f.check_box :terms_of_service, title: t("devise_views.users.registrations.new.terms_title"), label: false %> - - <%= t("devise_views.users.registrations.new.terms", - terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions", - title: t("shared.target_blank_html"), - target: "_blank")).html_safe %> - - <% end %> + <%= f.check_box :terms_of_service, + title: t("devise_views.users.registrations.new.terms_title"), + label: t("devise_views.users.registrations.new.terms", + terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions", + title: t("shared.target_blank_html"), + target: "_blank") + ).html_safe %> +
<%= f.submit t("devise_views.users.registrations.new.submit"), class: "button expanded" %>
diff --git a/app/views/valuation/budget_investments/_dossier_form.html.erb b/app/views/valuation/budget_investments/_dossier_form.html.erb index 469fce699..cb1230c18 100644 --- a/app/views/valuation/budget_investments/_dossier_form.html.erb +++ b/app/views/valuation/budget_investments/_dossier_form.html.erb @@ -7,22 +7,19 @@ <%= t("valuation.budget_investments.edit.feasibility") %>
- <%= f.radio_button :feasibility, "undecided", label: false %> - <%= f.label :feasibility_undecided, t("valuation.budget_investments.edit.undefined_feasible") %> + <%= f.radio_button :feasibility, "undecided" %>
- <%= f.radio_button :feasibility, "feasible", label: false %> - <%= f.label :feasibility_feasible, t("valuation.budget_investments.edit.feasible") %> + <%= f.radio_button :feasibility, "feasible" %>
- <%= f.radio_button :feasibility, "unfeasible", label: false %> - <%= f.label :feasibility_unfeasible, t("valuation.budget_investments.edit.unfeasible") %> + <%= f.radio_button :feasibility, "unfeasible" %>
@@ -33,8 +30,9 @@
- <%= f.label :unfeasibility_explanation, t("valuation.budget_investments.edit.feasible_explanation_html") %> - <%= f.text_area :unfeasibility_explanation, label: false, rows: 3 %> + <%= f.text_area :unfeasibility_explanation, + label: t("valuation.budget_investments.edit.feasible_explanation_html"), + rows: 3 %>
@@ -44,27 +42,29 @@
- <%= f.label :price, "#{t("valuation.budget_investments.edit.price_html", currency: budget.currency_symbol)}" %> - <%= f.number_field :price, label: false, max: 1000000000000000 %> + <%= f.number_field :price, + label: t("valuation.budget_investments.edit.price_html", currency: budget.currency_symbol), + max: 1000000000000000 %>
- <%= f.label :price_first_year, "#{t("valuation.budget_investments.edit.price_first_year_html", currency: budget.currency_symbol)}" %> - <%= f.number_field :price_first_year, label: false, max: 1000000000000000 %> + <%= f.number_field :price_first_year, + label: t("valuation.budget_investments.edit.price_first_year_html", currency: budget.currency_symbol), + max: 1000000000000000 %>
- <%= f.label :price_explanation, t("valuation.budget_investments.edit.price_explanation_html") %> - <%= f.text_area :price_explanation, label: false, rows: 3 %> + <%= f.text_area :price_explanation, + label: t("valuation.budget_investments.edit.price_explanation_html"), + rows: 3 %>
- <%= f.label :duration, t("valuation.budget_investments.edit.duration_html") %> - <%= f.text_field :duration, label: false %> + <%= f.text_field :duration, label: t("valuation.budget_investments.edit.duration_html") %>
@@ -72,14 +72,11 @@
- <%= f.label :valuation_finished do %> - <%= f.check_box :valuation_finished, - title: t("valuation.budget_investments.edit.valuation_finished"), - label: false, id: "js-investment-report-alert", - "data-alert": t("valuation.budget_investments.edit.valuation_finished_alert"), - "data-not-feasible-alert": t("valuation.budget_investments.edit.not_feasible_alert") %> - <%= t("valuation.budget_investments.edit.valuation_finished") %> - <% end %> + <%= f.check_box :valuation_finished, + label: t("valuation.budget_investments.edit.valuation_finished"), + id: "js-investment-report-alert", + "data-alert": t("valuation.budget_investments.edit.valuation_finished_alert"), + "data-not-feasible-alert": t("valuation.budget_investments.edit.not_feasible_alert") %>
diff --git a/app/views/verification/residence/new.html.erb b/app/views/verification/residence/new.html.erb index b95523a75..9c9adb322 100644 --- a/app/views/verification/residence/new.html.erb +++ b/app/views/verification/residence/new.html.erb @@ -39,8 +39,8 @@
- <%= f.label t("verification.residence.new.document_type_label") %> - <%= f.select :document_type, document_types, prompt: "", label: false %> + <%= f.select :document_type, document_types, prompt: "", + label: t("verification.residence.new.document_type_label") %>
@@ -64,32 +64,26 @@
- <%= f.label t("verification.residence.new.date_of_birth") %> <%= f.date_select :date_of_birth, prompt: true, start_year: 1900, end_year: minimum_required_age.years.ago.year, - label: false %> + label: t("verification.residence.new.date_of_birth") %>
- <%= f.label t("verification.residence.new.postal_code") %> -

<%= t("verification.residence.new.postal_code_note") %>

-
- <%= f.text_field :postal_code, label: false, aria: { describedby: "postal-code-help-text" } %> -
+ <%= f.text_field :postal_code, + label: t("verification.residence.new.postal_code"), + hint: t("verification.residence.new.postal_code_note") %>
- <%= f.label :terms_of_service do %> - <%= f.check_box :terms_of_service, title: t("verification.residence.new.accept_terms_text_title"), label: false %> - - <%= t("verification.residence.new.accept_terms_text", - terms_url: link_to(t("verification.residence.new.terms"), "/census_terms", - title: t("shared.target_blank_html"), - target: "_blank")).html_safe - %> - - <% end %> + <%= f.check_box :terms_of_service, + title: t("verification.residence.new.accept_terms_text_title"), + label: t("verification.residence.new.accept_terms_text", + terms_url: link_to(t("verification.residence.new.terms"), "/census_terms", + title: t("shared.target_blank_html"), + target: "_blank") + ).html_safe %>
diff --git a/app/views/verification/sms/edit.html.erb b/app/views/verification/sms/edit.html.erb index 51189f2bc..af9c70e1f 100644 --- a/app/views/verification/sms/edit.html.erb +++ b/app/views/verification/sms/edit.html.erb @@ -33,8 +33,7 @@ <% end %>
- <%= f.label t("verification.sms.edit.confirmation_code") %> - <%= f.text_field :confirmation_code, label: false %> + <%= f.text_field :confirmation_code, label: t("verification.sms.edit.confirmation_code") %>
<%= f.submit t("verification.sms.edit.submit_button"), class: "button success" %> diff --git a/config/initializers/foundation_rails_helper.rb b/config/initializers/foundation_rails_helper.rb deleted file mode 100644 index 3e121f0d9..000000000 --- a/config/initializers/foundation_rails_helper.rb +++ /dev/null @@ -1,17 +0,0 @@ -module FoundationRailsHelper - class FormBuilder < ActionView::Helpers::FormBuilder - def cktext_area(attribute, options) - field(attribute, options) do |opts| - super(attribute, opts) - end - end - - def enum_select(attribute, options = {}, html_options = {}) - choices = object.class.send(attribute.to_s.pluralize).keys.map do |name| - [object.class.human_attribute_name("#{attribute}.#{name}"), name] - end - - select attribute, choices, options, html_options - end - end -end diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml index f63161e4b..62ba0b9eb 100644 --- a/config/locales/en/activerecord.yml +++ b/config/locales/en/activerecord.yml @@ -153,6 +153,9 @@ en: organization_name: "If you are proposing in the name of a collective/organization, or on behalf of more people, write its name" image: "Proposal descriptive image" image_title: "Image title" + feasibility_feasible: "Feasible" + feasibility_undecided: "Undefined" + feasibility_unfeasible: "Unfeasible" budget/investment/translation: title: "Title" description: "Description" diff --git a/config/locales/en/valuation.yml b/config/locales/en/valuation.yml index 2c8c6d7c2..9153fe244 100644 --- a/config/locales/en/valuation.yml +++ b/config/locales/en/valuation.yml @@ -60,9 +60,6 @@ en: price_first_year_html: "Cost during the first year (%{currency}) (optional, data not public)" price_explanation_html: Price explanation feasibility: Feasibility - feasible: Feasible - unfeasible: Not feasible - undefined_feasible: Pending feasible_explanation_html: Feasibility explanation valuation_finished: Valuation finished valuation_finished_alert: "Are you sure you want to mark this report as completed? If you do it, it can no longer be modified." diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml index 87f4b19be..e7ea7d05d 100644 --- a/config/locales/es/activerecord.yml +++ b/config/locales/es/activerecord.yml @@ -155,6 +155,9 @@ es: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva del proyecto de gasto" image_title: "Título de la imagen" + feasibility_feasible: "Viable" + feasibility_undecided: "Sin decidir" + feasibility_unfeasible: "Inviable" budget/investment/translation: title: "Título" description: "Descripción" diff --git a/config/locales/es/valuation.yml b/config/locales/es/valuation.yml index 15d6b7c31..bf4ff09e2 100644 --- a/config/locales/es/valuation.yml +++ b/config/locales/es/valuation.yml @@ -60,9 +60,6 @@ es: price_first_year_html: "Coste en el primer año (%{currency}) (opcional, dato no público)" price_explanation_html: Informe de coste (opcional, dato público) feasibility: Viabilidad - feasible: Viable - unfeasible: Inviable - undefined_feasible: Sin decidir feasible_explanation_html: Informe de inviabilidad (en caso de que lo sea, dato público) valuation_finished: Informe finalizado valuation_finished_alert: "¿Estás seguro/a de querer marcar este informe como completado? Una vez hecho, no se puede deshacer la acción." diff --git a/lib/consul_form_builder.rb b/lib/consul_form_builder.rb new file mode 100644 index 000000000..9cf822823 --- /dev/null +++ b/lib/consul_form_builder.rb @@ -0,0 +1,72 @@ +class ConsulFormBuilder < FoundationRailsHelper::FormBuilder + def enum_select(attribute, options = {}, html_options = {}) + choices = object.class.send(attribute.to_s.pluralize).keys.map do |name| + [object.class.human_attribute_name("#{attribute}.#{name}"), name] + end + + select attribute, choices, options, html_options + end + + %i[text_field text_area cktext_area number_field password_field email_field].each do |field| + define_method field do |attribute, options = {}| + label_with_hint(attribute, options.merge(label_options: label_options_for(options))) + + super(attribute, options.merge( + label: false, hint: false, + aria: { describedby: help_text_id(attribute, options) } + )) + end + end + + def check_box(attribute, options = {}) + if options[:label] != false + label = content_tag(:span, label_text(object, attribute, options[:label]), class: "checkbox") + + super(attribute, options.merge(label: label, label_options: label_options_for(options))) + else + super + end + end + + def radio_button(attribute, tag_value, options = {}) + default_label = object.class.human_attribute_name("#{attribute}_#{tag_value}") + + super(attribute, tag_value, { label: default_label }.merge(options)) + end + + private + + def label_with_hint(attribute, options) + custom_label(attribute, options[:label], options[:label_options]) + + help_text(attribute, options) + end + + def label_text(object, attribute, text) + if text.nil? || text == true + default_label_text(object, attribute) + else + text + end + end + + def label_options_for(options) + label_options = options[:label_options] || {} + + if options[:id] + { for: options[:id] }.merge(label_options) + else + label_options + end + end + + def help_text(attribute, options) + if options[:hint] + content_tag :span, options[:hint], class: "help-text", id: help_text_id(attribute, options) + end + end + + def help_text_id(attribute, options) + if options[:hint] + "#{custom_label(attribute, nil, nil).match(/for=\"(.+)\"/)[1]}-help-text" + end + end +end