2022-09-08 11:25:39 +02:00
|
|
|
class EditableChamp::PieceJustificativeComponent < EditableChamp::EditableChampBaseComponent
|
2022-12-08 00:15:05 +01:00
|
|
|
def view_as
|
|
|
|
if @champ.dossier.brouillon?
|
|
|
|
:link
|
|
|
|
else
|
|
|
|
:download
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def user_can_destroy?
|
|
|
|
!@champ.mandatory? || @champ.dossier.brouillon?
|
|
|
|
end
|
|
|
|
|
2022-12-13 15:22:18 +01:00
|
|
|
def user_can_replace?
|
|
|
|
@champ.mandatory? && @champ.dossier.en_construction?
|
|
|
|
end
|
|
|
|
|
2022-12-08 00:15:05 +01:00
|
|
|
def max
|
|
|
|
[true, nil].include?(@champ.procedure&.piece_justificative_multiple?) ? Attachment::MultipleComponent::DEFAULT_MAX_ATTACHMENTS : 1
|
|
|
|
end
|
2022-08-12 10:45:04 +02:00
|
|
|
end
|