2024-02-13 08:04:27 +01:00
|
|
|
.attachment.fr-upload-group{ id: (attachment ? dom_id(attachment, :edit) : nil), class: class_names("fr-mb-1w": !(as_multiple? && attachments.any?(&:persisted?))) }
|
|
|
|
- if as_multiple?
|
|
|
|
- attachments.each do |attachment|
|
|
|
|
- if attachment.persisted?
|
|
|
|
%div{ id: dom_id(attachment, :persisted_row) }
|
|
|
|
.flex.flex-gap-2{ class: class_names("attachment-error": attachment.virus_scanner_error?) }
|
|
|
|
- if user_can_destroy?
|
|
|
|
= render NestedForms::OwnedButtonComponent.new(formaction: destroy_attachment_path, http_method: :delete, opt: {class: "fr-btn fr-btn--tertiary fr-btn--sm fr-icon-delete-line", title: t(".delete_file", filename: attachment.filename)}) do
|
|
|
|
= t('.delete')
|
|
|
|
|
|
|
|
- if downloadable?(attachment)
|
|
|
|
= render Dsfr::DownloadComponent.new(attachment: attachment)
|
|
|
|
- else
|
|
|
|
.fr-py-1v
|
|
|
|
%span.attachment-filename.fr-mr-1w= link_to_if(viewable?(attachment), attachment.filename.to_s, helpers.url_for(attachment.blob), title: t(".open_file", filename: attachment.filename), **helpers.external_link_attributes)
|
|
|
|
|
|
|
|
= render Attachment::ProgressComponent.new(attachment: attachment, ignore_antivirus: true)
|
|
|
|
|
|
|
|
- if error?(attachment)
|
|
|
|
%p.fr-error-text= error_message(attachment)
|
|
|
|
- else
|
|
|
|
- if persisted?
|
|
|
|
%div{ id: dom_id(attachment, :persisted_row) }
|
|
|
|
.flex.flex-gap-2{ class: class_names("attachment-error": attachment.virus_scanner_error?) }
|
|
|
|
- if user_can_destroy?
|
|
|
|
= render NestedForms::OwnedButtonComponent.new(formaction: destroy_attachment_path, http_method: :delete, opt: {class: "fr-btn fr-btn--tertiary fr-btn--sm fr-icon-delete-line", title: t(".delete_file", filename: attachment.filename)}) do
|
|
|
|
= t('.delete')
|
|
|
|
|
|
|
|
- if downloadable?(attachment)
|
|
|
|
= render Dsfr::DownloadComponent.new(attachment:)
|
|
|
|
- else
|
|
|
|
.fr-py-1v
|
|
|
|
%span.attachment-filename.fr-mr-1w= link_to_if(viewable?(attachment), attachment.filename.to_s, helpers.url_for(attachment.blob), title: t(".open_file", filename: attachment.filename), **helpers.external_link_attributes)
|
|
|
|
|
|
|
|
= render Attachment::ProgressComponent.new(attachment: attachment, ignore_antivirus: true)
|
|
|
|
|
|
|
|
- if error?(attachment)
|
|
|
|
%p.fr-error-text= error_message(attachment)
|
|
|
|
|
|
|
|
- if first? && !persisted?
|
2023-09-25 14:32:09 +02:00
|
|
|
%p.fr-hint-text.fr-mb-1w
|
2022-11-09 12:33:20 +01:00
|
|
|
- if max_file_size.present?
|
|
|
|
= t('.max_file_size', max_file_size: number_to_human_size(max_file_size))
|
2023-09-20 17:35:17 +02:00
|
|
|
- if allowed_formats.present?
|
2022-11-22 19:25:45 +01:00
|
|
|
= t('.allowed_formats', formats: allowed_formats.join(', '))
|
2024-04-15 12:34:22 +02:00
|
|
|
- if as_multiple?
|
|
|
|
= t('.multiple_files')
|
2022-06-16 15:51:45 +02:00
|
|
|
|
2024-02-13 08:04:27 +01:00
|
|
|
- if !persisted? || champ.present? && champ.titre_identite?
|
2022-11-17 19:18:58 +01:00
|
|
|
= file_field(champ, field_name, **file_field_options)
|
2022-11-09 12:33:20 +01:00
|
|
|
|
2024-02-13 08:04:27 +01:00
|
|
|
- attachments.filter(&:persisted?).each do |attachment|
|
|
|
|
- if attachment.persisted?
|
|
|
|
- Attachment::PendingPollComponent.new(attachment: attachment, poll_url: poll_url, context: poll_context).then do |component|
|
|
|
|
.fr-mt-2w
|
|
|
|
= render component
|
|
|
|
|
|
|
|
.attachment-upload-error.hidden
|
|
|
|
%p.fr-error-text= t('.errors.uploading')
|
|
|
|
= button_tag(**retry_button_options) do
|
|
|
|
= t(".retry")
|