style(attachments): improve when we can download our multiple attachments (dossier en_construction)

This commit is contained in:
Colin Darie 2022-11-24 13:00:12 +01:00
parent 920f90d2e3
commit 1db40de70e
5 changed files with 19 additions and 7 deletions

View file

@ -21,3 +21,14 @@
margin-top: 0.5rem; margin-top: 0.5rem;
} }
} }
.attachment-multiple:not(.fr-downloads-group) {
ul {
list-style-type: none;
padding-inline-start: 0;
}
li {
padding-bottom: 0;
}
}

View file

@ -170,8 +170,7 @@
input[type=number], input[type=number],
input[type=tel], input[type=tel],
textarea, textarea,
select, select {
.attachment {
display: block; display: block;
margin-bottom: $default-fields-spacer; margin-bottom: $default-fields-spacer;

View file

@ -1,4 +1,4 @@
.fr-mb-2w.attachment.fr-upload-group{ id: attachment ? dom_id(attachment, :edit) : nil } .attachment.fr-upload-group{ id: attachment ? dom_id(attachment, :edit) : nil, class: class_names("fr-mb-2w": !(as_multiple? && downloadable?)) }
- if persisted? - if persisted?
%div{ id: dom_id(attachment, :persisted_row) } %div{ id: dom_id(attachment, :persisted_row) }
.flex.flex-gap-2{ class: class_names("attachment-error": attachment.virus_scanner_error?) } .flex.flex-gap-2{ class: class_names("attachment-error": attachment.virus_scanner_error?) }

View file

@ -10,6 +10,7 @@ class Attachment::MultipleComponent < ApplicationComponent
attr_reader :max attr_reader :max
attr_reader :user_can_destroy attr_reader :user_can_destroy
attr_reader :user_can_download attr_reader :user_can_download
alias user_can_download? user_can_download
delegate :count, :empty?, to: :attachments, prefix: true delegate :count, :empty?, to: :attachments, prefix: true

View file

@ -1,9 +1,10 @@
.fr-mb-4w.attachment-multiple .fr-mb-4w.attachment-multiple{ class: class_names("fr-downloads-group": user_can_download?) }
= template = template
- each_attachment do |attachment, index| %ul
%div{ id: dom_id(attachment) } - each_attachment do |attachment, index|
= render Attachment::EditComponent.new(champ:, attached_file:, attachment:, index:, as_multiple: true, user_can_destroy:, user_can_download:) %li{ id: dom_id(attachment) }
= render Attachment::EditComponent.new(champ:, attached_file:, attachment:, index:, as_multiple: true, user_can_destroy:, user_can_download:)
%div{ id: empty_component_id, class: class_names("hidden": !can_attach_next?) } %div{ id: empty_component_id, class: class_names("hidden": !can_attach_next?) }
= render Attachment::EditComponent.new(champ:, attached_file:, attachment: nil, index: attachments_count, user_can_destroy:) = render Attachment::EditComponent.new(champ:, attached_file:, attachment: nil, index: attachments_count, user_can_destroy:)