From 2659d0f966a25d06404891ba9f5e2ce86a22c16a Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Mon, 27 May 2024 17:56:05 +0200 Subject: [PATCH] create component for footer --- .../procedure/fixed_footer_component.rb | 10 ++++++++++ .../fixed_footer_component.html.fr.yml | 4 ++++ .../fixed_footer_component.html.haml | 20 +++++++++++++++++++ ...nstructeurs_management_component.html.haml | 7 ++----- .../sva_svr_form_component.html.haml | 9 +-------- .../dossier_submitted_messages/edit.html.haml | 9 +-------- .../experts_procedures/index.html.haml | 6 +----- .../mail_templates/index.html.haml | 8 +------- .../procedure_administrateurs/index.html.haml | 6 +----- .../procedures/accuse_lecture.html.haml | 8 +------- .../administrateurs/procedures/edit.html.haml | 11 +--------- .../procedures/jeton.html.haml | 9 +-------- .../procedures/modifications.html.haml | 6 +----- .../procedures/monavis.html.haml | 9 +-------- .../procedures/zones.html.haml | 9 +-------- .../administrateurs/services/_form.html.haml | 9 +-------- .../administrateurs/services/index.html.haml | 6 +----- 17 files changed, 49 insertions(+), 97 deletions(-) create mode 100644 app/components/procedure/fixed_footer_component.rb create mode 100644 app/components/procedure/fixed_footer_component/fixed_footer_component.html.fr.yml create mode 100644 app/components/procedure/fixed_footer_component/fixed_footer_component.html.haml diff --git a/app/components/procedure/fixed_footer_component.rb b/app/components/procedure/fixed_footer_component.rb new file mode 100644 index 000000000..b67548bca --- /dev/null +++ b/app/components/procedure/fixed_footer_component.rb @@ -0,0 +1,10 @@ +class Procedure::FixedFooterComponent < ApplicationComponent + def initialize(procedure:, form: nil, is_form_disabled: nil, extra_class_names: nil) + @procedure = procedure + @form = form + @is_form_disabled = is_form_disabled + @extra_class_names = extra_class_names + end + + attr_reader :form, :is_form_disabled, :extra_class_names +end diff --git a/app/components/procedure/fixed_footer_component/fixed_footer_component.html.fr.yml b/app/components/procedure/fixed_footer_component/fixed_footer_component.html.fr.yml new file mode 100644 index 000000000..0c67a97f1 --- /dev/null +++ b/app/components/procedure/fixed_footer_component/fixed_footer_component.html.fr.yml @@ -0,0 +1,4 @@ +fr: + back: Revenir à l'écran de gestion + submit: Enregistrer + cancel: Annuler et revenir à l'écran de gestion diff --git a/app/components/procedure/fixed_footer_component/fixed_footer_component.html.haml b/app/components/procedure/fixed_footer_component/fixed_footer_component.html.haml new file mode 100644 index 000000000..2116e38ff --- /dev/null +++ b/app/components/procedure/fixed_footer_component/fixed_footer_component.html.haml @@ -0,0 +1,20 @@ +- if form + .padded-fixed-footer + .fixed-footer + .fr-container + .fr-grid-row + %div{ class: "fr-col-12 #{extra_class_names}" } + %ul.fr-btns-group.fr-btns-group--inline-md + %li + = link_to t('.cancel'), admin_procedure_path(id: @procedure), class: 'fr-btn fr-btn--secondary', data: { confirm: 'Si vous avez fait des modifications elles ne seront pas sauvegardées.'} + %li + = form.submit t(".submit"), class: "fr-btn", disabled: is_form_disabled + +- else + .padded-fixed-footer + .fixed-footer + .fr-container + .fr-grid-row + %div{ class: "fr-col-12 fr-pb-2w #{extra_class_names}" } + = link_to admin_procedure_path(id: @procedure), class: 'fr-link fr-icon-arrow-left-line fr-link--icon-left fr-mb-2w' do + = t('.back') diff --git a/app/components/procedure/instructeurs_management_component/instructeurs_management_component.html.haml b/app/components/procedure/instructeurs_management_component/instructeurs_management_component.html.haml index 5b22e5325..3b538bdb1 100644 --- a/app/components/procedure/instructeurs_management_component/instructeurs_management_component.html.haml +++ b/app/components/procedure/instructeurs_management_component/instructeurs_management_component.html.haml @@ -11,8 +11,5 @@ available_instructeur_emails: @available_instructeur_emails, disabled_as_super_admin: @disabled_as_super_admin } -.padded-fixed-footer - .fixed-footer.fr-pb-2w - .fr-container - = link_to admin_procedure_path(id: @procedure), class: 'fr-link fr-icon-arrow-left-line fr-link--icon-left' do - Revenir à l'écran de gestion + += render Procedure::FixedFooterComponent.new(procedure: @procedure) diff --git a/app/components/procedure/sva_svr_form_component/sva_svr_form_component.html.haml b/app/components/procedure/sva_svr_form_component/sva_svr_form_component.html.haml index 1eac6cb13..85719eb9a 100644 --- a/app/components/procedure/sva_svr_form_component/sva_svr_form_component.html.haml +++ b/app/components/procedure/sva_svr_form_component/sva_svr_form_component.html.haml @@ -37,11 +37,4 @@ = render Dsfr::RadioButtonListComponent.new(form: f, target: :resume, buttons: resume_buttons) - .padded-fixed-footer - .fixed-footer - .fr-container - %ul.fr-btns-group.fr-btns-group--inline-md - %li - = link_to "Annuler et revenir à l'écran de gestion", admin_procedure_path(id: @procedure), class: 'fr-btn fr-btn--secondary', data: { confirm: 'Êtes-vous sûr de vouloir annuler les modifications effectuées ?'} - %li - = f.submit t(".submit"), class: "fr-btn", disabled: form_disabled? + = render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f, is_form_disabled: form_disabled?) diff --git a/app/views/administrateurs/dossier_submitted_messages/edit.html.haml b/app/views/administrateurs/dossier_submitted_messages/edit.html.haml index ed794cd73..dc289c291 100644 --- a/app/views/administrateurs/dossier_submitted_messages/edit.html.haml +++ b/app/views/administrateurs/dossier_submitted_messages/edit.html.haml @@ -30,11 +30,4 @@ .procedure-preview = render partial: 'users/dossiers/merci', locals: { procedure: @procedure, dossier: nil} - .padded-fixed-footer - .fixed-footer - .fr-container - %ul.fr-btns-group.fr-btns-group--inline-md - %li - = link_to "Annuler et revenir à l'écran de gestion", admin_procedure_path(id: @procedure), class: 'fr-btn fr-btn--secondary', data: { confirm: 'Êtes-vous sûr de vouloir annuler les modifications effectuées ?'} - %li - = f.button 'Enregistrer', class: 'fr-btn' + = render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f) diff --git a/app/views/administrateurs/experts_procedures/index.html.haml b/app/views/administrateurs/experts_procedures/index.html.haml index 55995ed69..e1d6b6d88 100644 --- a/app/views/administrateurs/experts_procedures/index.html.haml +++ b/app/views/administrateurs/experts_procedures/index.html.haml @@ -108,8 +108,4 @@ %h2.empty-text Aucun expert invité pour le moment. %p.empty-text-details Les instructeurs de cette démarche n’ont pas encore fait appel aux experts. -.padded-fixed-footer - .fixed-footer.fr-pb-2w - .fr-container - = link_to admin_procedure_path(id: @procedure), class: 'fr-link fr-icon-arrow-left-line fr-link--icon-left' do - Revenir à l'écran de gestion += render Procedure::FixedFooterComponent.new(procedure: @procedure) diff --git a/app/views/administrateurs/mail_templates/index.html.haml b/app/views/administrateurs/mail_templates/index.html.haml index 7a6640439..9fd744726 100644 --- a/app/views/administrateurs/mail_templates/index.html.haml +++ b/app/views/administrateurs/mail_templates/index.html.haml @@ -18,10 +18,4 @@ = render Procedure::EmailTemplateCardComponent.new(email_template: mail_template) -.padded-fixed-footer - .fixed-footer - .fr-container - .fr-grid-row - .fr-col-12.fr-pb-2w - = link_to admin_procedure_path(id: @procedure), class: 'fr-link fr-icon-arrow-left-line fr-link--icon-left fr-mb-2w' do - Revenir à la démarche += render Procedure::FixedFooterComponent.new(procedure: @procedure) diff --git a/app/views/administrateurs/procedure_administrateurs/index.html.haml b/app/views/administrateurs/procedure_administrateurs/index.html.haml index 0545d0f43..3e9bf37aa 100644 --- a/app/views/administrateurs/procedure_administrateurs/index.html.haml +++ b/app/views/administrateurs/procedure_administrateurs/index.html.haml @@ -20,8 +20,4 @@ %tbody#administrateurs = render(Procedure::ProcedureAdministrateurs::AdministrateurComponent.with_collection(@procedure.administrateurs.order('users.email'), procedure: @procedure)) -.padded-fixed-footer - .fixed-footer.fr-pb-2w - .fr-container - = link_to admin_procedure_path(id: @procedure), class: 'fr-link fr-icon-arrow-left-line fr-link--icon-left' do - Revenir à l'écran de gestion += render Procedure::FixedFooterComponent.new(procedure: @procedure) diff --git a/app/views/administrateurs/procedures/accuse_lecture.html.haml b/app/views/administrateurs/procedures/accuse_lecture.html.haml index 65b1e5143..90be126cc 100644 --- a/app/views/administrateurs/procedures/accuse_lecture.html.haml +++ b/app/views/administrateurs/procedures/accuse_lecture.html.haml @@ -33,10 +33,4 @@ hint: "L’accusé de lecture est à activer uniquement pour les démarches avec voies de recours car il complexifie l’accès à la décision finale pour les usagers", opt: {"checked" => @procedure.accuse_lecture}) -.padded-fixed-footer - .fixed-footer - .fr-container - .fr-grid-row - .fr-col-12.fr-col-offset-md-2.fr-col-md-8.fr-pb-2w - = link_to admin_procedure_path(id: @procedure), class: 'fr-link fr-icon-arrow-left-line fr-link--icon-left fr-mb-2w' do - Revenir à l'écran de gestion += render Procedure::FixedFooterComponent.new(procedure: @procedure, extra_class_names: 'fr-col-offset-md-2 fr-col-md-8' ) diff --git a/app/views/administrateurs/procedures/edit.html.haml b/app/views/administrateurs/procedures/edit.html.haml index f79244721..95164e8e6 100644 --- a/app/views/administrateurs/procedures/edit.html.haml +++ b/app/views/administrateurs/procedures/edit.html.haml @@ -16,13 +16,4 @@ = render partial: 'administrateurs/procedures/informations', locals: { f: f } - .padded-fixed-footer - .fixed-footer - .fr-container - .fr-grid-row - .fr-col-12.fr-col-offset-md-2.fr-col-md-8 - %ul.fr-btns-group.fr-btns-group--inline-md - %li - = link_to "Annuler et revenir à l'écran de gestion", admin_procedure_path(id: @procedure), class: 'fr-btn fr-btn--secondary', data: { confirm: 'Êtes-vous sûr de vouloir annuler les modifications effectuées ?'} - %li - = f.button 'Enregistrer', class: 'fr-btn' + = render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f, extra_class_names: 'fr-col-offset-md-2 fr-col-md-8') diff --git a/app/views/administrateurs/procedures/jeton.html.haml b/app/views/administrateurs/procedures/jeton.html.haml index 31d076d23..35d92ab90 100644 --- a/app/views/administrateurs/procedures/jeton.html.haml +++ b/app/views/administrateurs/procedures/jeton.html.haml @@ -22,11 +22,4 @@ = f.label :api_entreprise_token, "Jeton", class: 'fr-label' = f.password_field :api_entreprise_token, value: @procedure.read_attribute(:api_entreprise_token), class: 'fr-input' - .padded-fixed-footer - .fixed-footer - .fr-container - %ul.fr-btns-group.fr-btns-group--inline-md - %li - = link_to "Annuler et revenir à l'écran de gestion", admin_procedure_path(id: @procedure), class: 'fr-btn fr-btn--secondary', data: { confirm: 'Êtes-vous sûr de vouloir annuler les modifications effectuées ?'} - %li - = f.button 'Enregistrer', class: 'fr-btn' + = render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f) diff --git a/app/views/administrateurs/procedures/modifications.html.haml b/app/views/administrateurs/procedures/modifications.html.haml index 6c890f8fe..ea9e9c32b 100644 --- a/app/views/administrateurs/procedures/modifications.html.haml +++ b/app/views/administrateurs/procedures/modifications.html.haml @@ -31,8 +31,4 @@ = render Procedure::RevisionChangesComponent.new changes:, previous_revision: - previous_revision = revision -.padded-fixed-footer - .fixed-footer.fr-pb-2w - .fr-container - = link_to admin_procedure_path(id: @procedure), class: 'fr-link fr-icon-arrow-left-line fr-link--icon-left' do - Revenir à l'écran de gestion += render Procedure::FixedFooterComponent.new(procedure: @procedure) diff --git a/app/views/administrateurs/procedures/monavis.html.haml b/app/views/administrateurs/procedures/monavis.html.haml index 1b8189d6b..ee5e98fe9 100644 --- a/app/views/administrateurs/procedures/monavis.html.haml +++ b/app/views/administrateurs/procedures/monavis.html.haml @@ -11,11 +11,4 @@ .fr-container = render partial: 'monavis', locals: { f: f } - .padded-fixed-footer - .fixed-footer - .fr-container - %ul.fr-btns-group.fr-btns-group--inline-md - %li - = link_to "Annuler et revenir à l'écran de gestion", admin_procedure_path(id: @procedure), class: 'fr-btn fr-btn--secondary', data: { confirm: 'Êtes-vous sûr de vouloir annuler les modifications effectuées ?'} - %li - = f.button 'Enregistrer', class: 'fr-btn' + = render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f) diff --git a/app/views/administrateurs/procedures/zones.html.haml b/app/views/administrateurs/procedures/zones.html.haml index a0f5989e0..f30e5c737 100644 --- a/app/views/administrateurs/procedures/zones.html.haml +++ b/app/views/administrateurs/procedures/zones.html.haml @@ -25,11 +25,4 @@ = b.check_box = b.label class: "fr-label" - .padded-fixed-footer - .fixed-footer - .fr-container - %ul.fr-btns-group.fr-btns-group--inline-md - %li - = link_to "Annuler et revenir à l'écran de gestion", admin_procedure_path(id: @procedure), class: 'fr-btn fr-btn--secondary', data: { confirm: 'Êtes-vous sûr de vouloir annuler les modifications effectuées ?'} - %li - = f.button 'Enregistrer', class: 'fr-btn' + = render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f) diff --git a/app/views/administrateurs/services/_form.html.haml b/app/views/administrateurs/services/_form.html.haml index ec4a7233a..9c6040508 100644 --- a/app/views/administrateurs/services/_form.html.haml +++ b/app/views/administrateurs/services/_form.html.haml @@ -34,11 +34,4 @@ - if procedure_id.present? = hidden_field_tag :procedure_id, procedure_id - .padded-fixed-footer - .fixed-footer - .fr-container - %ul.fr-btns-group.fr-btns-group--inline-md - %li - = link_to "Annuler et revenir à l'écran de gestion", admin_procedure_path(id: @procedure.id), class: "fr-btn fr-btn--secondary" - %li - = f.submit "Enregistrer", class: "fr-btn" + = render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f) diff --git a/app/views/administrateurs/services/index.html.haml b/app/views/administrateurs/services/index.html.haml index a837c14f6..123e76536 100644 --- a/app/views/administrateurs/services/index.html.haml +++ b/app/views/administrateurs/services/index.html.haml @@ -34,8 +34,4 @@ data: { confirm: "Confirmez vous la suppression de #{service.nom}" }, class: 'btn btn-link ml-2' -.padded-fixed-footer - .fixed-footer.fr-pb-2w - .fr-container - = link_to admin_procedure_path(id: @procedure), class: 'fr-link fr-icon-arrow-left-line fr-link--icon-left' do - Revenir à l'écran de gestion += render Procedure::FixedFooterComponent.new(procedure: @procedure)