Merge pull request #8667 from mfo/US/fix-attachement-edit-component-with-missing-attachement-delete-form
correctif(attachement_edit): ajoute le composant <form> pour supprimer un attachment via le nouveau <button>
This commit is contained in:
commit
b9fad1ab00
10 changed files with 17 additions and 7 deletions
7
app/components/attachment/delete_form_component.rb
Normal file
7
app/components/attachment/delete_form_component.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# Display a form for destroying a file attachment via a button, but since it might already be nested within a form
|
||||||
|
# put this component before the actual form containing the editcomponent
|
||||||
|
class Attachment::DeleteFormComponent < ApplicationComponent
|
||||||
|
def call
|
||||||
|
form_tag('/attachments/:id', method: :delete, data: { 'turbo-method': :delete, turbo: true }, id: dom_id(ActiveStorage::Attachment.new, :delete)) {}
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
.procedure-form#attestation-template-edit
|
.procedure-form#attestation-template-edit
|
||||||
.procedure-form__columns.container
|
.procedure-form__columns.container
|
||||||
|
= render Attachment::DeleteFormComponent.new
|
||||||
= form_for @attestation_template,
|
= form_for @attestation_template,
|
||||||
url: admin_procedure_attestation_template_path(@procedure),
|
url: admin_procedure_attestation_template_path(@procedure),
|
||||||
html: { multipart: true, class: 'form form-ds-fr-white procedure-form__column--form' } do |f|
|
html: { multipart: true, class: 'form form-ds-fr-white procedure-form__column--form' } do |f|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
['Description']] }
|
['Description']] }
|
||||||
.procedure-form
|
.procedure-form
|
||||||
.procedure-form__columns.container
|
.procedure-form__columns.container
|
||||||
|
= render Attachment::DeleteFormComponent.new
|
||||||
= form_for @procedure,
|
= form_for @procedure,
|
||||||
url: url_for({ controller: 'administrateurs/procedures', action: :update, id: @procedure.id }),
|
url: url_for({ controller: 'administrateurs/procedures', action: :update, id: @procedure.id }),
|
||||||
html: { class: 'form procedure-form__column--form',
|
html: { class: 'form procedure-form__column--form',
|
||||||
|
|
|
@ -6,12 +6,14 @@
|
||||||
|
|
||||||
.procedure-form
|
.procedure-form
|
||||||
.procedure-form__columns.container
|
.procedure-form__columns.container
|
||||||
|
= render Attachment::DeleteFormComponent.new
|
||||||
= form_for @procedure,
|
= form_for @procedure,
|
||||||
url: url_for({ controller: 'administrateurs/procedures', action: :create, id: @procedure.id }),
|
url: url_for({ controller: 'administrateurs/procedures', action: :create, id: @procedure.id }),
|
||||||
html: { class: 'form procedure-form__column--form', multipart: true } do |f|
|
html: { class: 'form procedure-form__column--form', multipart: true } do |f|
|
||||||
|
|
||||||
%h1.page-title Nouvelle démarche
|
%h1.page-title Nouvelle démarche
|
||||||
|
|
||||||
|
|
||||||
= render partial: 'administrateurs/procedures/informations', locals: { f: f }
|
= render partial: 'administrateurs/procedures/informations', locals: { f: f }
|
||||||
|
|
||||||
.procedure-form__actions.sticky--bottom
|
.procedure-form__actions.sticky--bottom
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
- if @avis.introduction_file.attached?
|
- if @avis.introduction_file.attached?
|
||||||
= render Attachment::ShowComponent.new(attachment: @avis.introduction_file.attachment)
|
= render Attachment::ShowComponent.new(attachment: @avis.introduction_file.attachment)
|
||||||
%br/
|
%br/
|
||||||
|
= render Attachment::DeleteFormComponent.new
|
||||||
= 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|
|
= 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
|
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
|
||||||
= render Attachment::EditComponent.new(attached_file: @avis.piece_justificative_file, view_as: :download)
|
= render Attachment::EditComponent.new(attached_file: @avis.piece_justificative_file, view_as: :download)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
%section.ask-avis
|
%section.ask-avis
|
||||||
%h1.tab-title Inviter des personnes à donner leur avis
|
%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.
|
%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.
|
||||||
|
= render Attachment::DeleteFormComponent.new
|
||||||
= 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|
|
= 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
|
= hidden_field_tag 'avis[emails]', nil
|
||||||
= react_component("ComboMultiple",
|
= react_component("ComboMultiple",
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
= render Attachment::ShowComponent.new(attachment: @avis.introduction_file.attachment)
|
= render Attachment::ShowComponent.new(attachment: @avis.introduction_file.attachment)
|
||||||
%br/
|
%br/
|
||||||
|
|
||||||
|
= render Attachment::DeleteFormComponent.new
|
||||||
= form_for @avis, url: instructeur_avis_path(@avis.procedure, @avis), html: { class: 'form' } do |f|
|
= 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
|
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
|
||||||
= render Attachment::EditComponent.new(attached_file: @avis.piece_justificative_file)
|
= render Attachment::EditComponent.new(attached_file: @avis.piece_justificative_file)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
%p#avis-emails-description.avis-notice
|
%p#avis-emails-description.avis-notice
|
||||||
Entrez les adresses email des experts à qui vous souhaitez demander un avis
|
Entrez les adresses email des experts à qui vous souhaitez demander un avis
|
||||||
|
|
||||||
|
= render Attachment::DeleteFormComponent.new
|
||||||
= 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|
|
= 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
|
= hidden_field_tag 'avis[emails]', nil
|
||||||
= react_component("ComboMultiple",
|
= react_component("ComboMultiple",
|
||||||
|
|
|
@ -9,11 +9,7 @@
|
||||||
- form_options = { url: brouillon_dossier_url(dossier), method: :patch, data: { save_on_input: true } }
|
- form_options = { url: brouillon_dossier_url(dossier), method: :patch, data: { save_on_input: true } }
|
||||||
- else
|
- else
|
||||||
- form_options = { url: modifier_dossier_url(dossier), method: :patch }
|
- form_options = { url: modifier_dossier_url(dossier), method: :patch }
|
||||||
|
= render Attachment::DeleteFormComponent.new
|
||||||
%div
|
|
||||||
= form_tag('/attachments/:id', method: :delete, data: { 'turbo-method': :delete, turbo: true }, id: dom_id(ActiveStorage::Attachment.new, :delete)) do
|
|
||||||
-# otherwise the closing tag bugs
|
|
||||||
|
|
||||||
= form_for dossier, form_options.merge({ html: { id: 'dossier-edit-form', class: 'form', multipart: true, novalidate: 'novalidate' } }) do |f|
|
= form_for dossier, form_options.merge({ html: { id: 'dossier-edit-form', class: 'form', multipart: true, novalidate: 'novalidate' } }) do |f|
|
||||||
|
|
||||||
%header.mb-6
|
%header.mb-6
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
= render Attachment::DeleteFormComponent.new
|
||||||
= 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|
|
= 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
|
- dossier = commentaire.dossier
|
||||||
- placeholder = t('views.shared.dossiers.messages.form.write_message_to_administration_placeholder')
|
- placeholder = t('views.shared.dossiers.messages.form.write_message_to_administration_placeholder')
|
||||||
|
|
Loading…
Reference in a new issue