From 6774dd008ff8ce89ca7953c69a2646d24dd4cec0 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 27 Feb 2017 17:44:08 +0100 Subject: [PATCH 01/10] List dossiers archived --- .../backoffice/dossiers_list_controller.rb | 10 ++++ app/facades/dossier_facades.rb | 2 +- app/models/dossier.rb | 2 + .../dossiers_list_gestionnaire_service.rb | 5 ++ app/views/backoffice/dossiers/_list.html.haml | 12 ++--- app/views/backoffice/dossiers/index.html.haml | 46 +++++++++++-------- app/views/backoffice/dossiers/show.html.haml | 2 +- ...ckoffice_dossierscontroller_show.html.haml | 24 ++++++---- 8 files changed, 67 insertions(+), 36 deletions(-) diff --git a/app/controllers/backoffice/dossiers_list_controller.rb b/app/controllers/backoffice/dossiers_list_controller.rb index 2bcb2a6dd..632c2c750 100644 --- a/app/controllers/backoffice/dossiers_list_controller.rb +++ b/app/controllers/backoffice/dossiers_list_controller.rb @@ -55,6 +55,16 @@ class Backoffice::DossiersListController < ApplicationController partial: "backoffice/dossiers/list", array: true, default_sort: dossiers_list_facade.service.default_sort + + + @procedure = current_gestionnaire.procedures.find(params[:id]) + @dossiers_archived = @procedure.dossiers.archived + smart_listing_create :dossiers_archived, + @dossiers_archived, + partial: "backoffice/dossiers/list", + array: true, + default_sort: dossiers_list_facade.service.default_sort + end private diff --git a/app/facades/dossier_facades.rb b/app/facades/dossier_facades.rb index 6893f4bcb..6d707f7fc 100644 --- a/app/facades/dossier_facades.rb +++ b/app/facades/dossier_facades.rb @@ -2,7 +2,7 @@ class DossierFacades #TODO rechercher en fonction de la personne/email def initialize(dossier_id, email, champ_id = nil) - @dossier = Dossier.where(archived: false).find(dossier_id) + @dossier = Dossier.find(dossier_id) @champ_id = champ_id end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 90eed3839..0ce360cbb 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -232,6 +232,8 @@ class Dossier < ActiveRecord::Base where(state: TERMINE, archived: false).order("updated_at #{order}") end + scope :archived, -> { where(archived: true) } + def cerfa_available? procedure.cerfa_flag? && cerfa.size != 0 end diff --git a/app/services/dossiers_list_gestionnaire_service.rb b/app/services/dossiers_list_gestionnaire_service.rb index 23c5accb3..8aa9fd3b5 100644 --- a/app/services/dossiers_list_gestionnaire_service.rb +++ b/app/services/dossiers_list_gestionnaire_service.rb @@ -14,6 +14,7 @@ class DossiersListGestionnaireService 'deposes' => deposes, 'a_instruire' => a_instruire, 'termine' => termine, + 'archive' => archive, 'all_state' => all_state}[@liste] end @@ -50,6 +51,10 @@ class DossiersListGestionnaireService @a_instruire ||= filter_dossiers.a_instruire end + def archive + @archive ||= filter_dossiers.archived + end + def termine @termine ||= filter_dossiers.termine end diff --git a/app/views/backoffice/dossiers/_list.html.haml b/app/views/backoffice/dossiers/_list.html.haml index 348b51baf..bf18a4ad2 100644 --- a/app/views/backoffice/dossiers/_list.html.haml +++ b/app/views/backoffice/dossiers/_list.html.haml @@ -1,9 +1,9 @@ %table#dossiers_list.table %thead - if smart_listing.name.to_s == 'follow_dossiers' - %th.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center + %th.col-xs-1.center %i.fa.fa-bell - %th.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1 + %th.col-xs-1 État - @facade_data_view.preference_list_dossiers_filter.each do |preference| @@ -17,14 +17,14 @@ %i.filter.fa.fa-filter{style: "color:#{(preference.filter.blank? ? 'grey' : 'orange')}", id: "filter_#{smart_listing.name.to_s}_#{preference.table_attr.sub('.', '_')}"} = render partial: 'backoffice/dossiers/filter_framed', locals:{preference: preference, filter_framed_id: "framed_filter_#{smart_listing.name.to_s}_#{preference.table_attr.sub('.', '_')}"} - %th.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center Actions - %th.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center Abonnés + %th.col-xs-1.center Actions + %th.col-xs-1.center Abonnés - unless smart_listing.empty? - smart_listing.collection.each do |dossier| %tr.dossier-row{id: "tr_dossier_#{dossier.id}", 'data-dossier_url' => backoffice_dossier_url(id: dossier.id)} - if smart_listing.name.to_s == 'follow_dossiers' - %td.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1.center + %td.col-xs-1.center - total_notif = dossier.notifications.where(already_read: false).count - if total_notif == 0 .badge.progress-bar-default @@ -32,7 +32,7 @@ - else .badge.progress-bar-warning = total_notif - %td.col-md-1.col-lg-1.col-sm-1.col-xs-1.col-sm-1.col-xs-1 + %td.col-xs-1 = dossier.decorate.display_state - @facade_data_view.preference_list_dossiers_filter.each_with_index do |preference, index| - unless preference.libelle == 'Statut' || preference.libelle == 'État' diff --git a/app/views/backoffice/dossiers/index.html.haml b/app/views/backoffice/dossiers/index.html.haml index 4c622f1ec..def2b8722 100644 --- a/app/views/backoffice/dossiers/index.html.haml +++ b/app/views/backoffice/dossiers/index.html.haml @@ -5,51 +5,61 @@ .default_data_block %div.row.show-block#new_dossiers %div.header - %div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title + %div.col-xs-10.title %div.carret-right %div.carret-down Nouveaux dossiers - %div.col-lg-2.col-md-2.col-sm-2.col-xs-2.count - =@facade_data_view.nouveaux_total - dossiers + %div.col-xs-2.count + = pluralize(@facade_data_view.nouveaux_total, "dossier") %div.body = smart_listing_render :new_dossiers .row.center - .col-lg-1.col-md-1.col-sm-1.col-xs-1 - .col-lg-2.col-md-2.col-sm-2.col-xs-2 + .col-xs-2.col-xs-offset-1 =link_to 'Tous les états', '?liste=all_state', class: 'text-info', style:"text-decoration: #{@facade_data_view.liste == 'all_state'? 'underline' : ''}" - .col-lg-2.col-md-2.col-sm-2.col-xs-2 + .col-xs-2 =link_to 'En construction', '?liste=a_traiter', class: 'text-danger', style:"text-decoration: #{@facade_data_view.liste == 'a_traiter'? 'underline' : ''}" - .col-lg-2.col-md-2.col-sm-2.col-xs-2 + .col-xs-2 =link_to 'À receptionner', '?liste=deposes', class: 'text-purple', style:"text-decoration: #{@facade_data_view.liste == 'deposes'? 'underline' : ''}" - .col-lg-2.col-md-2.col-sm-2.col-xs-2 + .col-xs-2 =link_to 'À instruire', '?liste=a_instruire', class: 'text-warning', style:"text-decoration: #{@facade_data_view.liste == 'a_instruire'? 'underline' : ''}" - .col-lg-2.col-md-2.col-sm-2.col-xs-2 + .col-xs-2 =link_to 'Terminés', '?liste=termine', class: 'text-success', style:"text-decoration: #{@facade_data_view.liste == 'termine'? 'underline' : ''}" .default_data_block.default_visible %div.row.show-block#follow_dossiers %div.header - %div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title + %div.col-xs-10.title %div.carret-right %div.carret-down Dossiers suivis - %div.col-lg-2.col-md-2.col-sm-2.col-xs-2.count - =@facade_data_view.suivi_total - dossiers + %div.col-xs-2.count + = pluralize(@facade_data_view.suivi_total, "dossier") %div.body = smart_listing_render :follow_dossiers .default_data_block %div.row.show-block#all_dossiers %div.header - %div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title + %div.col-xs-10.title %div.carret-right %div.carret-down Tous les dossiers - %div.col-lg-2.col-md-2.col-sm-2.col-xs-2.count - =@facade_data_view.all_state_total - dossiers + %div.col-xs-2.count + = pluralize(@facade_data_view.all_state_total, "dossier") %div.body = smart_listing_render :all_state_dossiers + + + .default_data_block + %div.row.show-block#all_dossiers + %div.header + %div.col-xs-10.title + %div.carret-right + %div.carret-down + Dossiers archivés + %div.col-xs-2.count + = pluralize(@dossiers_archived.count, "dossier") + + %div.body + = smart_listing_render :dossiers_archived diff --git a/app/views/backoffice/dossiers/show.html.haml b/app/views/backoffice/dossiers/show.html.haml index 1e8fd6961..76c8c1d0a 100644 --- a/app/views/backoffice/dossiers/show.html.haml +++ b/app/views/backoffice/dossiers/show.html.haml @@ -1,2 +1,2 @@ -%div.col-lg-12.col-md-12.col-sm-12.col-xs-12#backoffice_dossier_show +.col-xs-12#backoffice_dossier_show = render partial: "dossiers/dossier_show" 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 512ceb8f0..6244f1947 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 @@ -1,8 +1,8 @@ -%div#first-block - %div.infos +#first-block + .infos #dossier_id= t('dynamics.dossiers.numéro') + @facade.dossier.id.to_s -%div#action-block +#action-block - if gestionnaire_signed_in? - if !@facade.dossier.read_only? = form_tag(url_for({controller: 'backoffice/dossiers', action: :valid, dossier_id: @facade.dossier.id}), class: 'form-inline', method: 'POST') do @@ -23,18 +23,22 @@ %button.action.refuse-dossier %i.fa.fa-times - - unless @facade.dossier.archived? + - if @facade.dossier.archived? + %hr + %p + Archivé + - else = link_to 'Archiver', backoffice_dossier_archive_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block' -%div#menu-block +#menu-block -%div#infos-block - %div.split-hr-left - %div.dossier-state= @facade.dossier.display_state - %div.split-hr-left - %div.notifications +#infos-block + .split-hr-left + .dossier-state= @facade.dossier.display_state + .split-hr-left + .notifications - if @facade.dossier.notifications.empty? Aucune notification pour le moment. - else From ef1d46d30e6311ac537486785f00b854605d1563 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 28 Feb 2017 11:37:37 +0100 Subject: [PATCH 02/10] Fix tests --- .../backoffice/dossiers_list_controller.rb | 3 ++- app/views/backoffice/dossiers/index.html.haml | 23 ++++++++++--------- .../backoffice/dossiers_controller_spec.rb | 6 ----- .../dossiers/index_html.haml_spec.rb | 2 +- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/app/controllers/backoffice/dossiers_list_controller.rb b/app/controllers/backoffice/dossiers_list_controller.rb index 632c2c750..09575f43c 100644 --- a/app/controllers/backoffice/dossiers_list_controller.rb +++ b/app/controllers/backoffice/dossiers_list_controller.rb @@ -57,7 +57,8 @@ class Backoffice::DossiersListController < ApplicationController default_sort: dossiers_list_facade.service.default_sort - @procedure = current_gestionnaire.procedures.find(params[:id]) + procedure_id = params[:id] || params[:procedure_id] + @procedure = current_gestionnaire.procedures.find(procedure_id) @dossiers_archived = @procedure.dossiers.archived smart_listing_create :dossiers_archived, @dossiers_archived, diff --git a/app/views/backoffice/dossiers/index.html.haml b/app/views/backoffice/dossiers/index.html.haml index def2b8722..38f0cf915 100644 --- a/app/views/backoffice/dossiers/index.html.haml +++ b/app/views/backoffice/dossiers/index.html.haml @@ -51,15 +51,16 @@ = smart_listing_render :all_state_dossiers - .default_data_block - %div.row.show-block#all_dossiers - %div.header - %div.col-xs-10.title - %div.carret-right - %div.carret-down - Dossiers archivés - %div.col-xs-2.count - = pluralize(@dossiers_archived.count, "dossier") + - if @dossiers_archived + .default_data_block + %div.row.show-block#archived_dossiers + %div.header + %div.col-xs-10.title + %div.carret-right + %div.carret-down + Dossiers archivés + %div.col-xs-2.count + = pluralize(@dossiers_archived.count, "dossier") - %div.body - = smart_listing_render :dossiers_archived + %div.body + = smart_listing_render :dossiers_archived diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 89153cfaf..938ad037f 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -104,12 +104,6 @@ describe Backoffice::DossiersController, type: :controller do end end - context ' when dossier is archived' do - let(:dossier_id) { dossier_archived } - - it { expect(subject).to redirect_to('/backoffice') } - end - context 'when dossier id does not exist' do let(:dossier_id) { bad_dossier_id } diff --git a/spec/views/backoffice/dossiers/index_html.haml_spec.rb b/spec/views/backoffice/dossiers/index_html.haml_spec.rb index 84a3eef1f..212fc05b2 100644 --- a/spec/views/backoffice/dossiers/index_html.haml_spec.rb +++ b/spec/views/backoffice/dossiers/index_html.haml_spec.rb @@ -81,7 +81,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do subject { rendered } - it { is_expected.to have_content('Nouveaux dossiers 1 dossiers') } + it { is_expected.to have_content('Nouveaux dossiers 1 dossier') } it { is_expected.to have_content('Dossiers suivis 0 dossiers') } it { is_expected.to have_content('Tous les dossiers 9 dossiers') } From fa884f3ed0a09f7609056971db22788f86ce4e88 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 28 Feb 2017 14:33:05 +0100 Subject: [PATCH 03/10] Unarchive button & tests --- .../backoffice/dossiers_controller.rb | 11 +++++++- ...ckoffice_dossierscontroller_show.html.haml | 10 +++++--- config/routes.rb | 5 +++- .../backoffice/dossiers_controller_spec.rb | 2 +- ...backoffice_dossierscontroller_show_spec.rb | 25 ++++++++++++++++++- 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index 9237e091a..f376bb93f 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -162,7 +162,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController end def archive - facade = create_dossier_facade params[:dossier_id] + facade = create_dossier_facade params[:id] unless facade.dossier.archived facade.dossier.update(archived: true) flash.notice = 'Dossier archivé' @@ -170,6 +170,15 @@ class Backoffice::DossiersController < Backoffice::DossiersListController redirect_to backoffice_dossiers_path end + def unarchive + @dossier = Dossier.find(params[:id]) + if @dossier.archived + @dossier.update(archived: false) + flash.notice = 'Dossier désarchivé' + end + redirect_to backoffice_dossier_path(@dossier) + end + private def create_dossier_facade dossier_id 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 6244f1947..0cf584104 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 @@ -23,12 +23,14 @@ %button.action.refuse-dossier %i.fa.fa-times + %hr - if @facade.dossier.archived? - %hr - %p - Archivé + %p + Archivé + = link_to 'Désarchiver', unarchive_backoffice_dossier_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block' + - else - = link_to 'Archiver', backoffice_dossier_archive_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block' + = link_to 'Archiver', archive_backoffice_dossier_path(@facade.dossier), method: :post, class: 'btn btn-default btn-block' diff --git a/config/routes.rb b/config/routes.rb index 4925ef475..acfa44978 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -164,7 +164,10 @@ Rails.application.routes.draw do post 'refuse' => 'dossiers#refuse' post 'without_continuation' => 'dossiers#without_continuation' post 'close' => 'dossiers#close' - post 'archive' => 'dossiers#archive' + member do + post 'archive' + post 'unarchive' + end put 'follow' => 'dossiers#follow' resources :commentaires, only: [:index] diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 938ad037f..99714ddd1 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -383,7 +383,7 @@ describe Backoffice::DossiersController, type: :controller do sign_in gestionnaire end - subject { post :archive, params: {dossier_id: dossier_id} } + subject { post :archive, params: {id: dossier_id} } it 'change state to archived' do subject diff --git a/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb b/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb index 032adf4a4..8815b71f4 100644 --- a/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb +++ b/spec/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_show_spec.rb @@ -2,8 +2,9 @@ require 'spec_helper' describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.html.haml', type: :view do - let!(:dossier) { create(:dossier, :with_entreprise, state: state) } + let!(:dossier) { create(:dossier, :with_entreprise, state: state, archived: archived) } let(:state) { 'draft' } + let(:archived) { false } let(:gestionnaire) { create(:gestionnaire) } before do @@ -165,6 +166,28 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm expect(rendered).not_to have_css('form[data-toggle="tooltip"][title="Refuser"]') end end + + context 'when dossier is not archived' do + let(:archived) { false } + + before do + render + end + + it { expect(rendered).to have_link('Archiver') } + end + + context 'when dossier is archived' do + let(:archived) { true } + + before do + render + end + + it { expect(rendered).to have_content('Archivé') } + it { expect(rendered).to have_link('Désarchiver') } + + end end end \ No newline at end of file From 8dc634f4d3bd2bcce4d1186fba3aec596b77e6a5 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 1 Mar 2017 14:19:22 +0100 Subject: [PATCH 04/10] Dossier_list_controller: factorize smart_listing_create --- .../backoffice/dossiers_list_controller.rb | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/app/controllers/backoffice/dossiers_list_controller.rb b/app/controllers/backoffice/dossiers_list_controller.rb index 09575f43c..38d9612c8 100644 --- a/app/controllers/backoffice/dossiers_list_controller.rb +++ b/app/controllers/backoffice/dossiers_list_controller.rb @@ -38,38 +38,28 @@ class Backoffice::DossiersListController < ApplicationController params[:dossiers_smart_listing] = {page: dossiers_list_facade.service.default_page} end - smart_listing_create :new_dossiers, - new_dossiers_list, - partial: "backoffice/dossiers/list", - array: true, - default_sort: dossiers_list_facade.service.default_sort + default_smart_listing_create :new_dossiers, new_dossiers_list - smart_listing_create :follow_dossiers, - follow_dossiers_list, - partial: "backoffice/dossiers/list", - array: true, - default_sort: dossiers_list_facade.service.default_sort - - smart_listing_create :all_state_dossiers, - all_state_dossiers_list, - partial: "backoffice/dossiers/list", - array: true, - default_sort: dossiers_list_facade.service.default_sort + default_smart_listing_create :follow_dossiers, follow_dossiers_list + default_smart_listing_create :all_state_dossiers, all_state_dossiers_list procedure_id = params[:id] || params[:procedure_id] @procedure = current_gestionnaire.procedures.find(procedure_id) @dossiers_archived = @procedure.dossiers.archived - smart_listing_create :dossiers_archived, - @dossiers_archived, - partial: "backoffice/dossiers/list", - array: true, - default_sort: dossiers_list_facade.service.default_sort - + default_smart_listing_create :dossiers_archived, @dossiers_archived end private + def default_smart_listing_create name, collection + smart_listing_create name, + collection, + partial: 'backoffice/dossiers/list', + array: true, + default_sort: dossiers_list_facade.service.default_sort + end + def param_smart_listing params[:dossiers_smart_listing] end From 925a087f4a6dad1c90cc399890e69eb4dfef74cd Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 1 Mar 2017 14:38:58 +0100 Subject: [PATCH 05/10] Dossier_list_controller: use same system for archived dossiers --- app/controllers/backoffice/dossiers_list_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/backoffice/dossiers_list_controller.rb b/app/controllers/backoffice/dossiers_list_controller.rb index 38d9612c8..1d3d2cb81 100644 --- a/app/controllers/backoffice/dossiers_list_controller.rb +++ b/app/controllers/backoffice/dossiers_list_controller.rb @@ -33,6 +33,9 @@ class Backoffice::DossiersListController < ApplicationController new_dossiers_list = dossiers_list_facade.service.nouveaux follow_dossiers_list = dossiers_list_facade.service.suivi all_state_dossiers_list = dossiers_list_facade.service.all_state + archived_dossier_list = dossiers_list_facade.service.archive + + @dossiers_archived = archived_dossier_list if param_page.nil? params[:dossiers_smart_listing] = {page: dossiers_list_facade.service.default_page} @@ -44,10 +47,7 @@ class Backoffice::DossiersListController < ApplicationController default_smart_listing_create :all_state_dossiers, all_state_dossiers_list - procedure_id = params[:id] || params[:procedure_id] - @procedure = current_gestionnaire.procedures.find(procedure_id) - @dossiers_archived = @procedure.dossiers.archived - default_smart_listing_create :dossiers_archived, @dossiers_archived + default_smart_listing_create :dossiers_archived, archived_dossier_list end private From 5b475fdd0675cf8dd2a000896d78dd6091694601 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 1 Mar 2017 15:15:52 +0100 Subject: [PATCH 06/10] Dossier_list_controller: simplify smartlisting --- .../backoffice/dossiers_list_controller.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/app/controllers/backoffice/dossiers_list_controller.rb b/app/controllers/backoffice/dossiers_list_controller.rb index 1d3d2cb81..fc963f6f9 100644 --- a/app/controllers/backoffice/dossiers_list_controller.rb +++ b/app/controllers/backoffice/dossiers_list_controller.rb @@ -29,11 +29,7 @@ class Backoffice::DossiersListController < ApplicationController def smartlisting_dossier dossiers_list=nil, liste='all_state' dossiers_list_facade liste - - new_dossiers_list = dossiers_list_facade.service.nouveaux - follow_dossiers_list = dossiers_list_facade.service.suivi - all_state_dossiers_list = dossiers_list_facade.service.all_state - archived_dossier_list = dossiers_list_facade.service.archive + service = dossiers_list_facade.service @dossiers_archived = archived_dossier_list @@ -41,13 +37,10 @@ class Backoffice::DossiersListController < ApplicationController params[:dossiers_smart_listing] = {page: dossiers_list_facade.service.default_page} end - default_smart_listing_create :new_dossiers, new_dossiers_list - - default_smart_listing_create :follow_dossiers, follow_dossiers_list - - default_smart_listing_create :all_state_dossiers, all_state_dossiers_list - - default_smart_listing_create :dossiers_archived, archived_dossier_list + default_smart_listing_create :new_dossiers, service.nouveaux + default_smart_listing_create :follow_dossiers, service.suivi + default_smart_listing_create :all_state_dossiers, service.all_state + default_smart_listing_create :dossiers_archived, service.archive end private From 0862f2fc511354037e0f50fb215f80c664d14a31 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 1 Mar 2017 15:16:32 +0100 Subject: [PATCH 07/10] Dossier_list_controller: same name pattern --- app/controllers/backoffice/dossiers_list_controller.rb | 2 +- app/views/backoffice/dossiers/index.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/backoffice/dossiers_list_controller.rb b/app/controllers/backoffice/dossiers_list_controller.rb index fc963f6f9..e39ee9177 100644 --- a/app/controllers/backoffice/dossiers_list_controller.rb +++ b/app/controllers/backoffice/dossiers_list_controller.rb @@ -40,7 +40,7 @@ class Backoffice::DossiersListController < ApplicationController default_smart_listing_create :new_dossiers, service.nouveaux default_smart_listing_create :follow_dossiers, service.suivi default_smart_listing_create :all_state_dossiers, service.all_state - default_smart_listing_create :dossiers_archived, service.archive + default_smart_listing_create :archived_dossiers, service.archive end private diff --git a/app/views/backoffice/dossiers/index.html.haml b/app/views/backoffice/dossiers/index.html.haml index 38f0cf915..aeb4accac 100644 --- a/app/views/backoffice/dossiers/index.html.haml +++ b/app/views/backoffice/dossiers/index.html.haml @@ -63,4 +63,4 @@ = pluralize(@dossiers_archived.count, "dossier") %div.body - = smart_listing_render :dossiers_archived + = smart_listing_render :archived_dossiers From ca799421c98b42564927f91a72ccc31fb012d01e Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 1 Mar 2017 15:02:47 +0100 Subject: [PATCH 08/10] backoffice dossiers index: simple cleaning --- app/views/backoffice/dossiers/index.html.haml | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/app/views/backoffice/dossiers/index.html.haml b/app/views/backoffice/dossiers/index.html.haml index aeb4accac..aafa36114 100644 --- a/app/views/backoffice/dossiers/index.html.haml +++ b/app/views/backoffice/dossiers/index.html.haml @@ -3,15 +3,15 @@ = render partial: 'backoffice/dossiers/pref_list' .default_data_block - %div.row.show-block#new_dossiers - %div.header - %div.col-xs-10.title - %div.carret-right - %div.carret-down + .row.show-block#new_dossiers + .header + .col-xs-10.title + .carret-right + .carret-down Nouveaux dossiers - %div.col-xs-2.count + .col-xs-2.count = pluralize(@facade_data_view.nouveaux_total, "dossier") - %div.body + .body = smart_listing_render :new_dossiers .row.center @@ -27,40 +27,40 @@ =link_to 'Terminés', '?liste=termine', class: 'text-success', style:"text-decoration: #{@facade_data_view.liste == 'termine'? 'underline' : ''}" .default_data_block.default_visible - %div.row.show-block#follow_dossiers - %div.header - %div.col-xs-10.title - %div.carret-right - %div.carret-down + .row.show-block#follow_dossiers + .header + .col-xs-10.title + .carret-right + .carret-down Dossiers suivis - %div.col-xs-2.count + .col-xs-2.count = pluralize(@facade_data_view.suivi_total, "dossier") - %div.body + .body = smart_listing_render :follow_dossiers .default_data_block - %div.row.show-block#all_dossiers - %div.header - %div.col-xs-10.title - %div.carret-right - %div.carret-down + .row.show-block#all_dossiers + .header + .col-xs-10.title + .carret-right + .carret-down Tous les dossiers - %div.col-xs-2.count + .col-xs-2.count = pluralize(@facade_data_view.all_state_total, "dossier") - %div.body + .body = smart_listing_render :all_state_dossiers - if @dossiers_archived .default_data_block - %div.row.show-block#archived_dossiers - %div.header - %div.col-xs-10.title - %div.carret-right - %div.carret-down + .row.show-block#archived_dossiers + .header + .col-xs-10.title + .carret-right + .carret-down Dossiers archivés - %div.col-xs-2.count + .col-xs-2.count = pluralize(@dossiers_archived.count, "dossier") - %div.body + .body = smart_listing_render :archived_dossiers From 494d5fed5c8e2400387c0ec9633d50fc637dc17b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 1 Mar 2017 15:53:55 +0100 Subject: [PATCH 09/10] Dossier_list_controller: renaming --- app/controllers/backoffice/dossiers_list_controller.rb | 3 ++- app/views/backoffice/dossiers/index.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/backoffice/dossiers_list_controller.rb b/app/controllers/backoffice/dossiers_list_controller.rb index e39ee9177..52274bb79 100644 --- a/app/controllers/backoffice/dossiers_list_controller.rb +++ b/app/controllers/backoffice/dossiers_list_controller.rb @@ -31,7 +31,6 @@ class Backoffice::DossiersListController < ApplicationController dossiers_list_facade liste service = dossiers_list_facade.service - @dossiers_archived = archived_dossier_list if param_page.nil? params[:dossiers_smart_listing] = {page: dossiers_list_facade.service.default_page} @@ -41,6 +40,8 @@ class Backoffice::DossiersListController < ApplicationController default_smart_listing_create :follow_dossiers, service.suivi default_smart_listing_create :all_state_dossiers, service.all_state default_smart_listing_create :archived_dossiers, service.archive + + @archived_dossiers = service.archive end private diff --git a/app/views/backoffice/dossiers/index.html.haml b/app/views/backoffice/dossiers/index.html.haml index aafa36114..8e80fbe6d 100644 --- a/app/views/backoffice/dossiers/index.html.haml +++ b/app/views/backoffice/dossiers/index.html.haml @@ -51,7 +51,7 @@ = smart_listing_render :all_state_dossiers - - if @dossiers_archived + - if @archived_dossiers .default_data_block .row.show-block#archived_dossiers .header @@ -60,7 +60,7 @@ .carret-down Dossiers archivés .col-xs-2.count - = pluralize(@dossiers_archived.count, "dossier") + = pluralize(@archived_dossiers.count, "dossier") .body = smart_listing_render :archived_dossiers From 0a111653080254bbc8766fcc00109aa5dbe9189c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 2 Mar 2017 17:52:28 +0100 Subject: [PATCH 10/10] Tests for display archived dossiers --- .../dossiers/procedure_controller_spec.rb | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb b/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb index 7967e1010..3dc9f34bd 100644 --- a/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe Backoffice::Dossiers::ProcedureController, type: :controller do let(:gestionnaire) { create :gestionnaire } let(:procedure) { create :procedure } + let(:archived) { false } + let(:dossier) { create :dossier, procedure: procedure, archived: archived, state: 'initiated'} before do create :assign_to, gestionnaire: gestionnaire, procedure: procedure @@ -28,6 +30,24 @@ describe Backoffice::Dossiers::ProcedureController, type: :controller do it { is_expected.to redirect_to backoffice_dossiers_path } it { expect(flash[:alert]).to be_present} end + + context 'when procedure contains a dossier' do + render_views + + before do + dossier + subject + end + + it { expect(response.body).to have_content('Tous les dossiers 1 dossier') } + + context 'archived' do + let(:archived) { true } + + it { expect(response.body).to have_content('Tous les dossiers 0 dossiers') } + it { expect(response.body).to have_content('Dossiers archivés 1 dossier') } + end + end end describe 'GET #filter' do