From 4a51a9a3518edcab1bf035163c3b916251a67fc6 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 22 May 2023 15:36:48 +0200 Subject: [PATCH] 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