2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-10-11 12:18:00 +02:00
|
|
|
class Dossiers::EditFooterComponent < ApplicationComponent
|
2024-06-05 19:16:41 +02:00
|
|
|
delegate :can_passer_en_construction?, to: :@dossier
|
2024-06-05 17:34:17 +02:00
|
|
|
|
2023-03-01 18:30:10 +01:00
|
|
|
def initialize(dossier:, annotation:)
|
2022-10-11 12:18:00 +02:00
|
|
|
@dossier = dossier
|
2023-03-01 18:30:10 +01:00
|
|
|
@annotation = annotation
|
2022-10-11 12:18:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def owner?
|
|
|
|
controller.current_user.owns?(@dossier)
|
|
|
|
end
|
|
|
|
|
2023-03-01 18:30:10 +01:00
|
|
|
def annotation?
|
2023-03-07 18:48:06 +01:00
|
|
|
@annotation.present?
|
2023-03-01 18:30:10 +01:00
|
|
|
end
|
|
|
|
|
2024-06-05 17:34:17 +02:00
|
|
|
def disabled_submit_buttons_options
|
|
|
|
{
|
|
|
|
class: 'fr-text--sm fr-mb-0 fr-mr-2w',
|
|
|
|
data: { 'fr-opened': "true" },
|
|
|
|
aria: { controls: 'modal-eligibilite-rules-dialog' }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-03-21 18:24:39 +01:00
|
|
|
def submit_draft_button_options
|
2022-10-11 12:18:00 +02:00
|
|
|
{
|
|
|
|
class: 'fr-btn fr-btn--sm',
|
2024-06-05 19:16:41 +02:00
|
|
|
disabled: !owner? || !can_passer_en_construction?,
|
2022-10-11 12:18:00 +02:00
|
|
|
method: :post,
|
2024-06-05 17:34:17 +02:00
|
|
|
data: { 'disable-with': t('.submitting'), controller: 'autosave-submit', turbo_force: :server }
|
2022-10-11 12:18:00 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2023-03-21 18:24:39 +01:00
|
|
|
def submit_en_construction_button_options
|
|
|
|
{
|
|
|
|
class: 'fr-btn fr-btn--sm',
|
2024-06-05 19:16:41 +02:00
|
|
|
disabled: !can_passer_en_construction?,
|
2023-03-21 18:24:39 +01:00
|
|
|
method: :post,
|
2024-06-05 17:34:17 +02:00
|
|
|
data: { 'disable-with': t('.submitting'), controller: 'autosave-submit', turbo_force: :server },
|
2023-04-11 18:31:16 +02:00
|
|
|
form: { id: "form-submit-en-construction" }
|
2023-03-21 18:24:39 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2022-10-11 12:18:00 +02:00
|
|
|
def render?
|
|
|
|
!@dossier.for_procedure_preview?
|
|
|
|
end
|
|
|
|
end
|