demarches-normaliennes/app/components/editable_champ/piece_justificative_component.rb
Colin Darie 4824363879 refactor(attachment): rename user_can_download -> explicit view_as
- link: shows a simple link to open attachment
- download: shows complete DSFR download UI
2022-12-08 20:36:15 +01:00

17 lines
430 B
Ruby

class EditableChamp::PieceJustificativeComponent < EditableChamp::EditableChampBaseComponent
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