From 46f43236bb17922052f4d31b328e34d9ec73c342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 15 Oct 2023 15:08:47 +0200 Subject: [PATCH] Extract component to render the "I agree" checkbox IMHO the best solution would be to completely remove this checkbox on forms that require registration. Other than the fact that people have already agreed with these terms when registering (although I guess these terms might have changed since then) and that approximately 0% of the population will read the conditions every time they agree with them, there's the fact that these links are inside a label and people might accidentally click on them while trying to click on the label in order to check the checkbox. I guess the idea is that these conditions might have changed since the moment people registered. In a fair world, checking "I agree" would have no legal meaning because it's unreasonable to expect that people will read these conditions every time they fill in a form, so whatever we're trying to do here would be pointless. But, since I'm not sure about the legal implications of removing this field in a world where you have to inform people that websites requiring identification use cookies, for now the field will stay where it is. --- .../budgets/investments/form_component.html.erb | 5 +---- app/components/debates/form_component.html.erb | 5 +---- app/components/proposals/form_component.html.erb | 5 +---- ...with_terms_of_service_field_component.html.erb | 1 + ...agree_with_terms_of_service_field_component.rb | 15 +++++++++++++++ app/views/legislation/proposals/_form.html.erb | 5 +---- 6 files changed, 20 insertions(+), 16 deletions(-) create mode 100644 app/components/shared/agree_with_terms_of_service_field_component.html.erb create mode 100644 app/components/shared/agree_with_terms_of_service_field_component.rb diff --git a/app/components/budgets/investments/form_component.html.erb b/app/components/budgets/investments/form_component.html.erb index 25a886bd8..f5aa72e31 100644 --- a/app/components/budgets/investments/form_component.html.erb +++ b/app/components/budgets/investments/form_component.html.erb @@ -89,10 +89,7 @@
<% unless current_user.manager? || investment.persisted? %>
- <%= f.check_box :terms_of_service, - 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) %>
<% end %> diff --git a/app/components/debates/form_component.html.erb b/app/components/debates/form_component.html.erb index 5df529206..1816d437c 100644 --- a/app/components/debates/form_component.html.erb +++ b/app/components/debates/form_component.html.erb @@ -41,10 +41,7 @@
<% if debate.new_record? %>
- <%= f.check_box :terms_of_service, - 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) %>
<% end %> diff --git a/app/components/proposals/form_component.html.erb b/app/components/proposals/form_component.html.erb index b77eba8a7..c4467fe7d 100644 --- a/app/components/proposals/form_component.html.erb +++ b/app/components/proposals/form_component.html.erb @@ -96,10 +96,7 @@
<% if proposal.new_record? %>
- <%= f.check_box :terms_of_service, - 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) %>
<% end %> diff --git a/app/components/shared/agree_with_terms_of_service_field_component.html.erb b/app/components/shared/agree_with_terms_of_service_field_component.html.erb new file mode 100644 index 000000000..dcfcb0e32 --- /dev/null +++ b/app/components/shared/agree_with_terms_of_service_field_component.html.erb @@ -0,0 +1 @@ +<%= form.check_box :terms_of_service, label: label %> diff --git a/app/components/shared/agree_with_terms_of_service_field_component.rb b/app/components/shared/agree_with_terms_of_service_field_component.rb new file mode 100644 index 000000000..808dbe812 --- /dev/null +++ b/app/components/shared/agree_with_terms_of_service_field_component.rb @@ -0,0 +1,15 @@ +class Shared::AgreeWithTermsOfServiceFieldComponent < ApplicationComponent + attr_reader :form + + def initialize(form) + @form = form + end + + private + + def label + t("form.accept_terms", + policy: link_to(t("form.policy"), "/privacy", target: "_blank"), + conditions: link_to(t("form.conditions"), "/conditions", target: "_blank")) + end +end diff --git a/app/views/legislation/proposals/_form.html.erb b/app/views/legislation/proposals/_form.html.erb index 179d1bb4b..0bea7d205 100644 --- a/app/views/legislation/proposals/_form.html.erb +++ b/app/views/legislation/proposals/_form.html.erb @@ -62,10 +62,7 @@
<% if @proposal.new_record? %> - <%= f.check_box :terms_of_service, - 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) %> <% end %>