feat(dossier): show lien_notice when available
This commit is contained in:
parent
d92a38a80b
commit
7ade521582
7 changed files with 40 additions and 14 deletions
27
app/components/procedure/notice_component.rb
Normal file
27
app/components/procedure/notice_component.rb
Normal 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
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
en:
|
||||||
|
name: 'Download the notice of the procedure'
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
fr:
|
||||||
|
name: 'Télécharger le guide de la démarche'
|
|
@ -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?)
|
|
@ -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
|
|
|
@ -77,6 +77,5 @@
|
||||||
#accordion-117.fr-collapse
|
#accordion-117.fr-collapse
|
||||||
= t('shared.procedure_description.estimated_fill_duration_detail', estimated_minutes: estimated_fill_duration_minutes(procedure))
|
= t('shared.procedure_description.estimated_fill_duration_detail', estimated_minutes: estimated_fill_duration_minutes(procedure))
|
||||||
|
|
||||||
- if procedure.notice.attached?
|
.fr-my-3w
|
||||||
.fr-my-3w
|
= render Procedure::NoticeComponent.new(procedure:)
|
||||||
= render Dsfr::DownloadComponent.new(attachment: procedure.notice , url: notice_url(procedure), name: t("views.shared.dossiers.edit.notice"), ephemeral_link: administrateur_signed_in?)
|
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
- if dossier.brouillon?
|
- if dossier.brouillon?
|
||||||
= t('views.shared.dossiers.edit.autosave')
|
= t('views.shared.dossiers.edit.autosave')
|
||||||
|
|
||||||
- if dossier.procedure.notice.attached?
|
= render Procedure::NoticeComponent.new(procedure: dossier.procedure)
|
||||||
= 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 EditableChamp::SectionComponent.new(champs: dossier_for_editing.champs_public)
|
= render EditableChamp::SectionComponent.new(champs: dossier_for_editing.champs_public)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue