refactor(dossier): extract dossier edit footer into a component
This commit is contained in:
parent
d409b6f4ef
commit
25c774b3a1
7 changed files with 47 additions and 19 deletions
24
app/components/dossiers/edit_footer_component.rb
Normal file
24
app/components/dossiers/edit_footer_component.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
class Dossiers::EditFooterComponent < ApplicationComponent
|
||||
def initialize(dossier:)
|
||||
@dossier = dossier
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def owner?
|
||||
controller.current_user.owns?(@dossier)
|
||||
end
|
||||
|
||||
def button_options
|
||||
{
|
||||
class: 'fr-btn fr-btn--sm',
|
||||
disabled: !owner?,
|
||||
method: :post,
|
||||
data: { 'disable-with': t('.sbumitting'), controller: 'autosave-submit' }
|
||||
}
|
||||
end
|
||||
|
||||
def render?
|
||||
!@dossier.for_procedure_preview?
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
en:
|
||||
submit: Submit the file
|
||||
submitting: Submitting…
|
||||
invite_notice: You are invited to make amendments to this file but only the owner themselves can submit it.
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fr:
|
||||
submit: Déposer le dossier
|
||||
submitting: Envoi en cours…
|
||||
invite_notice: En tant qu’invité, vous pouvez remplir ce formulaire – mais le titulaire du dossier doit le déposer lui-même.
|
|
@ -0,0 +1,12 @@
|
|||
.dossier-edit-sticky-footer
|
||||
.send-dossier-actions-bar
|
||||
= render partial: 'shared/dossiers/autosave', locals: { dossier: @dossier }
|
||||
|
||||
- if @dossier.can_transition_to_en_construction?
|
||||
= button_to t('.submit'), brouillon_dossier_url(@dossier), button_options
|
||||
|
||||
- if @dossier.brouillon? && !owner?
|
||||
.send-notice.invite-cannot-submit
|
||||
= t('.invite_notice')
|
||||
|
||||
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
|
|
@ -47,20 +47,4 @@
|
|||
= fields_for champ.input_name, champ do |form|
|
||||
= render EditableChamp::EditableChampComponent.new form: form, champ: champ
|
||||
|
||||
- if !dossier.for_procedure_preview?
|
||||
.dossier-edit-sticky-footer
|
||||
.send-dossier-actions-bar
|
||||
= render partial: 'shared/dossiers/autosave', locals: { dossier: dossier }
|
||||
|
||||
- if dossier.can_transition_to_en_construction?
|
||||
= button_to t('views.shared.dossiers.edit.submit_dossier'), brouillon_dossier_url(dossier),
|
||||
class: 'fr-btn fr-btn--sm',
|
||||
disabled: !current_user.owns?(dossier),
|
||||
method: :post,
|
||||
data: { 'disable-with': "Envoi en cours…", controller: 'autosave-submit' }
|
||||
|
||||
- if dossier.brouillon? && !current_user.owns?(dossier)
|
||||
.send-notice.invite-cannot-submit
|
||||
En tant qu’invité, vous pouvez remplir ce formulaire – mais le titulaire du dossier doit le déposer lui-même.
|
||||
|
||||
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: dossier }
|
||||
= render Dossiers::EditFooterComponent.new(dossier: dossier)
|
||||
|
|
|
@ -138,7 +138,6 @@ en:
|
|||
autosave: Your file is automatically saved after each modification. You can close the window at any time and pick up where you left off later.
|
||||
notice: "Download the notice of the procedure"
|
||||
notice_title: "To help you complete your file, you can consult the notice to this procedure."
|
||||
submit_dossier: Submit the file
|
||||
messages:
|
||||
form:
|
||||
send_message: "Send message"
|
||||
|
|
|
@ -133,7 +133,6 @@ fr:
|
|||
autosave: Votre dossier est enregistré automatiquement après chaque modification. Vous pouvez à tout moment fermer la fenêtre et reprendre plus tard là où vous en étiez.
|
||||
notice: Télécharger le guide de la démarche
|
||||
notice_title: "Pour vous aider à remplir votre dossier, vous pouvez consulter le guide de cette démarche."
|
||||
submit_dossier: Déposer le dossier
|
||||
messages:
|
||||
form:
|
||||
send_message: "Envoyer le message"
|
||||
|
|
Loading…
Reference in a new issue