limitation des params selon le type de PJ

This commit is contained in:
Benoit Queyron 2024-07-16 10:59:57 +02:00
parent ec24ce3dad
commit 79ba52317a
No known key found for this signature in database
GPG key ID: 9E723480C7317E22
2 changed files with 8 additions and 1 deletions

View file

@ -20,6 +20,7 @@ class Attachment::EditComponent < ApplicationComponent
@user_can_replace = user_can_replace
@as_multiple = as_multiple
@auto_attach_url = auto_attach_url
# Adaptation pour la gestion des pièces jointes multiples
@attachments = attachments.presence || (kwargs.key?(:attachment) ? [kwargs.delete(:attachment)] : [])
@attachments << attached_file.attachment if attached_file.respond_to?(:attachment) && @attachments.empty?
@ -28,6 +29,7 @@ class Attachment::EditComponent < ApplicationComponent
# Utilisation du premier attachement comme référence pour la rétrocompatibilité
@attachment = @attachments.first
# When parent form has nested attributes, pass the form builder object_name
# to correctly infer the input attribute name.
@form_object_name = kwargs.delete(:form_object_name)
@ -54,7 +56,11 @@ class Attachment::EditComponent < ApplicationComponent
end
def destroy_attachment_path
attachment_path(dossier_id: champ&.dossier_id, stable_id: champ&.stable_id, row_id: champ&.row_id, auto_attach_url: @auto_attach_url, view_as: @view_as, direct_upload: @direct_upload)
if champ.present?
attachment_path(dossier_id: champ&.dossier_id, stable_id: champ&.stable_id, row_id: champ&.row_id)
else
attachment_path(auto_attach_url: @auto_attach_url, view_as: @view_as, direct_upload: @direct_upload)
end
end
def attachment_input_class

View file

@ -20,6 +20,7 @@ class AttachmentsController < ApplicationController
@attachment = @blob.attachments.find(params[:id])
@attachment.purge_later
flash.notice = 'La pièce jointe a bien été supprimée.'
if params[:dossier_id]
@champ = find_champ
else