From 4a51a9a3518edcab1bf035163c3b916251a67fc6 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 22 May 2023 15:36:48 +0200 Subject: [PATCH 01/10] add two more fields for procedure description what et and for_who --- app/assets/stylesheets/procedure_context.scss | 28 +--------- .../administrateurs/procedures_controller.rb | 2 + app/controllers/users/dossiers_controller.rb | 4 ++ app/javascript/new_design/procedure-form.js | 4 ++ app/models/procedure.rb | 5 +- .../procedures/_informations.html.haml | 13 +++-- app/views/commencer/show.html.haml | 56 ++++++++++--------- app/views/layouts/procedure_context.html.haml | 19 +++---- .../shared/_procedure_description.html.haml | 39 ++++++++++--- config/locales/models/procedure/en.yml | 2 + config/locales/models/procedure/fr.yml | 4 +- ...two_fields_for_description_to_procedure.rb | 6 ++ 12 files changed, 104 insertions(+), 78 deletions(-) create mode 100644 db/migrate/20230516132925_add_two_fields_for_description_to_procedure.rb diff --git a/app/assets/stylesheets/procedure_context.scss b/app/assets/stylesheets/procedure_context.scss index 109724fab..6219a6afa 100644 --- a/app/assets/stylesheets/procedure_context.scss +++ b/app/assets/stylesheets/procedure_context.scss @@ -31,23 +31,6 @@ $procedure-description-line-height: 22px; font-size: 12px; } - .procedure-title { - font-size: 26px; - margin: 0 0 20px 0; - text-align: center; - - @media (min-width: $procedure-context-breakpoint) { - margin: 50px 0 32px; - font-size: 30px; - text-align: left; - } - } - - .procedure-configuration { - font-size: 20px; - margin-bottom: 32px; - } - .procedure-configuration--auto-archive { cursor: pointer; @@ -104,7 +87,6 @@ $procedure-description-line-height: 22px; .procedure-logos { display: flex; - justify-content: space-around; align-items: center; margin-bottom: 20px; @@ -116,16 +98,8 @@ $procedure-description-line-height: 22px; max-width: 100%; max-height: 50px; - // Fix Chrome flexbox issue - // See https://github.com/philipwalton/flexbugs/issues/225 - width: 100%; - height: 100%; - min-width: 0; - object-fit: contain; - @media (min-width: $procedure-context-breakpoint) { - max-width: 500px; - max-height: 130px; + max-height: 90px; } } } diff --git a/app/controllers/administrateurs/procedures_controller.rb b/app/controllers/administrateurs/procedures_controller.rb index c31d605ad..cf839babc 100644 --- a/app/controllers/administrateurs/procedures_controller.rb +++ b/app/controllers/administrateurs/procedures_controller.rb @@ -457,6 +457,8 @@ module Administrateurs editable_params = [ :libelle, :description, + :description_for_who, + :description_what, :organisation, :direction, :lien_site_web, diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 5068478ea..8f396dad3 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -92,10 +92,12 @@ module Users def identite @dossier = dossier @user = current_user + @hide_description = true end def update_identite @dossier = dossier + @hide_description = true if @dossier.individual.update(individual_params) @dossier.update!(autorisation_donnees: true, identity_updated_at: Time.zone.now) @@ -110,10 +112,12 @@ module Users def siret @dossier = dossier + @hide_description = true end def update_siret @dossier = dossier + @hide_description = true # We use the user as the holder model object for the siret value # (so that we can restore it on the form in case of error). diff --git a/app/javascript/new_design/procedure-form.js b/app/javascript/new_design/procedure-form.js index 0c161bbb7..770d19fcd 100644 --- a/app/javascript/new_design/procedure-form.js +++ b/app/javascript/new_design/procedure-form.js @@ -11,7 +11,11 @@ function syncInputToElement(fromSelector, toSelector) { function syncFormToPreview() { syncInputToElement('#procedure_libelle', '.procedure-title'); syncInputToElement('#procedure_description', '.procedure-description-body'); + syncInputToElement('#procedure_description_what', '.js_description_what p'); + syncInputToElement('#procedure_description_for_who', '.js_description_for_who p'); } delegate('input', '.procedure-form #procedure_libelle', syncFormToPreview); delegate('input', '.procedure-form #procedure_description', syncFormToPreview); +delegate('input', '.procedure-form #procedure_description_what', syncFormToPreview); +delegate('input', '.procedure-form #procedure_description_for_who', syncFormToPreview); diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 42bf32233..053dfa68f 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -16,6 +16,8 @@ # closed_at :datetime # declarative_with_state :string # description :string +# description_for_who :string +# description_what :string # dossiers_count_computed_at :datetime # duree_conservation_dossiers_dans_ds :integer # duree_conservation_etendue_par_ds :boolean default(FALSE), not null @@ -280,7 +282,8 @@ class Procedure < ApplicationRecord } validates :libelle, presence: true, allow_blank: false, allow_nil: false - validates :description, presence: true, allow_blank: false, allow_nil: false + validates :description, presence: true, allow_blank: false, allow_nil: false, if: -> { description_what.nil? && description_for_who.nil?} + validates :description_what, :description_for_who, presence: true, allow_blank: false, allow_nil: false, if: -> { description.nil?} validates :administrateurs, presence: true validates :lien_site_web, presence: true, if: :publiee? validates :draft_types_de_champ_public, diff --git a/app/views/administrateurs/procedures/_informations.html.haml b/app/views/administrateurs/procedures/_informations.html.haml index 80d842e9e..d451f421e 100644 --- a/app/views/administrateurs/procedures/_informations.html.haml +++ b/app/views/administrateurs/procedures/_informations.html.haml @@ -6,12 +6,17 @@ = f.label :libelle do Titre de la démarche %span.mandatory * -= f.text_field :libelle, class: 'form-control', placeholder: 'Titre', required: true += f.text_field :libelle, class: 'form-control', placeholder: 'Titre' -= f.label :description do - Description += f.label :description_what do + Quel est l’objet de la démarche ? %span.mandatory * -= f.text_area :description, rows: '6', placeholder: 'Description de la démarche, destinataires, etc. ', class: 'form-control', required: true += f.text_area :description_what, rows: '6', placeholder: 'Décrivez en quelques lignes le contexte, la finalité etc.', class: 'form-control' + += f.label :description_for_who do + À qui s’adresse la démarche ? + %span.mandatory * += f.text_area :description_for_who, rows: '6', placeholder: 'Décrivez en quelques lignes les destinataires finaux de la démarche, les critères d’éligibilité s’il y en a, les pré-requis, etc.', class: 'form-control' %h3.header-subsection Logo de la démarche = render Attachment::EditComponent.new(attached_file: @procedure.logo, view_as: :link) diff --git a/app/views/commencer/show.html.haml b/app/views/commencer/show.html.haml index 211c113bc..4bf80acdb 100644 --- a/app/views/commencer/show.html.haml +++ b/app/views/commencer/show.html.haml @@ -2,13 +2,14 @@ .commencer.form - if !user_signed_in? - %h2.huge-title= t('views.commencer.show.start_procedure') - = render partial: 'shared/france_connect_login', locals: { url: commencer_france_connect_path(path: @procedure.path, prefill_token: @prefilled_dossier&.prefill_token) } - = link_to commencer_sign_up_path(path: @procedure.path, prefill_token: @prefilled_dossier&.prefill_token), class: 'fr-btn fr-btn--lg fr-my-2w' do - = t('views.shared.account.create') - %span.optional-on-small-screens.fr-ml-1v - #{APPLICATION_NAME} - = link_to t('views.shared.account.already_user'), commencer_sign_in_path(path: @procedure.path, prefill_token: @prefilled_dossier&.prefill_token), class: 'fr-btn fr-btn--secondary fr-btn--lg fr-my-2w' + = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.start_procedure")) do |c| + - c.body do + = render partial: 'shared/france_connect_login', locals: { url: commencer_france_connect_path(path: @procedure.path, prefill_token: @prefilled_dossier&.prefill_token) } + = link_to commencer_sign_up_path(path: @procedure.path, prefill_token: @prefilled_dossier&.prefill_token), class: 'fr-btn fr-mb-2w fr-mr-2w' do + = t('views.shared.account.create') + %span.optional-on-small-screens.fr-ml-1v + #{APPLICATION_NAME} + = link_to t('views.shared.account.already_user'), commencer_sign_in_path(path: @procedure.path, prefill_token: @prefilled_dossier&.prefill_token), class: 'fr-btn fr-btn--secondary fr-mb-2w' - else - revision = @revision.draft? ? @revision : @procedure.revisions.where.not(id: @procedure.draft_revision_id) @@ -17,37 +18,42 @@ - not_drafts = dossiers.merge(Dossier.state_not_brouillon) - if @prefilled_dossier - %h2.huge-title= t('views.commencer.show.prefilled_draft') - %p= t('views.commencer.show.prefilled_draft_detail_html', time_ago: time_ago_in_words(@prefilled_dossier.created_at), procedure: @procedure.libelle) - = link_to t('views.commencer.show.go_to_prefilled_file'), url_for_dossier(@prefilled_dossier), class: 'fr-btn fr-btn--lg fr-my-2w' + = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.prefilled_draft")) do |c| + - c.body do + %p= t('views.commencer.show.prefilled_draft_detail_html', time_ago: time_ago_in_words(@prefilled_dossier.created_at), procedure: @procedure.libelle) + = link_to t('views.commencer.show.go_to_prefilled_file'), url_for_dossier(@prefilled_dossier), class: 'fr-btn fr-mb-2w' - elsif dossiers.empty? - = link_to t('views.commencer.show.start_procedure'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--lg fr-my-2w' + = link_to t('views.commencer.show.start_procedure'), url_for_new_dossier(@revision), class: 'fr-btn fr-mb-2w' - elsif drafts.size == 1 && not_drafts.empty? - dossier = drafts.first - %h2.huge-title= t('views.commencer.show.already_draft') - %p - = t('views.commencer.show.already_draft_detail_html', time_ago: time_ago_in_words(dossier.created_at), procedure: dossier.procedure.libelle) - = link_to t('views.commencer.show.continue_file'), url_for_dossier(dossier), class: 'fr-btn fr-btn--lg fr-my-2w' - = link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--lg fr-btn--secondary fr-my-2w' + = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.already_draft")) do |c| + - c.body do + %p + = t('views.commencer.show.already_draft_detail_html', time_ago: time_ago_in_words(dossier.created_at), procedure: dossier.procedure.libelle) + = link_to t('views.commencer.show.continue_file'), url_for_dossier(dossier), class: 'fr-btn fr-mb-2w' + = link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary fr-mb-2w' - elsif not_drafts.size == 1 - dossier = not_drafts.first - %h2.huge-title= t('views.commencer.show.already_not_draft') - %p - = t('views.commencer.show.already_not_draft_detail_html', time_ago: time_ago_in_words(dossier.depose_at), procedure: dossier.procedure.libelle) - = link_to t('views.commencer.show.show_my_submitted_file'), url_for_dossier(dossier), class: 'fr-btn fr-btn--lg fr-my-2w' - = link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--lg fr-btn--secondary fr-my-2w' + = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.already_not_draft")) do |c| + - c.body do + %p + = t('views.commencer.show.already_not_draft_detail_html', time_ago: time_ago_in_words(dossier.depose_at), procedure: dossier.procedure.libelle) + = link_to t('views.commencer.show.show_my_submitted_file'), url_for_dossier(dossier), class: 'fr-btn fr-mb-2w' + = link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary fr-mb-2w' - else - %h2.huge-title= t('views.commencer.show.existing_dossiers') - = link_to t('views.commencer.show.show_dossiers'), dossiers_path, class: "fr-btn fr-btn--lg fr-my-2w" - = link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: "fr-btn fr-btn--lg fr-btn--secondary fr-my-2w" + = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.existing_dossiers")) do |c| + - c.body do + = link_to t('views.commencer.show.show_dossiers'), dossiers_path, class: "fr-btn fr-mb-2w" + = link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: "fr-btn fr-btn--secondary fr-mb-2w" + - if @procedure.feature_enabled?(:dossier_pdf_vide) %hr %p= t('views.commencer.show.want_empty_pdf', service: @procedure&.service&.nom, adresse: @procedure&.service&.adresse) %br - = link_to t('views.commencer.show.download_empty_pdf'), commencer_dossier_vide_for_revision_path(@revision), class: "fr-btn fr-btn--lg fr-btn--secondary fr-my-2w" + = link_to t('views.commencer.show.download_empty_pdf'), commencer_dossier_vide_for_revision_path(@revision), class: "fr-btn fr-btn--secondary fr-mb-2w" diff --git a/app/views/layouts/procedure_context.html.haml b/app/views/layouts/procedure_context.html.haml index 4c2874c34..9de8f65fb 100644 --- a/app/views/layouts/procedure_context.html.haml +++ b/app/views/layouts/procedure_context.html.haml @@ -1,17 +1,14 @@ - procedure = @procedure || @dossier&.procedure || nil - content_for :content do - .two-columns.procedure-context - .columns-container - - .column.procedure-preview - - if procedure - = render partial: 'shared/procedure_description', locals: { procedure: procedure } - - else - = render partial: 'layouts/commencer/no_procedure' - - .column.procedure-context-content - = yield + .fr-container.fr-mt-5w + .fr-grid-row + .fr-col-12.fr-col-md-8.fr-col-offset-md-2 + .procedure-preview.fr-mb-5w + - if procedure + = render partial: 'shared/procedure_description', locals: { procedure: procedure } + - else + = render partial: 'layouts/commencer/no_procedure' - content_for :footer do - if procedure diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index 8e2af15c9..46c27e301 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -3,25 +3,46 @@ - if procedure.service.present? - procedure_logo_alt = "#{procedure.service.nom} − #{procedure.service.organisme}" = image_tag procedure.logo_url, alt: procedure_logo_alt + - if procedure.euro_flag = image_tag("flag_of_europe.svg", id: 'euro_flag', class: (!procedure.euro_flag ? "hidden" : "")) -%h1.procedure-title +%h1.procedure-title.fr-h2 = procedure.libelle - if procedure.persisted? && procedure.estimated_duration_visible? - %p.procedure-configuration.procedure-configuration--fill-duration - %span.icon.clock - = t('shared.procedure_description.estimated_fill_duration', estimated_minutes: estimated_fill_duration_minutes(procedure)) + %p + %small + %span.fr-icon-timer-line + + = t('shared.procedure_description.estimated_fill_duration', estimated_minutes: estimated_fill_duration_minutes(procedure)) + += yield - if procedure.auto_archive_on - %details.procedure-configuration.procedure-configuration--auto-archive + %details.procedure-configuration--auto-archive %summary %span.icon.edit %span.procedure-auto-archive-title Date limite : #{procedure_auto_archive_date(procedure)} %p Vous pouvez déposer vos dossiers jusqu’au #{procedure_auto_archive_datetime(procedure)}. -.procedure-description - .procedure-description-body.read-more-enabled.read-more-collapsed{ tabindex: "0", role: "region", "aria-label": t('views.users.dossiers.identite.description') } - = h render SimpleFormatComponent.new(procedure.description, allow_a: true) - = button_tag "Afficher la description complète", class: 'button read-more-button' +- if !@hide_description + - if procedure.description.present? + .procedure-description + .procedure-description-body.read-more-enabled.read-more-collapsed{ tabindex: "0", role: "region", "aria-label": t('views.users.dossiers.identite.description') } + = h render SimpleFormatComponent.new(procedure.description, allow_a: true) + = button_tag "Afficher la description complète", class: 'button read-more-button' + + - else + .fr-accordions-group + %section.fr-accordion + %h3.fr-accordion__title + %button.fr-accordion__btn{"aria-controls" => "accordion-114", "aria-expanded" => "true"} Quel est l’objet de cette démarche ? + #accordion-114.fr-collapse.js_description_what + = h render SimpleFormatComponent.new(procedure.description_what, allow_a: true) + + %section.fr-accordion + %h3.fr-accordion__title + %button.fr-accordion__btn{"aria-controls" => "accordion-115", "aria-expanded" => "false"} À qui s’adresse la démarche ? + #accordion-115.fr-collapse.js_description_for_who + = h render SimpleFormatComponent.new(procedure.description_for_who, allow_a: true) diff --git a/config/locales/models/procedure/en.yml b/config/locales/models/procedure/en.yml index 7794527c6..cb43ad58e 100644 --- a/config/locales/models/procedure/en.yml +++ b/config/locales/models/procedure/en.yml @@ -8,6 +8,8 @@ en: procedure: path: Public link organisation: Service + description_for_who: For who + description_what: Procedure subject duree_conservation_dossiers_dans_ds: Duration files will be kept max_duree_conservation_dossiers_dans_ds: Max duration allowed to keep files aasm_state: diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index 2c223d149..af2b98ab2 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -8,10 +8,12 @@ fr: procedure: path: Lien public organisation: Organisme + description_for_who: À qui s’adresse la démarche + description_what: Objet de la démarche duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers sur demarches-simplifiees.fr (choisi par un usager) max_duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers maximum (autorisé par un super admin de DS) id: Id - libelle: Libelle + libelle: Titre de la démarche published_at: 'Date de publication' aasm_state: 'Statut' admin_count: 'Nb administrateurs' diff --git a/db/migrate/20230516132925_add_two_fields_for_description_to_procedure.rb b/db/migrate/20230516132925_add_two_fields_for_description_to_procedure.rb new file mode 100644 index 000000000..1f66e4c2b --- /dev/null +++ b/db/migrate/20230516132925_add_two_fields_for_description_to_procedure.rb @@ -0,0 +1,6 @@ +class AddTwoFieldsForDescriptionToProcedure < ActiveRecord::Migration[7.0] + def change + add_column :procedures, :description_what, :string + add_column :procedures, :description_for_who, :string + end +end From b6cc35df6805f5fbc8d1f9061b1fce196009fa1d Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 22 May 2023 16:26:50 +0200 Subject: [PATCH 02/10] fix specs --- app/javascript/new_design/procedure-form.js | 17 +++++++++++--- app/models/procedure.rb | 4 ++-- app/views/layouts/procedure_context.html.haml | 1 + .../shared/_procedure_description.html.haml | 4 ++-- spec/models/procedure_spec.rb | 23 ++++++++++++++++--- spec/support/feature_matchers.rb | 4 ++++ spec/system/sessions/sign_in_spec.rb | 2 +- spec/system/users/sign_up_spec.rb | 2 +- 8 files changed, 45 insertions(+), 12 deletions(-) diff --git a/app/javascript/new_design/procedure-form.js b/app/javascript/new_design/procedure-form.js index 770d19fcd..5ff78a9d4 100644 --- a/app/javascript/new_design/procedure-form.js +++ b/app/javascript/new_design/procedure-form.js @@ -12,10 +12,21 @@ function syncFormToPreview() { syncInputToElement('#procedure_libelle', '.procedure-title'); syncInputToElement('#procedure_description', '.procedure-description-body'); syncInputToElement('#procedure_description_what', '.js_description_what p'); - syncInputToElement('#procedure_description_for_who', '.js_description_for_who p'); + syncInputToElement( + '#procedure_description_for_who', + '.js_description_for_who p' + ); } delegate('input', '.procedure-form #procedure_libelle', syncFormToPreview); delegate('input', '.procedure-form #procedure_description', syncFormToPreview); -delegate('input', '.procedure-form #procedure_description_what', syncFormToPreview); -delegate('input', '.procedure-form #procedure_description_for_who', syncFormToPreview); +delegate( + 'input', + '.procedure-form #procedure_description_what', + syncFormToPreview +); +delegate( + 'input', + '.procedure-form #procedure_description_for_who', + syncFormToPreview +); diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 053dfa68f..04c52ecf1 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -282,8 +282,8 @@ class Procedure < ApplicationRecord } validates :libelle, presence: true, allow_blank: false, allow_nil: false - validates :description, presence: true, allow_blank: false, allow_nil: false, if: -> { description_what.nil? && description_for_who.nil?} - validates :description_what, :description_for_who, presence: true, allow_blank: false, allow_nil: false, if: -> { description.nil?} + validates :description, presence: true, allow_blank: false, allow_nil: false, if: -> { description_what.nil? && description_for_who.nil? } + validates :description_what, :description_for_who, presence: true, allow_blank: false, allow_nil: false, if: -> { description.nil? } validates :administrateurs, presence: true validates :lien_site_web, presence: true, if: :publiee? validates :draft_types_de_champ_public, diff --git a/app/views/layouts/procedure_context.html.haml b/app/views/layouts/procedure_context.html.haml index 9de8f65fb..74b6bc0d8 100644 --- a/app/views/layouts/procedure_context.html.haml +++ b/app/views/layouts/procedure_context.html.haml @@ -9,6 +9,7 @@ = render partial: 'shared/procedure_description', locals: { procedure: procedure } - else = render partial: 'layouts/commencer/no_procedure' + = yield - content_for :footer do - if procedure diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index 46c27e301..c5b799a19 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -37,12 +37,12 @@ .fr-accordions-group %section.fr-accordion %h3.fr-accordion__title - %button.fr-accordion__btn{"aria-controls" => "accordion-114", "aria-expanded" => "true"} Quel est l’objet de cette démarche ? + %button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } Quel est l’objet de cette démarche ? #accordion-114.fr-collapse.js_description_what = h render SimpleFormatComponent.new(procedure.description_what, allow_a: true) %section.fr-accordion %h3.fr-accordion__title - %button.fr-accordion__btn{"aria-controls" => "accordion-115", "aria-expanded" => "false"} À qui s’adresse la démarche ? + %button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } À qui s’adresse la démarche ? #accordion-115.fr-collapse.js_description_for_who = h render SimpleFormatComponent.new(procedure.description_for_who, allow_a: true) diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index df79d17ab..1553978f3 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -178,9 +178,26 @@ describe Procedure do end context 'description' do - it { is_expected.not_to allow_value(nil).for(:description) } - it { is_expected.not_to allow_value('').for(:description) } - it { is_expected.to allow_value('Description Demande de subvention').for(:description) } + context 'description can not be nil if description_what and description_for_who are nil too' do + let(:procedure) { build(:procedure, description: nil) } + it { is_expected.to allow_value('Description Demande de subvention').for(:description) } + it { expect(procedure.valid?).to eq(false) } + end + + context 'description can be nil if description_what and description_for_who are filled' do + let(:procedure) { build(:procedure, description: nil, description_for_who: 'for who', description_what: 'what') } + it { expect(procedure.valid?).to eq(true) } + end + + context 'description_what and description_for_who can not be nil if description is nil too' do + let(:procedure) { build(:procedure, description: nil) } + it { expect(procedure.valid?).to eq(false) } + end + + context 'description_what and description_for_who can be nil if description is filled' do + let(:procedure) { build(:procedure, description: 'description') } + it { expect(procedure.valid?).to eq(true) } + end end context 'organisation' do diff --git a/spec/support/feature_matchers.rb b/spec/support/feature_matchers.rb index b61c8beee..cf771367f 100644 --- a/spec/support/feature_matchers.rb +++ b/spec/support/feature_matchers.rb @@ -5,5 +5,9 @@ module Capybara def has_procedure_description?(procedure) has_content?(procedure.libelle) && has_content?(procedure.description) && has_content?(procedure.service.email) end + + def has_procedure_sumup_description?(procedure) + has_content?(procedure.libelle) && has_content?(procedure.service.email) + end end end diff --git a/spec/system/sessions/sign_in_spec.rb b/spec/system/sessions/sign_in_spec.rb index c5679805c..4057b6f77 100644 --- a/spec/system/sessions/sign_in_spec.rb +++ b/spec/system/sessions/sign_in_spec.rb @@ -43,7 +43,7 @@ describe 'Signin in:' do click_on 'Commencer la démarche' expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last) - expect(page).to have_procedure_description(procedure) + expect(page).to have_procedure_sumup_description(procedure) expect(page).to have_content "Données d’identité" end end diff --git a/spec/system/users/sign_up_spec.rb b/spec/system/users/sign_up_spec.rb index 9c77cfbac..d6f431d8a 100644 --- a/spec/system/users/sign_up_spec.rb +++ b/spec/system/users/sign_up_spec.rb @@ -84,7 +84,7 @@ describe 'Signing up:' do click_on 'Commencer la démarche' expect(page).to have_current_path identite_dossier_path(procedure.reload.dossiers.last) - expect(page).to have_procedure_description(procedure) + expect(page).to have_procedure_sumup_description(procedure) end end From 6274594c70109578951788a71e995e7bf142d76f Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Tue, 23 May 2023 15:24:42 +0200 Subject: [PATCH 03/10] add new layout to handle new full screen design --- app/controllers/users/commencer_controller.rb | 2 +- app/controllers/users/dossiers_controller.rb | 4 -- .../procedures/_informations.html.haml | 2 +- .../administrateurs/procedures/edit.html.haml | 2 +- .../administrateurs/procedures/new.html.haml | 2 +- app/views/commencer/show.html.haml | 10 ++--- app/views/layouts/procedure_context.html.haml | 20 +++++---- .../procedure_context_full_screen.html.haml | 20 +++++++++ app/views/prefill_descriptions/edit.html.haml | 2 +- .../shared/_procedure_description.html.haml | 41 +++++++++---------- spec/support/feature_matchers.rb | 4 -- .../administrateurs/procedure_spec_helper.rb | 3 +- spec/system/sessions/sign_in_spec.rb | 2 +- spec/system/users/sign_up_spec.rb | 2 +- .../_procedure_description.html.haml_spec.rb | 2 +- 15 files changed, 66 insertions(+), 52 deletions(-) create mode 100644 app/views/layouts/procedure_context_full_screen.html.haml diff --git a/app/controllers/users/commencer_controller.rb b/app/controllers/users/commencer_controller.rb index 63e7dacdd..d70f5facd 100644 --- a/app/controllers/users/commencer_controller.rb +++ b/app/controllers/users/commencer_controller.rb @@ -1,6 +1,6 @@ module Users class CommencerController < ApplicationController - layout 'procedure_context' + layout 'procedure_context_full_screen' def commencer @procedure = retrieve_procedure diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 8f396dad3..5068478ea 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -92,12 +92,10 @@ module Users def identite @dossier = dossier @user = current_user - @hide_description = true end def update_identite @dossier = dossier - @hide_description = true if @dossier.individual.update(individual_params) @dossier.update!(autorisation_donnees: true, identity_updated_at: Time.zone.now) @@ -112,12 +110,10 @@ module Users def siret @dossier = dossier - @hide_description = true end def update_siret @dossier = dossier - @hide_description = true # We use the user as the holder model object for the siret value # (so that we can restore it on the form in case of error). diff --git a/app/views/administrateurs/procedures/_informations.html.haml b/app/views/administrateurs/procedures/_informations.html.haml index d451f421e..e15874281 100644 --- a/app/views/administrateurs/procedures/_informations.html.haml +++ b/app/views/administrateurs/procedures/_informations.html.haml @@ -6,7 +6,7 @@ = f.label :libelle do Titre de la démarche %span.mandatory * -= f.text_field :libelle, class: 'form-control', placeholder: 'Titre' += f.text_field :libelle, class: 'form-control', placeholder: 'Titre', required: true = f.label :description_what do Quel est l’objet de la démarche ? diff --git a/app/views/administrateurs/procedures/edit.html.haml b/app/views/administrateurs/procedures/edit.html.haml index 7571094af..1e1b66792 100644 --- a/app/views/administrateurs/procedures/edit.html.haml +++ b/app/views/administrateurs/procedures/edit.html.haml @@ -25,4 +25,4 @@ .procedure-form__preview.sticky--top %h3.procedure-form__preview-title Aperçu .procedure-preview - = render partial: 'shared/procedure_description', locals: { procedure: @procedure } + = render partial: 'shared/procedure_description', locals: { procedure: @procedure, full_screen_display: false } diff --git a/app/views/administrateurs/procedures/new.html.haml b/app/views/administrateurs/procedures/new.html.haml index 99b375169..aae964bc0 100644 --- a/app/views/administrateurs/procedures/new.html.haml +++ b/app/views/administrateurs/procedures/new.html.haml @@ -25,4 +25,4 @@ .procedure-form__preview.sticky--top %h3.procedure-form__preview-title Aperçu .procedure-preview - = render partial: 'shared/procedure_description', locals: { procedure: @procedure } + = render partial: 'shared/procedure_description', locals: { procedure: @procedure, full_screen_display: false } diff --git a/app/views/commencer/show.html.haml b/app/views/commencer/show.html.haml index 4bf80acdb..1cae0d8d3 100644 --- a/app/views/commencer/show.html.haml +++ b/app/views/commencer/show.html.haml @@ -2,7 +2,7 @@ .commencer.form - if !user_signed_in? - = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.start_procedure")) do |c| + = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.start_procedure"), heading_level: 'h2') do |c| - c.body do = render partial: 'shared/france_connect_login', locals: { url: commencer_france_connect_path(path: @procedure.path, prefill_token: @prefilled_dossier&.prefill_token) } = link_to commencer_sign_up_path(path: @procedure.path, prefill_token: @prefilled_dossier&.prefill_token), class: 'fr-btn fr-mb-2w fr-mr-2w' do @@ -18,7 +18,7 @@ - not_drafts = dossiers.merge(Dossier.state_not_brouillon) - if @prefilled_dossier - = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.prefilled_draft")) do |c| + = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.prefilled_draft"), heading_level: 'h2') do |c| - c.body do %p= t('views.commencer.show.prefilled_draft_detail_html', time_ago: time_ago_in_words(@prefilled_dossier.created_at), procedure: @procedure.libelle) = link_to t('views.commencer.show.go_to_prefilled_file'), url_for_dossier(@prefilled_dossier), class: 'fr-btn fr-mb-2w' @@ -28,7 +28,7 @@ - elsif drafts.size == 1 && not_drafts.empty? - dossier = drafts.first - = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.already_draft")) do |c| + = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.already_draft"), heading_level: 'h2') do |c| - c.body do %p = t('views.commencer.show.already_draft_detail_html', time_ago: time_ago_in_words(dossier.created_at), procedure: dossier.procedure.libelle) @@ -37,7 +37,7 @@ - elsif not_drafts.size == 1 - dossier = not_drafts.first - = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.already_not_draft")) do |c| + = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.already_not_draft"), heading_level: 'h2') do |c| - c.body do %p = t('views.commencer.show.already_not_draft_detail_html', time_ago: time_ago_in_words(dossier.depose_at), procedure: dossier.procedure.libelle) @@ -45,7 +45,7 @@ = link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary fr-mb-2w' - else - = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.existing_dossiers")) do |c| + = render Dsfr::CalloutComponent.new(title: t("views.commencer.show.existing_dossiers"), heading_level: 'h2') do |c| - c.body do = link_to t('views.commencer.show.show_dossiers'), dossiers_path, class: "fr-btn fr-mb-2w" = link_to t('views.commencer.show.start_new_file'), url_for_new_dossier(@revision), class: "fr-btn fr-btn--secondary fr-mb-2w" diff --git a/app/views/layouts/procedure_context.html.haml b/app/views/layouts/procedure_context.html.haml index 74b6bc0d8..474828a85 100644 --- a/app/views/layouts/procedure_context.html.haml +++ b/app/views/layouts/procedure_context.html.haml @@ -1,15 +1,17 @@ - procedure = @procedure || @dossier&.procedure || nil - content_for :content do - .fr-container.fr-mt-5w - .fr-grid-row - .fr-col-12.fr-col-md-8.fr-col-offset-md-2 - .procedure-preview.fr-mb-5w - - if procedure - = render partial: 'shared/procedure_description', locals: { procedure: procedure } - - else - = render partial: 'layouts/commencer/no_procedure' - = yield + .two-columns.procedure-context + .columns-container + + .column.procedure-preview + - if procedure + = render partial: 'shared/procedure_description', locals: { procedure: procedure, full_screen_display: false } + - else + = render partial: 'layouts/commencer/no_procedure' + + .column.procedure-context-content + = yield - content_for :footer do - if procedure diff --git a/app/views/layouts/procedure_context_full_screen.html.haml b/app/views/layouts/procedure_context_full_screen.html.haml new file mode 100644 index 000000000..f7f2b36fb --- /dev/null +++ b/app/views/layouts/procedure_context_full_screen.html.haml @@ -0,0 +1,20 @@ +- procedure = @procedure || @dossier&.procedure || nil + +- content_for :content do + .fr-container.fr-mt-5w + .fr-grid-row + .fr-col-12.fr-col-md-8.fr-col-offset-md-2 + .procedure-preview.fr-mb-5w + - if procedure + = render partial: 'shared/procedure_description', locals: { procedure: procedure, full_screen_display: true } + - else + = render partial: 'layouts/commencer/no_procedure' + = yield + +- content_for :footer do + - if procedure + = render partial: 'users/procedure_footer', locals: { procedure: procedure, dossier: @dossier } + - else + = render partial: 'users/dossiers/index_footer' + += render template: 'layouts/application' diff --git a/app/views/prefill_descriptions/edit.html.haml b/app/views/prefill_descriptions/edit.html.haml index 4c94fabf7..8514ed493 100644 --- a/app/views/prefill_descriptions/edit.html.haml +++ b/app/views/prefill_descriptions/edit.html.haml @@ -7,7 +7,7 @@ .two-columns.procedure-context .columns-container .column.procedure-preview - = render partial: 'shared/procedure_description', locals: { procedure: @prefill_description } + = render partial: 'shared/procedure_description', locals: { procedure: @prefill_description, full_screen_display: false } .column.procedure-context-content %p = t("views.prefill_descriptions.edit.intro_html", libelle: @prefill_description.libelle) diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index c5b799a19..23ebfb3e4 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -3,7 +3,6 @@ - if procedure.service.present? - procedure_logo_alt = "#{procedure.service.nom} − #{procedure.service.organisme}" = image_tag procedure.logo_url, alt: procedure_logo_alt - - if procedure.euro_flag = image_tag("flag_of_europe.svg", id: 'euro_flag', class: (!procedure.euro_flag ? "hidden" : "")) %h1.procedure-title.fr-h2 @@ -13,10 +12,10 @@ %p %small %span.fr-icon-timer-line - = t('shared.procedure_description.estimated_fill_duration', estimated_minutes: estimated_fill_duration_minutes(procedure)) -= yield +- if full_screen_display + = yield - if procedure.auto_archive_on %details.procedure-configuration--auto-archive @@ -26,23 +25,23 @@ %span.procedure-auto-archive-title Date limite : #{procedure_auto_archive_date(procedure)} %p Vous pouvez déposer vos dossiers jusqu’au #{procedure_auto_archive_datetime(procedure)}. -- if !@hide_description - - if procedure.description.present? - .procedure-description - .procedure-description-body.read-more-enabled.read-more-collapsed{ tabindex: "0", role: "region", "aria-label": t('views.users.dossiers.identite.description') } - = h render SimpleFormatComponent.new(procedure.description, allow_a: true) - = button_tag "Afficher la description complète", class: 'button read-more-button' - - else - .fr-accordions-group - %section.fr-accordion - %h3.fr-accordion__title - %button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } Quel est l’objet de cette démarche ? - #accordion-114.fr-collapse.js_description_what - = h render SimpleFormatComponent.new(procedure.description_what, allow_a: true) +- if procedure.description_what.present? && procedure.description_for_who.present? + .fr-accordions-group + %section.fr-accordion + %h3.fr-accordion__title + %button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } Quel est l’objet de cette démarche ? + #accordion-114.fr-collapse.js_description_what + = h render SimpleFormatComponent.new(procedure.description_what, allow_a: true) - %section.fr-accordion - %h3.fr-accordion__title - %button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } À qui s’adresse la démarche ? - #accordion-115.fr-collapse.js_description_for_who - = h render SimpleFormatComponent.new(procedure.description_for_who, allow_a: true) + %section.fr-accordion + %h3.fr-accordion__title + %button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } À qui s’adresse la démarche ? + #accordion-115.fr-collapse.js_description_for_who + = h render SimpleFormatComponent.new(procedure.description_for_who, allow_a: true) + +- else + .procedure-description + .procedure-description-body.read-more-enabled.read-more-collapsed{ tabindex: "0", role: "region", "aria-label": t('views.users.dossiers.identite.description') } + = h render SimpleFormatComponent.new(procedure.description, allow_a: true) + = button_tag "Afficher la description complète", class: 'button read-more-button' diff --git a/spec/support/feature_matchers.rb b/spec/support/feature_matchers.rb index cf771367f..b61c8beee 100644 --- a/spec/support/feature_matchers.rb +++ b/spec/support/feature_matchers.rb @@ -5,9 +5,5 @@ module Capybara def has_procedure_description?(procedure) has_content?(procedure.libelle) && has_content?(procedure.description) && has_content?(procedure.service.email) end - - def has_procedure_sumup_description?(procedure) - has_content?(procedure.libelle) && has_content?(procedure.service.email) - end end end diff --git a/spec/system/administrateurs/procedure_spec_helper.rb b/spec/system/administrateurs/procedure_spec_helper.rb index 134e93ec9..72db34d66 100644 --- a/spec/system/administrateurs/procedure_spec_helper.rb +++ b/spec/system/administrateurs/procedure_spec_helper.rb @@ -1,7 +1,8 @@ module ProcedureSpecHelper def fill_in_dummy_procedure_details(fill_path: true) fill_in 'procedure_libelle', with: 'libelle de la procedure' - fill_in 'procedure_description', with: 'description de la procedure' + fill_in 'procedure_description_what', with: "description de l'objet de la procedure" + fill_in 'procedure_description_for_who', with: "description d'à qui s'adresse la procedure" fill_in 'procedure_cadre_juridique', with: 'cadre juridique' fill_in 'procedure_duree_conservation_dossiers_dans_ds', with: '3' end diff --git a/spec/system/sessions/sign_in_spec.rb b/spec/system/sessions/sign_in_spec.rb index 4057b6f77..c5679805c 100644 --- a/spec/system/sessions/sign_in_spec.rb +++ b/spec/system/sessions/sign_in_spec.rb @@ -43,7 +43,7 @@ describe 'Signin in:' do click_on 'Commencer la démarche' expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last) - expect(page).to have_procedure_sumup_description(procedure) + expect(page).to have_procedure_description(procedure) expect(page).to have_content "Données d’identité" end end diff --git a/spec/system/users/sign_up_spec.rb b/spec/system/users/sign_up_spec.rb index d6f431d8a..9c77cfbac 100644 --- a/spec/system/users/sign_up_spec.rb +++ b/spec/system/users/sign_up_spec.rb @@ -84,7 +84,7 @@ describe 'Signing up:' do click_on 'Commencer la démarche' expect(page).to have_current_path identite_dossier_path(procedure.reload.dossiers.last) - expect(page).to have_procedure_sumup_description(procedure) + expect(page).to have_procedure_description(procedure) end end diff --git a/spec/views/shared/_procedure_description.html.haml_spec.rb b/spec/views/shared/_procedure_description.html.haml_spec.rb index 431de7fe3..9ced93cc9 100644 --- a/spec/views/shared/_procedure_description.html.haml_spec.rb +++ b/spec/views/shared/_procedure_description.html.haml_spec.rb @@ -2,7 +2,7 @@ describe 'shared/_procedure_description', type: :view do let(:estimated_duration_visible) { true } let(:procedure) { create(:procedure, :published, :with_service, estimated_duration_visible:) } - subject { render partial: 'shared/procedure_description', locals: { procedure: procedure } } + subject { render partial: 'shared/procedure_description', locals: { procedure: procedure, full_screen_display: false } } it 'renders the view' do subject From 8291d58dbb8e87b99f69ee816938d119e5706a46 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Tue, 23 May 2023 17:22:19 +0200 Subject: [PATCH 04/10] add dsfr style and add depreciated field description for older procedure --- .../procedures/_informations.html.haml | 65 +++++++++++-------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/app/views/administrateurs/procedures/_informations.html.haml b/app/views/administrateurs/procedures/_informations.html.haml index e15874281..11e559b8f 100644 --- a/app/views/administrateurs/procedures/_informations.html.haml +++ b/app/views/administrateurs/procedures/_informations.html.haml @@ -2,27 +2,38 @@ .card.warning .card-title Cette démarche est publiée. Certains éléments de la description ne sont plus modifiables. +.fr-input-group + = f.label :libelle, class: 'fr-label' do + Titre de la démarche + %span.mandatory * + = f.text_field :libelle, class: 'fr-input', required: true -= f.label :libelle do - Titre de la démarche - %span.mandatory * -= f.text_field :libelle, class: 'form-control', placeholder: 'Titre', required: true +- if @procedure.description.present? + .fr-input-group + = f.label :description, class: 'fr-label' do + Description + %span.fr-hint-text Ce champ est déprécié, il n'est plus possible de le modifier. Pour plus de clarté pour les usagers, la description a été scindée en deux nouveaux champs : "objet de la démarche" et "à qui s'adresse la démarche". Vous pouvez remplir ces nouveaux champs en remplacement. + = f.text_field :description, class: 'fr-input', disabled: true -= f.label :description_what do - Quel est l’objet de la démarche ? - %span.mandatory * -= f.text_area :description_what, rows: '6', placeholder: 'Décrivez en quelques lignes le contexte, la finalité etc.', class: 'form-control' +.fr-input-group + = f.label :description_what, class: 'fr-label' do + Quel est l’objet de la démarche ? + %span.mandatory * + %span.fr-hint-text Décrivez en quelques lignes le contexte, la finalité etc. + = f.text_area :description_what, rows: '6', class: 'fr-input' -= f.label :description_for_who do - À qui s’adresse la démarche ? - %span.mandatory * -= f.text_area :description_for_who, rows: '6', placeholder: 'Décrivez en quelques lignes les destinataires finaux de la démarche, les critères d’éligibilité s’il y en a, les pré-requis, etc.', class: 'form-control' +.fr-input-group + = f.label :description_for_who, class: 'fr-label' do + À qui s’adresse la démarche ? + %span.mandatory * + %span.fr-hint-text Décrivez en quelques lignes les destinataires finaux de la démarche, les critères d’éligibilité s’il y en a, les pré-requis, etc. + = f.text_area :description_for_who, rows: '6', class: 'fr-input' %h3.header-subsection Logo de la démarche = render Attachment::EditComponent.new(attached_file: @procedure.logo, view_as: :link) %h3.header-subsection Conservation des données -= f.label :duree_conservation_dossiers_dans_ds do += f.label :duree_conservation_dossiers_dans_ds, class: 'fr-label' do Sur #{APPLICATION_NAME} %span.mandatory * @@ -30,12 +41,12 @@ = t(:notice, scope: [:administrateurs, :duree_conservation_dossiers_dans_ds]) - if f.object.duree_conservation_dossiers_dans_ds.to_i < Procedure::NEW_MAX_DUREE_CONSERVATION = t(:new_duration_constraint, scope: [:administrateurs, :duree_conservation_dossiers_dans_ds], new_duration_in_month: f.object.max_duree_conservation_dossiers_dans_ds) -= f.number_field :duree_conservation_dossiers_dans_ds, { class: 'form-control', placeholder: '6', required: true, max: f.object.max_duree_conservation_dossiers_dans_ds } += f.number_field :duree_conservation_dossiers_dans_ds, { class: 'fr-input', placeholder: '6', required: true, max: f.object.max_duree_conservation_dossiers_dans_ds } - if @procedure.created_at.present? - = f.label :lien_site_web do + = f.label :lien_site_web, class: 'fr-label' do Où les usagers trouveront-ils le lien vers la démarche ? - = f.text_field :lien_site_web, class: 'form-control', placeholder: 'https://exemple.gouv.fr/ma_demarche' + = f.text_field :lien_site_web, class: 'fr-input', placeholder: 'https://exemple.gouv.fr/ma_demarche' %h3.header-subsection Cadre juridique @@ -53,10 +64,10 @@ %p.notice Vous pouvez saisir un lien web vers ce texte, ou l’importer depuis un fichier. -= f.label :cadre_juridique, 'Lien vers le texte' -= f.text_field :cadre_juridique, class: 'form-control', placeholder: 'https://www.legifrance.gouv.fr/' += f.label :cadre_juridique, 'Lien vers le texte', class: 'fr-label' += f.text_field :cadre_juridique, class: 'fr-input', placeholder: 'https://www.legifrance.gouv.fr/' -= f.label :deliberation, 'Importer le texte' += f.label :deliberation, 'Importer le texte', class: 'fr-label' = render Attachment::EditComponent.new(attached_file: @procedure.deliberation, view_as: :download) %h3.header-subsection @@ -64,8 +75,8 @@ %p.notice Pour certaines démarches, veuillez indiquer soit le mail de contact de votre délégué à la protection des données, soit un lien web pointant vers les informations -= f.label :lien_dpo, 'Lien ou email pour contacter le Délégué à la Protection des Données (DPO)' -= f.text_field :lien_dpo, class: 'form-control' += f.label :lien_dpo, 'Lien ou email pour contacter le Délégué à la Protection des Données (DPO)', class: 'fr-label' += f.text_field :lien_dpo, class: 'fr-input' - if Rails.application.config.ds_opendata_enabled %h3.header-subsection= t(:opendata_header, scope: [:administrateurs, :informations]) @@ -83,7 +94,7 @@ %p.notice Une notice explicative est un document destiné à guider l’usager dans sa démarche. C’est un document que vous avez élaboré et qui peut prendre la forme d’un fichier doc, d’un pdf ou encore de diapositives. Le bouton pour télécharger cette notice apparaît en haut du formulaire pour l’usager. -= f.label :notice, 'Notice' += f.label :notice, 'Notice', class: 'fr-label' %p.notice Formats acceptés : .doc, .odt, .pdf, .ppt, .pptx = render Attachment::EditComponent.new(attached_file: @procedure.notice, view_as: :download) @@ -96,7 +107,7 @@ Ma démarche s’adresse à un particulier %p.notice En choisissant cette option, l’usager devra renseigner son nom et prénom avant d’accéder au formulaire - = f.label :for_individual, value: false do + = f.label :for_individual, value: false, class: 'fr-label' do = f.radio_button :for_individual, false Ma démarche s’adresse à une personne morale %p.notice @@ -124,14 +135,14 @@ %h3.header-subsection Options avancées - if feature_enabled?(:administrateur_web_hook) - = f.label :web_hook_url do + = f.label :web_hook_url, class: 'fr-label' do Lien de rappel HTTP (webhook) %p.notice Vous pouvez définir un lien de rappel HTTP (aussi appelé webhook) pour informer un service tiers du changement de l'état d’un dossier de cette démarche sur #{APPLICATION_NAME}. = link_to("Consulter la documentation du webhook", WEBHOOK_DOC_URL, target: "_blank", rel: "noopener") - = f.text_field :web_hook_url, class: 'form-control', placeholder: 'https://callback.exemple.fr/' + = f.text_field :web_hook_url, class: 'fr-input', placeholder: 'https://callback.exemple.fr/' - = f.label :auto_archive_on do + = f.label :auto_archive_on, class: 'fr-label' do Date limite de dépôt des dossiers %p.notice Si une date est définie, aucun dossier ne pourra plus être déposé ou modifié après cette limite. @@ -141,7 +152,7 @@ = f.date_field :auto_archive_on, id: 'auto_archive_on', value: value #{procedure_auto_archive_time(@procedure)}. - = f.label :declarative_with_state do + = f.label :declarative_with_state, class: 'fr-label' do Démarche déclarative %p.notice Par défaut, un dossier déposé peut être complété ou corrigé par le demandeur jusqu'à sa mise en instruction.
From 7340206f81ec60bd5e63fac54f03cf0088f9b53c Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Wed, 24 May 2023 11:18:54 +0200 Subject: [PATCH 05/10] rollback - add just one new field and use actual description field --- .../administrateurs/procedures_controller.rb | 3 +- app/javascript/new_design/procedure-form.js | 12 ++++---- app/models/procedure.rb | 6 ++-- .../procedures/_informations.html.haml | 16 +++------- .../shared/_procedure_description.html.haml | 30 ++++++++----------- config/locales/models/procedure/en.yml | 3 +- config/locales/models/procedure/fr.yml | 3 +- ...escription_target_audience_to_procedure.rb | 5 ++++ ...two_fields_for_description_to_procedure.rb | 6 ---- spec/models/procedure_spec.rb | 23 ++------------ .../administrateurs/procedure_spec_helper.rb | 4 +-- 11 files changed, 36 insertions(+), 75 deletions(-) create mode 100644 db/migrate/20230516132925_add_description_target_audience_to_procedure.rb delete mode 100644 db/migrate/20230516132925_add_two_fields_for_description_to_procedure.rb diff --git a/app/controllers/administrateurs/procedures_controller.rb b/app/controllers/administrateurs/procedures_controller.rb index cf839babc..b115c4e93 100644 --- a/app/controllers/administrateurs/procedures_controller.rb +++ b/app/controllers/administrateurs/procedures_controller.rb @@ -457,8 +457,7 @@ module Administrateurs editable_params = [ :libelle, :description, - :description_for_who, - :description_what, + :description_target_audience, :organisation, :direction, :lien_site_web, diff --git a/app/javascript/new_design/procedure-form.js b/app/javascript/new_design/procedure-form.js index 5ff78a9d4..807112df2 100644 --- a/app/javascript/new_design/procedure-form.js +++ b/app/javascript/new_design/procedure-form.js @@ -10,23 +10,21 @@ function syncInputToElement(fromSelector, toSelector) { function syncFormToPreview() { syncInputToElement('#procedure_libelle', '.procedure-title'); - syncInputToElement('#procedure_description', '.procedure-description-body'); - syncInputToElement('#procedure_description_what', '.js_description_what p'); + syncInputToElement('#procedure_description', '.js_description p'); syncInputToElement( - '#procedure_description_for_who', - '.js_description_for_who p' + '#procedure_description_target_audience', + '.js_description_target_audience p' ); } delegate('input', '.procedure-form #procedure_libelle', syncFormToPreview); -delegate('input', '.procedure-form #procedure_description', syncFormToPreview); delegate( 'input', - '.procedure-form #procedure_description_what', + '.procedure-form #procedure_description', syncFormToPreview ); delegate( 'input', - '.procedure-form #procedure_description_for_who', + '.procedure-form #procedure_description_target_audience', syncFormToPreview ); diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 04c52ecf1..ac169ada2 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -16,8 +16,7 @@ # closed_at :datetime # declarative_with_state :string # description :string -# description_for_who :string -# description_what :string +# description_target_audience :string # dossiers_count_computed_at :datetime # duree_conservation_dossiers_dans_ds :integer # duree_conservation_etendue_par_ds :boolean default(FALSE), not null @@ -282,8 +281,7 @@ class Procedure < ApplicationRecord } validates :libelle, presence: true, allow_blank: false, allow_nil: false - validates :description, presence: true, allow_blank: false, allow_nil: false, if: -> { description_what.nil? && description_for_who.nil? } - validates :description_what, :description_for_who, presence: true, allow_blank: false, allow_nil: false, if: -> { description.nil? } + validates :description, presence: true, allow_blank: false, allow_nil: false validates :administrateurs, presence: true validates :lien_site_web, presence: true, if: :publiee? validates :draft_types_de_champ_public, diff --git a/app/views/administrateurs/procedures/_informations.html.haml b/app/views/administrateurs/procedures/_informations.html.haml index 11e559b8f..af4f8b843 100644 --- a/app/views/administrateurs/procedures/_informations.html.haml +++ b/app/views/administrateurs/procedures/_informations.html.haml @@ -8,26 +8,18 @@ %span.mandatory * = f.text_field :libelle, class: 'fr-input', required: true -- if @procedure.description.present? - .fr-input-group - = f.label :description, class: 'fr-label' do - Description - %span.fr-hint-text Ce champ est déprécié, il n'est plus possible de le modifier. Pour plus de clarté pour les usagers, la description a été scindée en deux nouveaux champs : "objet de la démarche" et "à qui s'adresse la démarche". Vous pouvez remplir ces nouveaux champs en remplacement. - = f.text_field :description, class: 'fr-input', disabled: true - .fr-input-group - = f.label :description_what, class: 'fr-label' do + = f.label :description, class: 'fr-label' do Quel est l’objet de la démarche ? %span.mandatory * %span.fr-hint-text Décrivez en quelques lignes le contexte, la finalité etc. - = f.text_area :description_what, rows: '6', class: 'fr-input' + = f.text_area :description, rows: '6', class: 'fr-input', required: true .fr-input-group - = f.label :description_for_who, class: 'fr-label' do + = f.label :description_target_audience, class: 'fr-label' do À qui s’adresse la démarche ? - %span.mandatory * %span.fr-hint-text Décrivez en quelques lignes les destinataires finaux de la démarche, les critères d’éligibilité s’il y en a, les pré-requis, etc. - = f.text_area :description_for_who, rows: '6', class: 'fr-input' + = f.text_area :description_target_audience, rows: '6', class: 'fr-input' %h3.header-subsection Logo de la démarche = render Attachment::EditComponent.new(attached_file: @procedure.logo, view_as: :link) diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index 23ebfb3e4..6ba6066fb 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -26,22 +26,16 @@ %p Vous pouvez déposer vos dossiers jusqu’au #{procedure_auto_archive_datetime(procedure)}. -- if procedure.description_what.present? && procedure.description_for_who.present? - .fr-accordions-group - %section.fr-accordion - %h3.fr-accordion__title - %button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } Quel est l’objet de cette démarche ? - #accordion-114.fr-collapse.js_description_what - = h render SimpleFormatComponent.new(procedure.description_what, allow_a: true) - - %section.fr-accordion - %h3.fr-accordion__title - %button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } À qui s’adresse la démarche ? - #accordion-115.fr-collapse.js_description_for_who - = h render SimpleFormatComponent.new(procedure.description_for_who, allow_a: true) - -- else - .procedure-description - .procedure-description-body.read-more-enabled.read-more-collapsed{ tabindex: "0", role: "region", "aria-label": t('views.users.dossiers.identite.description') } +.fr-accordions-group + %section.fr-accordion + %h2.fr-accordion__title + %button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } Quel est l’objet de cette démarche ? + #accordion-114.fr-collapse.js_description = h render SimpleFormatComponent.new(procedure.description, allow_a: true) - = button_tag "Afficher la description complète", class: 'button read-more-button' + + - if procedure.description_target_audience.present? + %section.fr-accordion + %h2.fr-accordion__title + %button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } À qui s’adresse la démarche ? + #accordion-115.fr-collapse.js_description_target_audience + = h render SimpleFormatComponent.new(procedure.description_target_audience, allow_a: true) diff --git a/config/locales/models/procedure/en.yml b/config/locales/models/procedure/en.yml index cb43ad58e..6c2cdcdc3 100644 --- a/config/locales/models/procedure/en.yml +++ b/config/locales/models/procedure/en.yml @@ -8,8 +8,7 @@ en: procedure: path: Public link organisation: Service - description_for_who: For who - description_what: Procedure subject + description_target_audience: For who duree_conservation_dossiers_dans_ds: Duration files will be kept max_duree_conservation_dossiers_dans_ds: Max duration allowed to keep files aasm_state: diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index af2b98ab2..e5b18856c 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -8,8 +8,7 @@ fr: procedure: path: Lien public organisation: Organisme - description_for_who: À qui s’adresse la démarche - description_what: Objet de la démarche + description_target_audience: À qui s’adresse la démarche duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers sur demarches-simplifiees.fr (choisi par un usager) max_duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers maximum (autorisé par un super admin de DS) id: Id diff --git a/db/migrate/20230516132925_add_description_target_audience_to_procedure.rb b/db/migrate/20230516132925_add_description_target_audience_to_procedure.rb new file mode 100644 index 000000000..e0c1a0f96 --- /dev/null +++ b/db/migrate/20230516132925_add_description_target_audience_to_procedure.rb @@ -0,0 +1,5 @@ +class AddDescriptionTargetAudienceToProcedure < ActiveRecord::Migration[7.0] + def change + add_column :procedures, :description_target_audience, :string + end +end diff --git a/db/migrate/20230516132925_add_two_fields_for_description_to_procedure.rb b/db/migrate/20230516132925_add_two_fields_for_description_to_procedure.rb deleted file mode 100644 index 1f66e4c2b..000000000 --- a/db/migrate/20230516132925_add_two_fields_for_description_to_procedure.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddTwoFieldsForDescriptionToProcedure < ActiveRecord::Migration[7.0] - def change - add_column :procedures, :description_what, :string - add_column :procedures, :description_for_who, :string - end -end diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 1553978f3..df79d17ab 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -178,26 +178,9 @@ describe Procedure do end context 'description' do - context 'description can not be nil if description_what and description_for_who are nil too' do - let(:procedure) { build(:procedure, description: nil) } - it { is_expected.to allow_value('Description Demande de subvention').for(:description) } - it { expect(procedure.valid?).to eq(false) } - end - - context 'description can be nil if description_what and description_for_who are filled' do - let(:procedure) { build(:procedure, description: nil, description_for_who: 'for who', description_what: 'what') } - it { expect(procedure.valid?).to eq(true) } - end - - context 'description_what and description_for_who can not be nil if description is nil too' do - let(:procedure) { build(:procedure, description: nil) } - it { expect(procedure.valid?).to eq(false) } - end - - context 'description_what and description_for_who can be nil if description is filled' do - let(:procedure) { build(:procedure, description: 'description') } - it { expect(procedure.valid?).to eq(true) } - end + it { is_expected.not_to allow_value(nil).for(:description) } + it { is_expected.not_to allow_value('').for(:description) } + it { is_expected.to allow_value('Description Demande de subvention').for(:description) } end context 'organisation' do diff --git a/spec/system/administrateurs/procedure_spec_helper.rb b/spec/system/administrateurs/procedure_spec_helper.rb index 72db34d66..279e2d1ae 100644 --- a/spec/system/administrateurs/procedure_spec_helper.rb +++ b/spec/system/administrateurs/procedure_spec_helper.rb @@ -1,8 +1,8 @@ module ProcedureSpecHelper def fill_in_dummy_procedure_details(fill_path: true) fill_in 'procedure_libelle', with: 'libelle de la procedure' - fill_in 'procedure_description_what', with: "description de l'objet de la procedure" - fill_in 'procedure_description_for_who', with: "description d'à qui s'adresse la procedure" + fill_in 'procedure_description', with: "description de l'objet de la procedure" + fill_in 'procedure_description_target_audience', with: "description d'à qui s'adresse la procedure" fill_in 'procedure_cadre_juridique', with: 'cadre juridique' fill_in 'procedure_duree_conservation_dossiers_dans_ds', with: '3' end From 6fa44a4c1110f930608ece099097a243b92df882 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Wed, 24 May 2023 11:48:17 +0200 Subject: [PATCH 06/10] remove read more function because of accordion for procedure description --- app/assets/stylesheets/commencer.scss | 10 ------ app/assets/stylesheets/procedure_context.scss | 31 ------------------- app/javascript/entrypoints/application.js | 1 - .../new_design/procedure-context.js | 20 ------------ app/javascript/new_design/procedure-form.js | 6 +--- config/locales/en.yml | 1 - config/locales/fr.yml | 1 - 7 files changed, 1 insertion(+), 69 deletions(-) delete mode 100644 app/javascript/new_design/procedure-context.js diff --git a/app/assets/stylesheets/commencer.scss b/app/assets/stylesheets/commencer.scss index 517a87f57..01e78d1eb 100644 --- a/app/assets/stylesheets/commencer.scss +++ b/app/assets/stylesheets/commencer.scss @@ -1,16 +1,6 @@ @import "constants"; .commencer { - @media (min-width: $two-columns-breakpoint) { - .button:first-of-type { - margin-top: 4 * $default-spacer; - } - } - - .button { - margin-bottom: 2 * $default-spacer; - } - .optional-on-small-screens { color: #FFFFFF; } diff --git a/app/assets/stylesheets/procedure_context.scss b/app/assets/stylesheets/procedure_context.scss index 6219a6afa..cd8e35e65 100644 --- a/app/assets/stylesheets/procedure_context.scss +++ b/app/assets/stylesheets/procedure_context.scss @@ -2,7 +2,6 @@ @import "constants"; $procedure-context-breakpoint: $two-columns-breakpoint; -$procedure-description-line-height: 22px; .procedure-preview { .paperless-logo { @@ -55,36 +54,6 @@ $procedure-description-line-height: 22px; border-bottom: 1px dotted $blue-france-500; } - .read-more-button { - display: none; - } - - @media (max-width: $procedure-context-breakpoint) { - // Truncate description and display the "Read more" UI if the text is too long - .procedure-description-body.read-more-collapsed { - // Setting the description at 25% of the viewport height: - // - displays more text on screens having more vertical space (like small tablets); - // - is enough for the action buttons to be visible on the bottom (even on mobiles). - max-height: 25vh; - - // If the text exceeds the max-height, - // truncate it and displays the "Read more" button. - &.read-more-enabled { - overflow: auto; - border-bottom: 1px solid $border-grey; - - + .read-more-button { - display: block; - position: relative; - margin-left: auto; - margin-right: auto; - top: -19px; - margin-bottom: -19px; - } - } - } - } - .procedure-logos { display: flex; align-items: center; diff --git a/app/javascript/entrypoints/application.js b/app/javascript/entrypoints/application.js index ffad913d7..f8eb08b1b 100644 --- a/app/javascript/entrypoints/application.js +++ b/app/javascript/entrypoints/application.js @@ -12,7 +12,6 @@ import '../shared/toggle-target'; import { registerControllers } from '../shared/stimulus-loader'; import '../new_design/form-validation'; -import '../new_design/procedure-context'; import '../new_design/procedure-form'; import { toggleCondidentielExplanation } from '../new_design/avis'; diff --git a/app/javascript/new_design/procedure-context.js b/app/javascript/new_design/procedure-context.js deleted file mode 100644 index 753811c76..000000000 --- a/app/javascript/new_design/procedure-context.js +++ /dev/null @@ -1,20 +0,0 @@ -import { delegate } from '@utils'; - -function updateReadMoreVisibility() { - const descBody = document.querySelector('.procedure-description-body'); - if (descBody) { - // If the description text overflows, display a "Read more" button. - const isOverflowing = descBody.scrollHeight > descBody.clientHeight; - descBody.classList.toggle('read-more-enabled', isOverflowing); - } -} - -function expandProcedureDescription() { - const descBody = document.querySelector('.procedure-description-body'); - descBody.classList.remove('read-more-collapsed'); -} - -addEventListener('DOMContentLoaded', updateReadMoreVisibility); -addEventListener('resize', updateReadMoreVisibility); - -delegate('click', '.read-more-button', expandProcedureDescription); diff --git a/app/javascript/new_design/procedure-form.js b/app/javascript/new_design/procedure-form.js index 807112df2..153b806ce 100644 --- a/app/javascript/new_design/procedure-form.js +++ b/app/javascript/new_design/procedure-form.js @@ -18,11 +18,7 @@ function syncFormToPreview() { } delegate('input', '.procedure-form #procedure_libelle', syncFormToPreview); -delegate( - 'input', - '.procedure-form #procedure_description', - syncFormToPreview -); +delegate('input', '.procedure-form #procedure_description', syncFormToPreview); delegate( 'input', '.procedure-form #procedure_description_target_audience', diff --git a/config/locales/en.yml b/config/locales/en.yml index 1a7718ce6..25163cabf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -395,7 +395,6 @@ en: identity_data: Identity data all_required: All fields are required. civility: Civility - description: Description of the procedure first_name: First Name last_name: Last Name birthdate: Date de naissance diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 3025b0236..bbf8efa34 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -396,7 +396,6 @@ fr: identity_data: Données d’identité all_required: Tous les champs sont obligatoires. civility: Civilité - description: Description de la démarche first_name: Prénom last_name: Nom birthdate: Date de naissance From 1c409f0145711262d176f086a3e27a8417158c6c Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Wed, 24 May 2023 17:44:15 +0200 Subject: [PATCH 07/10] use DSFR input components for form --- .../input_component/input_component.html.haml | 4 +-- .../procedures/_informations.html.haml | 30 +++++-------------- config/locales/models/procedure/en.yml | 11 ++++++- config/locales/models/procedure/fr.yml | 10 +++++++ 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/app/components/dsfr/input_component/input_component.html.haml b/app/components/dsfr/input_component/input_component.html.haml index 4e52ec670..018def6af 100644 --- a/app/components/dsfr/input_component/input_component.html.haml +++ b/app/components/dsfr/input_component/input_component.html.haml @@ -4,8 +4,8 @@ = label - if @required %span.mandatory  * - - if hint? - %span.fr-hint-text= hint + - if hint? + %span.fr-hint-text= hint = @form.public_send(@input_type, @attribute, input_opts) diff --git a/app/views/administrateurs/procedures/_informations.html.haml b/app/views/administrateurs/procedures/_informations.html.haml index af4f8b843..ddaed9ad1 100644 --- a/app/views/administrateurs/procedures/_informations.html.haml +++ b/app/views/administrateurs/procedures/_informations.html.haml @@ -2,24 +2,12 @@ .card.warning .card-title Cette démarche est publiée. Certains éléments de la description ne sont plus modifiables. -.fr-input-group - = f.label :libelle, class: 'fr-label' do - Titre de la démarche - %span.mandatory * - = f.text_field :libelle, class: 'fr-input', required: true -.fr-input-group - = f.label :description, class: 'fr-label' do - Quel est l’objet de la démarche ? - %span.mandatory * - %span.fr-hint-text Décrivez en quelques lignes le contexte, la finalité etc. - = f.text_area :description, rows: '6', class: 'fr-input', required: true += render Dsfr::InputComponent.new(form: f, attribute: :libelle, input_type: :text_field, opts: {}) -.fr-input-group - = f.label :description_target_audience, class: 'fr-label' do - À qui s’adresse la démarche ? - %span.fr-hint-text Décrivez en quelques lignes les destinataires finaux de la démarche, les critères d’éligibilité s’il y en a, les pré-requis, etc. - = f.text_area :description_target_audience, rows: '6', class: 'fr-input' += render Dsfr::InputComponent.new(form: f, attribute: :description, input_type: :text_area, opts: {}) + += render Dsfr::InputComponent.new(form: f, attribute: :description_target_audience, input_type: :text_area, opts: {}, required: false) %h3.header-subsection Logo de la démarche = render Attachment::EditComponent.new(attached_file: @procedure.logo, view_as: :link) @@ -36,9 +24,7 @@ = f.number_field :duree_conservation_dossiers_dans_ds, { class: 'fr-input', placeholder: '6', required: true, max: f.object.max_duree_conservation_dossiers_dans_ds } - if @procedure.created_at.present? - = f.label :lien_site_web, class: 'fr-label' do - Où les usagers trouveront-ils le lien vers la démarche ? - = f.text_field :lien_site_web, class: 'fr-input', placeholder: 'https://exemple.gouv.fr/ma_demarche' + = render Dsfr::InputComponent.new(form: f, attribute: :lien_site_web, input_type: :text_field, opts: {}, required: false) %h3.header-subsection Cadre juridique @@ -56,8 +42,7 @@ %p.notice Vous pouvez saisir un lien web vers ce texte, ou l’importer depuis un fichier. -= f.label :cadre_juridique, 'Lien vers le texte', class: 'fr-label' -= f.text_field :cadre_juridique, class: 'fr-input', placeholder: 'https://www.legifrance.gouv.fr/' += render Dsfr::InputComponent.new(form: f, attribute: :cadre_juridique, input_type: :text_field, opts: {}) = f.label :deliberation, 'Importer le texte', class: 'fr-label' = render Attachment::EditComponent.new(attached_file: @procedure.deliberation, view_as: :download) @@ -67,8 +52,7 @@ %p.notice Pour certaines démarches, veuillez indiquer soit le mail de contact de votre délégué à la protection des données, soit un lien web pointant vers les informations -= f.label :lien_dpo, 'Lien ou email pour contacter le Délégué à la Protection des Données (DPO)', class: 'fr-label' -= f.text_field :lien_dpo, class: 'fr-input' += render Dsfr::InputComponent.new(form: f, attribute: :lien_dpo, input_type: :text_field, opts: {}, required: false) - if Rails.application.config.ds_opendata_enabled %h3.header-subsection= t(:opendata_header, scope: [:administrateurs, :informations]) diff --git a/config/locales/models/procedure/en.yml b/config/locales/models/procedure/en.yml index 6c2cdcdc3..706f96434 100644 --- a/config/locales/models/procedure/en.yml +++ b/config/locales/models/procedure/en.yml @@ -6,9 +6,18 @@ en: other: Procedure attributes: procedure: + hints: + description: Describe in a few lines the context, the aim etc. + description_target_audience: Describe in a few lines the final recipients of the process, the eligibility criteria if there are any, the prerequisites, etc. + lien_site_web: "Exemple: 'https://exemple.gouv.fr/ma_demarche'" + cadre_juridique: "Exemple: 'https://www.legifrance.gouv.fr/'" path: Public link organisation: Service - description_target_audience: For who + description: Procedure subject + description_target_audience: For who is the procedure ? + lien_site_web: Where to find the procedure link ? + cadre_juridique: Link to the legal text + lien_dpo: Link or email to contact the data protection officer (DPO) duree_conservation_dossiers_dans_ds: Duration files will be kept max_duree_conservation_dossiers_dans_ds: Max duration allowed to keep files aasm_state: diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index e5b18856c..d44229255 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -6,6 +6,11 @@ fr: other: Démarches attributes: procedure: + hints: + description: Décrivez en quelques lignes le contexte, la finalité etc. + description_target_audience: Décrivez en quelques lignes les destinataires finaux de la démarche, les critères d’éligibilité s’il y en a, les pré-requis, etc. + lien_site_web: "Exemple: 'https://exemple.gouv.fr/ma_demarche'" + cadre_juridique: "Exemple: 'https://www.legifrance.gouv.fr/'" path: Lien public organisation: Organisme description_target_audience: À qui s’adresse la démarche @@ -13,6 +18,11 @@ fr: max_duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers maximum (autorisé par un super admin de DS) id: Id libelle: Titre de la démarche + description: Quel est l’objet de la démarche ? + description_target_audience: À qui s’adresse la démarche ? + lien_site_web: Où les usagers trouveront-ils le lien vers la démarche ? + cadre_juridique: Lien vers le texte + lien_dpo: Lien ou email pour contacter le Délégué à la Protection des Données (DPO) published_at: 'Date de publication' aasm_state: 'Statut' admin_count: 'Nb administrateurs' From 31969b290befefb9a608e4f252ce885ca20904c1 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Thu, 25 May 2023 15:19:55 +0200 Subject: [PATCH 08/10] create a new layout without procedure for login and use same layout full_screen without description for identite step --- app/controllers/users/commencer_controller.rb | 2 +- app/controllers/users/dossiers_controller.rb | 4 +++ .../users/registrations_controller.rb | 2 +- app/controllers/users/sessions_controller.rb | 2 +- .../administrateurs/procedures/edit.html.haml | 2 +- .../administrateurs/procedures/new.html.haml | 2 +- app/views/layouts/login.html.haml | 17 +++++++++++ app/views/layouts/procedure_context.html.haml | 16 ++++------- .../procedure_context_full_screen.html.haml | 20 ------------- app/views/prefill_descriptions/edit.html.haml | 2 +- .../shared/_procedure_description.html.haml | 28 +++++++++---------- spec/system/sessions/sign_in_spec.rb | 3 +- spec/system/users/sign_up_spec.rb | 4 +-- .../procedure_context.html.haml_spec.rb | 14 ---------- .../_procedure_description.html.haml_spec.rb | 2 +- 15 files changed, 49 insertions(+), 71 deletions(-) create mode 100644 app/views/layouts/login.html.haml delete mode 100644 app/views/layouts/procedure_context_full_screen.html.haml diff --git a/app/controllers/users/commencer_controller.rb b/app/controllers/users/commencer_controller.rb index d70f5facd..63e7dacdd 100644 --- a/app/controllers/users/commencer_controller.rb +++ b/app/controllers/users/commencer_controller.rb @@ -1,6 +1,6 @@ module Users class CommencerController < ApplicationController - layout 'procedure_context_full_screen' + layout 'procedure_context' def commencer @procedure = retrieve_procedure diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 5068478ea..4a2a2eaf6 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -92,10 +92,12 @@ module Users def identite @dossier = dossier @user = current_user + @no_description = true end def update_identite @dossier = dossier + @no_description = true if @dossier.individual.update(individual_params) @dossier.update!(autorisation_donnees: true, identity_updated_at: Time.zone.now) @@ -110,10 +112,12 @@ module Users def siret @dossier = dossier + @no_description = true end def update_siret @dossier = dossier + @no_description = true # We use the user as the holder model object for the siret value # (so that we can restore it on the form in case of error). diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 9136649cd..8698670c7 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -5,7 +5,7 @@ class Users::RegistrationsController < Devise::RegistrationsController # before_action :configure_account_update_params, only: [:update] before_action :restore_procedure_context, only: [:new, :create] - layout 'procedure_context', only: [:new, :create] + layout 'login', only: [:new, :create] # GET /resource/sign_up def new diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index 41cbb9254..747646cdf 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -3,7 +3,7 @@ class Users::SessionsController < Devise::SessionsController include TrustedDeviceConcern include ActionView::Helpers::DateHelper - layout 'procedure_context', only: [:new, :create] + layout 'login', only: [:new, :create] before_action :restore_procedure_context, only: [:new, :create] diff --git a/app/views/administrateurs/procedures/edit.html.haml b/app/views/administrateurs/procedures/edit.html.haml index 1e1b66792..7571094af 100644 --- a/app/views/administrateurs/procedures/edit.html.haml +++ b/app/views/administrateurs/procedures/edit.html.haml @@ -25,4 +25,4 @@ .procedure-form__preview.sticky--top %h3.procedure-form__preview-title Aperçu .procedure-preview - = render partial: 'shared/procedure_description', locals: { procedure: @procedure, full_screen_display: false } + = render partial: 'shared/procedure_description', locals: { procedure: @procedure } diff --git a/app/views/administrateurs/procedures/new.html.haml b/app/views/administrateurs/procedures/new.html.haml index aae964bc0..99b375169 100644 --- a/app/views/administrateurs/procedures/new.html.haml +++ b/app/views/administrateurs/procedures/new.html.haml @@ -25,4 +25,4 @@ .procedure-form__preview.sticky--top %h3.procedure-form__preview-title Aperçu .procedure-preview - = render partial: 'shared/procedure_description', locals: { procedure: @procedure, full_screen_display: false } + = render partial: 'shared/procedure_description', locals: { procedure: @procedure } diff --git a/app/views/layouts/login.html.haml b/app/views/layouts/login.html.haml new file mode 100644 index 000000000..fe55afe5c --- /dev/null +++ b/app/views/layouts/login.html.haml @@ -0,0 +1,17 @@ +- procedure = @procedure || @dossier&.procedure || nil + +- content_for :content do + .two-columns.procedure-context + .columns-container + .column.procedure-preview + = yield + .column.procedure-context-content + = render partial: 'layouts/commencer/no_procedure' + +- content_for :footer do + - if procedure + = render partial: 'users/procedure_footer', locals: { procedure: procedure, dossier: @dossier } + - else + = render partial: 'users/dossiers/index_footer' + += render template: 'layouts/application' diff --git a/app/views/layouts/procedure_context.html.haml b/app/views/layouts/procedure_context.html.haml index 474828a85..3f927808b 100644 --- a/app/views/layouts/procedure_context.html.haml +++ b/app/views/layouts/procedure_context.html.haml @@ -1,17 +1,11 @@ - procedure = @procedure || @dossier&.procedure || nil - content_for :content do - .two-columns.procedure-context - .columns-container - - .column.procedure-preview - - if procedure - = render partial: 'shared/procedure_description', locals: { procedure: procedure, full_screen_display: false } - - else - = render partial: 'layouts/commencer/no_procedure' - - .column.procedure-context-content - = yield + .fr-container.fr-mt-5w + .fr-grid-row + .fr-col-12.fr-col-md-8.fr-col-offset-md-2 + .procedure-preview.fr-mb-5w + = render partial: 'shared/procedure_description', locals: { procedure: procedure } - content_for :footer do - if procedure diff --git a/app/views/layouts/procedure_context_full_screen.html.haml b/app/views/layouts/procedure_context_full_screen.html.haml deleted file mode 100644 index f7f2b36fb..000000000 --- a/app/views/layouts/procedure_context_full_screen.html.haml +++ /dev/null @@ -1,20 +0,0 @@ -- procedure = @procedure || @dossier&.procedure || nil - -- content_for :content do - .fr-container.fr-mt-5w - .fr-grid-row - .fr-col-12.fr-col-md-8.fr-col-offset-md-2 - .procedure-preview.fr-mb-5w - - if procedure - = render partial: 'shared/procedure_description', locals: { procedure: procedure, full_screen_display: true } - - else - = render partial: 'layouts/commencer/no_procedure' - = yield - -- content_for :footer do - - if procedure - = render partial: 'users/procedure_footer', locals: { procedure: procedure, dossier: @dossier } - - else - = render partial: 'users/dossiers/index_footer' - -= render template: 'layouts/application' diff --git a/app/views/prefill_descriptions/edit.html.haml b/app/views/prefill_descriptions/edit.html.haml index 8514ed493..4c94fabf7 100644 --- a/app/views/prefill_descriptions/edit.html.haml +++ b/app/views/prefill_descriptions/edit.html.haml @@ -7,7 +7,7 @@ .two-columns.procedure-context .columns-container .column.procedure-preview - = render partial: 'shared/procedure_description', locals: { procedure: @prefill_description, full_screen_display: false } + = render partial: 'shared/procedure_description', locals: { procedure: @prefill_description } .column.procedure-context-content %p = t("views.prefill_descriptions.edit.intro_html", libelle: @prefill_description.libelle) diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index 6ba6066fb..0a3f2dc7f 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -14,8 +14,8 @@ %span.fr-icon-timer-line = t('shared.procedure_description.estimated_fill_duration', estimated_minutes: estimated_fill_duration_minutes(procedure)) -- if full_screen_display - = yield + += yield - if procedure.auto_archive_on %details.procedure-configuration--auto-archive @@ -25,17 +25,17 @@ %span.procedure-auto-archive-title Date limite : #{procedure_auto_archive_date(procedure)} %p Vous pouvez déposer vos dossiers jusqu’au #{procedure_auto_archive_datetime(procedure)}. - -.fr-accordions-group - %section.fr-accordion - %h2.fr-accordion__title - %button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } Quel est l’objet de cette démarche ? - #accordion-114.fr-collapse.js_description - = h render SimpleFormatComponent.new(procedure.description, allow_a: true) - - - if procedure.description_target_audience.present? +- unless @no_description + .fr-accordions-group %section.fr-accordion %h2.fr-accordion__title - %button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } À qui s’adresse la démarche ? - #accordion-115.fr-collapse.js_description_target_audience - = h render SimpleFormatComponent.new(procedure.description_target_audience, allow_a: true) + %button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } Quel est l’objet de cette démarche ? + #accordion-114.fr-collapse.js_description + = h render SimpleFormatComponent.new(procedure.description, allow_a: true) + + - if procedure.description_target_audience.present? + %section.fr-accordion + %h2.fr-accordion__title + %button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } À qui s’adresse la démarche ? + #accordion-115.fr-collapse.js_description_target_audience + = h render SimpleFormatComponent.new(procedure.description_target_audience, allow_a: true) diff --git a/spec/system/sessions/sign_in_spec.rb b/spec/system/sessions/sign_in_spec.rb index c5679805c..0bd1beaeb 100644 --- a/spec/system/sessions/sign_in_spec.rb +++ b/spec/system/sessions/sign_in_spec.rb @@ -35,7 +35,6 @@ describe 'Signin in:' do scenario 'an existing user can sign-in and fill the procedure' do click_on 'J’ai déjà un compte' expect(page).to have_current_path new_user_session_path - expect(page).to have_procedure_description(procedure) sign_in_with user.email, password @@ -43,7 +42,7 @@ describe 'Signin in:' do click_on 'Commencer la démarche' expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last) - expect(page).to have_procedure_description(procedure) + expect(page).to have_content(procedure.libelle) expect(page).to have_content "Données d’identité" end end diff --git a/spec/system/users/sign_up_spec.rb b/spec/system/users/sign_up_spec.rb index 9c77cfbac..9f576b48a 100644 --- a/spec/system/users/sign_up_spec.rb +++ b/spec/system/users/sign_up_spec.rb @@ -70,7 +70,6 @@ describe 'Signing up:' do click_on 'Créer un compte' expect(page).to have_current_path new_user_registration_path - expect(page).to have_procedure_description(procedure) sign_up_with user_email, user_password expect(page).to have_content "nous avons besoin de vérifier votre adresse #{user_email}" @@ -84,7 +83,7 @@ describe 'Signing up:' do click_on 'Commencer la démarche' expect(page).to have_current_path identite_dossier_path(procedure.reload.dossiers.last) - expect(page).to have_procedure_description(procedure) + expect(page).to have_content(procedure.libelle) end end @@ -141,7 +140,6 @@ describe 'Signing up:' do click_procedure_sign_in_link_for user_email expect(page).to have_current_path new_user_session_path - expect(page).to have_procedure_description(procedure) end end end diff --git a/spec/views/layouts/procedure_context.html.haml_spec.rb b/spec/views/layouts/procedure_context.html.haml_spec.rb index da578e5fa..15013c457 100644 --- a/spec/views/layouts/procedure_context.html.haml_spec.rb +++ b/spec/views/layouts/procedure_context.html.haml_spec.rb @@ -51,18 +51,4 @@ describe 'layouts/procedure_context', type: :view do expect(subject).to have_text(dossier.procedure.service.email) end end - - context 'when neither procedure or dossier are assigned' do - it 'renders a placeholder for the procedure' do - expect(subject).to have_selector('.no-procedure') - end - - it 'renders the inner content' do - expect(subject).to have_text('Column content') - end - - it 'renders a generic footer' do - expect(subject).to have_text('Mentions légales') - end - end end diff --git a/spec/views/shared/_procedure_description.html.haml_spec.rb b/spec/views/shared/_procedure_description.html.haml_spec.rb index 9ced93cc9..431de7fe3 100644 --- a/spec/views/shared/_procedure_description.html.haml_spec.rb +++ b/spec/views/shared/_procedure_description.html.haml_spec.rb @@ -2,7 +2,7 @@ describe 'shared/_procedure_description', type: :view do let(:estimated_duration_visible) { true } let(:procedure) { create(:procedure, :published, :with_service, estimated_duration_visible:) } - subject { render partial: 'shared/procedure_description', locals: { procedure: procedure, full_screen_display: false } } + subject { render partial: 'shared/procedure_description', locals: { procedure: procedure } } it 'renders the view' do subject From 7f53120815e8f564e68c1386ff459cf6cbaec47a Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Thu, 25 May 2023 16:49:07 +0200 Subject: [PATCH 09/10] fix specs - forget to remove description in siret context --- app/views/users/dossiers/siret.html.haml | 2 +- spec/support/feature_matchers.rb | 9 --------- spec/system/users/dossier_creation_spec.rb | 5 ++--- 3 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 spec/support/feature_matchers.rb diff --git a/app/views/users/dossiers/siret.html.haml b/app/views/users/dossiers/siret.html.haml index 436e1076d..64bc5a761 100644 --- a/app/views/users/dossiers/siret.html.haml +++ b/app/views/users/dossiers/siret.html.haml @@ -2,7 +2,7 @@ - if !dossier_submission_is_closed?(@dossier) = form_for current_user, url: siret_dossier_path(@dossier), html: { class: 'form', method: 'post' } do |f| - %h2.huge-title Identifier votre établissement + %h2.fr-h4 Identifier votre établissement %p.mb-1 Merci de remplir le numéro de SIRET de votre entreprise, administration ou association pour commencer la démarche. diff --git a/spec/support/feature_matchers.rb b/spec/support/feature_matchers.rb deleted file mode 100644 index b61c8beee..000000000 --- a/spec/support/feature_matchers.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Capybara - class Session - # Find the description of a procedure on the page - # Usage: expect(page).to have_procedure_description(procedure) - def has_procedure_description?(procedure) - has_content?(procedure.libelle) && has_content?(procedure.description) && has_content?(procedure.service.email) - end - end -end diff --git a/spec/system/users/dossier_creation_spec.rb b/spec/system/users/dossier_creation_spec.rb index c2fcbae6d..5f0bb56ce 100644 --- a/spec/system/users/dossier_creation_spec.rb +++ b/spec/system/users/dossier_creation_spec.rb @@ -19,7 +19,6 @@ describe 'Creating a new dossier:' do click_on 'Commencer la démarche' expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last) - expect(page).to have_procedure_description(procedure) expect(page).to have_title(libelle) choose 'Monsieur' @@ -91,7 +90,7 @@ describe 'Creating a new dossier:' do click_on 'Commencer la démarche' expect(page).to have_current_path siret_dossier_path(dossier) - expect(page).to have_procedure_description(procedure) + expect(page).to have_content(procedure.libelle) fill_in 'Numéro SIRET', with: siret click_on 'Valider' @@ -108,7 +107,7 @@ describe 'Creating a new dossier:' do click_on 'Commencer la démarche' expect(page).to have_current_path(siret_dossier_path(dossier)) - expect(page).to have_procedure_description(procedure) + expect(page).to have_content(procedure.libelle) fill_in 'Numéro SIRET', with: '0000' click_on 'Valider' From 83884e08e3356b1c1b4f356188add1192d5ac87e Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Thu, 25 May 2023 17:24:23 +0200 Subject: [PATCH 10/10] remove duplicate translation and improve english translations --- config/locales/models/procedure/en.yml | 6 +++--- config/locales/models/procedure/fr.yml | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/config/locales/models/procedure/en.yml b/config/locales/models/procedure/en.yml index 706f96434..f7346f11e 100644 --- a/config/locales/models/procedure/en.yml +++ b/config/locales/models/procedure/en.yml @@ -13,9 +13,9 @@ en: cadre_juridique: "Exemple: 'https://www.legifrance.gouv.fr/'" path: Public link organisation: Service - description: Procedure subject - description_target_audience: For who is the procedure ? - lien_site_web: Where to find the procedure link ? + description: What is the purpose of this procedure? + description_target_audience: Who is the procedure intended for? + lien_site_web: Where will users find the link to the procedure? cadre_juridique: Link to the legal text lien_dpo: Link or email to contact the data protection officer (DPO) duree_conservation_dossiers_dans_ds: Duration files will be kept diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index d44229255..27ea70305 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -13,7 +13,6 @@ fr: cadre_juridique: "Exemple: 'https://www.legifrance.gouv.fr/'" path: Lien public organisation: Organisme - description_target_audience: À qui s’adresse la démarche duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers sur demarches-simplifiees.fr (choisi par un usager) max_duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers maximum (autorisé par un super admin de DS) id: Id