Merge pull request #5283 from consuldemocracy/label_links

Allow links in forms to open in new tabs
This commit is contained in:
Javi Martín
2023-10-24 16:30:59 +02:00
committed by GitHub
28 changed files with 95 additions and 58 deletions

View File

@@ -34,7 +34,7 @@
<%= actions.action(:show,
text: t("admin.site_customization.pages.index.see_page"),
path: page.url,
options: { target: "_blank" }) %>
target: "_blank") %>
<% end %>
<% end %>
</td>

View File

@@ -89,11 +89,7 @@
<div class="actions">
<% unless current_user.manager? || investment.persisted? %>
<div>
<%= 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")) %>
<%= render Shared::AgreeWithTermsOfServiceFieldComponent.new(f) %>
</div>
<% end %>

View File

@@ -41,11 +41,7 @@
<div class="actions">
<% if debate.new_record? %>
<div>
<%= 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")) %>
<%= render Shared::AgreeWithTermsOfServiceFieldComponent.new(f) %>
</div>
<% end %>

View File

@@ -2,9 +2,7 @@
<%= back_link_to debates_path, t("debates.index.section_header.title") %>
<%= header do %>
<%= link_to help_path(anchor: "debates"), title: t("shared.target_blank"), target: "_blank" do %>
<%= t("debates.new.more_info") %>
<% end %>
<%= link_to t("debates.new.more_info"), help_path(anchor: "debates") %>
<% end %>
<aside>

View File

@@ -1,6 +1,7 @@
class Debates::NewComponent < ApplicationComponent
include Header
attr_reader :debate
delegate :new_window_link_to, to: :helpers
def initialize(debate)
@debate = debate

View File

@@ -7,8 +7,8 @@
<p class="info">
<%= sanitize(t("layouts.footer.description",
open_source: link_to(t("layouts.footer.open_source"), t("layouts.footer.open_source_url"), target: "blank", rel: "nofollow"),
consul: link_to(t("layouts.footer.consul"), t("layouts.footer.consul_url"), target: "blank", rel: "nofollow"))) %>
open_source: link_to(t("layouts.footer.open_source"), t("layouts.footer.open_source_url"), target: "_blank", rel: "nofollow"),
consul: link_to(t("layouts.footer.consul"), t("layouts.footer.consul_url"), target: "_blank", rel: "nofollow"))) %>
</p>
</div>

View File

@@ -96,11 +96,7 @@
<div class="actions">
<% if proposal.new_record? %>
<div>
<%= 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")) %>
<%= render Shared::AgreeWithTermsOfServiceFieldComponent.new(f) %>
</div>
<% end %>

View File

@@ -2,9 +2,7 @@
<%= back_link_to proposals_path, t("proposals.index.section_header.title") %>
<%= header do %>
<%= link_to help_path(anchor: "proposals"), title: t("shared.target_blank"), target: "_blank" do %>
<%= t("proposals.new.more_info") %>
<% end %>
<%= new_window_link_to t("proposals.new.more_info"), help_path(anchor: "proposals") %>
<% end %>
<aside>

View File

@@ -1,6 +1,7 @@
class Proposals::NewComponent < ApplicationComponent
include Header
attr_reader :proposal
delegate :new_window_link_to, to: :helpers
def initialize(proposal)
@proposal = proposal

View File

@@ -14,10 +14,8 @@
<%= f.text_field :related_sdg_list,
class: "input",
hint: sanitize(t("sdg.related_list_selector.hint",
link: link_to(t("sdg.related_list_selector.help.text"),
sdg_help_path,
title: t("shared.target_blank"),
target: "_blank")),
link: new_window_link_to(t("sdg.related_list_selector.help.text"),
sdg_help_path)),
attributes: %w[href title target]),
data: { "suggestions-list": sdg_related_suggestions,
"remove-tag-text": t("sdg.related_list_selector.remove_tag") } %>

View File

@@ -1,5 +1,6 @@
class SDG::RelatedListSelectorComponent < ApplicationComponent
attr_reader :f
delegate :new_window_link_to, to: :helpers
def initialize(form)
@f = form

View File

@@ -0,0 +1 @@
<%= form.check_box :terms_of_service, label: label %>

View File

@@ -0,0 +1,16 @@
class Shared::AgreeWithTermsOfServiceFieldComponent < ApplicationComponent
attr_reader :form
delegate :new_window_link_to, to: :helpers
def initialize(form)
@form = form
end
private
def label
t("form.accept_terms",
policy: new_window_link_to(t("form.policy"), "/privacy"),
conditions: new_window_link_to(t("form.conditions"), "/conditions"))
end
end