[Fix #1016] display notifications for champs publics
This commit is contained in:
parent
dfbd52c7a0
commit
c6be745067
12 changed files with 81 additions and 13 deletions
|
@ -12,3 +12,4 @@ $lighter-green: lighten($green, 30%);
|
|||
$light-green: lighten($green, 25%);
|
||||
$dark-green: darken($green, 20%);
|
||||
$orange: #F59415;
|
||||
$orange-bg: lighten($orange, 35%);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
@import "colors";
|
||||
@import "constants";
|
||||
|
||||
.dossier-champs {
|
||||
.table.dossier-champs {
|
||||
th,
|
||||
td {
|
||||
vertical-align: top;
|
||||
|
@ -9,4 +10,23 @@
|
|||
.libelle {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
td.updated-at {
|
||||
font-size: 13px;
|
||||
color: $grey;
|
||||
text-align: right;
|
||||
width: 190px;
|
||||
|
||||
> span {
|
||||
opacity: 0;
|
||||
|
||||
&.highlighted {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tr:hover .updated-at > span {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
@import "colors";
|
||||
|
||||
.pull-left {
|
||||
float: left;
|
||||
}
|
||||
|
@ -32,3 +34,8 @@
|
|||
text-align: center;
|
||||
margin: 60px 0;
|
||||
}
|
||||
|
||||
.highlighted {
|
||||
background: $orange-bg;
|
||||
color: $black;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,14 @@ module NewGestionnaire
|
|||
include ActionView::Helpers::NumberHelper
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
||||
after_action :mark_demande_as_read, only: :show
|
||||
|
||||
def attestation
|
||||
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
||||
end
|
||||
|
||||
def show
|
||||
dossier.notifications.demande.mark_as_read
|
||||
current_gestionnaire.mark_tab_as_seen(dossier, :demande)
|
||||
@demande_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.demande_seen_at
|
||||
end
|
||||
|
||||
def messagerie
|
||||
|
@ -192,5 +193,10 @@ module NewGestionnaire
|
|||
|
||||
dossier&.attestation&.emailable?
|
||||
end
|
||||
|
||||
def mark_demande_as_read
|
||||
dossier.notifications.demande.mark_as_read
|
||||
current_gestionnaire.mark_tab_as_seen(dossier, :demande)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,4 +8,10 @@ module DossierHelper
|
|||
'refused'
|
||||
end
|
||||
end
|
||||
|
||||
def highlight_if_unseen_class(seen_at, updated_at)
|
||||
if seen_at&.<(updated_at)
|
||||
"highlighted"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,9 +9,9 @@ class Follow < ActiveRecord::Base
|
|||
private
|
||||
|
||||
def set_default_date
|
||||
self.demande_seen_at = DateTime.now
|
||||
self.annotations_privees_seen_at = DateTime.now
|
||||
self.avis_seen_at = DateTime.now
|
||||
self.messagerie_seen_at = DateTime.now
|
||||
self.demande_seen_at ||= DateTime.now
|
||||
self.annotations_privees_seen_at ||= DateTime.now
|
||||
self.avis_seen_at ||= DateTime.now
|
||||
self.messagerie_seen_at ||= DateTime.now
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
- champs = @dossier.ordered_champs.decorate
|
||||
- if champs.any?
|
||||
.card
|
||||
= render partial: 'new_gestionnaire/dossiers/champs', locals: { champs: champs }
|
||||
= render partial: 'new_gestionnaire/dossiers/champs', locals: { champs: champs, dossier: @dossier, demande_seen_at: nil }
|
||||
|
||||
- if @dossier.procedure.use_api_carto
|
||||
.accompagnateur-title Cartographie
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
%tr
|
||||
- case c.type_champ
|
||||
- when "header_section"
|
||||
%th.header-section{ colspan: 2 }
|
||||
%th.header-section{ colspan: 3 }
|
||||
= c.libelle
|
||||
- when "multiple_drop_down_list"
|
||||
%th.libelle
|
||||
|
@ -34,4 +34,10 @@
|
|||
%th.libelle
|
||||
= "#{c.libelle} :"
|
||||
%td.rich-text
|
||||
= sanitize(c.value)
|
||||
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
||||
= sanitize(c.value)
|
||||
- if c.type_champ != "header_section"
|
||||
%td.updated-at
|
||||
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
||||
modifié le
|
||||
= c.updated_at.localtime.strftime("%d/%m/%Y à %H:%M")
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
- champs = @dossier.ordered_champs.decorate
|
||||
- if champs.any?
|
||||
= render partial: "champs", locals: { champs: champs }
|
||||
= render partial: "champs", locals: { champs: champs, dossier: @dossier }
|
||||
|
||||
- if @dossier.procedure.use_api_carto
|
||||
%h3 Cartographie
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
- champs = @dossier.ordered_champs.includes(:type_de_champ).decorate
|
||||
- if champs.any?
|
||||
.card
|
||||
= render partial: "champs", locals: { champs: champs }
|
||||
= render partial: "champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: @demande_seen_at }
|
||||
|
||||
- if @dossier.procedure.use_api_carto
|
||||
.accompagnateur-title Cartographie
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
let(:demande_seen_at) { nil }
|
||||
|
||||
before do
|
||||
view.extend DossierHelper
|
||||
view.extend DossierLinkHelper
|
||||
allow(view).to receive(:current_gestionnaire).and_return(gestionnaire)
|
||||
end
|
||||
|
||||
subject { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs }
|
||||
subject { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs, demande_seen_at: demande_seen_at }
|
||||
|
||||
context "there are some champs" do
|
||||
let(:dossier) { create(:dossier) }
|
||||
|
@ -48,4 +50,22 @@ describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
|
|||
|
||||
it { is_expected.to include("Pas de dossier associé") }
|
||||
end
|
||||
|
||||
context "with seen_at" do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:champ1) { create(:champ, :checkbox, value: "true") }
|
||||
let(:champs) { [champ1] }
|
||||
|
||||
context "with a demande_seen_at after champ updated_at" do
|
||||
let(:demande_seen_at) { champ1.updated_at + 1.hour }
|
||||
|
||||
it { is_expected.not_to have_css(".highlighted") }
|
||||
end
|
||||
|
||||
context "with a demande_seen_at after champ updated_at" do
|
||||
let(:demande_seen_at) { champ1.updated_at - 1.hour }
|
||||
|
||||
it { is_expected.to have_css(".highlighted") }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
describe 'new_gestionnaire/dossiers/show.html.haml', type: :view do
|
||||
before { view.extend DossierHelper }
|
||||
|
||||
let(:current_gestionnaire) { create(:gestionnaire) }
|
||||
let(:individual) { nil }
|
||||
let(:entreprise) { nil }
|
||||
|
|
Loading…
Reference in a new issue