diff --git a/app/assets/stylesheets/new_design/_colors.scss b/app/assets/stylesheets/new_design/_colors.scss index c46c85b3def..059b41ef174 100644 --- a/app/assets/stylesheets/new_design/_colors.scss +++ b/app/assets/stylesheets/new_design/_colors.scss @@ -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%); diff --git a/app/assets/stylesheets/new_design/dossier_champs.scss b/app/assets/stylesheets/new_design/dossier_champs.scss index 7b663274c6c..fd8183ca632 100644 --- a/app/assets/stylesheets/new_design/dossier_champs.scss +++ b/app/assets/stylesheets/new_design/dossier_champs.scss @@ -1,6 +1,7 @@ +@import "colors"; @import "constants"; -.dossier-champs { +table.dossier-champs { th, td { vertical-align: top; @@ -9,4 +10,16 @@ .libelle { width: 250px; } + + td.updated-at { + visibility: hidden; + font-size: 13px; + color: $grey; + text-align: right; + width: 190px; + } + + tr:hover .updated-at { + visibility: visible; + } } diff --git a/app/assets/stylesheets/new_design/utils.scss b/app/assets/stylesheets/new_design/utils.scss index 599609dd538..44d53176c28 100644 --- a/app/assets/stylesheets/new_design/utils.scss +++ b/app/assets/stylesheets/new_design/utils.scss @@ -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; +} diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 937b0797114..702805a18fe 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -3,13 +3,14 @@ class DossiersController < ProceduresController 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) + @follow = current_gestionnaire.follows.find_by(dossier: dossier) end def messagerie @@ -192,5 +193,10 @@ def check_attestation_emailable 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 diff --git a/app/helpers/dossier_helper.rb b/app/helpers/dossier_helper.rb index aade090280f..0291078c5df 100644 --- a/app/helpers/dossier_helper.rb +++ b/app/helpers/dossier_helper.rb @@ -8,4 +8,10 @@ def button_or_label_class(dossier) 'refused' end end + + def updated_at_bg_class(seen_at, updated_at) + if seen_at&.<(updated_at) + "highlighted" + end + end end diff --git a/app/models/follow.rb b/app/models/follow.rb index 2df639902f5..ea18f9e0ff3 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -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 diff --git a/app/views/new_gestionnaire/avis/show.html.haml b/app/views/new_gestionnaire/avis/show.html.haml index cb8994db3a6..a267a12ea25 100644 --- a/app/views/new_gestionnaire/avis/show.html.haml +++ b/app/views/new_gestionnaire/avis/show.html.haml @@ -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, follow: nil } - if @dossier.procedure.use_api_carto .accompagnateur-title Cartographie diff --git a/app/views/new_gestionnaire/dossiers/_champs.html.haml b/app/views/new_gestionnaire/dossiers/_champs.html.haml index 7d71293305e..1cf25b14528 100644 --- a/app/views/new_gestionnaire/dossiers/_champs.html.haml +++ b/app/views/new_gestionnaire/dossiers/_champs.html.haml @@ -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 @@ -30,4 +30,10 @@ %th.libelle = "#{c.libelle} :" %td.rich-text - = sanitize(c.value) + %span{ class: updated_at_bg_class(follow&.demande_seen_at, c.updated_at) } + = sanitize(c.value) + - if c.type_champ != "header_section" + %td.updated-at + %span{ class: updated_at_bg_class(follow&.demande_seen_at, c.updated_at) } + modifié le + = c.updated_at.strftime("%d/%m/%Y à %H:%M") diff --git a/app/views/new_gestionnaire/dossiers/print.html.haml b/app/views/new_gestionnaire/dossiers/print.html.haml index d557a198e33..1f4d1025a4a 100644 --- a/app/views/new_gestionnaire/dossiers/print.html.haml +++ b/app/views/new_gestionnaire/dossiers/print.html.haml @@ -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 diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index 0519f69f533..7fcb3c32410 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -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, follow: @follow } - if @dossier.procedure.use_api_carto .accompagnateur-title Cartographie diff --git a/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb b/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb index 3ad9c9cb95a..a3ddc9f1db3 100644 --- a/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb +++ b/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb @@ -1,31 +1,47 @@ describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do - before { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs } + before { view.extend DossierHelper } - context "there are some champs" do - let(:dossier) { create(:dossier) } - let(:champ1) { create(:champ, :checkbox, value: "true") } - let(:champ2) { create(:champ, :header_section, value: "Section") } - let(:champ3) { create(:champ, :explication, value: "mazette") } - let(:champ4) { create(:champ, :dossier_link, value: dossier.id) } - let(:champs) { [champ1, champ2, champ3, champ4] } + subject { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs, dossier: dossier, follow: follow } + + let(:dossier) { create(:dossier) } + let(:champ1) { create(:champ, :checkbox, value: "true") } + let(:champ2) { create(:champ, :header_section, value: "Section") } + let(:champ3) { create(:champ, :explication, value: "mazette") } + let(:champ4) { create(:champ, :dossier_link, value: dossier.id) } + let(:champs) { [champ1, champ2, champ3, champ4] } + let(:seen_at) { champ1.updated_at + 1.hour } + let(:follow) { create(:follow, gestionnaire: create(:gestionnaire), dossier: dossier, demande_seen_at: seen_at) } - it { expect(rendered).to include(champ1.libelle) } - it { expect(rendered).to include(champ1.value) } + context "there are some champs" do + it { is_expected.to include(champ1.libelle) } + it { is_expected.to include(champ1.value) } - it { expect(rendered).to have_css(".header-section") } - it { expect(rendered).to include(champ2.libelle) } + it { is_expected.to have_css(".header-section") } + it { is_expected.to include(champ2.libelle) } - it { expect(rendered).not_to include(champ3.libelle) } - it { expect(rendered).not_to include(champ3.value) } + it { is_expected.not_to include(champ3.libelle) } + it { is_expected.not_to include(champ3.value) } - it { expect(rendered).to have_link("Dossier nº #{dossier.id}") } - it { expect(rendered).to include(dossier.text_summary) } + it { is_expected.to have_link("Dossier nº #{dossier.id}") } + it { is_expected.to include(dossier.text_summary) } end context "with a dossier_link champ but without value" do let(:champ) { create(:champ, :dossier_link, value: nil) } let(:champs) { [champ] } - it { expect(rendered).to include("Pas de dossier associé") } + it { is_expected.to include("Pas de dossier associé") } + end + + context "with a seen_at after champ updated_at" do + let(:seen_at) { champ1.updated_at + 1.hour } + + it { is_expected.not_to have_css(".highlighted") } + end + + context "with a seen_at after champ updated_at" do + let(:seen_at) { champ1.updated_at - 1.hour } + + it { is_expected.to have_css(".highlighted") } end end diff --git a/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb b/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb index 68ad70c78f3..966912d4fbc 100644 --- a/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb +++ b/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb @@ -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 }