2023-06-26 11:47:20 +02:00
|
|
|
.attachment.fr-upload-group{ { id: attachment ? dom_id(attachment, :edit) : nil, class: class_names("fr-mb-1w": !(as_multiple? && downloadable?)) }.compact, **replace_controller_attributes }
|
2022-05-11 08:57:25 +02:00
|
|
|
- if persisted?
|
2022-11-09 12:33:20 +01:00
|
|
|
%div{ id: dom_id(attachment, :persisted_row) }
|
|
|
|
.flex.flex-gap-2{ class: class_names("attachment-error": attachment.virus_scanner_error?) }
|
2022-11-21 18:32:17 +01:00
|
|
|
- if user_can_destroy?
|
2023-03-31 16:10:47 +02:00
|
|
|
= 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
|
2023-02-20 10:33:47 +01:00
|
|
|
= t('.delete')
|
2022-12-13 15:22:18 +01:00
|
|
|
- elsif user_can_replace?
|
2022-12-13 18:00:45 +01:00
|
|
|
= button_tag t('.replace'), **replace_button_options, class: "fr-btn fr-btn--tertiary fr-btn--sm", title: t(".replace_file", filename: attachment.filename)
|
2022-11-21 18:32:17 +01:00
|
|
|
|
2022-12-13 16:13:31 +01:00
|
|
|
- if downloadable?
|
|
|
|
= render Dsfr::DownloadComponent.new(attachment:)
|
|
|
|
- else
|
|
|
|
.fr-py-1v
|
2023-02-22 16:51:58 +01:00
|
|
|
%span.attachment-filename.fr-mr-1w= link_to_if(viewable?, attachment.filename.to_s, helpers.url_for(attachment.blob), title: t(".open_file", filename: attachment.filename), **helpers.external_link_attributes)
|
2022-11-22 15:47:28 +01:00
|
|
|
|
2022-11-22 17:12:16 +01:00
|
|
|
= render Attachment::ProgressComponent.new(attachment: attachment)
|
2022-05-11 08:57:25 +02:00
|
|
|
|
2022-11-09 12:33:20 +01:00
|
|
|
- if error?
|
|
|
|
%p.fr-error-text= error_message
|
|
|
|
|
|
|
|
- elsif first?
|
|
|
|
%p.fr-text--sm.fr-text-mention--grey.fr-mb-1w
|
|
|
|
- if max_file_size.present?
|
|
|
|
= t('.max_file_size', max_file_size: number_to_human_size(max_file_size))
|
2022-11-09 09:48:36 +01:00
|
|
|
- if allowed_formats
|
2022-11-22 19:25:45 +01:00
|
|
|
= t('.allowed_formats', formats: allowed_formats.join(', '))
|
2022-06-16 15:51:45 +02:00
|
|
|
|
2022-11-09 12:33:20 +01:00
|
|
|
|
|
|
|
- if !as_multiple?
|
2022-11-17 19:18:58 +01:00
|
|
|
= file_field(champ, field_name, **file_field_options)
|
2022-11-09 12:33:20 +01:00
|
|
|
|
2022-11-23 12:54:09 +01:00
|
|
|
- if persisted?
|
2022-12-07 18:36:03 +01:00
|
|
|
- Attachment::PendingPollComponent.new(attachment: attachment, poll_url:, context: poll_context).then do |component|
|
2022-11-23 12:54:09 +01:00
|
|
|
.fr-mt-2w
|
|
|
|
= render component
|
2022-11-09 12:33:20 +01:00
|
|
|
|
2022-11-24 14:05:53 +01:00
|
|
|
.attachment-upload-error.hidden
|
|
|
|
%p.fr-error-text= t('.errors.uploading')
|
|
|
|
= button_tag(**retry_button_options) do
|
|
|
|
= t(".retry")
|
2022-06-16 15:51:45 +02:00
|
|
|
|