refactor(attachment): update Attachment::EditComponent everywhere

This commit is contained in:
Colin Darie 2022-11-17 19:18:58 +01:00
parent b13c5e56f6
commit 0a114270af
22 changed files with 109 additions and 65 deletions

View file

@ -25,7 +25,7 @@
= tag[:description]
%h3.header-subsection Logo de l'attestation
= render Attachment::EditComponent.new(form: f, attached_file: @attestation_template.logo, direct_upload: false, user_can_destroy: true)
= render Attachment::EditComponent.new(attached_file: @attestation_template.logo, direct_upload: false)
%p.notice
Formats acceptés : JPG / JPEG / PNG.
@ -33,7 +33,7 @@
Dimensions conseillées : au minimum 500 px de largeur ou de hauteur, poids maximum : 0,5 Mo.
%h3.header-subsection Tampon de l'attestation
= render Attachment::EditComponent.new(form: f, attached_file: @attestation_template.signature, direct_upload: false, user_can_destroy: true)
= render Attachment::EditComponent.new(attached_file: @attestation_template.signature, direct_upload: false)
%p.notice
Formats acceptés : JPG / JPEG / PNG.

View file

@ -14,7 +14,7 @@
= f.text_area :description, rows: '6', placeholder: 'Description de la démarche, destinataires, etc. ', class: 'form-control'
%h3.header-subsection Logo de la démarche
= render Attachment::EditComponent.new(form: f, attached_file: @procedure.logo, direct_upload: true, user_can_destroy: true)
= render Attachment::EditComponent.new(attached_file: @procedure.logo, user_can_download: true)
%h3.header-subsection Conservation des données
= f.label :duree_conservation_dossiers_dans_ds do
@ -52,7 +52,7 @@
= f.text_field :cadre_juridique, class: 'form-control', placeholder: 'https://www.legifrance.gouv.fr/'
= f.label :deliberation, 'Importer le texte'
= render Attachment::EditComponent.new(form: f, attached_file: @procedure.deliberation, user_can_destroy: true)
= render Attachment::EditComponent.new(attached_file: @procedure.deliberation, user_can_download: true)
%h3.header-subsection
RGPD
@ -81,7 +81,7 @@
= f.label :notice, 'Notice'
%p.notice
Formats acceptés : .doc, .odt, .pdf, .ppt, .pptx
= render Attachment::EditComponent.new(form: f, attached_file: @procedure.notice, user_can_destroy: true)
= render Attachment::EditComponent.new(attached_file: @procedure.notice, user_can_download: true)
- if !@procedure.locked?
%h3.header-subsection À qui sadresse ma démarche ?

View file

@ -8,8 +8,8 @@
.procedure-form__columns.container
= form_for @procedure,
url: url_for({ controller: 'administrateurs/procedures', action: :update, id: @procedure.id }),
multipart: true,
html: { class: 'form procedure-form__column--form' } do |f|
html: { class: 'form procedure-form__column--form',
multipart: true } do |f|
%h1.page-title Description

View file

@ -8,8 +8,7 @@
.procedure-form__columns.container
= form_for @procedure,
url: url_for({ controller: 'administrateurs/procedures', action: :create, id: @procedure.id }),
multipart: true,
html: { class: 'form procedure-form__column--form' } do |f|
html: { class: 'form procedure-form__column--form', multipart: true } do |f|
%h1.page-title Nouvelle démarche

View file

@ -1,5 +1,5 @@
= turbo_stream.replace dom_id(@attachment, :edit) do
- if @user_can_edit
= render Attachment::EditComponent.new(attachment: @attachment, attached_file: @attachment.record.public_send(@attachment.name), auto_attach_url: @auto_attach_url)
= render Attachment::EditComponent.new(attachment: @attachment, attached_file: @attachment.record.public_send(@attachment.name), auto_attach_url: @auto_attach_url, user_can_download: @user_can_download)
- else
= render Attachment::ShowComponent.new(attachment: @attachment)

View file

@ -15,9 +15,9 @@
= render Attachment::ShowComponent.new(attachment: @avis.introduction_file.attachment)
%br/
= form_for @avis, url: expert_avis_path(@avis.procedure, @avis), html: { class: 'form', data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@avis) } } do |f|
= form_for @avis, url: expert_avis_path(@avis.procedure, @avis), html: { class: 'form', data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@avis) }, multipart: true } do |f|
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
= render Attachment::EditComponent.new(form: f, attached_file: @avis.piece_justificative_file, user_can_destroy: true)
= render Attachment::EditComponent.new(attached_file: @avis.piece_justificative_file, user_can_download: true)
.flex.justify-between.align-baseline
%p.confidentiel.flex

View file

@ -7,7 +7,7 @@
= f.text_area :introduction, rows: 3, value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true
%p.tab-title Ajouter une pièce jointe
.form-group
= render Attachment::EditComponent.new(form: f, attached_file: avis.introduction_file, user_can_destroy: true)
= render Attachment::EditComponent.new(attached_file: avis.introduction_file)
- if linked_dossiers.present?
= f.check_box :invite_linked_dossiers, {}, true, false

View file

@ -3,7 +3,7 @@
%h1.tab-title Inviter des personnes à donner leur avis
%p.avis-notice Les invités pourront consulter le dossier, donner un avis et contribuer au fil de messagerie. Ils ne pourront pas modifier le dossier.
= form_for avis, url: url, html: { class: 'form', data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@avis.dossier, :avis_by_expert) } } do |f|
= form_for avis, url: url, html: { class: 'form', multipart: true, data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@avis.dossier, :avis_by_expert) } } do |f|
= hidden_field_tag 'avis[emails]', nil
= react_component("ComboMultiple",
options: [], selected: [], disabled: [],
@ -14,7 +14,7 @@
= f.text_area :introduction, rows: 3, value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true
%p.tab-title Ajouter une pièce jointe
.form-group
= render Attachment::EditComponent.new(form: f, attached_file: avis.introduction_file, user_can_destroy: true)
= render Attachment::EditComponent.new(attached_file: avis.introduction_file)
- if linked_dossiers.present?
= f.check_box :invite_linked_dossiers, {}, true, false

View file

@ -17,7 +17,7 @@
= form_for @avis, url: instructeur_avis_path(@avis.procedure, @avis), html: { class: 'form' } do |f|
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
= render Attachment::EditComponent.new(object: f.object, attached_file: @avis.piece_justificative_file, user_can_destroy: true)
= render Attachment::EditComponent.new(attached_file: @avis.piece_justificative_file)
.flex.justify-between.align-baseline
%p.confidentiel.flex

View file

@ -8,7 +8,7 @@
%p#avis-emails-description.avis-notice
Entrez les adresses email des experts à qui vous souhaitez demander un avis
= form_for avis, url: url, html: { class: 'form', data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@dossier, :avis_by_instructeur) } } do |f|
= form_for avis, url: url, html: { class: 'form', multipart: true, data: { controller: 'persisted-form', persisted_form_key_value: dom_id(@dossier, :avis_by_instructeur) } } do |f|
= hidden_field_tag 'avis[emails]', nil
= react_component("ComboMultiple",
options: @dossier.procedure.experts_require_administrateur_invitation ? @experts_emails : [],
@ -21,7 +21,7 @@
= f.text_area :introduction, rows: 3, value: avis.introduction || 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true
%p.tab-title Ajouter une pièce jointe
.form-group
= render Attachment::EditComponent.new(object: f.object, attached_file: avis.introduction_file, user_can_destroy: true)
= render Attachment::EditComponent.new(attached_file: avis.introduction_file)
- if linked_dossiers.present?
= f.check_box :invite_linked_dossiers, {}, true, false

View file

@ -355,6 +355,7 @@
- champ = @dossier.champs_public.first
- tdc = @dossier.champs_public.find { _1.type_champ == TypeDeChamp.type_champs.fetch(:piece_justificative) }.type_de_champ
- avis = Avis.new
- if attachment = ActiveStorage::Attachment.last
- attachment.update(created_at: 1.second.ago)
@ -378,9 +379,18 @@
- attachment.blob.metadata[:virus_scan_result] = ActiveStorage::VirusScanner::INFECTED
= render Attachment::EditComponent.new(champ:, attached_file: Champ.new.piece_justificative_file, attachment:)
%h3.fr-mt-4w New attachment not on Champ
%h3.fr-mt-4w New attachment on TypeDeChamp
= render Attachment::EditComponent.new(auto_attach_url: "/some-auto-attach-path", attached_file: tdc.piece_justificative_template, attachment: nil)
%h3.fr-mt-4w Existing attachment not on Champ
%h3.fr-mt-4w Existing attachment on TypeDeChamp
= render Attachment::EditComponent.new(auto_attach_url: "/some-auto-attach-path", attached_file: tdc.piece_justificative_template, attachment: attachment.reload)
%h3.fr-mt-4w Existing attachment on TypeDeChamp can download
= render Attachment::EditComponent.new(auto_attach_url: "/some-auto-attach-path", attached_file: tdc.piece_justificative_template, attachment: attachment.reload, user_can_download: true)
%h3.fr-mt-4w New attachment on generic object
= render Attachment::EditComponent.new(attached_file: avis.introduction_file)
%h3.fr-mt-4w Existing attachment on generic object, can download
= render Attachment::EditComponent.new(attached_file: avis.introduction_file, attachment: attachment.reload, user_can_download: true)

View file

@ -1,4 +1,4 @@
= form_for(commentaire, url: form_url, html: { class: 'form', data: { controller: 'persisted-form', persisted_form_key_value: @dossier.present? ? dom_id(@dossier) : dom_id(@procedure, :bulk_message) } }) do |f|
= form_for(commentaire, url: form_url, html: { class: 'form', multipart: true, data: { controller: 'persisted-form', persisted_form_key_value: @dossier.present? ? dom_id(@dossier) : dom_id(@procedure, :bulk_message) } }) do |f|
- dossier = commentaire.dossier
- placeholder = t('views.shared.dossiers.messages.form.write_message_to_administration_placeholder')
- if instructeur_signed_in? || administrateur_signed_in? || expert_signed_in?
@ -8,7 +8,7 @@
- disable_piece_jointe = defined?(disable_piece_jointe) ? disable_piece_jointe : false
%div
- if !disable_piece_jointe
= render Attachment::EditComponent.new(object: f.object, attached_file: commentaire.piece_jointe)
= render Attachment::EditComponent.new(attached_file: commentaire.piece_jointe)
%div
= f.submit t('views.shared.dossiers.messages.form.send_message'), class: 'button primary send', data: { disable: true }