messagerie: add a reply button next to the latest message

This commit is contained in:
Pierre de La Morinerie 2019-07-16 10:11:24 +00:00
parent 09efd06dff
commit 92dd91a31b
10 changed files with 39 additions and 12 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path d="M74.524 65.23l-3.498-5.592c-6.497-10.413-18.79-17.191-33.783-17.673l-.12 17.602c.1 1.265-1.002 1.856-1.744 1.346L3.101 32.538c-2.57-2.624 0-4.317 0-4.317L34.454 2.483c1.544-1.174 2.802-.77 2.801 1.16l-.112 17.33c20.69.868 37.013 18.232 37.281 37.996l.06 4.424zM4.76 30.905l28.786 23.912v-16.42h1.899c14.593 0 26.986 5.524 34.982 14.299-2.698-15.91-17.291-28.059-34.982-28.059h-1.9V8.535z" stroke-width="3.182" stroke-linejoin="round" transform="matrix(.31704 0 0 .3003 -.132 1.934)" fill="#0069cc" stroke="#0069cc"/></svg>

After

Width:  |  Height:  |  Size: 594 B

View file

@ -91,6 +91,10 @@
background-image: image-url("icons/mail.svg"); background-image: image-url("icons/mail.svg");
} }
&.reply {
background-image: image-url("icons/reply.svg");
}
&.search { &.search {
background-image: image-url("icons/search-blue.svg"); background-image: image-url("icons/search-blue.svg");
} }

View file

@ -38,4 +38,8 @@
.attachment-link { .attachment-link {
margin-top: $default-spacer; margin-top: $default-spacer;
} }
.message-answer-button {
margin-left: auto;
}
} }

View file

@ -0,0 +1,9 @@
module MessagerieHelper
def show_reply_button(commentaire, connected_user)
commentaire.dossier.present? &&
commentaire.dossier.messagerie_available? &&
commentaire.dossier.user == connected_user &&
!commentaire.sent_by?(connected_user) &&
commentaire.dossier.commentaires.last == commentaire
end
end

View file

@ -63,7 +63,7 @@
%ul.messages-list %ul.messages-list
- @dossier.commentaires.with_attached_piece_jointe.each do |commentaire| - @dossier.commentaires.with_attached_piece_jointe.each do |commentaire|
%li %li
= render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: current_gestionnaire, messagerie_seen_at: nil } = render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: current_gestionnaire, messagerie_seen_at: nil, show_reply_button: false }
%script{ type: "text/javascript" } %script{ type: "text/javascript" }
window.print(); window.print();

View file

@ -21,6 +21,7 @@
%span.icon.person %span.icon.person
%span.icon.super-admin %span.icon.super-admin
%span.icon.mail %span.icon.mail
%span.icon.reply
%span.icon.search %span.icon.search
%span.icon.sign-out %span.icon.sign-out
%span.icon.info %span.icon.info

View file

@ -2,7 +2,7 @@
%ul.messages-list %ul.messages-list
- dossier.commentaires.with_attached_piece_jointe.each do |commentaire| - dossier.commentaires.with_attached_piece_jointe.each do |commentaire|
%li.message{ class: commentaire_is_from_me_class(commentaire, connected_user) } %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 } = render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: connected_user, messagerie_seen_at: messagerie_seen_at, show_reply_button: show_reply_button(commentaire, connected_user) }
- if dossier.messagerie_available? - if dossier.messagerie_available?
= render partial: "shared/dossiers/messages/form", locals: { commentaire: new_commentaire, form_url: form_url } = render partial: "shared/dossiers/messages/form", locals: { commentaire: new_commentaire, form_url: form_url }

View file

@ -10,11 +10,17 @@
= commentaire_date(commentaire) = commentaire_date(commentaire)
.rich-text= sanitize(simple_format(commentaire.body)) .rich-text= sanitize(simple_format(commentaire.body))
- if commentaire.piece_jointe.attached? .message-extras.flex.justify-start
.attachment-link - if commentaire.piece_jointe.attached?
= render partial: "shared/attachment/show", locals: { attachment: commentaire.piece_jointe.attachment } .attachment-link
- elsif commentaire.file.present? = render partial: "shared/attachment/show", locals: { attachment: commentaire.piece_jointe.attachment }
.attachment-link - elsif commentaire.file.present?
= link_to commentaire.file_url, class: "button", target: "_blank", rel: "noopener", title: "Télécharger" do .attachment-link
%span.icon.attachment = link_to commentaire.file_url, class: "button", target: "_blank", rel: "noopener", title: "Télécharger" do
= commentaire.file_identifier %span.icon.attachment
= commentaire.file_identifier
- if show_reply_button
= button_tag type: 'button', class: 'button small message-answer-button', onclick: 'document.querySelector("#commentaire_body").focus()' do
%span.icon.reply
Répondre

View file

@ -4,6 +4,6 @@
%h3.tab-title Dernier message %h3.tab-title Dernier message
.message.inverted-background .message.inverted-background
= render partial: "shared/dossiers/messages/message", locals: { commentaire: latest_message, connected_user: current_user, messagerie_seen_at: nil } = render partial: "shared/dossiers/messages/message", locals: { commentaire: latest_message, connected_user: current_user, messagerie_seen_at: nil, show_reply_button: false }
= link_to commentaire_answer_action(latest_message, current_user), messagerie_dossier_url(dossier, anchor: 'new_commentaire'), class: 'button send' = link_to commentaire_answer_action(latest_message, current_user), messagerie_dossier_url(dossier, anchor: 'new_commentaire'), class: 'button send'

View file

@ -1,12 +1,14 @@
describe 'shared/dossiers/messages/message.html.haml', type: :view do describe 'shared/dossiers/messages/message.html.haml', type: :view do
before { view.extend DossierHelper } before { view.extend DossierHelper }
subject { render 'shared/dossiers/messages/message.html.haml', commentaire: commentaire, messagerie_seen_at: seen_at, connected_user: dossier.user } subject { render 'shared/dossiers/messages/message.html.haml', commentaire: commentaire, messagerie_seen_at: seen_at, connected_user: dossier.user, show_reply_button: true }
let(:dossier) { create(:dossier, :en_construction) } let(:dossier) { create(:dossier, :en_construction) }
let(:commentaire) { create(:commentaire, dossier: dossier) } let(:commentaire) { create(:commentaire, dossier: dossier) }
let(:seen_at) { commentaire.created_at + 1.hour } let(:seen_at) { commentaire.created_at + 1.hour }
it { is_expected.to have_button("Répondre") }
context "with a seen_at after commentaire created_at" do context "with a seen_at after commentaire created_at" do
let(:seen_at) { commentaire.created_at + 1.hour } let(:seen_at) { commentaire.created_at + 1.hour }