diff --git a/app/assets/javascripts/new_design/messagerie.js b/app/assets/javascripts/new_design/messagerie.js index 1b8d1d324..5f7c67a08 100644 --- a/app/assets/javascripts/new_design/messagerie.js +++ b/app/assets/javascripts/new_design/messagerie.js @@ -1,7 +1,23 @@ TPS.scrollMessagerie = function () { + var scrollTo = function ($container, $scrollTo) { + $container.scrollTop( + $scrollTo.offset().top - $container.offset().top + $container.scrollTop() + ); + } + + var scrollToBottom = function ($container) { + $container.scrollTop($container.prop('scrollHeight')); + } + var $ul = $(".messagerie ul").first(); if($ul.length) { - $ul.scrollTop($ul.prop('scrollHeight')); + var $elementToScroll = $('.date.highlighted').first(); + + if ($elementToScroll.length != 0) { + scrollTo($ul, $elementToScroll); + } else { + scrollToBottom($ul); + } } }; diff --git a/app/assets/stylesheets/new_design/_colors.scss b/app/assets/stylesheets/new_design/_colors.scss index c46c85b3d..059b41ef1 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 7b663274c..8260c9777 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,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; + } } diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index b5f428c2e..41769313d 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -7,6 +7,11 @@ margin-bottom: 20px; } + @mixin notice-text-style { + font-size: 14px; + color: $grey; + } + label { margin-bottom: $default-padding; display: block; @@ -16,10 +21,24 @@ } .notice { - font-size: 14px; + @include notice-text-style; display: block; margin-top: $default-spacer; - color: $grey; + } + } + + .champ { + .updated-at { + @include notice-text-style; + float: right; + display: inline-block; + margin-left: $default-spacer; + visibility: hidden; + } + + &:hover .updated-at, + .updated-at.highlighted { + visibility: visible; } } diff --git a/app/assets/stylesheets/new_design/utils.scss b/app/assets/stylesheets/new_design/utils.scss index 599609dd5..44d53176c 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 937b07971..6f78b3bff 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -3,29 +3,30 @@ module NewGestionnaire include ActionView::Helpers::NumberHelper include ActionView::Helpers::TextHelper + after_action :mark_demande_as_read, only: :show + after_action :mark_messagerie_as_read, only: [:messagerie, :create_commentaire] + after_action :mark_avis_as_read, only: [:avis, :create_avis] + after_action :mark_annotations_privees_as_read, only: [:annotations_privees, :update_annotations] + 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 - dossier.notifications.messagerie.mark_as_read - current_gestionnaire.mark_tab_as_seen(dossier, :messagerie) @commentaire = Commentaire.new + @messagerie_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.messagerie_seen_at end def annotations_privees - dossier.notifications.annotations_privees.mark_as_read - current_gestionnaire.mark_tab_as_seen(dossier, :annotations_privees) + @annotations_privees_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.annotations_privees_seen_at end def avis - dossier.notifications.avis.mark_as_read - current_gestionnaire.mark_tab_as_seen(dossier, :avis) + @avis_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.avis_seen_at end def personnes_impliquees @@ -192,5 +193,25 @@ 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 + + def mark_messagerie_as_read + dossier.notifications.messagerie.mark_as_read + current_gestionnaire.mark_tab_as_seen(dossier, :messagerie) + end + + def mark_avis_as_read + dossier.notifications.avis.mark_as_read + current_gestionnaire.mark_tab_as_seen(dossier, :avis) + end + + def mark_annotations_privees_as_read + dossier.notifications.annotations_privees.mark_as_read + current_gestionnaire.mark_tab_as_seen(dossier, :annotations_privees) + end end end diff --git a/app/helpers/dossier_helper.rb b/app/helpers/dossier_helper.rb index aade09028..3034af966 100644 --- a/app/helpers/dossier_helper.rb +++ b/app/helpers/dossier_helper.rb @@ -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 diff --git a/app/models/follow.rb b/app/models/follow.rb index 2df639902..ea18f9e0f 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/_avis_list.html.haml b/app/views/new_gestionnaire/avis/_avis_list.html.haml index 5520cb025..8828f315e 100644 --- a/app/views/new_gestionnaire/avis/_avis_list.html.haml +++ b/app/views/new_gestionnaire/avis/_avis_list.html.haml @@ -15,7 +15,8 @@ %span.confidentiel confidentiel %span.icon.lock{ title: "Cet avis n'est pas affiché avec les autres experts consultés" } - %span.date Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y')} + %span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.created_at) } + Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y à %H:%M')} %p= avis.introduction .answer.flex.align-start @@ -24,7 +25,8 @@ %h2.gestionnaire = (avis.email_to_display == current_gestionnaire.email) ? 'Vous' : avis.email_to_display - if avis.answer.present? - %span.date Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y')} + %span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.updated_at) } + Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y à %H:%M')} - else %span.waiting En attente de réponse %p= avis.answer diff --git a/app/views/new_gestionnaire/avis/instruction.html.haml b/app/views/new_gestionnaire/avis/instruction.html.haml index bd59d91b2..1dc5860d4 100644 --- a/app/views/new_gestionnaire/avis/instruction.html.haml +++ b/app/views/new_gestionnaire/avis/instruction.html.haml @@ -42,4 +42,4 @@ .send-wrapper = f.submit 'Demander un avis', class: 'button send' - = render partial: 'avis_list', locals: { avis: @dossier.avis_for(current_gestionnaire) } + = render partial: 'avis_list', locals: { avis: @dossier.avis_for(current_gestionnaire), avis_seen_at: nil } diff --git a/app/views/new_gestionnaire/avis/messagerie.html.haml b/app/views/new_gestionnaire/avis/messagerie.html.haml index cf022f20e..d6b71b69b 100644 --- a/app/views/new_gestionnaire/avis/messagerie.html.haml +++ b/app/views/new_gestionnaire/avis/messagerie.html.haml @@ -6,6 +6,6 @@ %ul.messages-list - @dossier.commentaires.each do |commentaire| %li - = render partial: "new_gestionnaire/shared/commentaires/commentaire", locals: { commentaire: commentaire } + = 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) } diff --git a/app/views/new_gestionnaire/avis/show.html.haml b/app/views/new_gestionnaire/avis/show.html.haml index cb8994db3..486a2c843 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, demande_seen_at: nil } - if @dossier.procedure.use_api_carto .accompagnateur-title Cartographie @@ -26,4 +26,4 @@ - if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? .accompagnateur-title Pièces jointes .card - = render partial: "new_gestionnaire/dossiers/pieces_jointes", locals: { dossier: @dossier } + = render partial: "new_gestionnaire/dossiers/pieces_jointes", locals: { dossier: @dossier, demande_seen_at: nil } diff --git a/app/views/new_gestionnaire/dossiers/_champs.html.haml b/app/views/new_gestionnaire/dossiers/_champs.html.haml index 3abfe424a..1354f4624 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 @@ -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") diff --git a/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml b/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml index c37a65765..7618de5bc 100644 --- a/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml +++ b/app/views/new_gestionnaire/dossiers/_pieces_jointes.html.haml @@ -1,4 +1,4 @@ -%table.table.vertical.pj +%table.table.vertical.pj.dossier-champs %tbody - if dossier.procedure.cerfa_flag? %tr @@ -8,17 +8,22 @@ = link_to "Télécharger", @dossier.cerfa.last.content_url, class: "link", target: :blank - else Pièce non fournie + %td + - dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| + - pjs = dossier.retrieve_all_piece_justificative_by_type(type_de_piece_justificative.id).to_ary.dup + - pj = pjs.shift if pjs.present? %tr %th= "#{type_de_piece_justificative.libelle} :" - - pjs = dossier.retrieve_all_piece_justificative_by_type(type_de_piece_justificative.id).to_ary.dup - - if pjs.present? - - first_pj = pjs.pop - %td= display_pj_filename(first_pj) - %td= link_to "Télécharger", first_pj.content_url, class: "link", target: :blank + - if pj %td + %span{ class: highlight_if_unseen_class(demande_seen_at, pj.updated_at) } + = display_pj_filename(pj) + · + = link_to "Télécharger", pj.content_url, class: "link", target: :blank - if pjs.present? + %br %span.button.dropdown anciennes versions .dropdown-content.fade-in-down @@ -28,6 +33,11 @@ = link_to pj.content_url, { target: :blank } do %span.filename= display_pj_filename(pj) %span - ajoutée le #{pj.created_at.localtime.strftime('%d/%m %H:%M')} + ajoutée le #{pj.created_at.localtime.strftime('%d/%m/%Y à %H:%M')} - else %td Pièce non fournie + %td.updated-at + - if pj + %span{ class: highlight_if_unseen_class(demande_seen_at, pj.updated_at) } + modifié le + = pj.updated_at.localtime.strftime("%d/%m/%Y à %H:%M") diff --git a/app/views/new_gestionnaire/dossiers/annotations_privees.html.haml b/app/views/new_gestionnaire/dossiers/annotations_privees.html.haml index 42193d67f..5fc446f23 100644 --- a/app/views/new_gestionnaire/dossiers/annotations_privees.html.haml +++ b/app/views/new_gestionnaire/dossiers/annotations_privees.html.haml @@ -10,8 +10,8 @@ = form_for @dossier, url: annotations_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f| = f.fields_for :champs_private, f.object.ordered_champs_private do |champ_form| - champ = champ_form.object - = render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}", - locals: { champ: champ, form: champ_form } + = render partial: "new_gestionnaire/dossiers/champs/champ", + locals: { champ: champ, form: champ_form, seen_at: @annotations_privees_seen_at } .send-wrapper = f.submit 'Sauvegarder', class: 'button send', data: { disable_with: "Envoi..." } diff --git a/app/views/new_gestionnaire/dossiers/avis.html.haml b/app/views/new_gestionnaire/dossiers/avis.html.haml index 35e446a19..0e9664df0 100644 --- a/app/views/new_gestionnaire/dossiers/avis.html.haml +++ b/app/views/new_gestionnaire/dossiers/avis.html.haml @@ -17,4 +17,4 @@ .send-wrapper = f.submit 'Demander un avis', class: 'button send', data: { disable_with: "Envoi..." } - = render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis } + = render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis, avis_seen_at: @avis_seen_at } diff --git a/app/views/new_gestionnaire/dossiers/champs/_address.html.haml b/app/views/new_gestionnaire/dossiers/champs/_address.html.haml index c0707410f..e4ed08e33 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_address.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_address.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.text_field :value, 'data-address': 'true', diff --git a/app/views/new_gestionnaire/dossiers/champs/_champ.html.haml b/app/views/new_gestionnaire/dossiers/champs/_champ.html.haml new file mode 100644 index 000000000..e852d1674 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_champ.html.haml @@ -0,0 +1,3 @@ +.champ + = render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}", + locals: { champ: champ, form: form, seen_at: seen_at } diff --git a/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml b/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml index 000439a3a..a75334b35 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml @@ -2,5 +2,10 @@ #{champ.libelle} - if champ.mandatory %span.mandatory * + + - if champ.updated_at.present? + %span.updated-at{ class: highlight_if_unseen_class(seen_at, champ.updated_at) } + = "modifié le #{champ.updated_at.strftime('%d/%m/%Y à %H:%M')}" + - if champ.description.present? %span.notice= champ.description diff --git a/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml b/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml index 2668405ba..882404c2e 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.check_box :value, { required: champ.mandatory }, diff --git a/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml b/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml index b968388f6..456af953e 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } .radios %label diff --git a/app/views/new_gestionnaire/dossiers/champs/_date.html.haml b/app/views/new_gestionnaire/dossiers/champs/_date.html.haml index 5bdd4ad45..86b27120a 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_date.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_date.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.date_field :value, value: champ.value, diff --git a/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml b/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml index 4dabb6705..e6a92eceb 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } - parsed_value = champ.value.present? ? DateTime.parse(champ.value) : DateTime.now diff --git a/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml b/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml index c16358e58..bd1bf253d 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.select :value, Champ.departements, diff --git a/app/views/new_gestionnaire/dossiers/champs/_dossier_link.html.haml b/app/views/new_gestionnaire/dossiers/champs/_dossier_link.html.haml index 54c9d9b12..cbf2dea64 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_dossier_link.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_dossier_link.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } - dossier = Dossier.find_by(id: champ.value) - show_text_summary = dossier.present? diff --git a/app/views/new_gestionnaire/dossiers/champs/_drop_down_list.html.haml b/app/views/new_gestionnaire/dossiers/champs/_drop_down_list.html.haml index ee46b4b26..2f36bceb8 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_drop_down_list.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_drop_down_list.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } - if champ.drop_down_list && champ.drop_down_list.options.any? = form.select :value, diff --git a/app/views/new_gestionnaire/dossiers/champs/_email.html.haml b/app/views/new_gestionnaire/dossiers/champs/_email.html.haml index c9819de88..f065cb6ca 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_email.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_email.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.email_field :value, placeholder: champ.libelle, diff --git a/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml b/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml index 2668405ba..882404c2e 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.check_box :value, { required: champ.mandatory }, diff --git a/app/views/new_gestionnaire/dossiers/champs/_multiple_drop_down_list.html.haml b/app/views/new_gestionnaire/dossiers/champs/_multiple_drop_down_list.html.haml index 5f0fb9439..cc8617eaf 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_multiple_drop_down_list.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_multiple_drop_down_list.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } - if champ.drop_down_list && champ.drop_down_list.options.any? = form.select :value, diff --git a/app/views/new_gestionnaire/dossiers/champs/_number.html.haml b/app/views/new_gestionnaire/dossiers/champs/_number.html.haml index c9bcb8eae..f020980b9 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_number.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_number.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.number_field :value, placeholder: champ.libelle, diff --git a/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml b/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml index cad18df07..f52c146e9 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.select :value, Champ.pays, diff --git a/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml b/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml index e42dbfad1..7888eff8c 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.phone_field :value, placeholder: champ.libelle, diff --git a/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml b/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml index eb9ffaf8d..5946d812c 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.select :value, Champ.regions, diff --git a/app/views/new_gestionnaire/dossiers/champs/_text.html.haml b/app/views/new_gestionnaire/dossiers/champs/_text.html.haml index 2e34ffa6c..bef083c2f 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_text.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_text.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } = form.text_field :value, placeholder: champ.libelle, diff --git a/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml b/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml index 5e2b2164c..4b3b832c8 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } ~ form.text_area :value, row: 6, diff --git a/app/views/new_gestionnaire/dossiers/champs/_yes_no.html.haml b/app/views/new_gestionnaire/dossiers/champs/_yes_no.html.haml index 7893c60b8..9daf80548 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_yes_no.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_yes_no.html.haml @@ -1,4 +1,4 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at } .radios %label diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index b7423effc..5dac5390a 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -6,6 +6,6 @@ %ul.messages-list - @dossier.commentaires.each do |commentaire| %li - = render partial: "new_gestionnaire/shared/commentaires/commentaire", locals: { commentaire: commentaire } + = 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) } diff --git a/app/views/new_gestionnaire/dossiers/print.html.haml b/app/views/new_gestionnaire/dossiers/print.html.haml index d557a198e..1f4d1025a 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 0519f69f5..efae124ec 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, demande_seen_at: @demande_seen_at } - if @dossier.procedure.use_api_carto .accompagnateur-title Cartographie @@ -25,4 +25,4 @@ - if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? .accompagnateur-title Pièces jointes .card - = render partial: "pieces_jointes", locals: { dossier: @dossier } + = render partial: "pieces_jointes", locals: { dossier: @dossier, demande_seen_at: @demande_seen_at } diff --git a/app/views/new_gestionnaire/shared/commentaires/_commentaire.html.haml b/app/views/new_gestionnaire/shared/commentaires/_commentaire.html.haml index d3cbb9610..5de924c4f 100644 --- a/app/views/new_gestionnaire/shared/commentaires/_commentaire.html.haml +++ b/app/views/new_gestionnaire/shared/commentaires/_commentaire.html.haml @@ -4,9 +4,10 @@ %h2 %span.mail = render partial: 'new_gestionnaire/shared/commentaires/commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } - - if ![current_gestionnaire.email, @dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email) + - if ![current_gestionnaire.email, commentaire.dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email) %span.guest Invité - %span.date= I18n.l(commentaire.created_at.localtime, format: '%H:%M le %d/%m/%Y') + %span.date{ class: highlight_if_unseen_class(messagerie_seen_at, commentaire.created_at) } + = I18n.l(commentaire.created_at.localtime, format: '%d/%m/%Y à %H:%M ') .rich-text= sanitize(commentaire.body) - if commentaire.piece_justificative diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 27e3039cd..77288ecfc 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -23,8 +23,8 @@ = form_for @dossier, url: '', html: { class: 'form' } do |f| = f.fields_for :champs do |champ_form| - champ = champ_form.object - = render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}", - locals: { champ: champ, form: champ_form } + = render partial: "new_gestionnaire/dossiers/champs/champ", + locals: { champ: champ, form: champ_form, seen_at: nil } %input{ type: "password", value: "12345678" } .send-wrapper diff --git a/spec/helpers/dossier_helper_spec.rb b/spec/helpers/dossier_helper_spec.rb new file mode 100644 index 000000000..0ceec6d96 --- /dev/null +++ b/spec/helpers/dossier_helper_spec.rb @@ -0,0 +1,28 @@ +require 'rails_helper' + +RSpec.describe DossierHelper, type: :helper do + describe ".highlight_if_unseen_class" do + let(:seen_at) { DateTime.now } + + subject { highlight_if_unseen_class(seen_at, updated_at) } + + context "when commentaire date is created before last seen datetime" do + let(:updated_at) { seen_at - 2.days } + + it { is_expected.to eq nil } + end + + context "when commentaire date is created after last seen datetime" do + let(:updated_at) { seen_at + 2.hours } + + it { is_expected.to eq "highlighted" } + end + + context "when there is no last seen datetime" do + let(:updated_at) { DateTime.now } + let(:seen_at) { nil } + + it { is_expected.to eq nil } + end + end +end diff --git a/spec/views/new_gestionnaire/avis/avis_list.html.haml_spec.rb b/spec/views/new_gestionnaire/avis/avis_list.html.haml_spec.rb new file mode 100644 index 000000000..0a197e1a7 --- /dev/null +++ b/spec/views/new_gestionnaire/avis/avis_list.html.haml_spec.rb @@ -0,0 +1,20 @@ +describe 'new_gestionnaire/avis/avis_list.html.haml', type: :view do + before { view.extend DossierHelper } + + subject { render 'new_gestionnaire/avis/avis_list.html.haml', avis: avis, avis_seen_at: seen_at, current_gestionnaire: gestionnaire } + + let(:gestionnaire) { create(:gestionnaire) } + let(:avis) { [create(:avis, claimant: gestionnaire)] } + + context "with a seen_at after avis created_at" do + let(:seen_at) { avis.first.created_at + 1.hour } + + it { is_expected.not_to have_css(".highlighted") } + end + + context "with a seen_at after avis created_at" do + let(:seen_at) { avis.first.created_at - 1.hour } + + it { is_expected.to have_css(".highlighted") } + end +end 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 91075ffa1..21925c3f9 100644 --- a/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb +++ b/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb @@ -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 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 68ad70c78..966912d4f 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 } diff --git a/spec/views/new_gestionnaire/shared/commentaires/commentaire.html.haml_spec.rb b/spec/views/new_gestionnaire/shared/commentaires/commentaire.html.haml_spec.rb new file mode 100644 index 000000000..e866a356d --- /dev/null +++ b/spec/views/new_gestionnaire/shared/commentaires/commentaire.html.haml_spec.rb @@ -0,0 +1,22 @@ +describe 'new_gestionnaire/shared/commentaires/commentaire.html.haml', type: :view do + before { view.extend DossierHelper } + + subject { render 'new_gestionnaire/shared/commentaires/commentaire.html.haml', commentaire: commentaire, messagerie_seen_at: seen_at, current_gestionnaire: current_gestionnaire } + + let(:dossier) { create(:dossier) } + let(:commentaire) { create(:commentaire, dossier: dossier) } + let(:current_gestionnaire) { create(:gestionnaire) } + let(:seen_at) { commentaire.created_at + 1.hour } + + context "with a seen_at after commentaire created_at" do + let(:seen_at) { commentaire.created_at + 1.hour } + + it { is_expected.not_to have_css(".highlighted") } + end + + context "with a seen_at after commentaire created_at" do + let(:seen_at) { commentaire.created_at - 1.hour } + + it { is_expected.to have_css(".highlighted") } + end +end