Merge pull request #8207 from colinux/fix-attachments-ui
style: minor attachments improvements in edge cases
This commit is contained in:
commit
1963f46eac
5 changed files with 21 additions and 5 deletions
|
@ -35,3 +35,18 @@
|
|||
padding-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.attachment {
|
||||
// Anti-virus badge for just uploaded attachment when seen as downloadable
|
||||
.fr-download + .fr-badge {
|
||||
position: relative;
|
||||
top: -1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.attachment-multiple.fr-downloads-group.destroyable {
|
||||
ul {
|
||||
list-style-type: none;
|
||||
padding-inline-start: 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ class Attachment::MultipleComponent < ApplicationComponent
|
|||
attr_reader :form_object_name
|
||||
attr_reader :max
|
||||
attr_reader :user_can_destroy
|
||||
alias user_can_destroy? user_can_destroy
|
||||
attr_reader :user_can_download
|
||||
alias user_can_download? user_can_download
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.fr-mb-4w.attachment-multiple{ class: class_names("fr-downloads-group": user_can_download?) }
|
||||
.fr-mb-4w.attachment-multiple{ class: class_names("fr-downloads-group": user_can_download?, "destroyable": user_can_destroy?) }
|
||||
= template
|
||||
|
||||
%ul
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
- if commentaire.piece_jointe.attached?
|
||||
.fr-ml-2w
|
||||
= render Attachment::ShowComponent.new(attachment: commentaire.piece_jointe.attachment)
|
||||
= render Attachment::ShowComponent.new(attachment: commentaire.piece_jointe.attachment, new_tab: true)
|
||||
|
||||
- if show_reply_button?
|
||||
= button_tag type: 'button', class: 'button small message-answer-button', onclick: 'document.querySelector("#commentaire_body").focus()' do
|
||||
|
|
|
@ -250,14 +250,14 @@ describe 'The user' do
|
|||
expect(page).to have_text('white.png')
|
||||
|
||||
click_on("Supprimer le fichier file.pdf")
|
||||
expect(page).to have_no_text('file.pdf')
|
||||
expect(page).not_to have_text('file.pdf')
|
||||
expect(page).to have_text("La pièce jointe a bien été supprimée")
|
||||
|
||||
attach_file('Pièce justificative 1', Rails.root + 'spec/fixtures/files/black.png')
|
||||
|
||||
# Mark all attachments as safe to test turbo poll
|
||||
# They are not immediately attached in db, so we have to wait a bit before continuing
|
||||
# NOTE: we'res using files not used in other tests to avoid conflicts
|
||||
# NOTE: we're using files not used in other tests to avoid conflicts with concurrent tests
|
||||
attachments = Timeout.timeout(5) do
|
||||
filenames = ['white.png', 'black.png']
|
||||
attachments = ActiveStorage::Attachment.where(name: "piece_justificative_file").includes(:blob).filter do |attachment|
|
||||
|
@ -280,7 +280,7 @@ describe 'The user' do
|
|||
|
||||
visit current_path
|
||||
|
||||
expect(page).to have_no_text('file.pdf')
|
||||
expect(page).not_to have_text('file.pdf')
|
||||
expect(page).to have_text('white.png')
|
||||
expect(page).to have_text('black.png')
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue