Skip to content

Commit 5fd3814

Browse files
authored
Merge pull request #196 from etalab/ux/tos-summary
Enhance ToS UX
2 parents 9052178 + d6c3413 commit 5fd3814

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

app/form_builders/authorization_request_form_builder.rb

+18
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,27 @@ def cgu_check_box(opts = {})
6262
I18n.t('authorization_request_forms.default.terms_of_service_accepted.label', link: @object.definition.cgu_link).html_safe
6363
end
6464

65+
opts[:class] ||= []
66+
opts[:class] << 'fr-input-group--error' if all_terms_not_accepted_error?(:terms_of_service_accepted)
67+
6568
dsfr_check_box(:terms_of_service_accepted, opts)
6669
end
6770

71+
def data_protection_officer_informed_check_box(opts = {})
72+
opts[:class] ||= []
73+
opts[:class] << 'fr-input-group--error' if all_terms_not_accepted_error?(:data_protection_officer_informed)
74+
75+
dsfr_check_box(:data_protection_officer_informed, opts)
76+
end
77+
78+
def all_terms_not_accepted_error?(attribute)
79+
return false if @object.public_send(attribute).present?
80+
81+
@object.errors.any? do |error|
82+
error.attribute == :base && error.type == :all_terms_not_accepted
83+
end
84+
end
85+
6886
def dsfr_file_field(attribute, opts = {})
6987
opts[:class] ||= 'fr-upload-group'
7088

Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
<%= f.cgu_check_box %>
2-
<%= f.dsfr_check_box :data_protection_officer_informed %>
2+
<%= f.data_protection_officer_informed_check_box %>

app/views/authorization_request_forms/summary.html.erb

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@
8484

8585
<%= render partial: 'authorization_requests/shared/organization_and_applicant' %>
8686

87-
<% if @authorization_request.draft? && !@authorization_request.reopening? %>
88-
<%= render partial: 'authorization_request_forms/shared/tos_checkboxes', locals: { f: f } %>
89-
<% end %>
90-
9187
<% if @authorization_request.filling? %>
9288
<% @authorization_request.editable_blocks.each do |block| %>
9389
<%= render partial: "authorization_requests/shared/blocks/#{block[:name]}", locals: { f: f, editable: true } %>
@@ -111,6 +107,10 @@
111107
<% end %>
112108
<% end %>
113109

110+
<% if @authorization_request.draft? && !@authorization_request.reopening? %>
111+
<%= render partial: 'authorization_request_forms/shared/tos_checkboxes', locals: { f: f } %>
112+
<% end %>
113+
114114
<% if policy(@authorization_request).submit? %>
115115
<div class="fr-btns-group fr-btns-group--inline-lg fr-btns-group--icon-left fr-btns-group--right">
116116
<%= f.button t('authorization_request_forms.form.submit'), type: :submit, name: :submit, id: :submit_authorization_request, class: %w(fr-btn fr-btn--sm fr-icon-checkbox-line fr-btn--icon-left) %>

0 commit comments

Comments
 (0)