Merge pull request #1107 from sgmap/improve-messagerie-ui

Improve messagerie readability
This commit is contained in:
Mathieu Magnin 2017-12-15 11:06:24 +01:00 committed by GitHub
commit ae0a22408b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 3 deletions

View file

@ -7,13 +7,23 @@
max-height: 350px; max-height: 350px;
overflow-y: scroll; overflow-y: scroll;
border: 1px solid $border-grey; border: 1px solid $border-grey;
background: $light-grey;
padding: 2 * $default-spacer; padding: 2 * $default-spacer;
margin-bottom: $default-spacer; margin-bottom: $default-spacer;
border-radius: 4px;
> li { > li {
display: flex; display: flex;
align-items: flex-start; 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 .messagerie.container
%ul.messages-list %ul.messages-list
- @dossier.commentaires.each do |commentaire| - @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/commentaire", locals: { commentaire: commentaire, messagerie_seen_at: nil }
= render partial: "new_gestionnaire/shared/commentaires/form", locals: { commentaire: @commentaire, form_url: commentaire_avis_path(@avis) } = render partial: "new_gestionnaire/shared/commentaires/form", locals: { commentaire: @commentaire, form_url: commentaire_avis_path(@avis) }

View file

@ -5,7 +5,7 @@
.messagerie.container .messagerie.container
%ul.messages-list %ul.messages-list
- @dossier.commentaires.each do |commentaire| - @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/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) } = 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