2019-10-22 10:58:04 +02:00
|
|
|
|
-# Display a widget for uploading, editing and deleting a file attachment
|
|
|
|
|
|
|
|
|
|
- attachment = attached_file.attachment
|
|
|
|
|
- attachment_id = attachment ? attachment.id : SecureRandom.uuid
|
|
|
|
|
- persisted = attachment && attachment.persisted?
|
|
|
|
|
- accept = defined?(accept) ? accept : nil
|
|
|
|
|
- user_can_destroy = defined?(user_can_destroy) ? user_can_destroy : false
|
2020-07-29 12:15:58 +02:00
|
|
|
|
- direct_upload = direct_upload != nil ? false : true
|
2022-01-05 11:44:07 +01:00
|
|
|
|
- champ = form.object.is_a?(Champ) ? form.object : nil
|
2019-10-22 10:58:04 +02:00
|
|
|
|
|
|
|
|
|
.attachment
|
|
|
|
|
- if defined?(template) && template.attached?
|
|
|
|
|
%p.mb-1
|
|
|
|
|
Veuillez télécharger, remplir et joindre
|
|
|
|
|
= link_to('le modèle suivant', url_for(template), target: '_blank', rel: 'noopener')
|
|
|
|
|
|
|
|
|
|
- if persisted
|
2020-03-24 18:05:36 +01:00
|
|
|
|
.attachment-actions{ class: "attachment-actions-#{attachment_id}" }
|
2019-10-22 10:58:04 +02:00
|
|
|
|
.attachment-action
|
|
|
|
|
= render partial: "shared/attachment/show", locals: { attachment: attachment, user_can_upload: true }
|
|
|
|
|
- if user_can_destroy
|
|
|
|
|
.attachment-action
|
2021-03-16 15:11:54 +01:00
|
|
|
|
= link_to 'Supprimer', attachment_url(attachment.id, { signed_id: attachment.blob.signed_id }), remote: true, method: :delete, class: 'button small danger', data: { disable: true }, role: 'button'
|
2019-10-22 10:58:04 +02:00
|
|
|
|
.attachment-action
|
2020-03-24 18:05:36 +01:00
|
|
|
|
= button_tag 'Remplacer', type: 'button', class: 'button small', data: { 'toggle-target': ".attachment-input-#{attachment_id}" }
|
2019-10-22 10:58:04 +02:00
|
|
|
|
|
2020-03-30 15:34:56 +02:00
|
|
|
|
.attachment-error.hidden
|
|
|
|
|
.attachment-error-message
|
|
|
|
|
%p.attachment-error-title
|
|
|
|
|
Une erreur s’est produite pendant l’envoi du fichier.
|
|
|
|
|
%p.attachment-error-description
|
2022-02-02 18:04:41 +01:00
|
|
|
|
Une erreur inconnue s'est produite pendant l'envoi du fichier
|
2020-03-30 15:34:56 +02:00
|
|
|
|
= button_tag type: 'button', class: 'button attachment-error-retry', data: { 'input-target': ".attachment-input-#{attachment_id}" } do
|
|
|
|
|
%span.icon.retry
|
|
|
|
|
Ré-essayer
|
|
|
|
|
|
2019-10-22 10:58:04 +02:00
|
|
|
|
= form.file_field attached_file.name,
|
2020-03-24 18:05:36 +01:00
|
|
|
|
class: "attachment-input attachment-input-#{attachment_id} #{'hidden' if persisted}",
|
2019-10-22 10:58:04 +02:00
|
|
|
|
accept: accept,
|
2020-07-29 12:15:58 +02:00
|
|
|
|
direct_upload: direct_upload,
|
2022-01-05 11:44:07 +01:00
|
|
|
|
id: champ&.input_id,
|
|
|
|
|
aria: { describedby: champ&.describedby_id },
|
2020-03-30 15:34:56 +02:00
|
|
|
|
data: { 'auto-attach-url': auto_attach_url(form, form.object) }
|