Refactor message attachements to use active_storage

This commit is contained in:
Paul Chavard 2019-06-25 17:12:44 +02:00
parent 85f7412fa6
commit 3cb39c2840
20 changed files with 59 additions and 66 deletions

View file

@ -1,6 +1,6 @@
.messagerie.container
%ul.messages-list
- dossier.commentaires.each do |commentaire|
- dossier.commentaires.with_attached_piece_jointe.each do |commentaire|
%li.message{ class: commentaire_is_from_me_class(commentaire, connected_user) }
= render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: connected_user, messagerie_seen_at: messagerie_seen_at }

View file

@ -2,8 +2,8 @@
= f.text_area :body, rows: 5, placeholder: 'Répondre ici', required: true, class: 'message-textarea'
.flex.justify-between.wrap
%div
= f.file_field :file, id: :file, accept: commentaire.file.accept_extension_list
%label{ for: :file }
= f.file_field :piece_jointe, id: 'piece_jointe', direct_upload: true
%label{ for: :piece_jointe }
.notice
(taille max : 20 Mo)

View file

@ -10,7 +10,10 @@
= commentaire_date(commentaire)
.rich-text= sanitize(simple_format(commentaire.body))
- if commentaire.file.present?
- if commentaire.piece_jointe.attached?
.attachment-link
= render partial: "shared/attachment/show", locals: { attachment: commentaire.piece_jointe.attachment }
- elsif commentaire.file.present?
.attachment-link
= link_to commentaire.file_url, class: "button", target: "_blank", rel: "noopener", title: "Télécharger" do
%span.icon.attachment