Skip to content

Commit

Permalink
Change prefilled data banner logic for single page form
Browse files Browse the repository at this point in the history
We're going to introduce a single page form with some prefilled data not
displayed. Because of this, old behavior used to displayed the banner,
without prefilled data, which is a bit confusing.

This new way has some default too: we have to manually add the new
partial on each single page view. I think the tradeoff is OK because
we'll copy some views, which embed this partial. Moreover it'll be some
generator in the future.

Ref #500 (comment)
  • Loading branch information
skelz0r committed Oct 30, 2024
1 parent dcc7c1f commit dea8411
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
5 changes: 0 additions & 5 deletions app/helpers/authorization_requests_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ def within_summary?
end
# rubocop:enable Rails/HelperInstanceVariable

def single_page_form?(authorization_request)
!authorization_request.display_prefilled_banner_for_each_block? &&
authorization_request.prefilled_data?(authorization_request.data.keys)
end

# rubocop:disable Rails/HelperInstanceVariable
def english_step_name(translated_step_key = nil)
if translated_step_key.nil?
Expand Down
4 changes: 0 additions & 4 deletions app/views/authorization_request_forms/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
<%= render partial: "authorization_request_forms/shared/block_titles", locals: { f: f, block_name: english_step_name(params[:id]) } %>
<% end %>
<% if single_page_form?(@authorization_request) && !within_edit? && !within_summary? %>
<%= render partial: "authorization_request_forms/shared/prefilled_banner" %>
<% end %>
<%= yield %>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<%= authorization_request_form(@authorization_request) do |f| %>
<%= render partial: 'authorization_request_forms/shared/prefilled_banner_for_single_page_form' %>
<%= render partial: "authorization_request_forms/shared/block_titles", locals: { f:, block_name: :contacts } %>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<%= authorization_request_form(@authorization_request) do |f| %>
<%= render partial: 'authorization_request_forms/shared/prefilled_banner_for_single_page_form' %>

<p class="fr-alert fr-alert--info fr-my-3w">
Ce formulaire simplifié vous permet d'obtenir une habilitation pour un logiciel pré-configuré de
l'éditeur <%= @authorization_request.form.service_provider.name %>. Une partie des informations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<%= authorization_request_form(@authorization_request) do |f| %>
<%= render partial: 'authorization_request_forms/shared/prefilled_banner_for_single_page_form' %>

<p class="fr-alert fr-alert--info fr-my-3w">
Ce formulaire simplifié vous permet d'obtenir une habilitation pour un logiciel pré-configuré de
l'éditeur <%= @authorization_request.form.service_provider.name %>. Une partie des informations
Expand Down
2 changes: 2 additions & 0 deletions app/views/authorization_request_forms/hubee_cert_dc.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<%= authorization_request_form(@authorization_request) do |f| %>
<%= render partial: 'authorization_request_forms/shared/prefilled_banner_for_single_page_form' %>

<div class="fr-mt-4w">
<%= render partial: "authorization_requests/shared/organization_and_applicant" %>
</div>
Expand Down
8 changes: 5 additions & 3 deletions app/views/authorization_request_forms/hubee_dila.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<%= authorization_request_form(@authorization_request) do |f| %>
<%= render partial: 'authorization_request_forms/shared/prefilled_banner_for_single_page_form' %>

<div class="fr-mt-4w">
<%= render partial: "authorization_requests/shared/organization_and_applicant" %>
</div>

<%= render partial: "authorization_request_forms/shared/block_titles", locals: { f: f, block_name: :scopes } %>
<%= render partial: 'authorization_request_forms/shared/scopes', locals: { f: } %>
<%= render partial: "authorization_request_forms/shared/block_titles", locals: { f: f, block_name: :contacts } %>
<%= render partial: 'authorization_request_forms/shared/contacts', locals: { f: } %>
<%= render partial: 'authorization_request_forms/shared/submit_buttons', locals: { f: } %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<% if @authorization_request.prefilled_data?(@authorization_request.data.keys) && !within_edit? && !within_summary? %>
<%= render partial: "authorization_request_forms/shared/prefilled_banner" %>
<% end %>

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<%= authorization_request_form(@authorization_request) do |f| %>
<%= render partial: 'authorization_request_forms/shared/prefilled_banner_for_single_page_form' %>
<%= render partial: "authorization_request_forms/shared/block_titles", locals: { f: f, block_name: :basic_infos } %>
<%= render partial: 'authorization_request_forms/shared/basic_infos', locals: { f: f } %>
Expand Down

0 comments on commit dea8411

Please sign in to comment.