Merge pull request #3745 from consul/auto_labels

Simplify generating form fields with labels
This commit is contained in:
Javier Martín
2019-10-06 20:32:50 +02:00
committed by GitHub
58 changed files with 339 additions and 465 deletions

View File

@@ -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?

View File

@@ -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

View File

@@ -3,6 +3,7 @@ require "manager_authenticator"
class Management::SessionsController < ActionController::Base
include GlobalizeFallbacks
include AccessDeniedHandler
default_form_builder ConsulFormBuilder
def create
destroy_session

View File

@@ -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)

View File

@@ -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)

View File

@@ -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")

View File

@@ -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

View File

@@ -32,82 +32,40 @@
</div>
<div>
<%= f.label :public_activity do %>
<%= f.check_box :public_activity, title: t("account.show.public_activity_label"), label: false %>
<span class="checkbox">
<%= t("account.show.public_activity_label") %>
</span>
<% end %>
<%= f.check_box :public_activity, label: t("account.show.public_activity_label") %>
</div>
<div>
<%= f.label :public_interests do %>
<%= f.check_box :public_interests, title: t("account.show.public_interests_label"), label: false %>
<span class="checkbox">
<%= t("account.show.public_interests_label") %>
</span>
<% end %>
<%= f.check_box :public_interests, label: t("account.show.public_interests_label") %>
</div>
<% if @account.email.present? %>
<h2><%= t("account.show.notifications") %></h2>
<div>
<%= f.label :email_on_comment do %>
<%= f.check_box :email_on_comment, title: t("account.show.email_on_comment_label"), label: false %>
<span class="checkbox">
<%= t("account.show.email_on_comment_label") %>
</span>
<% end %>
<%= f.check_box :email_on_comment, label: t("account.show.email_on_comment_label") %>
</div>
<div>
<%= 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 %>
<span class="checkbox">
<%= t("account.show.email_on_comment_reply_label") %>
</span>
<% end %>
<%= f.check_box :email_on_comment_reply, label: t("account.show.email_on_comment_reply_label") %>
</div>
<div>
<%= f.label :email_newsletter_subscribed do %>
<%= f.check_box :newsletter, title: t("account.show.subscription_to_website_newsletter_label"), label: false %>
<span class="checkbox">
<%= t("account.show.subscription_to_website_newsletter_label") %>
</span>
<% end %>
<%= f.check_box :newsletter, label: t("account.show.subscription_to_website_newsletter_label") %>
</div>
<div>
<%= f.label :email_digest do %>
<%= f.check_box :email_digest, title: t("account.show.email_digest_label"), label: false %>
<span class="checkbox">
<%= t("account.show.email_digest_label") %>
</span>
<% end %>
<%= f.check_box :email_digest, label: t("account.show.email_digest_label") %>
</div>
<div>
<%= 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 %>
<span class="checkbox">
<%= t("account.show.email_on_direct_message_label") %>
</span>
<% end %>
<%= f.check_box :email_on_direct_message, label: t("account.show.email_on_direct_message_label") %>
</div>
<% end %>
<% if @account.official_level == 1 %>
<div>
<%= f.label :official_position_badge do %>
<%= f.check_box :official_position_badge,
title: t("account.show.official_position_badge_label"),
label: false %>
<span class="checkbox">
<%= t("account.show.official_position_badge_label") %>
</span>
<% end %>
<%= f.check_box :official_position_badge, label: t("account.show.official_position_badge_label") %>
</div>
<% end %>
@@ -116,23 +74,13 @@
<% if feature?("user.recommendations_on_debates") %>
<div>
<%= f.label :recommended_debates do %>
<%= f.check_box :recommended_debates, title: t("account.show.show_debates_recommendations"), label: false %>
<span class="checkbox">
<%= t("account.show.show_debates_recommendations") %>
</span>
<% end %>
<%= f.check_box :recommended_debates, label: t("account.show.show_debates_recommendations") %>
</div>
<% end %>
<% if feature?("user.recommendations_on_proposals") %>
<div>
<%= f.label :recommended_proposals do %>
<%= f.check_box :recommended_proposals, title: t("account.show.show_proposals_recommendations"), label: false %>
<span class="checkbox">
<%= t("account.show.show_proposals_recommendations") %>
</span>
<% end %>
<%= f.check_box :recommended_proposals, label: t("account.show.show_proposals_recommendations") %>
</div>
<% end %>
<% end %>

View File

@@ -7,9 +7,8 @@
<div class="row">
<% date_started_at = @banner.post_started_at.present? ? I18n.localize(@banner.post_started_at) : "" %>
<div class="small-12 medium-3 column">
<%= 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 @@
</div>
<% date_ended_at = @banner.post_ended_at.present? ? I18n.localize(@banner.post_ended_at) : "" %>
<div class="small-12 medium-3 column end">
<%= 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 @@
<div class="row">
<div class="small-12 medium-6 column">
<%= 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") %>
</div>
</div>

View File

@@ -22,16 +22,12 @@
maxlength: 8,
placeholder: t("admin.budget_headings.form.amount") %>
<%= f.label :population, t("admin.budget_headings.form.population") %>
<p class="help-text" id="budgets-population-help-text">
<%= t("admin.budget_headings.form.population_info") %>
</p>
<%= 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"),

View File

@@ -35,33 +35,28 @@
<div class="small-12 medium-3 column">
<%= 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") } %>
</div>
<div class="small-12 medium-3 column">
<%= 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") } %>
</div>
<div class="small-12 medium-3 column">
<%= 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") } %>
</div>
<div class="small-12 medium-3 column">
<%= 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") } %>
</div>
<div class="small-12 medium-3 column">
<%= 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") } %>
</div>
<div class="small-12 medium-6 column">

View File

@@ -29,10 +29,9 @@
<% end %>
<div class="small-12 column">
<%= 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") %>
</div>
<div class="small-12 column">
@@ -106,18 +105,16 @@
<% if @investment.incompatible? || @investment.winner? %>
<div class="small-12 medium-3 column">
<h2 id="incompatible"><%= t("admin.budget_investments.edit.compatibility") %></h2>
<%= f.label :incompatible do %>
<%= f.check_box :incompatible, title: t("admin.budget_investments.edit.compatibility"), label: false %>
<span class="checkbox"><%= t("admin.budget_investments.edit.mark_as_incompatible") %></span>
<% end %>
<%= f.check_box :incompatible,
title: t("admin.budget_investments.edit.compatibility"),
label: t("admin.budget_investments.edit.mark_as_incompatible") %>
</div>
<% end %>
<div class="small-12 medium-3 column float-left">
<h2 id="selected"><%= t("admin.budget_investments.edit.selection") %></h2>
<%= f.label :selected do %>
<%= f.check_box :selected, title: t("admin.budget_investments.edit.selection"), label: false %>
<span class="checkbox"><%= t("admin.budget_investments.edit.mark_as_selected") %></span>
<% end %>
<%= f.check_box :selected,
title: t("admin.budget_investments.edit.selection"),
label: t("admin.budget_investments.edit.mark_as_selected") %>
</div>
</div>

View File

@@ -6,50 +6,38 @@
<div class="row">
<div class="small-12 medium-6 column">
<%= 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") %>
</div>
<div class="small-12 medium-6 column">
<%= 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") %>
</div>
</div>
<div class="row">
<%= f.translatable_fields do |translations_form| %>
<div class="small-12 column">
<%= f.label :description, t("admin.budget_phases.edit.description") %>
<span class="help-text" id="phase-description-help-text">
<%= t("admin.budget_phases.edit.description_help_text") %>
</span>
<div class="ckeditor">
<%= 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") %>
</div>
</div>
<div class="small-12 column">
<%= f.label :summary, t("admin.budget_phases.edit.summary") %>
<span class="help-text" id="phase-summary-help-text">
<%= t("admin.budget_phases.edit.summary_help_text") %>
</span>
<div class="ckeditor">
<%= 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") %>
</div>
</div>
<% end %>

View File

@@ -5,9 +5,9 @@
<%= f.label :action_type %>
<% ::Dashboard::Action.action_types.keys.each do |action_type_value| %>
<span class="margin-right">
<%= 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" } %>
</span>
<% end %>
</div>
@@ -26,12 +26,10 @@
<div class="row expanded">
<div class="small-12 column">
<%= f.label :title %>
<%= f.text_field :title, label: false %>
<%= f.text_field :title %>
<div id="short_description" class="hide">
<%= f.label :short_description %>
<%= f.text_field :short_description, label: false %>
<%= f.text_field :short_description %>
</div>
<div class="ckeditor">
@@ -49,21 +47,18 @@
<div class="row expanded margin-top">
<div class="small-12 medium-4 column">
<%= f.label :day_offset %>
<p class="help-text"><%= t("admin.dashboard.actions.form.help_text") %></p>
<%= 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") %>
</div>
<div class="small-12 medium-4 column">
<%= f.label :required_supports %>
<p class="help-text"><%= t("admin.dashboard.actions.form.help_text") %></p>
<%= 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") %>
</div>
<div class="small-12 medium-4 column">
<%= f.label :order %>
<p class="help-text"><%= t("admin.dashboard.actions.form.help_text") %></p>
<%= 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") %>
</div>
</div>

View File

@@ -8,22 +8,16 @@
<div class="clear">
<div class="small-12 medium-6 large-4 column">
<%= f.label :census_code %>
<p class="help-text"><%= t("admin.geozones.geozone.code_help") %></p>
<%= f.text_field :census_code, label: false %>
<%= f.text_field :census_code, hint: t("admin.geozones.geozone.code_help") %>
</div>
<div class="small-12 medium-6 large-4 column end">
<%= f.label :external_code %>
<p class="help-text"><%= t("admin.geozones.geozone.code_help") %></p>
<%= f.text_field :external_code, label: false %>
<%= f.text_field :external_code, hint: t("admin.geozones.geozone.code_help") %>
</div>
</div>
<div class="small-12 large-8 column">
<%= f.label :html_map_coordinates %>
<p class="help-text"><%= t("admin.geozones.geozone.coordinates_help") %></p>
<%= f.text_field :html_map_coordinates, label: false %>
<%= f.text_field :html_map_coordinates, hint: t("admin.geozones.geozone.coordinates_help") %>
</div>
<div class="small-12 column">

View File

@@ -71,16 +71,14 @@
<div class="small-12 medium-9 column">
<%= 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}") %>
<span class="help-text"><%= t("admin.legislation.draft_versions.form.hints.status.#{status}") %></span>
<br>
<% end %>
</div>
<div class="small-12 medium-9 column">
<%= f.label :final_version %>
<%= f.check_box :final_version, label: false %>
<%= f.check_box :final_version %>
<span class="help-text"><%= t("admin.legislation.draft_versions.form.hints.final_version") %></span>
</div>

View File

@@ -16,10 +16,9 @@
<% end %>
<div class="small-12 medium-8 column">
<%= f.label :custom_list, t("admin.legislation.proposals.form.custom_categories") %>
<span class="help-text"><%= t("admin.legislation.proposals.form.custom_categories_description") %></span>
<%= 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" } %>

View File

@@ -15,17 +15,14 @@
<div class="row">
<div class="date-of-birth small-12">
<%= f.label :date_of_birth, t("admin.local_census_records.form.date_of_birth") %>
<div class="clear">
<%= f.date_select :date_of_birth,
prompt: true,
start_year: 1900, end_year: minimum_required_age.years.ago.year,
label: false %>
</div>
<%= 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") %>
</div>
</div>
<div class="row">
<div class="clear row">
<div class="small-12">
<%= f.text_field :postal_code %>
</div>

View File

@@ -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 } %>
<div class="margin-top">

View File

@@ -13,11 +13,9 @@
</div>
<div class="small-12 medium-3 column">
<label><%= t("admin.poll_shifts.new.task") %></label>
<%= 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" %>
</div>
@@ -25,13 +23,11 @@
<label><%= t("admin.poll_shifts.new.date") %></label>
<%= 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" %>
</div>

View File

@@ -14,10 +14,8 @@
<%= f.text_field :signable_id %>
</div>
<%= f.label :required_fields_to_verify %>
<p class="help-text" id="required-fields-to-verify-help-text"><%= required_fields_to_verify_text_help %></p>
<p class="help-text"> <%= example_text_help %></p>
<%= 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}<br/>#{example_text_help}") %>
<%= f.submit(class: "button", value: t("admin.signature_sheets.new.submit")) %>
<% end %>

View File

@@ -16,17 +16,14 @@
<% end %>
<div class="small-12 medium-6 column">
<%= 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) %>
</div>
<div class="small-12 medium-6 column">
<%= f.label :locale %>
<%= f.select :locale, I18n.available_locales, label: false %>
<%= f.select :locale, I18n.available_locales %>
</div>
<div class="small-12 column">
<%= f.label :body %>
<%= f.text_area :body, label: false, rows: 10 %>
<%= f.text_area :body, rows: 10 %>
<div class="small-12 medium-6 large-3">
<%= f.submit class: "button success expanded" %>
</div>

View File

@@ -13,11 +13,11 @@
<div class="small-12 medium-6 column">
<%= 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) %>
</div>
<div class="small-12 medium-6 column">
<%= 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) %>
</div>
<div class="small-12 column">
<%= label_tag :body %>

View File

@@ -22,8 +22,8 @@
<h3><%= t("admin.site_customization.pages.form.options") %></h3>
<%= 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}") %>
<br>
<% end %>
@@ -32,9 +32,8 @@
</div>
<div class="small-12 medium-6 column">
<%= f.label :slug %>
<p class="help-text"><%= 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") %>
</div>
</div>

View File

@@ -3,8 +3,7 @@
<%= form_for(@tag, url: admin_tags_path, as: :tag) do |f| %>
<div class="small-12 medium-6">
<%= 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") %>
</div>
<%= f.submit(t("admin.tags.create"), class: "button success") %>

View File

@@ -2,8 +2,7 @@
<div class="small-12 medium-6 margin-top">
<%= 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 %>
</div>

View File

@@ -2,8 +2,7 @@
<div class="small-12 medium-6 margin-top">
<%= 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 %>
</div>

View File

@@ -59,8 +59,7 @@
<% end %>
<div class="small-12 column">
<%= f.label :location, t("budgets.investments.form.location") %>
<%= f.text_field :location, label: false %>
<%= f.text_field :location, label: t("budgets.investments.form.location") %>
</div>
<div class="small-12 column">
@@ -90,14 +89,11 @@
<% unless current_user.manager? %>
<div class="small-12 column">
<%= f.label :terms_of_service do %>
<%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
<span class="checkbox">
<%= t("form.accept_terms",
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
</span>
<% 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 %>
</div>
<% end %>

View File

@@ -3,8 +3,11 @@
<% css_id = parent_or_commentable_dom_id(parent_id, commentable) %>
<div id="js-comment-form-<%= css_id %>" <%= "style='display:none'".html_safe if toggeable %> 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 %>
<div class="float-right">
<%= 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}" %>
</div>
<% end %>
<% if can? :comment_as_administrator, commentable %>
<div class="float-right">
<%= 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}" %>
</div>
<% end %>

View File

@@ -26,26 +26,21 @@
<%= f.invisible_captcha :subtitle %>
<div class="small-12 column">
<%= f.label :tag_list, t("debates.form.tags_label") %>
<p class="help-text" id="tag-list-help-text"><%= t("debates.form.tags_instructions") %></p>
<%= 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" %>
</div>
<div class="small-12 column">
<% if @debate.new_record? %>
<%= f.label :terms_of_service do %>
<%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
<span class="checkbox">
<%= t("form.accept_terms",
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
</span>
<% 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 %>
</div>

View File

@@ -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 %></p>
<%= f.label t("devise.password_expired.new_password") %>
<%= f.password_field :password, label: false %></p>
<%= f.password_field :password, label: t("devise.password_expired.new_password") %></p>
<%= f.password_field :password_confirmation %></p>
<p><%= f.submit t("devise.password_expired.change_password") %></p>

View File

@@ -21,10 +21,7 @@
<% if devise_mapping.rememberable? -%>
<div class="small-12 column">
<%= f.label :remember_me do %>
<%= f.check_box :remember_me, title: t("devise_views.sessions.new.remember_me"), label: false %>
<span class="checkbox"><%= t("devise_views.sessions.new.remember_me") %></span>
<% end %>
<%= f.check_box :remember_me, label: t("devise_views.sessions.new.remember_me") %>
</div>
<% end -%>

View File

@@ -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" %>
<div class="small-12 medium-4">
<%= f.submit t("users.direct_messages.new.submit_button"), class: "button expanded" %>

View File

@@ -25,8 +25,11 @@
<% css_id = parent_or_commentable_dom_id(nil, annotation) %>
<div id="js-comment-form-annotation-<%= annotation.id %>" style="display:none" class="comment-form js-comment-form-annotation">
<%= form_for @comment, url: legislation_process_draft_version_annotation_new_comment_path(annotation.draft_version.process, annotation.draft_version, annotation), remote: true do |f| %>
<%= label_tag "comment-body-#{css_id}", leave_comment_text(annotation) %>
<%= f.text_area :body, id: "comment-body-#{css_id}", maxlength: Comment.body_max_length, label: false, rows: 8 %>
<%= f.text_area :body,
id: "comment-body-#{css_id}",
maxlength: Comment.body_max_length,
label: leave_comment_text(annotation),
rows: 8 %>
<%= f.submit comment_button_text(nil, annotation), class: "button" %>
<% end %>
</div>

View File

@@ -5,30 +5,33 @@
<div class="row">
<div class="small-12 column">
<%= 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") %>
</div>
<%= f.invisible_captcha :subtitle %>
<div class="small-12 column">
<%= f.label :summary, t("proposals.form.proposal_summary") %>
<p class="help-text" id="summary-help-text"><%= t("proposals.form.proposal_summary_note") %></p>
<%= 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") %>
</div>
<div class="ckeditor small-12 column">
<%= 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") %>
</div>
<div class="small-12 column">
<%= f.label :video_url, t("proposals.form.proposal_video_url") %>
<p class="help-text" id="video-url-help-text"><%= t("proposals.form.proposal_video_url_note") %></p>
<%= 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") %>
</div>
<% if feature?(:allow_images) %>
@@ -42,8 +45,8 @@
</div>
<div class="small-12 medium-6 column">
<%= 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") %>
</div>
<div class="small-12 column">
@@ -66,14 +69,12 @@
<div class="small-12 column">
<% if @proposal.new_record? %>
<%= f.label :terms_of_service do %>
<%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
<span class="checkbox">
<%= t("form.accept_terms",
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
</span>
<% 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 %>
</div>

View File

@@ -13,11 +13,10 @@
label: t("management.users.email_optional_label"),
placeholder: t("management.email_label") %>
<div class="date-of-birth">
<%= 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") %>
</div>
<%= f.submit t("management.users.create_user_submit"), class: "button success" %>
<% end %>

View File

@@ -18,14 +18,8 @@
id: map_location_input_id(parent_class, "zoom") %>
<div>
<%= form.label :skip_map do %>
<%= form.check_box :skip_map,
title: t("#{i18n_namespace}.form.map_skip_checkbox"),
label: false,
class: "js-toggle-map" %>
<span class="checkbox">
<%= t("#{i18n_namespace}.form.map_skip_checkbox") %>
</span>
<% end %>
<%= form.check_box :skip_map,
label: t("#{i18n_namespace}.form.map_skip_checkbox"),
class: "js-toggle-map" %>
</div>
<% end %>

View File

@@ -5,7 +5,7 @@
<label><%= t("officing.poll_budgets.new.booth") %></label>
<%= 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") } %>
<label><%= t("officing.poll_budgets.new.csv_data") %></label>
<%= text_area_tag :data, nil, rows: 10 %>

View File

@@ -7,8 +7,7 @@
<label><%= t("officing.results.new.booth") %></label>
<%= 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") } %>
</div>
</div>

View File

@@ -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 %>
<p class="help-text" id="responsible-name-help-text"><%= t("devise_views.organizations.registrations.new.responsible_name_note") %></p>
<%= 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 %>
<span class="checkbox">
<%= 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 %></span>
<% 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 %>
<div class="small-12 medium-6 small-centered">
<%= f.submit t("devise_views.organizations.registrations.new.submit"), class: "button expanded" %>

View File

@@ -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 %>
<div class="small-12 medium-4">

View File

@@ -17,15 +17,10 @@
<div class="js-suggest" data-locale="<%= translations_form.locale %>"></div>
<div class="small-12 column">
<%= translations_form.label :summary %>
<p class="help-text" id="<%= summary_help_text_id(translations_form) %>">
<%= t("proposals.form.proposal_summary_note") %>
</p>
<%= 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") %>
</div>
<div class="ckeditor small-12 column">
@@ -38,11 +33,9 @@
<%= f.invisible_captcha :subtitle %>
<div class="small-12 column">
<%= f.label :video_url, t("proposals.form.proposal_video_url") %>
<p class="help-text" id="video-url-help-text"><%= t("proposals.form.proposal_video_url_note") %></p>
<%= 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") %>
</div>
<% if feature?(:allow_images) %>
@@ -58,8 +51,8 @@
<% end %>
<div class="small-12 medium-6 column">
<%= 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") %>
</div>
<% if feature?(:map) %>
@@ -99,23 +92,21 @@
<% if current_user.unverified? %>
<div class="small-12 column">
<%= f.label :responsible_name, t("proposals.form.proposal_responsible_name") %>
<p class="help-text" id="responsible-name-help-text"><%= t("proposals.form.proposal_responsible_name_note") %></p>
<%= 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") %>
</div>
<% end %>
<div class="small-12 column">
<% if @proposal.new_record? %>
<%= f.label :terms_of_service do %>
<%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
<span class="checkbox">
<%= t("form.accept_terms",
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
</span>
<% 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 %>
</div>

View File

@@ -16,8 +16,9 @@
<%= render "shared/errors", resource: @proposal %>
<div class="row">
<div class="small-12 medium-6 large-4 column">
<%= 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") %>
</div>
</div>

View File

@@ -31,9 +31,8 @@
<%= form_for(@resource, url: new_url_path, method: :get) do |f| %>
<div class="small-12 medium-4">
<%= 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") %>
</div>
<div class="actions small-12">

View File

@@ -4,11 +4,8 @@
<div class="row">
<div class="small-12 column">
<%= 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")) %>
</div>

View File

@@ -27,10 +27,9 @@
<div class="row">
<div class="column">
<%= 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 %>

View File

@@ -19,8 +19,10 @@
<% progress_options = { min: ProgressBar::RANGE.min, max: ProgressBar::RANGE.max, step: 1 } %>
<div class="row">
<div class="small-12 medium-6 large-2 column">
<%= f.label :percentage %>
<%= f.text_field :percentage, { type: :range,
id: "percentage_range",
label: false,
class: "column" }.merge(progress_options) %>
</div>

View File

@@ -6,8 +6,10 @@
<%= render "shared/errors", resource: resource %>
<div class="row">
<div class="small-12 column">
<%= 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") %>
</div>
<div class="small-12 column">
@@ -17,24 +19,26 @@
</div>
<div class="small-12 column">
<%= f.label :password, t("devise_views.users.registrations.edit.password_label") %>
<p class="help-text" id="password-help-text"><%= t("devise_views.users.registrations.edit.leave_blank") %></p>
<%= 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") %>
</div>
<div class="small-12 column">
<%= 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") %>
</div>
<div class="small-12 column">
<%= f.label :current_password, t("devise_views.users.registrations.edit.current_password_label") %>
<p class="help-text" id="current-password-help-text"><%= t("devise_views.users.registrations.edit.need_current") %></p>
<%= 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") %>
</div>
<div class="small-12 column">

View File

@@ -17,12 +17,9 @@
<%= f.hidden_field :use_redeemable_code %>
<%= f.hidden_field :locale, value: I18n.locale %>
<%= f.label :username %>
<p class="help-text" id="username-help-text"><%= t("devise_views.users.registrations.new.username_note") %></p>
<%= 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 %>
<span class="checkbox">
<%= 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 %>
</span>
<% 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 %>
<div class="small-12 medium-6 small-centered">
<%= f.submit t("devise_views.users.registrations.new.submit"), class: "button expanded" %>
</div>

View File

@@ -7,22 +7,19 @@
<legend><%= t("valuation.budget_investments.edit.feasibility") %></legend>
<div class="small-4 column">
<span class="radio">
<%= f.radio_button :feasibility, "undecided", label: false %>
<%= f.label :feasibility_undecided, t("valuation.budget_investments.edit.undefined_feasible") %>
<%= f.radio_button :feasibility, "undecided" %>
</span>
</div>
<div class="small-4 column">
<span class="radio">
<%= f.radio_button :feasibility, "feasible", label: false %>
<%= f.label :feasibility_feasible, t("valuation.budget_investments.edit.feasible") %>
<%= f.radio_button :feasibility, "feasible" %>
</span>
</div>
<div class="small-4 column">
<span class="radio">
<%= f.radio_button :feasibility, "unfeasible", label: false %>
<%= f.label :feasibility_unfeasible, t("valuation.budget_investments.edit.unfeasible") %>
<%= f.radio_button :feasibility, "unfeasible" %>
</span>
</div>
</fieldset>
@@ -33,8 +30,9 @@
<div class="row">
<div class="small-12 column">
<%= 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 %>
</div>
</div>
@@ -44,27 +42,29 @@
<div class="row">
<div class="small-12 medium-6 column">
<%= 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 %>
</div>
<div class="small-12 medium-6 column end">
<%= 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 %>
</div>
</div>
<div class="row">
<div class="small-12 column">
<%= 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 %>
</div>
</div>
<div class="row">
<div class="small-12 medium-6 column">
<%= 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") %>
</div>
</div>
@@ -72,14 +72,11 @@
<div class="row">
<div class="small-12 medium-8 column">
<%= 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") %>
<span class="checkbox"><%= t("valuation.budget_investments.edit.valuation_finished") %></span>
<% 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") %>
</div>
</div>

View File

@@ -39,8 +39,8 @@
<div class="row">
<div class="small-12 medium-8">
<div class="small-12 medium-3 column">
<%= 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") %>
</div>
<div class="small-12 medium-5 column end">
@@ -64,32 +64,26 @@
</div>
<div class="date-of-birth small-12 medium-6 clear">
<%= 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") %>
</div>
<div class="small-12 medium-5 clear">
<%= f.label t("verification.residence.new.postal_code") %>
<p class="help-text" id="postal-code-help-text"><%= t("verification.residence.new.postal_code_note") %></p>
<div class="medium-6">
<%= f.text_field :postal_code, label: false, aria: { describedby: "postal-code-help-text" } %>
</div>
<%= f.text_field :postal_code,
label: t("verification.residence.new.postal_code"),
hint: t("verification.residence.new.postal_code_note") %>
</div>
<div class="small-12">
<%= f.label :terms_of_service do %>
<%= f.check_box :terms_of_service, title: t("verification.residence.new.accept_terms_text_title"), label: false %>
<span class="checkbox">
<%= 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
%>
</span>
<% 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 %>
</div>
<div class="small-12 medium-3 clear">

View File

@@ -33,8 +33,7 @@
<% end %>
<div class="small-12 medium-6">
<%= 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") %>
</div>
<%= f.submit t("verification.sms.edit.submit_button"), class: "button success" %>

View File

@@ -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

View File

@@ -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"

View File

@@ -60,9 +60,6 @@ en:
price_first_year_html: "Cost during the first year (%{currency}) <small>(optional, data not public)</small>"
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."

View File

@@ -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"

View File

@@ -60,9 +60,6 @@ es:
price_first_year_html: "Coste en el primer año (%{currency}) <small>(opcional, dato no público)</small>"
price_explanation_html: Informe de coste <small>(opcional, dato público)</small>
feasibility: Viabilidad
feasible: Viable
unfeasible: Inviable
undefined_feasible: Sin decidir
feasible_explanation_html: Informe de inviabilidad <small>(en caso de que lo sea, dato público)</small>
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."

View File

@@ -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