From fb737df463c983c71c8b4c3de461fee75d4b307a Mon Sep 17 00:00:00 2001 From: JC Date: Tue, 27 Dec 2016 15:26:41 +0100 Subject: [PATCH] Both index and show have notification on there left pannels --- app/assets/javascripts/dossiers.js | 17 +++++++ app/assets/javascripts/dossiers_list_link.js | 9 ++-- app/assets/stylesheets/dossiers.scss | 10 ++--- app/assets/stylesheets/left_pannel.scss | 44 +++++++++++++++---- app/decorators/notification_decorator.rb | 8 ++++ app/facades/dossier_facades.rb | 4 ++ app/facades/dossiers_list_facades.rb | 2 +- app/models/gestionnaire.rb | 2 +- ...koffice_dossierscontroller_index.html.haml | 11 +++-- ...ckoffice_dossierscontroller_show.html.haml | 2 +- 10 files changed, 83 insertions(+), 26 deletions(-) create mode 100644 app/decorators/notification_decorator.rb diff --git a/app/assets/javascripts/dossiers.js b/app/assets/javascripts/dossiers.js index adc57a499..c294b6c16 100644 --- a/app/assets/javascripts/dossiers.js +++ b/app/assets/javascripts/dossiers.js @@ -1,5 +1,22 @@ $(document).on('page:load', the_terms); $(document).ready(the_terms); +$(document).on('page:load', pannel_switch); +$(document).ready(pannel_switch); + +function pannel_switch() { + $('#switch-notifications').click(function () { + $('#procedure_list').addClass('hidden'); + $('#notifications_list').removeClass('hidden'); + $(this).addClass('active'); + $('#switch-procedures').removeClass('active'); + }) + $('#switch-procedures').click(function () { + $('#notifications_list').addClass('hidden'); + $('#procedure_list').removeClass('hidden'); + $(this).addClass('active'); + $('#switch-notifications').removeClass('active'); + }) +} function the_terms() { var the_terms = $("#dossier_autorisation_donnees"); diff --git a/app/assets/javascripts/dossiers_list_link.js b/app/assets/javascripts/dossiers_list_link.js index 1764dd571..09fb31542 100644 --- a/app/assets/javascripts/dossiers_list_link.js +++ b/app/assets/javascripts/dossiers_list_link.js @@ -1,9 +1,8 @@ $(document).on('page:load', link_init); $(document).ready(link_init); - function link_init() { - $('#dossiers_list tr').on('click', function () { - $(location).attr('href', $(this).data('dossier_url')) - }); -} \ No newline at end of file + $('#dossiers_list tr').on('click', function () { + $(location).attr('href', $(this).data('dossier_url')) + }); +} diff --git a/app/assets/stylesheets/dossiers.scss b/app/assets/stylesheets/dossiers.scss index f7793c753..31fe3e57b 100644 --- a/app/assets/stylesheets/dossiers.scss +++ b/app/assets/stylesheets/dossiers.scss @@ -42,24 +42,22 @@ h5 span { cursor: pointer; } -#procedure_list { +#procedure_list, #notifications_list { margin-left: -10px; margin-top: 20px; a, a:hover { color: #FFFFFF; text-decoration: none; } - - .procedure_list_element.active{ + .procedure_list_element.active, .notification.active { background-color: #668ABD; } - - .procedure_list_element { + .procedure_list_element, .notification { padding: 15px 40px 15px 20px; cursor: pointer; line-height: 1.8em; } - .procedure_list_element:hover{ + .procedure_list_element:hover, .notification:hover { background-color: #668ABD; cursor: pointer; } diff --git a/app/assets/stylesheets/left_pannel.scss b/app/assets/stylesheets/left_pannel.scss index 8c113f4a2..08aadf3a1 100644 --- a/app/assets/stylesheets/left_pannel.scss +++ b/app/assets/stylesheets/left_pannel.scss @@ -52,8 +52,8 @@ } #menu-block { #switch-buttons { - height: 40px; - line-height: 40px; + height: 30px; + line-height: 30px; font-size: 16px; margin-top: 20px; margin-left: auto; @@ -62,21 +62,33 @@ border: 1px solid; padding: 0 0 0 10px; border-radius: 25px; + cursor: pointer; + .active { + background-color: #668ABD !important; + cursor: default; + } + .separator { + height: 26px; + width: 1px; + display: inline-block; + background-color: #FFFFFF; + } + #switch-procedures:hover, #switch-notifications:hover { + background-color: #668AEA; + } #switch-procedures { - height: 38px; - margin: 0 -5px 0 -10px; + height: 28px; + margin: 0 0 0 -10px; padding-left: 10px; width: 100px; display: inline-block; - background-color: #CCCCCC; border-radius: 25px 0 0 25px; } #switch-notifications { - width: 100px; - background-color: #CCCCCC; + width: 103px; display: inline-block; border-radius: 0 25px 25px 0; - height: 38px; + height: 28px; margin: 0 0 0 -5px; padding: 0 0 0 5px; } @@ -98,6 +110,20 @@ font-size: 25px; width: 200px; margin-top: 20px; + width: 200px; + margin-left: auto; + margin-right: auto; + } + #notifications_list { + .notification { + padding: 10px 10px 10px 20px; + .dossier, .updated-at { + display: inline-block; + color: #CCCCCC; + font-size: 12px; + text-align: left; + } + } } .notifications { margin: 20px 10px 0 5px; @@ -107,7 +133,7 @@ margin: 0 0 15px 0; } .notification { - margin: 10px 0 10px 0; + margin: 10px 0 10px 10px; .type { margin-bottom: 20px; } diff --git a/app/decorators/notification_decorator.rb b/app/decorators/notification_decorator.rb new file mode 100644 index 000000000..911471e1a --- /dev/null +++ b/app/decorators/notification_decorator.rb @@ -0,0 +1,8 @@ +class NotificationDecorator < Draper::Decorator + delegate_all + + def index_display + ['champs', 'piece_justificative'].include?(type_notif) ? type = liste.join(" ") : type = liste.last + { dossier: "Dossier n°#{dossier.id}", date: updated_at.strftime('%d/%m %H:%M'), type: type } + end +end diff --git a/app/facades/dossier_facades.rb b/app/facades/dossier_facades.rb index b0b622ae6..6893f4bcb 100644 --- a/app/facades/dossier_facades.rb +++ b/app/facades/dossier_facades.rb @@ -10,6 +10,10 @@ class DossierFacades @dossier.decorate end + def last_notifications + @dossier.notifications.order("updated_at DESC").limit(5) + end + def champs @dossier.ordered_champs end diff --git a/app/facades/dossiers_list_facades.rb b/app/facades/dossiers_list_facades.rb index b07b8652c..d32cb0eb4 100644 --- a/app/facades/dossiers_list_facades.rb +++ b/app/facades/dossiers_list_facades.rb @@ -138,4 +138,4 @@ class DossiersListFacades @procedure.nil? ? backoffice_dossiers_path(liste: liste) : backoffice_dossiers_procedure_path(id: @procedure.id, liste: liste) end -end \ No newline at end of file +end diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 10a6953af..580dc1b96 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -64,7 +64,7 @@ class Gestionnaire < ActiveRecord::Base end def notifications - Notification.where(already_read: false, dossier_id: follows.pluck(:dossier_id) ) + Notification.where(already_read: false, dossier_id: follows.pluck(:dossier_id) ).order("updated_at DESC") end def notifications_for procedure diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml index cfdc87824..e715a6ae6 100644 --- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml +++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml @@ -11,8 +11,7 @@ %div#menu-block %div.split-hr-left #switch-buttons - #switch-procedures Procédures - | + #switch-procedures.active Procédures #switch-notifications Notifications %div#infos-block @@ -29,4 +28,10 @@ -if procedure[:unread_notifications] > 0 .badge.progress-bar-warning{title: 'Notifications'} = procedure[:unread_notifications] - + #notifications_list.hidden + - @facade_data_view.unread_notifications.each do |notification| + = link_to backoffice_dossier_path(notification.dossier.id) do + .notification + .dossier= notification.decorate.index_display[:dossier] + .updated-at= notification.decorate.index_display[:date] + .type= notification.decorate.index_display[:type] diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml index be7e47390..6c2fd2e66 100644 --- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml +++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml @@ -34,7 +34,7 @@ = "Aucune notification pour le moment." - else %i.fa.fa-bell-o - - @facade.dossier.notifications.limit(5).each do |notification| + - @facade.last_notifications.each do |notification| .notification .updated-at= notification.updated_at.strftime('%d/%m/%Y %H:%M') - if ['champs'].include?(notification.type_notif)