feat(dossier): show lien_notice when available

This commit is contained in:
Paul Chavard 2023-06-16 16:21:10 +01:00
parent d92a38a80b
commit 7ade521582
7 changed files with 40 additions and 14 deletions

View file

@ -0,0 +1,27 @@
class Procedure::NoticeComponent < ApplicationComponent
def initialize(procedure:)
@procedure = procedure
end
private
def render?
link? || attachment?
end
def link?
@procedure.lien_notice.present?
end
def url
@procedure.lien_notice
end
def attachment?
@procedure.notice.present?
end
def attachment
@procedure.notice
end
end

View file

@ -0,0 +1,3 @@
---
en:
name: 'Download the notice of the procedure'

View file

@ -0,0 +1,3 @@
---
fr:
name: 'Télécharger le guide de la démarche'

View file

@ -0,0 +1,4 @@
- if link?
= link_to url, t(".name"), { class: "fr-download__link" }
- elsif attachment?
= render Dsfr::DownloadComponent.new(attachment:, name: t(".name"), ephemeral_link: administrateur_signed_in?)

View file

@ -1,9 +0,0 @@
module NoticeURLHelper
def notice_url(procedure)
if procedure.notice.attached?
url_for(procedure.notice)
elsif procedure.lien_notice.present?
procedure.lien_notice
end
end
end

View file

@ -77,6 +77,5 @@
#accordion-117.fr-collapse
= t('shared.procedure_description.estimated_fill_duration_detail', estimated_minutes: estimated_fill_duration_minutes(procedure))
- if procedure.notice.attached?
.fr-my-3w
= render Dsfr::DownloadComponent.new(attachment: procedure.notice , url: notice_url(procedure), name: t("views.shared.dossiers.edit.notice"), ephemeral_link: administrateur_signed_in?)
.fr-my-3w
= render Procedure::NoticeComponent.new(procedure:)

View file

@ -16,8 +16,7 @@
- if dossier.brouillon?
= t('views.shared.dossiers.edit.autosave')
- if dossier.procedure.notice.attached?
= render Dsfr::DownloadComponent.new(attachment: dossier.procedure.notice , url: notice_url(dossier.procedure), name: t("views.shared.dossiers.edit.notice"), ephemeral_link: administrateur_signed_in?)
= render Procedure::NoticeComponent.new(procedure: dossier.procedure)
= render EditableChamp::SectionComponent.new(champs: dossier_for_editing.champs_public)