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 }
|
Loading…
Add table
Add a link
Reference in a new issue