Improve messagerie readability

This commit is contained in:
Mathieu Magnin 2017-12-14 17:10:13 +01:00
parent 410a12b966
commit 5c46db3b3d
5 changed files with 41 additions and 3 deletions

View file

@ -7,13 +7,23 @@
max-height: 350px;
overflow-y: scroll;
border: 1px solid $border-grey;
background: $light-grey;
padding: 2 * $default-spacer;
margin-bottom: $default-spacer;
border-radius: 4px;
> li {
display: flex;
align-items: flex-start;
margin-bottom: 2 * $default-padding;
margin-bottom: $default-padding;
padding: $default-padding;
background: #FFFFFF;
width: 80%;
border-radius: 3px;
&.from-me {
margin-left: auto;
}
}
}

View file

@ -0,0 +1,7 @@
module CommentaireHelper
def commentaire_is_from_me_class(commentaire, email)
if commentaire.email == email
"from-me"
end
end
end

View file

@ -5,7 +5,7 @@
.messagerie.container
%ul.messages-list
- @dossier.commentaires.each do |commentaire|
%li
%li{ class: commentaire_is_from_me_class(commentaire, current_gestionnaire.email) }
= render partial: "new_gestionnaire/shared/commentaires/commentaire", locals: { commentaire: commentaire, messagerie_seen_at: nil }
= render partial: "new_gestionnaire/shared/commentaires/form", locals: { commentaire: @commentaire, form_url: commentaire_avis_path(@avis) }

View file

@ -5,7 +5,7 @@
.messagerie.container
%ul.messages-list
- @dossier.commentaires.each do |commentaire|
%li
%li{ class: commentaire_is_from_me_class(commentaire, current_gestionnaire.email) }
= render partial: "new_gestionnaire/shared/commentaires/commentaire", locals: { commentaire: commentaire, messagerie_seen_at: @messagerie_seen_at }
= render partial: "new_gestionnaire/shared/commentaires/form", locals: { commentaire: @commentaire, form_url: commentaire_dossier_path(@dossier.procedure, @dossier) }

View file

@ -0,0 +1,21 @@
require 'rails_helper'
RSpec.describe CommentaireHelper, type: :helper do
describe ".commentaire_is_from_me_class" do
let(:commentaire) { create(:commentaire, email: "michel@pref.fr") }
subject { commentaire_is_from_me_class(commentaire, me) }
context "when commentaire is from me" do
let(:me) { "michel@pref.fr" }
it { is_expected.to eq("from-me") }
end
context "when commentaire is not from me" do
let(:me) { "roger@usager.fr" }
it { is_expected.to eq nil }
end
end
end