refactor(dossier): cleanup user controller
This commit is contained in:
parent
671d121480
commit
1f5dd3bd02
5 changed files with 92 additions and 92 deletions
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Dossiers::EditFooterComponent < ApplicationComponent
|
||||
delegate :can_passer_en_construction?, to: :@dossier
|
||||
delegate :can_passer_en_construction?, :can_transition_to_en_construction?, :forked_with_changes?, to: :@dossier
|
||||
|
||||
def initialize(dossier:, annotation:)
|
||||
@dossier = dossier
|
||||
|
@ -18,7 +18,43 @@ class Dossiers::EditFooterComponent < ApplicationComponent
|
|||
@annotation.present?
|
||||
end
|
||||
|
||||
def disabled_submit_buttons_options
|
||||
def can_submit?
|
||||
can_submit_draft? || can_submit_en_construction?
|
||||
end
|
||||
|
||||
def can_submit_draft?
|
||||
!annotation? && can_transition_to_en_construction?
|
||||
end
|
||||
|
||||
def can_submit_en_construction?
|
||||
forked_with_changes?
|
||||
end
|
||||
|
||||
def submit_button_label
|
||||
if can_submit_draft?
|
||||
t('.submit')
|
||||
else
|
||||
t('.submit_changes')
|
||||
end
|
||||
end
|
||||
|
||||
def submit_button_path
|
||||
if can_submit_draft?
|
||||
brouillon_dossier_path(@dossier)
|
||||
else
|
||||
modifier_dossier_path(@dossier.editing_fork_origin)
|
||||
end
|
||||
end
|
||||
|
||||
def submit_button_options
|
||||
if can_submit_draft?
|
||||
submit_draft_button_options
|
||||
else
|
||||
submit_en_construction_button_options
|
||||
end
|
||||
end
|
||||
|
||||
def disabled_submit_button_options
|
||||
{
|
||||
class: 'fr-text--sm fr-mb-0 fr-mr-2w',
|
||||
data: { 'fr-opened': "true" },
|
||||
|
|
|
@ -2,16 +2,10 @@
|
|||
.send-dossier-actions-bar
|
||||
= render Dossiers::AutosaveFooterComponent.new(dossier: @dossier, annotation: annotation?)
|
||||
|
||||
- if !annotation? && @dossier.can_transition_to_en_construction?
|
||||
- if can_submit?
|
||||
- if !can_passer_en_construction?
|
||||
= link_to t('.submit_disabled'), "#", disabled_submit_buttons_options
|
||||
= button_to t('.submit'), brouillon_dossier_url(@dossier), submit_draft_button_options
|
||||
|
||||
- if @dossier.forked_with_changes?
|
||||
- if !can_passer_en_construction?
|
||||
= link_to t('.submit_disabled'), "#", disabled_submit_buttons_options
|
||||
= button_to t('.submit_changes'), modifier_dossier_url(@dossier.editing_fork_origin), submit_en_construction_button_options
|
||||
|
||||
= link_to t('.submit_disabled'), "#", disabled_submit_button_options
|
||||
= button_to submit_button_label, submit_button_path, submit_button_options
|
||||
|
||||
- if @dossier.brouillon? && !owner?
|
||||
.fr-pb-2w.invite-cannot-submit
|
||||
|
@ -19,7 +13,5 @@
|
|||
- c.with_body do
|
||||
%p.fr-pb-0= t('.invite_notice').html_safe
|
||||
|
||||
|
||||
|
||||
- if !annotation?
|
||||
= render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue