Simplify generating checkboxes in forms
Using the block syntax to generate the label with a <span> tag inside isn't necessary after upgrading foundation_rails_helpers. Before the upgrade, we couldn't do so because the <span> tag was escaped.
This commit is contained in:
@@ -32,82 +32,40 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :public_activity do %>
|
<%= f.check_box :public_activity, label: t("account.show.public_activity_label") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :public_interests do %>
|
<%= f.check_box :public_interests, label: t("account.show.public_interests_label") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if @account.email.present? %>
|
<% if @account.email.present? %>
|
||||||
<h2><%= t("account.show.notifications") %></h2>
|
<h2><%= t("account.show.notifications") %></h2>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :email_on_comment do %>
|
<%= f.check_box :email_on_comment, label: t("account.show.email_on_comment_label") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :email_on_comment_reply do %>
|
<%= f.check_box :email_on_comment_reply, label: t("account.show.email_on_comment_reply_label") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :email_newsletter_subscribed do %>
|
<%= f.check_box :newsletter, label: t("account.show.subscription_to_website_newsletter_label") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :email_digest do %>
|
<%= f.check_box :email_digest, label: t("account.show.email_digest_label") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :email_on_direct_message do %>
|
<%= f.check_box :email_on_direct_message, label: t("account.show.email_on_direct_message_label") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @account.official_level == 1 %>
|
<% if @account.official_level == 1 %>
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :official_position_badge do %>
|
<%= f.check_box :official_position_badge, label: t("account.show.official_position_badge_label") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
@@ -116,23 +74,13 @@
|
|||||||
|
|
||||||
<% if feature?("user.recommendations_on_debates") %>
|
<% if feature?("user.recommendations_on_debates") %>
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :recommended_debates do %>
|
<%= f.check_box :recommended_debates, label: t("account.show.show_debates_recommendations") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if feature?("user.recommendations_on_proposals") %>
|
<% if feature?("user.recommendations_on_proposals") %>
|
||||||
<div>
|
<div>
|
||||||
<%= f.label :recommended_proposals do %>
|
<%= f.check_box :recommended_proposals, label: t("account.show.show_proposals_recommendations") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -105,18 +105,16 @@
|
|||||||
<% if @investment.incompatible? || @investment.winner? %>
|
<% if @investment.incompatible? || @investment.winner? %>
|
||||||
<div class="small-12 medium-3 column">
|
<div class="small-12 medium-3 column">
|
||||||
<h2 id="incompatible"><%= t("admin.budget_investments.edit.compatibility") %></h2>
|
<h2 id="incompatible"><%= t("admin.budget_investments.edit.compatibility") %></h2>
|
||||||
<%= f.label :incompatible do %>
|
<%= f.check_box :incompatible,
|
||||||
<%= f.check_box :incompatible, title: t("admin.budget_investments.edit.compatibility"), label: false %>
|
title: t("admin.budget_investments.edit.compatibility"),
|
||||||
<span class="checkbox"><%= t("admin.budget_investments.edit.mark_as_incompatible") %></span>
|
label: t("admin.budget_investments.edit.mark_as_incompatible") %>
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="small-12 medium-3 column float-left">
|
<div class="small-12 medium-3 column float-left">
|
||||||
<h2 id="selected"><%= t("admin.budget_investments.edit.selection") %></h2>
|
<h2 id="selected"><%= t("admin.budget_investments.edit.selection") %></h2>
|
||||||
<%= f.label :selected do %>
|
<%= f.check_box :selected,
|
||||||
<%= f.check_box :selected, title: t("admin.budget_investments.edit.selection"), label: false %>
|
title: t("admin.budget_investments.edit.selection"),
|
||||||
<span class="checkbox"><%= t("admin.budget_investments.edit.mark_as_selected") %></span>
|
label: t("admin.budget_investments.edit.mark_as_selected") %>
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -89,14 +89,11 @@
|
|||||||
<% unless current_user.manager? %>
|
<% unless current_user.manager? %>
|
||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.label :terms_of_service do %>
|
<%= f.check_box :terms_of_service,
|
||||||
<%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
|
title: t("form.accept_terms_title"),
|
||||||
<span class="checkbox">
|
label: t("form.accept_terms",
|
||||||
<%= t("form.accept_terms",
|
|
||||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
|
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
|
||||||
</span>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -18,14 +18,18 @@
|
|||||||
|
|
||||||
<% if can? :comment_as_moderator, commentable %>
|
<% if can? :comment_as_moderator, commentable %>
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<%= f.check_box :as_moderator, title: t("comments.form.comment_as_moderator"), id: "comment-as-moderator-#{css_id}", label: false %>
|
<%= f.check_box :as_moderator,
|
||||||
<%= label_tag "comment-as-moderator-#{css_id}", t("comments.form.comment_as_moderator"), class: "checkbox" %>
|
label: t("comments.form.comment_as_moderator"),
|
||||||
|
id: "comment-as-moderator-#{css_id}",
|
||||||
|
label_options: { for: "comment-as-moderator-#{css_id}" } %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if can? :comment_as_administrator, commentable %>
|
<% if can? :comment_as_administrator, commentable %>
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<%= f.check_box :as_administrator, title: t("comments.form.comment_as_admin"), id: "comment-as-administrator-#{css_id}", label: false %>
|
<%= f.check_box :as_administrator,
|
||||||
<%= label_tag "comment-as-administrator-#{css_id}", t("comments.form.comment_as_admin"), class: "checkbox" %>
|
label: t("comments.form.comment_as_admin"),
|
||||||
|
id: "comment-as-administrator-#{css_id}",
|
||||||
|
label_options: { for: "comment-as-administrator-#{css_id}" } %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -35,14 +35,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<% if @debate.new_record? %>
|
<% if @debate.new_record? %>
|
||||||
<%= f.label :terms_of_service do %>
|
<%= f.check_box :terms_of_service,
|
||||||
<%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
|
title: t("form.accept_terms_title"),
|
||||||
<span class="checkbox">
|
label: t("form.accept_terms",
|
||||||
<%= t("form.accept_terms",
|
|
||||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
|
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")
|
||||||
</span>
|
).html_safe %>
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,7 @@
|
|||||||
|
|
||||||
<% if devise_mapping.rememberable? -%>
|
<% if devise_mapping.rememberable? -%>
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.label :remember_me do %>
|
<%= f.check_box :remember_me, label: t("devise_views.sessions.new.remember_me") %>
|
||||||
<%= 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 %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
|
|||||||
@@ -69,14 +69,12 @@
|
|||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<% if @proposal.new_record? %>
|
<% if @proposal.new_record? %>
|
||||||
<%= f.label :terms_of_service do %>
|
<%= f.check_box :terms_of_service,
|
||||||
<%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
|
title: t("form.accept_terms_title"),
|
||||||
<span class="checkbox">
|
label: t("form.accept_terms",
|
||||||
<%= t("form.accept_terms",
|
|
||||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
|
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")
|
||||||
</span>
|
).html_safe %>
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,8 @@
|
|||||||
id: map_location_input_id(parent_class, "zoom") %>
|
id: map_location_input_id(parent_class, "zoom") %>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<%= form.label :skip_map do %>
|
|
||||||
<%= form.check_box :skip_map,
|
<%= form.check_box :skip_map,
|
||||||
title: t("#{i18n_namespace}.form.map_skip_checkbox"),
|
label: t("#{i18n_namespace}.form.map_skip_checkbox"),
|
||||||
label: false,
|
|
||||||
class: "js-toggle-map" %>
|
class: "js-toggle-map" %>
|
||||||
<span class="checkbox">
|
|
||||||
<%= t("#{i18n_namespace}.form.map_skip_checkbox") %>
|
|
||||||
</span>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -27,12 +27,14 @@
|
|||||||
label: t("devise_views.organizations.registrations.new.password_confirmation_label"),
|
label: t("devise_views.organizations.registrations.new.password_confirmation_label"),
|
||||||
placeholder: 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,
|
||||||
<%= f.check_box :terms_of_service, title: t("devise_views.users.registrations.new.terms_title"), label: false %>
|
title: t("devise_views.users.registrations.new.terms_title"),
|
||||||
<span class="checkbox">
|
label: t("devise_views.users.registrations.new.terms",
|
||||||
<%= t("devise_views.users.registrations.new.terms",
|
terms: link_to(t("devise_views.users.registrations.new.terms_link"),
|
||||||
terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions", title: t("shared.target_blank_html"), target: "_blank")).html_safe %></span>
|
"/conditions",
|
||||||
<% end %>
|
title: t("shared.target_blank_html"),
|
||||||
|
target: "_blank")
|
||||||
|
).html_safe %>
|
||||||
|
|
||||||
<div class="small-12 medium-6 small-centered">
|
<div class="small-12 medium-6 small-centered">
|
||||||
<%= f.submit t("devise_views.organizations.registrations.new.submit"), class: "button expanded" %>
|
<%= f.submit t("devise_views.organizations.registrations.new.submit"), class: "button expanded" %>
|
||||||
|
|||||||
@@ -101,14 +101,12 @@
|
|||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<% if @proposal.new_record? %>
|
<% if @proposal.new_record? %>
|
||||||
<%= f.label :terms_of_service do %>
|
<%= f.check_box :terms_of_service,
|
||||||
<%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
|
title: t("form.accept_terms_title"),
|
||||||
<span class="checkbox">
|
label: t("form.accept_terms",
|
||||||
<%= t("form.accept_terms",
|
|
||||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
|
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")
|
||||||
</span>
|
).html_safe %>
|
||||||
<% end %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -36,15 +36,14 @@
|
|||||||
<%= f.text_field :redeemable_code, placeholder: t("devise_views.users.registrations.new.redeemable_code") %>
|
<%= f.text_field :redeemable_code, placeholder: t("devise_views.users.registrations.new.redeemable_code") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= f.label :terms_of_service do %>
|
<%= f.check_box :terms_of_service,
|
||||||
<%= f.check_box :terms_of_service, title: t("devise_views.users.registrations.new.terms_title"), label: false %>
|
title: t("devise_views.users.registrations.new.terms_title"),
|
||||||
<span class="checkbox">
|
label: t("devise_views.users.registrations.new.terms",
|
||||||
<%= t("devise_views.users.registrations.new.terms",
|
|
||||||
terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions",
|
terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions",
|
||||||
title: t("shared.target_blank_html"),
|
title: t("shared.target_blank_html"),
|
||||||
target: "_blank")).html_safe %>
|
target: "_blank")
|
||||||
</span>
|
).html_safe %>
|
||||||
<% end %>
|
|
||||||
<div class="small-12 medium-6 small-centered">
|
<div class="small-12 medium-6 small-centered">
|
||||||
<%= f.submit t("devise_views.users.registrations.new.submit"), class: "button expanded" %>
|
<%= f.submit t("devise_views.users.registrations.new.submit"), class: "button expanded" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -75,14 +75,12 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 medium-8 column">
|
<div class="small-12 medium-8 column">
|
||||||
<%= f.label :valuation_finished do %>
|
|
||||||
<%= f.check_box :valuation_finished,
|
<%= f.check_box :valuation_finished,
|
||||||
title: t("valuation.budget_investments.edit.valuation_finished"),
|
label: t("valuation.budget_investments.edit.valuation_finished"),
|
||||||
label: false, id: "js-investment-report-alert",
|
label_options: { for: "js-investment-report-alert" },
|
||||||
|
id: "js-investment-report-alert",
|
||||||
"data-alert": t("valuation.budget_investments.edit.valuation_finished_alert"),
|
"data-alert": t("valuation.budget_investments.edit.valuation_finished_alert"),
|
||||||
"data-not-feasible-alert": t("valuation.budget_investments.edit.not_feasible_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 %>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -77,16 +77,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12">
|
<div class="small-12">
|
||||||
<%= f.label :terms_of_service do %>
|
<%= f.check_box :terms_of_service,
|
||||||
<%= f.check_box :terms_of_service, title: t("verification.residence.new.accept_terms_text_title"), label: false %>
|
title: t("verification.residence.new.accept_terms_text_title"),
|
||||||
<span class="checkbox">
|
label: t("verification.residence.new.accept_terms_text",
|
||||||
<%= t("verification.residence.new.accept_terms_text",
|
|
||||||
terms_url: link_to(t("verification.residence.new.terms"), "/census_terms",
|
terms_url: link_to(t("verification.residence.new.terms"), "/census_terms",
|
||||||
title: t("shared.target_blank_html"),
|
title: t("shared.target_blank_html"),
|
||||||
target: "_blank")).html_safe
|
target: "_blank")
|
||||||
%>
|
).html_safe %>
|
||||||
</span>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-3 clear">
|
<div class="small-12 medium-3 clear">
|
||||||
|
|||||||
@@ -17,6 +17,16 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder
|
|||||||
end
|
end
|
||||||
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))
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def label_with_hint(attribute, options)
|
def label_with_hint(attribute, options)
|
||||||
@@ -24,6 +34,14 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder
|
|||||||
help_text(attribute, options)
|
help_text(attribute, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def label_text(object, attribute, text)
|
||||||
|
if text.nil? || text == true
|
||||||
|
default_label_text(object, attribute)
|
||||||
|
else
|
||||||
|
text
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def help_text(attribute, options)
|
def help_text(attribute, options)
|
||||||
if options[:hint]
|
if options[:hint]
|
||||||
content_tag :span, options[:hint], class: "help-text", id: help_text_id(attribute, options)
|
content_tag :span, options[:hint], class: "help-text", id: help_text_id(attribute, options)
|
||||||
|
|||||||
Reference in New Issue
Block a user