demarches-normaliennes/app/components/editable_champ/piece_justificative_component.rb
2024-08-22 09:26:48 +02:00

23 lines
510 B
Ruby

# frozen_string_literal: true
class EditableChamp::PieceJustificativeComponent < EditableChamp::EditableChampBaseComponent
def dsfr_input_classname
'fr-input'
end
def view_as
if @champ.dossier.brouillon?
:link
else
:download
end
end
def user_can_destroy?
!@champ.mandatory? || @champ.dossier.brouillon?
end
def max
[true, nil].include?(@champ.procedure&.piece_justificative_multiple?) ? Attachment::MultipleComponent::DEFAULT_MAX_ATTACHMENTS : 1
end
end