[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%);
|
$light-green: lighten($green, 25%);
|
||||||
$dark-green: darken($green, 20%);
|
$dark-green: darken($green, 20%);
|
||||||
$orange: #F59415;
|
$orange: #F59415;
|
||||||
|
$orange-bg: lighten($orange, 35%);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
@import "colors";
|
||||||
@import "constants";
|
@import "constants";
|
||||||
|
|
||||||
.dossier-champs {
|
.table.dossier-champs {
|
||||||
th,
|
th,
|
||||||
td {
|
td {
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
|
@ -9,4 +10,23 @@
|
||||||
.libelle {
|
.libelle {
|
||||||
width: 250px;
|
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 {
|
.pull-left {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
@ -32,3 +34,8 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 60px 0;
|
margin: 60px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.highlighted {
|
||||||
|
background: $orange-bg;
|
||||||
|
color: $black;
|
||||||
|
}
|
||||||
|
|
|
@ -3,13 +3,14 @@ module NewGestionnaire
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
include ActionView::Helpers::TextHelper
|
include ActionView::Helpers::TextHelper
|
||||||
|
|
||||||
|
after_action :mark_demande_as_read, only: :show
|
||||||
|
|
||||||
def attestation
|
def attestation
|
||||||
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
dossier.notifications.demande.mark_as_read
|
@demande_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.demande_seen_at
|
||||||
current_gestionnaire.mark_tab_as_seen(dossier, :demande)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def messagerie
|
def messagerie
|
||||||
|
@ -192,5 +193,10 @@ module NewGestionnaire
|
||||||
|
|
||||||
dossier&.attestation&.emailable?
|
dossier&.attestation&.emailable?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mark_demande_as_read
|
||||||
|
dossier.notifications.demande.mark_as_read
|
||||||
|
current_gestionnaire.mark_tab_as_seen(dossier, :demande)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,4 +8,10 @@ module DossierHelper
|
||||||
'refused'
|
'refused'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def highlight_if_unseen_class(seen_at, updated_at)
|
||||||
|
if seen_at&.<(updated_at)
|
||||||
|
"highlighted"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,9 +9,9 @@ class Follow < ActiveRecord::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_default_date
|
def set_default_date
|
||||||
self.demande_seen_at = DateTime.now
|
self.demande_seen_at ||= DateTime.now
|
||||||
self.annotations_privees_seen_at = DateTime.now
|
self.annotations_privees_seen_at ||= DateTime.now
|
||||||
self.avis_seen_at = DateTime.now
|
self.avis_seen_at ||= DateTime.now
|
||||||
self.messagerie_seen_at = DateTime.now
|
self.messagerie_seen_at ||= DateTime.now
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
- champs = @dossier.ordered_champs.decorate
|
- champs = @dossier.ordered_champs.decorate
|
||||||
- if champs.any?
|
- if champs.any?
|
||||||
.card
|
.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
|
- if @dossier.procedure.use_api_carto
|
||||||
.accompagnateur-title Cartographie
|
.accompagnateur-title Cartographie
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
%tr
|
%tr
|
||||||
- case c.type_champ
|
- case c.type_champ
|
||||||
- when "header_section"
|
- when "header_section"
|
||||||
%th.header-section{ colspan: 2 }
|
%th.header-section{ colspan: 3 }
|
||||||
= c.libelle
|
= c.libelle
|
||||||
- when "multiple_drop_down_list"
|
- when "multiple_drop_down_list"
|
||||||
%th.libelle
|
%th.libelle
|
||||||
|
@ -34,4 +34,10 @@
|
||||||
%th.libelle
|
%th.libelle
|
||||||
= "#{c.libelle} :"
|
= "#{c.libelle} :"
|
||||||
%td.rich-text
|
%td.rich-text
|
||||||
|
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
|
||||||
= sanitize(c.value)
|
= 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
|
- champs = @dossier.ordered_champs.decorate
|
||||||
- if champs.any?
|
- if champs.any?
|
||||||
= render partial: "champs", locals: { champs: champs }
|
= render partial: "champs", locals: { champs: champs, dossier: @dossier }
|
||||||
|
|
||||||
- if @dossier.procedure.use_api_carto
|
- if @dossier.procedure.use_api_carto
|
||||||
%h3 Cartographie
|
%h3 Cartographie
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
- champs = @dossier.ordered_champs.includes(:type_de_champ).decorate
|
- champs = @dossier.ordered_champs.includes(:type_de_champ).decorate
|
||||||
- if champs.any?
|
- if champs.any?
|
||||||
.card
|
.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
|
- if @dossier.procedure.use_api_carto
|
||||||
.accompagnateur-title Cartographie
|
.accompagnateur-title Cartographie
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
|
describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
|
||||||
let(:gestionnaire) { create(:gestionnaire) }
|
let(:gestionnaire) { create(:gestionnaire) }
|
||||||
|
let(:demande_seen_at) { nil }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
view.extend DossierHelper
|
||||||
view.extend DossierLinkHelper
|
view.extend DossierLinkHelper
|
||||||
allow(view).to receive(:current_gestionnaire).and_return(gestionnaire)
|
allow(view).to receive(:current_gestionnaire).and_return(gestionnaire)
|
||||||
end
|
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
|
context "there are some champs" do
|
||||||
let(:dossier) { create(:dossier) }
|
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é") }
|
it { is_expected.to include("Pas de dossier associé") }
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
describe 'new_gestionnaire/dossiers/show.html.haml', type: :view do
|
describe 'new_gestionnaire/dossiers/show.html.haml', type: :view do
|
||||||
|
before { view.extend DossierHelper }
|
||||||
|
|
||||||
let(:current_gestionnaire) { create(:gestionnaire) }
|
let(:current_gestionnaire) { create(:gestionnaire) }
|
||||||
let(:individual) { nil }
|
let(:individual) { nil }
|
||||||
let(:entreprise) { nil }
|
let(:entreprise) { nil }
|
||||||
|
|
Loading…
Reference in a new issue