From 480aefe8156805da30224b8e778b4c6fef66c43e Mon Sep 17 00:00:00 2001 From: benjaminhenkel Date: Wed, 30 Aug 2017 16:53:31 +0200 Subject: [PATCH 001/222] Update landing.html.haml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changement du numéro de téléphone de contact disponible sur le site TPS --- app/views/root/landing.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index 2801ddbdb..600b2f212 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -11,7 +11,7 @@ %a.hero-button{ target: "_blank", onclick: "javascript: ga('send', 'pageview', '/demander-une-demo'); $crisp.push(['do', 'chat:open'])" } Demander une démo %p.hero-phone-cta - ou nous appeler au 01 40 15 68 49 + ou nous appeler au 09 72 62 57 12 .hero-illustration %img{ :src => image_url("landing/hero/dematerialiser.svg") } From 48d88a110cf277749af7f5c34c529f05afcdf5d9 Mon Sep 17 00:00:00 2001 From: benjaminhenkel Date: Thu, 31 Aug 2017 14:35:10 +0200 Subject: [PATCH 002/222] Update landing.html.haml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changement du deuxième numéro de la page que j'avais oublié la première fois --- app/views/root/landing.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index 600b2f212..b0ec1f25e 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -130,4 +130,4 @@ %div %a.cta-panel-button{ target: "_blank", onclick: "javascript: ga('send', 'pageview', '/demander-une-demo'); $crisp.push(['do', 'chat:open'])" } Demander une démo %p.cta-panel-phone-cta - ou nous appeler au 01 40 15 68 49 + ou nous appeler au 09 72 62 57 12 From dcb3a48bd3809b8abe7181c5c2a3c89dd4f3bd92 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 29 Jun 2017 17:43:20 +0200 Subject: [PATCH 003/222] Tabs component in patron --- app/assets/stylesheets/new_design/_tabs.scss | 22 ++++++++++++++++++++ app/views/root/patron.html.haml | 10 +++++++++ 2 files changed, 32 insertions(+) create mode 100644 app/assets/stylesheets/new_design/_tabs.scss diff --git a/app/assets/stylesheets/new_design/_tabs.scss b/app/assets/stylesheets/new_design/_tabs.scss new file mode 100644 index 000000000..205256ce8 --- /dev/null +++ b/app/assets/stylesheets/new_design/_tabs.scss @@ -0,0 +1,22 @@ +@import "colors"; +@import "mixins"; + +.tabs { + li { + display: inline-block; + margin-right: 40px; + } + + a { + @include vertical-padding(14px); + display: block; + color: $black; + font-size: 22px; + + &.selected, + &:hover { + border-bottom: 2px solid $blue; + padding-bottom: 12px; + } + } +} diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 6d2a06f92..e04365bfb 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -29,6 +29,16 @@ %p = link_to ".button.primary.expand", "#", class: "button primary expand" + %h2 Onglets + + %ul.tabs + %li + = link_to "Onglet 1", "#", class: "selected" + %li + = link_to "Onglet 2", "#" + %li + = link_to "Onglet 3", "#" + %h2 Layout deux colonnes .two-columns From 810430de0ecb140a3a2ab146ff445a2acb573159 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 3 Jul 2017 14:01:35 +0200 Subject: [PATCH 004/222] Add flexbox utility css classes --- app/assets/stylesheets/new_design/flex.scss | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app/assets/stylesheets/new_design/flex.scss diff --git a/app/assets/stylesheets/new_design/flex.scss b/app/assets/stylesheets/new_design/flex.scss new file mode 100644 index 000000000..b3910bc37 --- /dev/null +++ b/app/assets/stylesheets/new_design/flex.scss @@ -0,0 +1,15 @@ +.flex { + display: flex; + + &.align-center { + align-items: center; + } + + &.align-start { + align-items: flex-start; + } + + &.justify-between { + justify-content: space-between; + } +} From ca94b2bfa4c28bed9f9babbab6fb2d70bab834c2 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 3 Jul 2017 14:02:57 +0200 Subject: [PATCH 005/222] Add generic .container class --- app/assets/stylesheets/new_design/common.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/stylesheets/new_design/common.scss b/app/assets/stylesheets/new_design/common.scss index 2ee0e05d7..d956cdc94 100644 --- a/app/assets/stylesheets/new_design/common.scss +++ b/app/assets/stylesheets/new_design/common.scss @@ -1,3 +1,4 @@ +@import "placeholders"; @import "typography"; body { @@ -10,3 +11,7 @@ h1 { font-size: 36px; font-weight: bold; } + +.container { + @extend %page-width-container; +} From 622a1707935b2b3ab0c4371aa4e64c26cd56160a Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 3 Jul 2017 14:05:55 +0200 Subject: [PATCH 006/222] Add and design new #index on procedures for gestionnaires --- .../new_design/procedure_list.scss | 61 +++++++++++++++++++ .../new_gestionnaire/procedures_controller.rb | 15 ++++- .../procedures/index.html.haml | 36 +++++++++++ config/routes.rb | 2 +- 4 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 app/assets/stylesheets/new_design/procedure_list.scss create mode 100644 app/views/new_gestionnaire/procedures/index.html.haml diff --git a/app/assets/stylesheets/new_design/procedure_list.scss b/app/assets/stylesheets/new_design/procedure_list.scss new file mode 100644 index 000000000..e15577c86 --- /dev/null +++ b/app/assets/stylesheets/new_design/procedure_list.scss @@ -0,0 +1,61 @@ +@import "colors"; +@import "mixins"; + +.procedure-list { + .procedure-item { + @include vertical-padding(24px); + border-bottom: 1px solid $border-grey; + + &:last-child { + border-bottom: none; + } + } + + .procedure-logo { + margin-right: 16px; + width: 40px; + height: 40px; + border-bottom: 1px solid $border-grey; + } + + .procedure-title { + min-height: 40px; + font-size: 20px; + margin-bottom: 16px; + + a { + color: $black; + + &:hover { + color: $blue; + } + } + } + + .procedure-stats { + li { + min-height: 36px; + border-left: 1px solid $border-grey; + width: 90px; + + &:last-child { + border-right: 1px solid $border-grey; + } + + .stats-number, + .stats-legend { + text-align: center; + } + + .stats-number { + font-size: 14px; + font-weight: bold; + } + + .stats-legend { + font-size: 12px; + color: $grey; + } + } + } +} diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index bfffad1fa..26940b425 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -1,6 +1,19 @@ module NewGestionnaire class ProceduresController < GestionnaireController - before_action :ensure_ownership! + layout "new_application" + + before_action :ensure_ownership!, except: [:index] + + def index + @procedures = current_gestionnaire.procedures + + dossiers = current_gestionnaire.dossiers.state_not_brouillon + @dossiers_count_per_procedure = dossiers.group(:procedure_id).count + @dossiers_nouveaux_count_per_procedure = dossiers.state_nouveaux.group(:procedure_id).count + @dossiers_archived_count_per_procedure = dossiers.archived.group(:procedure_id).count + + @followed_dossiers_count_per_procedure = current_gestionnaire.followed_dossiers.where(procedure: @procedures).group(:procedure_id).count + end private diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml new file mode 100644 index 000000000..b50e4d8a4 --- /dev/null +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -0,0 +1,36 @@ +.container + %h1 Procédures + + %ul.procedure-list + - @procedures.each do |p| + %li.procedure-item.flex.align-start + = image_tag p.logo, class: "procedure-logo" + .procedure-details + %p.procedure-title + = link_to p.libelle, backoffice_dossiers_procedure_path(p) + + %ul.procedure-stats.flex + %li + - dossier_count = @dossiers_count_per_procedure[p.id] || 0 + .stats-number + = dossier_count + .stats-legend + = "dossier".pluralize(dossier_count) + %li + - nouveaux_count = @dossiers_nouveaux_count_per_procedure[p.id] || 0 + .stats-number + = nouveaux_count + .stats-legend + = "nouveau".pluralize(nouveaux_count) + %li + - followed_count = @followed_dossiers_count_per_procedure[p.id] || 0 + .stats-number + = followed_count + .stats-legend + = "suivi".pluralize(followed_count) + %li + - archived_count = @dossiers_archived_count_per_procedure[p.id] || 0 + .stats-number + = archived_count + .stats-legend + = "archivé".pluralize(archived_count) diff --git a/config/routes.rb b/config/routes.rb index b93f66f2b..8ce8d4502 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -238,7 +238,7 @@ Rails.application.routes.draw do end scope module: 'new_gestionnaire' do - resources :procedures, only: [] do + resources :procedures, only: [:index] do resources :dossiers, only: [] do get 'attestation' end From eb2a33138c2d31fb32a89c19a2637106bb9a7ec3 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 4 Jul 2017 17:14:59 +0200 Subject: [PATCH 007/222] Add french inflections rules for nouveau=>nouveaux --- .../procedures/index.html.haml | 8 +++--- config/initializers/inflections.rb | 28 +++++++++++++++---- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index b50e4d8a4..937de14c0 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -15,22 +15,22 @@ .stats-number = dossier_count .stats-legend - = "dossier".pluralize(dossier_count) + = "dossier".pluralize(dossier_count, :fr) %li - nouveaux_count = @dossiers_nouveaux_count_per_procedure[p.id] || 0 .stats-number = nouveaux_count .stats-legend - = "nouveau".pluralize(nouveaux_count) + = "nouveau".pluralize(nouveaux_count, :fr) %li - followed_count = @followed_dossiers_count_per_procedure[p.id] || 0 .stats-number = followed_count .stats-legend - = "suivi".pluralize(followed_count) + = "suivi".pluralize(followed_count, :fr) %li - archived_count = @dossiers_archived_count_per_procedure[p.id] || 0 .stats-number = archived_count .stats-legend - = "archivé".pluralize(archived_count) + = "archivé".pluralize(archived_count, :fr) diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index 864ba4221..fc49561ab 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -18,12 +18,28 @@ ActiveSupport::Inflector.inflections(:en) do |inflect| inflect.irregular('avis', 'avis') end -# These inflection rules are supported but not enabled by default: -# ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' -# end +# From https://github.com/davidcelis/inflections ActiveSupport::Inflector.inflections(:fr) do |inflect| + inflect.clear + inflect.plural(/$/, 's') - inflect.plural(/(hib|ch|bij|caill|p|gen|jouj)ou$/i, '\1oux') - inflect.irregular('avis', 'avis') + inflect.singular(/s$/, '') + + inflect.plural(/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)$/, '\1x') + inflect.singular(/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)x$/, '\1') + + inflect.plural(/(bleu|émeu|landau|lieu|pneu|sarrau)$/, '\1s') + inflect.plural(/al$/, 'aux') + inflect.plural(/ail$/, 'ails') + inflect.singular(/(journ|chev)aux$/, '\1al') + inflect.singular(/ails$/, 'ail') + + inflect.plural(/(b|cor|ém|gemm|soupir|trav|vant|vitr)ail$/, '\1aux') + inflect.singular(/(b|cor|ém|gemm|soupir|trav|vant|vitr)aux$/, '\1ail') + + inflect.plural(/(s|x|z)$/, '\1') + + inflect.irregular('monsieur', 'messieurs') + inflect.irregular('madame', 'mesdames') + inflect.irregular('mademoiselle', 'mesdemoiselles') end From bc4e961200b3ec90141b00a234f4a71e438e72e1 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 3 Jul 2017 15:23:02 +0200 Subject: [PATCH 008/222] Style backoffice title --- app/assets/stylesheets/new_design/_constants.scss | 3 ++- app/assets/stylesheets/new_design/backoffice.scss | 8 ++++++++ app/views/new_gestionnaire/procedures/index.html.haml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 app/assets/stylesheets/new_design/backoffice.scss diff --git a/app/assets/stylesheets/new_design/_constants.scss b/app/assets/stylesheets/new_design/_constants.scss index 897512e1d..39b09ef41 100644 --- a/app/assets/stylesheets/new_design/_constants.scss +++ b/app/assets/stylesheets/new_design/_constants.scss @@ -1,3 +1,4 @@ $page-width: 1040px; -$default-padding: 15px; +$default-spacer: 8px; +$default-padding: 2 * $default-spacer; diff --git a/app/assets/stylesheets/new_design/backoffice.scss b/app/assets/stylesheets/new_design/backoffice.scss new file mode 100644 index 000000000..dd7f6dfe2 --- /dev/null +++ b/app/assets/stylesheets/new_design/backoffice.scss @@ -0,0 +1,8 @@ +@import "constants"; + +.backoffice-title { + font-size: 30px; + font-weight: normal; + margin-top: 3 * $default-spacer; + margin-bottom: 3 * $default-spacer; +} diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index 937de14c0..0e5527940 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -1,5 +1,5 @@ .container - %h1 Procédures + %h1.backoffice-title Procédures %ul.procedure-list - @procedures.each do |p| From 29b201ad001a6292cc365315e4324f88ba63a029 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 3 Jul 2017 16:01:44 +0200 Subject: [PATCH 009/222] Add left menu in navbar --- .../stylesheets/new_design/new_header.scss | 24 ++++++++++++++++++- app/views/layouts/_new_header.haml | 11 +++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss index 9ea00b625..d84f939f9 100644 --- a/app/assets/stylesheets/new_design/new_header.scss +++ b/app/assets/stylesheets/new_design/new_header.scss @@ -17,7 +17,29 @@ @extend %page-width-container; display: flex; justify-content: space-between; - padding-top: 17px; + height: 100%; +} + +.header-logo { + display: inline-block; + margin-right: 4 * $default-spacer; +} + +.header-left-menu { + li { + display: inline-block; + } + + a { + @include vertical-padding(23px); + font-size: 18px; + color: $black; + + &.active { + color: $blue; + border-bottom: 2px solid $blue; + } + } } .header-right-content { diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index e6919dc50..de39ce4d3 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -1,7 +1,14 @@ .new-header{ class: current_page?(root_path) ? nil : "new-header-with-border" } .header-inner-content - = link_to root_path do - %img{ src: image_url("header/logo-tps.svg") } + + .flex.align-center + = link_to root_path, class: "header-logo" do + %img{ src: image_url("header/logo-tps.svg") } + + - if gestionnaire_signed_in? + %ul.header-left-menu + %li + = link_to "Procédures", procedures_path, class: "active" %ul.header-right-content - if gestionnaire_signed_in? From 1d5321487070a2ad838b90d27616adcfddbcbde2 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 3 Jul 2017 16:29:29 +0200 Subject: [PATCH 010/222] Add archived label on procedures list --- app/assets/stylesheets/new_design/labels.scss | 11 +++++++++++ app/assets/stylesheets/new_design/procedure_list.scss | 4 ++++ app/views/new_gestionnaire/procedures/index.html.haml | 4 ++++ app/views/root/patron.html.haml | 4 ++++ 4 files changed, 23 insertions(+) create mode 100644 app/assets/stylesheets/new_design/labels.scss diff --git a/app/assets/stylesheets/new_design/labels.scss b/app/assets/stylesheets/new_design/labels.scss new file mode 100644 index 000000000..a623d900f --- /dev/null +++ b/app/assets/stylesheets/new_design/labels.scss @@ -0,0 +1,11 @@ +@import "colors"; +@import "constants"; + +.label { + display: inline-block; + padding: 4px $default-spacer; + background: $grey; + color: #FFFFFF; + border-radius: 4px; + font-size: 12px; +} diff --git a/app/assets/stylesheets/new_design/procedure_list.scss b/app/assets/stylesheets/new_design/procedure_list.scss index e15577c86..733d97c71 100644 --- a/app/assets/stylesheets/new_design/procedure_list.scss +++ b/app/assets/stylesheets/new_design/procedure_list.scss @@ -32,6 +32,10 @@ } } + .procedure-status { + margin-left: auto; + } + .procedure-stats { li { min-height: 36px; diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index 0e5527940..0c5b64d7d 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -34,3 +34,7 @@ = archived_count .stats-legend = "archivé".pluralize(archived_count, :fr) + + - if p.archivee? + .procedure-status + %span.label Archivée diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index e04365bfb..4b3d16152 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -39,6 +39,10 @@ %li = link_to "Onglet 3", "#" + %h2 Labels + + %span.label .label + %h2 Layout deux colonnes .two-columns From 05f83fb3d31a62f680d81c729b11b6703c98e3ce Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 4 Jul 2017 10:26:50 +0200 Subject: [PATCH 011/222] convert simple quote to double quote --- .../new_gestionnaire/procedures_controller_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index fc7623488..2e36d0e77 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe NewGestionnaire::ProceduresController, type: :controller do - describe 'before_action: ensure_ownership!' do - it 'is present' do + describe "before_action: ensure_ownership!" do + it "is present" do before_actions = NewGestionnaire::ProceduresController ._process_action_callbacks .find_all{|process_action_callbacks| process_action_callbacks.kind == :before} @@ -12,7 +12,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do end end - describe 'ensure_ownership!' do + describe "ensure_ownership!" do let(:gestionnaire) { create(:gestionnaire) } before do @@ -23,19 +23,19 @@ describe NewGestionnaire::ProceduresController, type: :controller do @controller.send(:ensure_ownership!) end - context 'when a gestionnaire asks for its procedure' do + context "when a gestionnaire asks for its procedure" do let(:asked_procedure) { create(:procedure, gestionnaires: [gestionnaire]) } - it 'does not redirects nor flash' do + it "does not redirects nor flash" do expect(@controller).not_to have_received(:redirect_to) expect(flash.alert).to eq(nil) end end - context 'when a gestionnaire asks for another procedure' do + context "when a gestionnaire asks for another procedure" do let(:asked_procedure) { create(:procedure) } - it 'redirects and flash' do + it "redirects and flash" do expect(@controller).to have_received(:redirect_to).with(root_path) expect(flash.alert).to eq("Vous n'avez pas accès à cette procédure") end From f7d1cfc462f8ad7de373525cc71caf12b83f87f8 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 4 Jul 2017 13:52:08 +0200 Subject: [PATCH 012/222] Add tests on procedures#index --- .../procedures_controller_spec.rb | 77 +++++++++++++++++++ spec/factories/procedure.rb | 6 ++ 2 files changed, 83 insertions(+) diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index 2e36d0e77..029da58d8 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -41,4 +41,81 @@ describe NewGestionnaire::ProceduresController, type: :controller do end end end + + describe "#index" do + let(:gestionnaire) { create(:gestionnaire) } + subject { get :index } + + context "when not logged" do + before { subject } + it { expect(response).to redirect_to(new_user_session_path)} + end + + context "when logged in" do + before { sign_in(gestionnaire) } + + it { expect(response).to have_http_status(:ok) } + + context "with procedures assigned" do + let(:procedure1) { create(:procedure, :published) } + let(:procedure2) { create(:procedure, :published, :archived) } + let(:procedure3) { create(:procedure) } + + before do + gestionnaire.procedures << procedure1 + gestionnaire.procedures << procedure2 + gestionnaire.procedures << procedure3 + subject + end + + it { expect(assigns(:procedures)).to include(procedure1, procedure2, procedure3) } + end + + context "with dossiers" do + let(:procedure) { create(:procedure, :published) } + let(:dossier) { create(:dossier, state: state, procedure: procedure) } + + before do + gestionnaire.procedures << procedure + dossier + end + + context "with draft state" do + let(:state) { "draft" } + before { subject } + + it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(nil) } + it { expect(assigns(:dossiers_nouveaux_count_per_procedure)[procedure.id]).to eq(nil) } + it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure.id]).to eq(nil) } + it { expect(assigns(:followed_dossiers_count_per_procedure)[procedure.id]).to eq(nil) } + end + + context "with not draft state on multiple procedures" do + let(:procedure2) { create(:procedure, :published) } + let(:state) { "initiated" } + + before do + gestionnaire.procedures << procedure2 + create(:dossier, procedure: procedure, state: "replied") + create(:dossier, procedure: procedure2, state: "updated") + create(:dossier, procedure: procedure, state: "received") + create(:dossier, procedure: procedure2, state: "closed") + create(:dossier, procedure: procedure, state: "without_continuation", archived: true) + gestionnaire.followed_dossiers << create(:dossier, procedure: procedure2, state: "refused") + subject + end + + it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(4) } + it { expect(assigns(:dossiers_nouveaux_count_per_procedure)[procedure.id]).to eq(1) } + it { expect(assigns(:followed_dossiers_count_per_procedure)[procedure.id]).to eq(nil) } + it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure.id]).to eq(1) } + + it { expect(assigns(:dossiers_count_per_procedure)[procedure2.id]).to eq(3) } + it { expect(assigns(:dossiers_nouveaux_count_per_procedure)[procedure2.id]).to eq(nil) } + it { expect(assigns(:followed_dossiers_count_per_procedure)[procedure2.id]).to eq(1) } + it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure2.id]).to eq(nil) } + end + end + end + end end diff --git a/spec/factories/procedure.rb b/spec/factories/procedure.rb index 558741a97..e258bd329 100644 --- a/spec/factories/procedure.rb +++ b/spec/factories/procedure.rb @@ -98,5 +98,11 @@ FactoryGirl.define do procedure.publish!(generate(:published_path)) end end + + trait :archived do + after(:build) do |procedure, _evaluator| + procedure.archived_at = Time.now + end + end end end From 22bb4b7c9249fbed97f140e202c80de709ea814c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 4 Jul 2017 14:29:38 +0200 Subject: [PATCH 013/222] Change link in switch profile menu to match new route --- app/views/layouts/_new_header.haml | 2 +- app/views/layouts/_switch_devise_profile_module.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index de39ce4d3..e8fab8fb4 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -34,7 +34,7 @@ Passer en usager - if gestionnaire_signed_in? %li - = link_to backoffice_dossiers_path, class: "menu-item menu-link" do + = link_to procedures_path, class: "menu-item menu-link" do = image_tag "icons/switch-profile.svg" Passer en accompagnateur - if administrateur_signed_in? diff --git a/app/views/layouts/_switch_devise_profile_module.html.haml b/app/views/layouts/_switch_devise_profile_module.html.haml index ab51a0053..b8b0de852 100644 --- a/app/views/layouts/_switch_devise_profile_module.html.haml +++ b/app/views/layouts/_switch_devise_profile_module.html.haml @@ -12,7 +12,7 @@ Usager - if gestionnaire_signed_in? %li - = link_to(backoffice_dossiers_path) do + = link_to(procedures_path) do %i.fa.fa-user   Accompagnateur From 009a478526a51e30f95e8996567f34902bfa488d Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 11:14:34 +0200 Subject: [PATCH 014/222] Remove %page-width-container from landing --- app/assets/stylesheets/new_design/landing.scss | 4 ---- app/views/root/landing.html.haml | 12 ++++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/new_design/landing.scss b/app/assets/stylesheets/new_design/landing.scss index 769f49622..39b2159e6 100644 --- a/app/assets/stylesheets/new_design/landing.scss +++ b/app/assets/stylesheets/new_design/landing.scss @@ -11,10 +11,6 @@ @include vertical-padding(60px); } -.landing-panel-inner-content { - @extend %page-width-container; -} - $landing-breakpoint: 1040px; .hero-wrapper { diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index b0ec1f25e..b57f03c79 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -1,6 +1,6 @@ .landing .landing-panel.hero-panel - .landing-panel-inner-content + .container .hero-wrapper .hero-text %p.hero-tagline @@ -17,7 +17,7 @@ %img{ :src => image_url("landing/hero/dematerialiser.svg") } .landing-panel.features-panel - .landing-panel-inner-content + .container %h2.landing-panel-title.features-panel-title Un outil dédié aux organismes publics %ul.features @@ -47,7 +47,7 @@ à plusieurs .landing-panel - .landing-panel-inner-content + .container %h2.landing-panel-title Ce que les utilisateurs pensent du service %ul.quotes @@ -75,7 +75,7 @@ - cache "numbers-panel", :expires_in => 3.hours do .landing-panel.numbers-panel - .landing-panel-inner-content + .container %h2.landing-panel-title TPS en chiffres %ul.numbers %li.number @@ -101,7 +101,7 @@ des délais de traitement .landing-panel.users-panel - .landing-panel-inner-content + .container %h2.landing-panel-title Ils nous font confiance %ul.users @@ -122,7 +122,7 @@ %img.user-image{ :src => image_url("landing/users/driea-idf.jpg") } .landing-panel.cta-panel - .landing-panel-inner-content + .container .cta-panel-wrapper %div %h1.cta-panel-title Commencez à dématerialiser vos procédures From d0fa94fef08affc255a26ea7692d9eca13063bff Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 12:17:20 +0200 Subject: [PATCH 015/222] Remove %page-width-container from footer --- app/assets/stylesheets/new_design/new_footer.scss | 4 ---- app/views/layouts/_new_footer.html.haml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/assets/stylesheets/new_design/new_footer.scss b/app/assets/stylesheets/new_design/new_footer.scss index c88b853cd..b87df08f1 100644 --- a/app/assets/stylesheets/new_design/new_footer.scss +++ b/app/assets/stylesheets/new_design/new_footer.scss @@ -9,10 +9,6 @@ border-top: 1px solid $border-grey; } -.footer-inner-content { - @extend %page-width-container; -} - .footer-columns { @extend %horizontal-list; justify-content: flex-start; diff --git a/app/views/layouts/_new_footer.html.haml b/app/views/layouts/_new_footer.html.haml index 4bcc09bc8..5bba26b0f 100644 --- a/app/views/layouts/_new_footer.html.haml +++ b/app/views/layouts/_new_footer.html.haml @@ -1,5 +1,5 @@ .footer - .footer-inner-content + .container %ul.footer-columns %li.footer-column %ul.footer-logos From 180044acff498eefd378fa3f1d90742ec0944ae6 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 12:23:33 +0200 Subject: [PATCH 016/222] Remove %page-width-container from layouts --- app/assets/stylesheets/new_design/layouts.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/new_design/layouts.scss b/app/assets/stylesheets/new_design/layouts.scss index 98fcfe043..467f18ff0 100644 --- a/app/assets/stylesheets/new_design/layouts.scss +++ b/app/assets/stylesheets/new_design/layouts.scss @@ -1,6 +1,6 @@ @import "colors"; +@import "common"; @import "constants"; -@import "placeholders"; .two-columns { $column-padding: 60px; @@ -9,7 +9,7 @@ background: linear-gradient(to right, #FFFFFF 0%, #FFFFFF 50%, $light-grey 50%, $light-grey 100%); .columns-container { - @extend %page-width-container; + @extend .container; display: flex; flex-direction: row; align-items: center; From b02264969972d7d28c8c330de5bfb4a3027ec410 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 13:47:19 +0200 Subject: [PATCH 017/222] Remove %page-width-container from header --- app/assets/stylesheets/new_design/new_header.scss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss index d84f939f9..11e0b1f4b 100644 --- a/app/assets/stylesheets/new_design/new_header.scss +++ b/app/assets/stylesheets/new_design/new_header.scss @@ -1,7 +1,7 @@ -@import "constants"; @import "colors"; +@import "common"; +@import "constants"; @import "mixins"; -@import "placeholders"; // FIXME: Rename when the header is generalized .new-header { @@ -14,7 +14,7 @@ } .header-inner-content { - @extend %page-width-container; + @extend .container; display: flex; justify-content: space-between; height: 100%; From e2735b4238d7b7da7ec986449cd920ef4a114ba8 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 14:14:16 +0200 Subject: [PATCH 018/222] Remove %page-width-container from patron --- app/assets/stylesheets/new_design/patron.scss | 4 ---- app/views/root/patron.html.haml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/app/assets/stylesheets/new_design/patron.scss b/app/assets/stylesheets/new_design/patron.scss index 54bc0e0d3..9c255eb6f 100644 --- a/app/assets/stylesheets/new_design/patron.scss +++ b/app/assets/stylesheets/new_design/patron.scss @@ -1,10 +1,6 @@ @import "placeholders"; .patron { - .patron-container { - @extend %page-width-container; - } - p { margin-bottom: 20px; } diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 4b3d16152..3a928dbc0 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -1,5 +1,5 @@ .patron - .patron-container + .container %h1 Patron %h2 Formulaires From 0528b83fcc3f4f751aa099f9d94fc3d6dc443447 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 14:15:57 +0200 Subject: [PATCH 019/222] Remove %page-width-container from common --- app/assets/stylesheets/new_design/_placeholders.scss | 7 ------- app/assets/stylesheets/new_design/common.scss | 6 +++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/new_design/_placeholders.scss b/app/assets/stylesheets/new_design/_placeholders.scss index 086e5ecfe..53e98918e 100644 --- a/app/assets/stylesheets/new_design/_placeholders.scss +++ b/app/assets/stylesheets/new_design/_placeholders.scss @@ -1,5 +1,4 @@ @import "constants"; -@import "mixins"; %horizontal-list { list-style-type: none; @@ -14,12 +13,6 @@ display: inline-block; } -%page-width-container { - @include horizontal-padding($default-padding); - max-width: $page-width + 2 * $default-padding; - margin: 0 auto; -} - %animation { animation-fill-mode: forwards; animation-duration: 0.3s; diff --git a/app/assets/stylesheets/new_design/common.scss b/app/assets/stylesheets/new_design/common.scss index d956cdc94..356958032 100644 --- a/app/assets/stylesheets/new_design/common.scss +++ b/app/assets/stylesheets/new_design/common.scss @@ -1,3 +1,5 @@ +@import "constants"; +@import "mixins"; @import "placeholders"; @import "typography"; @@ -13,5 +15,7 @@ h1 { } .container { - @extend %page-width-container; + @include horizontal-padding($default-padding); + max-width: $page-width + 2 * $default-padding; + margin: 0 auto; } From b48af51ee9483813e8b5f929b1acf35ca41b186c Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 11 Jul 2017 16:09:03 +0200 Subject: [PATCH 020/222] NewDesign: procedure show only header --- .../new_design/procedures_show.scss | 75 +++++++++++++++++++ .../new_gestionnaire/procedures_controller.rb | 20 +++++ app/models/dossier.rb | 24 +++--- .../procedures/show.html.haml | 33 ++++++++ config/locales/fr.yml | 17 +++++ config/routes.rb | 8 +- .../procedures_controller_spec.rb | 67 +++++++++++++++++ 7 files changed, 231 insertions(+), 13 deletions(-) create mode 100644 app/assets/stylesheets/new_design/procedures_show.scss create mode 100644 app/views/new_gestionnaire/procedures/show.html.haml diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss new file mode 100644 index 000000000..3e9772d98 --- /dev/null +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -0,0 +1,75 @@ +@import "colors"; +@import "common"; +@import "constants"; + +#procedure-show { + .header { + background-color: $light-grey; + padding-top: $default-padding; + + .container { + display: flex; + } + + .procedure-logo { + margin-right: $default-padding; + } + + h1 { + color: $black; + font-size: 22px; + margin-bottom: 2 * $default-padding; + } + + .dossiers-categories { + li { + display: inline-block; + height: 56px; + width: 130px; + line-height: 17px; + position: relative; + text-align: center; + font-size: 14px; + + a { + color: $black; + } + + &::before, + &:last-child::after { + content: ""; + position: absolute; + height: 36px; + width: 1px; + background-color: $border-grey; + margin-right: $default-padding; + } + + &::before { + left: 0px; + } + + &:last-child::after { + right: 0px; + top: 0px; + margin-right: 0px; + } + + &.active { + border-bottom: 2px solid $blue; + + a { + color: $blue; + } + } + + .dossiers-count { + position: relative; + display: block; + font-size: 16px; + font-weight: bold; + } + } + } + } +} diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index 26940b425..23e943b03 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -15,6 +15,26 @@ module NewGestionnaire @followed_dossiers_count_per_procedure = current_gestionnaire.followed_dossiers.where(procedure: @procedures).group(:procedure_id).count end + def show + @procedure = procedure + + @a_suivre_dossiers = procedure + .dossiers + .without_followers + .en_cours + + @followed_dossiers = current_gestionnaire + .followed_dossiers + .where(procedure: @procedure) + .en_cours + + @termines_dossiers = procedure.dossiers.termine + + @all_state_dossiers = procedure.dossiers.all_state + + @archived_dossiers = procedure.dossiers.archived + end + private def procedure diff --git a/app/models/dossier.rb b/app/models/dossier.rb index eb0c573f0..d916cc51a 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -17,6 +17,7 @@ class Dossier < ActiveRecord::Base WAITING_FOR_USER = %w(replied) EN_CONSTRUCTION = %w(initiated updated replied) EN_INSTRUCTION = %w(received) + EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION A_INSTRUIRE = %w(received) TERMINE = %w(closed refused without_continuation) @@ -43,16 +44,17 @@ class Dossier < ActiveRecord::Base belongs_to :user default_scope { where(hidden_at: nil) } - scope :state_brouillon, -> { where(state: BROUILLON) } - scope :state_not_brouillon, -> { where.not(state: BROUILLON) } - scope :state_nouveaux, -> { where(state: NOUVEAUX) } - scope :state_ouvert, -> { where(state: OUVERT) } - scope :state_waiting_for_gestionnaire, -> { where(state: WAITING_FOR_GESTIONNAIRE) } - scope :state_waiting_for_user, -> { where(state: WAITING_FOR_USER) } - scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) } - scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) } - scope :state_a_instruire, -> { where(state: A_INSTRUIRE) } - scope :state_termine, -> { where(state: TERMINE) } + scope :state_brouillon, -> { where(state: BROUILLON) } + scope :state_not_brouillon, -> { where.not(state: BROUILLON) } + scope :state_nouveaux, -> { where(state: NOUVEAUX) } + scope :state_ouvert, -> { where(state: OUVERT) } + scope :state_waiting_for_gestionnaire, -> { where(state: WAITING_FOR_GESTIONNAIRE) } + scope :state_waiting_for_user, -> { where(state: WAITING_FOR_USER) } + scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) } + scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) } + scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) } + scope :state_a_instruire, -> { where(state: A_INSTRUIRE) } + scope :state_termine, -> { where(state: TERMINE) } scope :archived, -> { where(archived: true) } scope :not_archived, -> { where(archived: false) } @@ -67,6 +69,8 @@ class Dossier < ActiveRecord::Base scope :a_instruire, -> { not_archived.state_a_instruire.order_by_updated_at(:asc) } scope :termine, -> { not_archived.state_termine.order_by_updated_at(:asc) } scope :downloadable, -> { state_not_brouillon.order_by_updated_at(:asc) } + scope :en_cours, -> { not_archived.state_en_construction_ou_instruction.order_by_updated_at(:asc) } + scope :without_followers, -> { includes(:follows).where(follows: { id: nil }) } accepts_nested_attributes_for :individual diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml new file mode 100644 index 000000000..916dd91fc --- /dev/null +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -0,0 +1,33 @@ +#procedure-show + .header + .container + - if @procedure.logo.present? + = image_tag @procedure.logo, height: 40, class: 'procedure-logo' + + .right + %h1= @procedure.libelle + %ul.dossiers-categories + %li{ class: (@statut == 'a-suivre') ? 'active' : nil }> + = link_to(procedure_path(@procedure, statut: 'a-suivre')) do + %span.dossiers-count= @a_suivre_dossiers.count + à suivre + + %li{ class: (@statut == 'suivis') ? 'active' : nil }> + = link_to(procedure_path(@procedure, statut: 'suivis')) do + %span.dossiers-count= @followed_dossiers.count + = t('pluralize.followed', count: @followed_dossiers.count) + + %li{ class: (@statut == 'traites') ? 'active' : nil }> + = link_to(procedure_path(@procedure, statut: 'traites')) do + %span.dossiers-count= @termines_dossiers.count + = t('pluralize.processed', count: @termines_dossiers.count) + + %li{ class: (@statut == 'tous') ? 'active' : nil }> + = link_to(procedure_path(@procedure, statut: 'tous')) do + %span.dossiers-count= @all_state_dossiers.count + tous les dossiers + + %li{ class: (@statut == 'archives') ? 'active' : nil }> + = link_to(procedure_path(@procedure, statut: 'archives')) do + %span.dossiers-count= @archived_dossiers.count + = t('pluralize.archived', count: @archived_dossiers.count) diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b94806305..590b7b894 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -285,3 +285,20 @@ fr: x_seconds: one: 1 seconde other: "%{count} secondes" + pluralize: + processed: + zero: traité + one: traité + other: traités + new: + zero: nouveau + one: nouveau + other: nouveaux + followed: + zero: suivi + one: suivi + other: suivis + archived: + zero: archivé + one: archivé + other: archivés diff --git a/config/routes.rb b/config/routes.rb index 8ce8d4502..50d309cbd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -238,9 +238,11 @@ Rails.application.routes.draw do end scope module: 'new_gestionnaire' do - resources :procedures, only: [:index] do - resources :dossiers, only: [] do - get 'attestation' + resources :procedures, only: [:index, :show], param: :procedure_id do + member do + resources :dossiers, only: [] do + get 'attestation' + end end end end diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index 029da58d8..e9c64db6c 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -118,4 +118,71 @@ describe NewGestionnaire::ProceduresController, type: :controller do end end end + + describe "#show" do + let(:gestionnaire) { create(:gestionnaire) } + let!(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) } + + context "when logged in" do + before do + sign_in(gestionnaire) + get :show, params: { procedure_id: procedure.id } + end + + it { expect(response).to have_http_status(:ok) } + it { expect(assigns(:procedure)).to eq(procedure) } + + context 'with a new draft dossier' do + let!(:draft_dossier) { create(:dossier, procedure: procedure, state: 'draft') } + + it { expect(assigns(:a_suivre_dossiers)).to be_empty } + it { expect(assigns(:followed_dossiers)).to be_empty } + it { expect(assigns(:termines_dossiers)).to be_empty } + it { expect(assigns(:all_state_dossiers)).to be_empty } + it { expect(assigns(:archived_dossiers)).to be_empty } + end + + context 'with a new dossier without follower' do + let!(:new_unfollow_dossier) { create(:dossier, procedure: procedure, state: 'received') } + + it { expect(assigns(:a_suivre_dossiers)).to match([new_unfollow_dossier]) } + it { expect(assigns(:followed_dossiers)).to be_empty } + it { expect(assigns(:termines_dossiers)).to be_empty } + it { expect(assigns(:all_state_dossiers)).to match([new_unfollow_dossier]) } + it { expect(assigns(:archived_dossiers)).to be_empty } + end + + context 'with a new dossier with a follower' do + let!(:new_followed_dossier) { create(:dossier, procedure: procedure, state: 'received') } + + before { gestionnaire.followed_dossiers << new_followed_dossier } + + it { expect(assigns(:a_suivre_dossiers)).to be_empty } + it { expect(assigns(:followed_dossiers)).to match([new_followed_dossier]) } + it { expect(assigns(:termines_dossiers)).to be_empty } + it { expect(assigns(:all_state_dossiers)).to match([new_followed_dossier]) } + it { expect(assigns(:archived_dossiers)).to be_empty } + end + + context 'with a termine dossier with a follower' do + let!(:termine_dossier) { create(:dossier, procedure: procedure, state: 'closed') } + + it { expect(assigns(:a_suivre_dossiers)).to be_empty } + it { expect(assigns(:followed_dossiers)).to be_empty } + it { expect(assigns(:termines_dossiers)).to match([termine_dossier]) } + it { expect(assigns(:all_state_dossiers)).to match([termine_dossier]) } + it { expect(assigns(:archived_dossiers)).to be_empty } + end + + context 'with an archived dossier' do + let!(:archived_dossier) { create(:dossier, procedure: procedure, state: 'received', archived: true) } + + it { expect(assigns(:a_suivre_dossiers)).to be_empty } + it { expect(assigns(:followed_dossiers)).to be_empty } + it { expect(assigns(:termines_dossiers)).to be_empty } + it { expect(assigns(:all_state_dossiers)).to be_empty } + it { expect(assigns(:archived_dossiers)).to match([archived_dossier]) } + end + end + end end From ad1a11ab52dd3e2e2d030ef41095af9a4a2f34ef Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 11 Jul 2017 15:40:09 +0200 Subject: [PATCH 021/222] NewDesign: procedure show add dossier table --- .../new_design/procedures_show.scss | 67 +++++++++++++++++++ .../new_gestionnaire/procedures_controller.rb | 15 +++++ .../procedures/show.html.haml | 17 +++++ .../procedures_controller_spec.rb | 53 +++++++++++++++ 4 files changed, 152 insertions(+) diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index 3e9772d98..55346a949 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -72,4 +72,71 @@ } } } + + .dossiers-table { + margin: (2 * $default-padding) auto; + width: 100%; + + tr { + border-bottom: 1px solid $border-grey; + + &:last-child { + border-bottom: none; + } + + &:hover { + background-color: $light-grey; + } + + &:first-child { + &:hover { + background: #FFFFFF; + } + } + } + + th { + font-weight: bold; + padding: (1.5 * $default-padding) 2px; + text-align: left; + } + + td { + vertical-align: middle; + } + + .number-col { + width: 130px; + + a::before { + content: ""; + background-image: image-url("icons/folder.svg"); + display: inline-block; + width: 24px; + height: 24px; + margin: 0 $default-spacer; + } + } + + .big-link { + color: $black; + display: flex; + align-items: center; + padding: (1.5 * $default-padding) 2px; + } + + .status-col { + width: 200px; + } + + .follow-col { + width: 200px; + } + + h2 { + font-size: 20px; + font-weight: bold; + text-align: center; + margin: 60px 0; + } } diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index 23e943b03..396834df5 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -33,6 +33,21 @@ module NewGestionnaire @all_state_dossiers = procedure.dossiers.all_state @archived_dossiers = procedure.dossiers.archived + + @statut = params[:statut].present? ? params[:statut] : 'a-suivre' + + @dossiers = case @statut + when 'a-suivre' + @a_suivre_dossiers + when 'suivis' + @followed_dossiers + when 'traites' + @termines_dossiers + when 'tous' + @all_state_dossiers + when 'archives' + @archived_dossiers + end end private diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 916dd91fc..21ccbb9a6 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -31,3 +31,20 @@ = link_to(procedure_path(@procedure, statut: 'archives')) do %span.dossiers-count= @archived_dossiers.count = t('pluralize.archived', count: @archived_dossiers.count) + + .container + - if @dossiers.present? + %table.dossiers-table + %tr + %th.number-col Nº dossier + %th Demandeur + %th.status-col Statut + %th.follow-col + - @dossiers.each do |dossier| + %tr + %td.number-col= link_to(dossier.id, backoffice_dossier_path(dossier), class: 'big-link') + %td= link_to(dossier.user.email, backoffice_dossier_path(dossier), class: 'big-link') + %td.status-col + %td.follow-col + - else + %h2 Aucun dossier diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index e9c64db6c..469ad1312 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -183,6 +183,59 @@ describe NewGestionnaire::ProceduresController, type: :controller do it { expect(assigns(:all_state_dossiers)).to be_empty } it { expect(assigns(:archived_dossiers)).to match([archived_dossier]) } end + + describe 'statut' do + let!(:a_suivre__dossier) { create(:dossier, procedure: procedure, state: 'received') } + let!(:new_followed_dossier) { create(:dossier, procedure: procedure, state: 'received') } + let!(:termine_dossier) { create(:dossier, procedure: procedure, state: 'closed') } + let!(:archived_dossier) { create(:dossier, procedure: procedure, state: 'received', archived: true) } + before do + gestionnaire.followed_dossiers << new_followed_dossier + get :show, params: { procedure_id: procedure.id, statut: statut } + end + + context 'when statut is empty' do + let(:statut) { nil } + + it { expect(assigns(:dossiers)).to match([a_suivre__dossier]) } + it { expect(assigns(:statut)).to eq('a-suivre') } + end + + context 'when statut is a-suivre' do + let(:statut) { 'a-suivre' } + + it { expect(assigns(:statut)).to eq('a-suivre') } + it { expect(assigns(:dossiers)).to match([a_suivre__dossier]) } + end + + context 'when statut is suivis' do + let(:statut) { 'suivis' } + + it { expect(assigns(:statut)).to eq('suivis') } + it { expect(assigns(:dossiers)).to match([new_followed_dossier]) } + end + + context 'when statut is traites' do + let(:statut) { 'traites' } + + it { expect(assigns(:statut)).to eq('traites') } + it { expect(assigns(:dossiers)).to match([termine_dossier]) } + end + + context 'when statut is tous' do + let(:statut) { 'tous' } + + it { expect(assigns(:statut)).to eq('tous') } + it { expect(assigns(:dossiers)).to match([a_suivre__dossier, new_followed_dossier, termine_dossier]) } + end + + context 'when statut is archives' do + let(:statut) { 'archives' } + + it { expect(assigns(:statut)).to eq('archives') } + it { expect(assigns(:dossiers)).to match([archived_dossier]) } + end + end end end end From 013f2463d19f8d80eeea5c93fdba0ac3ac6765eb Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 11 Jul 2017 15:43:20 +0200 Subject: [PATCH 022/222] NewDesign: procedure show add dossier status --- .../stylesheets/new_design/_colors.scss | 2 ++ .../new_design/procedures_show.scss | 30 +++++++++++++++++++ app/models/dossier.rb | 8 +++++ .../procedures/_status.html.haml | 10 +++++++ .../procedures/show.html.haml | 2 ++ 5 files changed, 52 insertions(+) create mode 100644 app/views/new_gestionnaire/procedures/_status.html.haml diff --git a/app/assets/stylesheets/new_design/_colors.scss b/app/assets/stylesheets/new_design/_colors.scss index ab61a6c21..fe9ece182 100644 --- a/app/assets/stylesheets/new_design/_colors.scss +++ b/app/assets/stylesheets/new_design/_colors.scss @@ -7,3 +7,5 @@ $border-grey: #CCCCCC; $dark-red: #A94442; $light-red: #EBCCD1; $lighter-red: #F2DEDE; +$green: #35D49E; +$orange: #F59415; diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index 55346a949..009f9de52 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -133,6 +133,36 @@ width: 200px; } + .label { + width: 110px; + text-align: center; + + &.instruction { + background-color: #FFFFFF; + color: $blue; + border: 1px solid $blue; + } + + &.construction { + background-color: #FFFFFF; + color: $black; + border: 1px solid $black; + } + + &.closed { + background-color: $green; + } + + &.refused { + background-color: $dark-red; + } + + &.without-continuation { + background-color: $black; + } + } + } + h2 { font-size: 20px; font-weight: bold; diff --git a/app/models/dossier.rb b/app/models/dossier.rb index d916cc51a..c58cf59a2 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -217,6 +217,14 @@ class Dossier < ActiveRecord::Base BROUILLON.include?(state) end + def en_construction? + EN_CONSTRUCTION.include?(state) + end + + def en_instruction? + EN_INSTRUCTION.include?(state) + end + def cerfa_available? procedure.cerfa_flag? && cerfa.size != 0 end diff --git a/app/views/new_gestionnaire/procedures/_status.html.haml b/app/views/new_gestionnaire/procedures/_status.html.haml new file mode 100644 index 000000000..23297e4e4 --- /dev/null +++ b/app/views/new_gestionnaire/procedures/_status.html.haml @@ -0,0 +1,10 @@ +- if dossier.en_instruction? + %span.label.instruction en instruction +- elsif dossier.en_construction? + %span.label.construction nouveau +- elsif dossier.closed? + %span.label.closed accepté +- elsif dossier.refused? + %span.label.refused refusé +- elsif dossier.without_continuation? + %span.label.without-continuation sans suite diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 21ccbb9a6..36e9ce746 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -45,6 +45,8 @@ %td.number-col= link_to(dossier.id, backoffice_dossier_path(dossier), class: 'big-link') %td= link_to(dossier.user.email, backoffice_dossier_path(dossier), class: 'big-link') %td.status-col + = link_to(backoffice_dossier_path(dossier), class: 'big-link') do + = render partial: 'status', locals: { dossier: dossier } %td.follow-col - else %h2 Aucun dossier From eb653188448b17a7df3d6f28be8880cea8b25209 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 11 Jul 2017 15:45:20 +0200 Subject: [PATCH 023/222] NewDesign: add follow and unfollow actions on dossier --- .../new_gestionnaire/dossiers_controller.rb | 10 +++++++++ config/routes.rb | 2 ++ .../dossiers_controller_spec.rb | 22 ++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 417e90ea8..a151ebd91 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -4,6 +4,16 @@ module NewGestionnaire send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf') end + def follow + current_gestionnaire.followed_dossiers << dossier + redirect_back(fallback_location: procedures_url) + end + + def unfollow + current_gestionnaire.followed_dossiers.delete(dossier) + redirect_back(fallback_location: procedures_url) + end + private def dossier diff --git a/config/routes.rb b/config/routes.rb index 50d309cbd..52d4c043b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -242,6 +242,8 @@ Rails.application.routes.draw do member do resources :dossiers, only: [] do get 'attestation' + patch 'follow' + patch 'unfollow' end end end diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 0ec7b4bda..f94e69ea9 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -2,12 +2,14 @@ require 'spec_helper' describe NewGestionnaire::DossiersController, type: :controller do let(:gestionnaire) { create(:gestionnaire) } + let(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) } + let(:dossier) { create(:dossier, procedure: procedure) } + before { sign_in(gestionnaire) } describe 'attestation' do context 'when a dossier has an attestation' do let(:fake_pdf) { double(read: 'pdf content') } - let!(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) } let!(:dossier) { create(:dossier, attestation: Attestation.new, procedure: procedure) } it 'returns the attestation pdf' do @@ -23,4 +25,22 @@ describe NewGestionnaire::DossiersController, type: :controller do end end end + + describe 'follow' do + before { patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id } } + + it { expect(gestionnaire.followed_dossiers).to match([dossier]) } + it { expect(response).to redirect_to(procedures_url) } + end + + describe 'unfollow' do + before do + gestionnaire.followed_dossiers << dossier + patch :unfollow, params: { procedure_id: procedure.id, dossier_id: dossier.id } + gestionnaire.reload + end + + it { expect(gestionnaire.followed_dossiers).to match([]) } + it { expect(response).to redirect_to(procedures_url) } + end end From a064ae64a4ba5a787edfa8c8be7ce88d568b26cd Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 11 Jul 2017 15:56:23 +0200 Subject: [PATCH 024/222] NewDesign: add archive and unarchive actions on dossier --- .../new_gestionnaire/dossiers_controller.rb | 10 +++++++++ config/routes.rb | 2 ++ .../dossiers_controller_spec.rb | 21 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index a151ebd91..2e29102ce 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -14,6 +14,16 @@ module NewGestionnaire redirect_back(fallback_location: procedures_url) end + def archive + dossier.update_attributes(archived: true) + redirect_back(fallback_location: procedures_url) + end + + def unarchive + dossier.update_attributes(archived: false) + redirect_back(fallback_location: procedures_url) + end + private def dossier diff --git a/config/routes.rb b/config/routes.rb index 52d4c043b..8ff672bb3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -244,6 +244,8 @@ Rails.application.routes.draw do get 'attestation' patch 'follow' patch 'unfollow' + patch 'archive' + patch 'unarchive' end end end diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index f94e69ea9..51100ab65 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -43,4 +43,25 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(gestionnaire.followed_dossiers).to match([]) } it { expect(response).to redirect_to(procedures_url) } end + + describe 'archive' do + before do + patch :archive, params: { procedure_id: procedure.id, dossier_id: dossier.id } + dossier.reload + end + + it { expect(dossier.archived).to be true } + it { expect(response).to redirect_to(procedures_url) } + end + + describe 'unarchive' do + before do + dossier.update_attributes(archived: true) + patch :unarchive, params: { procedure_id: procedure.id, dossier_id: dossier.id } + dossier.reload + end + + it { expect(dossier.archived).to be false } + it { expect(response).to redirect_to(procedures_url) } + end end From 0d3c145ef3358b029ab8a27bb5a87a129c789108 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 11 Jul 2017 15:58:31 +0200 Subject: [PATCH 025/222] NewDesign: procedure show add dossier actions --- app/assets/images/icons/archive.svg | 1 + app/assets/images/icons/folder.svg | 1 + app/assets/images/icons/follow-folder.svg | 1 + app/assets/images/icons/unarchive.svg | 1 + app/assets/images/icons/unfollow-folder.svg | 1 + .../stylesheets/new_design/buttons.scss | 9 +++++++++ app/assets/stylesheets/new_design/icons.scss | 19 +++++++++++++++++++ .../new_design/procedures_show.scss | 5 +++++ app/models/dossier.rb | 8 ++++++++ .../procedures/_dossier_actions.html.haml | 19 +++++++++++++++++++ .../procedures/show.html.haml | 2 +- app/views/root/patron.html.haml | 13 +++++++++++++ 12 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 app/assets/images/icons/archive.svg create mode 100644 app/assets/images/icons/folder.svg create mode 100644 app/assets/images/icons/follow-folder.svg create mode 100644 app/assets/images/icons/unarchive.svg create mode 100644 app/assets/images/icons/unfollow-folder.svg create mode 100644 app/assets/stylesheets/new_design/icons.scss create mode 100644 app/views/new_gestionnaire/procedures/_dossier_actions.html.haml diff --git a/app/assets/images/icons/archive.svg b/app/assets/images/icons/archive.svg new file mode 100644 index 000000000..845cd1e70 --- /dev/null +++ b/app/assets/images/icons/archive.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/icons/folder.svg b/app/assets/images/icons/folder.svg new file mode 100644 index 000000000..55cccb64e --- /dev/null +++ b/app/assets/images/icons/folder.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/icons/follow-folder.svg b/app/assets/images/icons/follow-folder.svg new file mode 100644 index 000000000..b5c7878b9 --- /dev/null +++ b/app/assets/images/icons/follow-folder.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/icons/unarchive.svg b/app/assets/images/icons/unarchive.svg new file mode 100644 index 000000000..b0098fd53 --- /dev/null +++ b/app/assets/images/icons/unarchive.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/icons/unfollow-folder.svg b/app/assets/images/icons/unfollow-folder.svg new file mode 100644 index 000000000..272efc828 --- /dev/null +++ b/app/assets/images/icons/unfollow-folder.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index bd4a512b8..187f7444d 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -1,4 +1,5 @@ @import "colors"; +@import "constants"; .button { display: inline-block; @@ -44,6 +45,14 @@ &.expand { width: 100%; } + + i { + width: 18px; + height: 18px; + background-size: 18px 18px; + vertical-align: middle; + margin-right: $default-spacer; + } } .link { diff --git a/app/assets/stylesheets/new_design/icons.scss b/app/assets/stylesheets/new_design/icons.scss new file mode 100644 index 000000000..4c4841270 --- /dev/null +++ b/app/assets/stylesheets/new_design/icons.scss @@ -0,0 +1,19 @@ +i { + display: inline-block; + + &.follow { + background-image: image-url("icons/follow-folder.svg"); + } + + &.unfollow { + background-image: image-url("icons/unfollow-folder.svg"); + } + + &.archive { + background-image: image-url("icons/archive.svg"); + } + + &.unarchive { + background-image: image-url("icons/unarchive.svg"); + } +} diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index 009f9de52..a6afebc3b 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -161,6 +161,11 @@ background-color: $black; } } + + .button { + width: 180px; + text-align: center; + } } h2 { diff --git a/app/models/dossier.rb b/app/models/dossier.rb index c58cf59a2..d96e90b1a 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -225,6 +225,14 @@ class Dossier < ActiveRecord::Base EN_INSTRUCTION.include?(state) end + def en_construction_ou_instruction? + EN_CONSTRUCTION_OU_INSTRUCTION.include?(state) + end + + def termine? + TERMINE.include?(state) + end + def cerfa_available? procedure.cerfa_flag? && cerfa.size != 0 end diff --git a/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml b/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml new file mode 100644 index 000000000..d3fb1feb9 --- /dev/null +++ b/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml @@ -0,0 +1,19 @@ +- if dossier.en_construction_ou_instruction? + - if current_gestionnaire.follow?(dossier) + = link_to dossier_unfollow_path(procedure, dossier), method: :patch, class: 'button' do + %i.unfollow> + ne plus suivre + - else + = link_to dossier_follow_path(procedure, dossier), method: :patch, class: 'button' do + %i.follow> + suivre le dossier + +- elsif dossier.termine? + - if dossier.archived + = link_to dossier_unarchive_path(procedure, dossier), method: :patch, class: 'button' do + %i.unarchive> + désarchiver le dossier + - else + = link_to dossier_archive_path(procedure, dossier), method: :patch, class: 'button' do + %i.archive> + archiver le dossier diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 36e9ce746..4b240158c 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -47,6 +47,6 @@ %td.status-col = link_to(backoffice_dossier_path(dossier), class: 'big-link') do = render partial: 'status', locals: { dossier: dossier } - %td.follow-col + %td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier } - else %h2 Aucun dossier diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 3a928dbc0..f94dbb1b7 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -26,6 +26,19 @@ = link_to ".button.large.primary", "#", class: "button large primary" + %p + = link_to "#", class: "button" do + %i.follow + = "%i.follow" + = link_to "#", class: "button" do + %i.unfollow + = "%i.unfollow" + = link_to "#", class: "button" do + %i.archive + = "%i.archive" + = link_to "#", class: "button" do + %i.unarchive + = "%i.unarchive" %p = link_to ".button.primary.expand", "#", class: "button primary expand" From 066788381763f49c7ff62fa79a1ca9094b640306 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 13 Jul 2017 11:09:50 +0200 Subject: [PATCH 026/222] NewDesign: new procedures index links to new procedure show ! --- app/views/new_gestionnaire/procedures/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index 0c5b64d7d..76aa7a868 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -7,7 +7,7 @@ = image_tag p.logo, class: "procedure-logo" .procedure-details %p.procedure-title - = link_to p.libelle, backoffice_dossiers_procedure_path(p) + = link_to(p.libelle, procedure_path(p)) %ul.procedure-stats.flex %li From 8cb770dc7a7e1c0d02784985743eabc890806aa1 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 13 Jul 2017 11:11:50 +0200 Subject: [PATCH 027/222] NewDesign: new procedures index respects logo dimension ratio --- app/assets/stylesheets/new_design/procedure_list.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/procedure_list.scss b/app/assets/stylesheets/new_design/procedure_list.scss index 733d97c71..a69dec297 100644 --- a/app/assets/stylesheets/new_design/procedure_list.scss +++ b/app/assets/stylesheets/new_design/procedure_list.scss @@ -14,7 +14,6 @@ .procedure-logo { margin-right: 16px; width: 40px; - height: 40px; border-bottom: 1px solid $border-grey; } From d58502ab4934d1e6d1fb7c1617fdad8c56cc4eb7 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 13 Jul 2017 14:47:17 +0200 Subject: [PATCH 028/222] NewDesign: fix pluralization on procedure index --- app/views/new_gestionnaire/procedures/index.html.haml | 8 ++++---- config/locales/fr.yml | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index 76aa7a868..98c1e015c 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -15,25 +15,25 @@ .stats-number = dossier_count .stats-legend - = "dossier".pluralize(dossier_count, :fr) + = t('pluralize.case', count: dossier_count) %li - nouveaux_count = @dossiers_nouveaux_count_per_procedure[p.id] || 0 .stats-number = nouveaux_count .stats-legend - = "nouveau".pluralize(nouveaux_count, :fr) + = t('pluralize.new', count: nouveaux_count) %li - followed_count = @followed_dossiers_count_per_procedure[p.id] || 0 .stats-number = followed_count .stats-legend - = "suivi".pluralize(followed_count, :fr) + = t('pluralize.followed', count: followed_count) %li - archived_count = @dossiers_archived_count_per_procedure[p.id] || 0 .stats-number = archived_count .stats-legend - = "archivé".pluralize(archived_count, :fr) + = t('pluralize.archived', count: archived_count) - if p.archivee? .procedure-status diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 590b7b894..2162eec59 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -286,6 +286,10 @@ fr: one: 1 seconde other: "%{count} secondes" pluralize: + case: + zero: dossier + one: dossier + other: dossiers processed: zero: traité one: traité From 962f55f6cc4f6c982314ce4987a215fe8a947149 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 13 Jul 2017 14:50:02 +0200 Subject: [PATCH 029/222] NewDesign: same order of categories in index and show --- .../new_gestionnaire/procedures/index.html.haml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index 98c1e015c..2bdeed3a1 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -10,12 +10,6 @@ = link_to(p.libelle, procedure_path(p)) %ul.procedure-stats.flex - %li - - dossier_count = @dossiers_count_per_procedure[p.id] || 0 - .stats-number - = dossier_count - .stats-legend - = t('pluralize.case', count: dossier_count) %li - nouveaux_count = @dossiers_nouveaux_count_per_procedure[p.id] || 0 .stats-number @@ -28,6 +22,12 @@ = followed_count .stats-legend = t('pluralize.followed', count: followed_count) + %li + - dossier_count = @dossiers_count_per_procedure[p.id] || 0 + .stats-number + = dossier_count + .stats-legend + = t('pluralize.case', count: dossier_count) %li - archived_count = @dossiers_archived_count_per_procedure[p.id] || 0 .stats-number From 5a0be8918efe97f4a62bbda1f8ddcea142c0a814 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 13 Jul 2017 15:14:03 +0200 Subject: [PATCH 030/222] NewDesign: procedure index show procedure image if present --- app/views/new_gestionnaire/procedures/index.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index 2bdeed3a1..d74dc7ca0 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -4,7 +4,9 @@ %ul.procedure-list - @procedures.each do |p| %li.procedure-item.flex.align-start - = image_tag p.logo, class: "procedure-logo" + - if p.logo.present? + = image_tag p.logo, class: "procedure-logo" + .procedure-details %p.procedure-title = link_to(p.libelle, procedure_path(p)) From 5b417889b2e2abdd65239c5104d03c742e1e5702 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 17 Jul 2017 11:22:12 +0200 Subject: [PATCH 031/222] Use same counters on procedures index than show --- .../new_gestionnaire/procedures_controller.rb | 13 +++++++++--- .../procedures/index.html.haml | 12 ++++++++--- .../procedures_controller_spec.rb | 21 ++++++++++++------- spec/factories/dossier.rb | 7 +++++++ 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index 396834df5..dfe750eb2 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -8,11 +8,18 @@ module NewGestionnaire @procedures = current_gestionnaire.procedures dossiers = current_gestionnaire.dossiers.state_not_brouillon - @dossiers_count_per_procedure = dossiers.group(:procedure_id).count - @dossiers_nouveaux_count_per_procedure = dossiers.state_nouveaux.group(:procedure_id).count + @dossiers_count_per_procedure = dossiers.all_state.group(:procedure_id).reorder(nil).count + @dossiers_a_suivre_count_per_procedure = dossiers.without_followers.en_cours.group(:procedure_id).reorder(nil).count @dossiers_archived_count_per_procedure = dossiers.archived.group(:procedure_id).count + @dossiers_termines_count_per_procedure = dossiers.termine.group(:procedure_id).reorder(nil).count - @followed_dossiers_count_per_procedure = current_gestionnaire.followed_dossiers.where(procedure: @procedures).group(:procedure_id).count + @followed_dossiers_count_per_procedure = current_gestionnaire + .followed_dossiers + .en_cours + .where(procedure: @procedures) + .group(:procedure_id) + .reorder(nil) + .count end def show diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index d74dc7ca0..953091bc0 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -13,17 +13,23 @@ %ul.procedure-stats.flex %li - - nouveaux_count = @dossiers_nouveaux_count_per_procedure[p.id] || 0 + - a_suivre_count = @dossiers_a_suivre_count_per_procedure[p.id] || 0 .stats-number - = nouveaux_count + = a_suivre_count .stats-legend - = t('pluralize.new', count: nouveaux_count) + à suivre %li - followed_count = @followed_dossiers_count_per_procedure[p.id] || 0 .stats-number = followed_count .stats-legend = t('pluralize.followed', count: followed_count) + %li + - termines_count = @dossiers_termines_count_per_procedure[p.id] || 0 + .stats-number + = termines_count + .stats-legend + = t('pluralize.processed', count: termines_count) %li - dossier_count = @dossiers_count_per_procedure[p.id] || 0 .stats-number diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index 469ad1312..1ba23a167 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -85,9 +85,10 @@ describe NewGestionnaire::ProceduresController, type: :controller do before { subject } it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(nil) } - it { expect(assigns(:dossiers_nouveaux_count_per_procedure)[procedure.id]).to eq(nil) } + it { expect(assigns(:dossiers_a_suivre_count_per_procedure)[procedure.id]).to eq(nil) } it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure.id]).to eq(nil) } it { expect(assigns(:followed_dossiers_count_per_procedure)[procedure.id]).to eq(nil) } + it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure.id]).to eq(nil) } end context "with not draft state on multiple procedures" do @@ -95,25 +96,29 @@ describe NewGestionnaire::ProceduresController, type: :controller do let(:state) { "initiated" } before do - gestionnaire.procedures << procedure2 create(:dossier, procedure: procedure, state: "replied") - create(:dossier, procedure: procedure2, state: "updated") create(:dossier, procedure: procedure, state: "received") - create(:dossier, procedure: procedure2, state: "closed") create(:dossier, procedure: procedure, state: "without_continuation", archived: true) - gestionnaire.followed_dossiers << create(:dossier, procedure: procedure2, state: "refused") + + gestionnaire.procedures << procedure2 + create(:dossier, :followed, procedure: procedure2, state: "updated") + create(:dossier, procedure: procedure2, state: "closed") + gestionnaire.followed_dossiers << create(:dossier, procedure: procedure2, state: "received") + subject end - it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(4) } - it { expect(assigns(:dossiers_nouveaux_count_per_procedure)[procedure.id]).to eq(1) } + it { expect(assigns(:dossiers_count_per_procedure)[procedure.id]).to eq(3) } + it { expect(assigns(:dossiers_a_suivre_count_per_procedure)[procedure.id]).to eq(3) } it { expect(assigns(:followed_dossiers_count_per_procedure)[procedure.id]).to eq(nil) } it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure.id]).to eq(1) } + it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure.id]).to eq(nil) } it { expect(assigns(:dossiers_count_per_procedure)[procedure2.id]).to eq(3) } - it { expect(assigns(:dossiers_nouveaux_count_per_procedure)[procedure2.id]).to eq(nil) } + it { expect(assigns(:dossiers_a_suivre_count_per_procedure)[procedure2.id]).to eq(nil) } it { expect(assigns(:followed_dossiers_count_per_procedure)[procedure2.id]).to eq(1) } it { expect(assigns(:dossiers_archived_count_per_procedure)[procedure2.id]).to eq(nil) } + it { expect(assigns(:dossiers_termines_count_per_procedure)[procedure2.id]).to eq(1) } end end end diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index f53eeb0f6..52c3ecc5b 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -65,6 +65,13 @@ FactoryGirl.define do end end + trait :followed do + after(:create) do |dossier, _evaluator| + g = create(:gestionnaire) + g.followed_dossiers << dossier + end + end + trait :replied do state 'replied' end From dc00c10366fc41ad93b5736fb9726c7784610ce7 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 15:49:29 +0200 Subject: [PATCH 032/222] Add card component to patron --- app/assets/stylesheets/new_design/card.scss | 22 +++++++++++++++++++++ app/views/root/patron.html.haml | 12 +++++++++++ 2 files changed, 34 insertions(+) create mode 100644 app/assets/stylesheets/new_design/card.scss diff --git a/app/assets/stylesheets/new_design/card.scss b/app/assets/stylesheets/new_design/card.scss new file mode 100644 index 000000000..1b5791288 --- /dev/null +++ b/app/assets/stylesheets/new_design/card.scss @@ -0,0 +1,22 @@ +@import "colors"; +@import "constants"; + +.card { + padding: ($default-spacer * 3) ($default-spacer * 2); + border: 1px solid $border-grey; + margin-bottom: $default-spacer * 2; + + &.featured { + border-top: 8px solid $blue; + + .card-title { + color: $blue; + } + } + + .card-title { + font-weight: bold; + font-size: 20px; + margin-bottom: $default-spacer; + } +} diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index f94dbb1b7..23fab1e13 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -56,6 +56,18 @@ %span.label .label + %h2 Cards + + .card + .card-title + Titre de la carte + Et voici le contenu de la carte + + .card.featured + .card-title + Titre de la carte mise en avant + Et voici le contenu de la carte + %h2 Layout deux colonnes .two-columns From 1c7d9eaa69cd911dc822e4e760dc1cb0bd38e104 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 16:25:51 +0200 Subject: [PATCH 033/222] Add table component to patron --- app/assets/stylesheets/new_design/table.scss | 21 ++++++++++++++++++++ app/views/root/patron.html.haml | 14 +++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 app/assets/stylesheets/new_design/table.scss diff --git a/app/assets/stylesheets/new_design/table.scss b/app/assets/stylesheets/new_design/table.scss new file mode 100644 index 000000000..18e85be56 --- /dev/null +++ b/app/assets/stylesheets/new_design/table.scss @@ -0,0 +1,21 @@ +@import "constants"; +@import "mixins"; + +.table { + width: 100%; + font-size: 14px; + line-height: 22px; + + th, + td { + @include vertical-padding($default-spacer) + } + + th { + text-align: left; + } + + td { + font-weight: bold; + } +} diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 23fab1e13..93cd99a2e 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -68,6 +68,20 @@ Titre de la carte mise en avant Et voici le contenu de la carte + %h2 Table + + %table.table + %tbody + %tr + %th Header 1 + %td Table Data 1 + %tr + %th Header 2 + %td Table Data 2 + %tr + %th Header 3 + %td Table Data 3 + %h2 Layout deux colonnes .two-columns From f9f313e990b449f4462b5ef452990cad358c14ba Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 16:33:36 +0200 Subject: [PATCH 034/222] =?UTF-8?q?Add=20identit=C3=A9=20demandeur=20for?= =?UTF-8?q?=20entreprise=20on=20dossier=20detail=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/new_design/card.scss | 2 +- .../new_gestionnaire/dossiers_controller.rb | 6 +- .../dossiers/_identite_entreprise.html.haml | 49 ++++++++++ .../new_gestionnaire/dossiers/show.html.haml | 5 + .../procedures/_dossier_actions.html.haml | 8 +- .../procedures/show.html.haml | 6 +- config/routes.rb | 14 +-- .../dossiers_controller_spec.rb | 95 +++++++++++++------ 8 files changed, 139 insertions(+), 46 deletions(-) create mode 100644 app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/show.html.haml diff --git a/app/assets/stylesheets/new_design/card.scss b/app/assets/stylesheets/new_design/card.scss index 1b5791288..c7c982d3c 100644 --- a/app/assets/stylesheets/new_design/card.scss +++ b/app/assets/stylesheets/new_design/card.scss @@ -17,6 +17,6 @@ .card-title { font-weight: bold; font-size: 20px; - margin-bottom: $default-spacer; + margin-bottom: $default-spacer * 2; } } diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 2e29102ce..9d314106d 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -4,6 +4,10 @@ module NewGestionnaire send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf') end + def show + @dossier = dossier + end + def follow current_gestionnaire.followed_dossiers << dossier redirect_back(fallback_location: procedures_url) @@ -27,7 +31,7 @@ module NewGestionnaire private def dossier - Dossier.find(params[:dossier_id]) + current_gestionnaire.dossiers.find(params[:dossier_id]) end end end diff --git a/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml b/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml new file mode 100644 index 000000000..6caa8fbba --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml @@ -0,0 +1,49 @@ +- entreprise = entreprise.decorate +- etablissement = entreprise.etablissement +%h4= entreprise.raison_sociale_or_name + +%table.table + %tbody + %tr + %th SIRET : + %td= entreprise.siret_siege_social + %tr + %th Forme juridique : + %td= entreprise.forme_juridique + - if etablissement.present? + %tr + %th Libellé NAF : + %td= etablissement.libelle_naf + %tr + %th Code NAF : + %td= etablissement.naf + %tr + %th Date de création : + %td= Time.at(entreprise.date_creation).localtime.strftime("%d/%m/%Y") + %tr + %th Effectif de l'organisation : + %td= entreprise.effectif + %tr + %th Code effectif : + %td= entreprise.code_effectif_entreprise + %tr + %th Numéro de TVA intracommunautaire : + %td= entreprise.numero_tva_intracommunautaire + - if etablissement.present? + %tr + %th Adresse : + %td + - etablissement.adresse.split("\n").each do |line| + = line + %br + %tr + %th Capital social : + %td= entreprise.pretty_capital_social + - if etablissement.present? + %tr + %th Exercices : + %td + - etablissement.exercices.each_with_index do |exercice, index| + = "#{exercice.dateFinExercice.year} : " + = number_to_currency(exercice.ca) + %br diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml new file mode 100644 index 000000000..fd77534c8 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -0,0 +1,5 @@ +.container + .card + .card-title Identité du demandeur + - if @dossier.entreprise.present? + = render partial: "identite_entreprise", locals: { entreprise: @dossier.entreprise } diff --git a/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml b/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml index d3fb1feb9..608671c6e 100644 --- a/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml +++ b/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml @@ -1,19 +1,19 @@ - if dossier.en_construction_ou_instruction? - if current_gestionnaire.follow?(dossier) - = link_to dossier_unfollow_path(procedure, dossier), method: :patch, class: 'button' do + = link_to unfollow_dossier_path(procedure, dossier), method: :patch, class: 'button' do %i.unfollow> ne plus suivre - else - = link_to dossier_follow_path(procedure, dossier), method: :patch, class: 'button' do + = link_to follow_dossier_path(procedure, dossier), method: :patch, class: 'button' do %i.follow> suivre le dossier - elsif dossier.termine? - if dossier.archived - = link_to dossier_unarchive_path(procedure, dossier), method: :patch, class: 'button' do + = link_to unarchive_dossier_path(procedure, dossier), method: :patch, class: 'button' do %i.unarchive> désarchiver le dossier - else - = link_to dossier_archive_path(procedure, dossier), method: :patch, class: 'button' do + = link_to archive_dossier_path(procedure, dossier), method: :patch, class: 'button' do %i.archive> archiver le dossier diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 4b240158c..a8de5fff6 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -42,10 +42,10 @@ %th.follow-col - @dossiers.each do |dossier| %tr - %td.number-col= link_to(dossier.id, backoffice_dossier_path(dossier), class: 'big-link') - %td= link_to(dossier.user.email, backoffice_dossier_path(dossier), class: 'big-link') + %td.number-col= link_to(dossier.id, dossier_path(@procedure, dossier), class: 'big-link') + %td= link_to(dossier.user.email, dossier_path(@procedure, dossier), class: 'big-link') %td.status-col - = link_to(backoffice_dossier_path(dossier), class: 'big-link') do + = link_to(dossier_path(@procedure, dossier), class: 'big-link') do = render partial: 'status', locals: { dossier: dossier } %td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier } - else diff --git a/config/routes.rb b/config/routes.rb index 8ff672bb3..b275f6afe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -240,12 +240,14 @@ Rails.application.routes.draw do scope module: 'new_gestionnaire' do resources :procedures, only: [:index, :show], param: :procedure_id do member do - resources :dossiers, only: [] do - get 'attestation' - patch 'follow' - patch 'unfollow' - patch 'archive' - patch 'unarchive' + resources :dossiers, only: [:show], param: :dossier_id do + member do + get 'attestation' + patch 'follow' + patch 'unfollow' + patch 'archive' + patch 'unarchive' + end end end end diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 51100ab65..6d967184a 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -3,14 +3,16 @@ require 'spec_helper' describe NewGestionnaire::DossiersController, type: :controller do let(:gestionnaire) { create(:gestionnaire) } let(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) } - let(:dossier) { create(:dossier, procedure: procedure) } - - before { sign_in(gestionnaire) } + let(:dossier) { create(:dossier, :replied, procedure: procedure) } describe 'attestation' do + before { sign_in(gestionnaire) } + context 'when a dossier has an attestation' do let(:fake_pdf) { double(read: 'pdf content') } - let!(:dossier) { create(:dossier, attestation: Attestation.new, procedure: procedure) } + let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) } + let!(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) } + let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) } it 'returns the attestation pdf' do allow_any_instance_of(Attestation).to receive(:pdf).and_return(fake_pdf) @@ -26,42 +28,73 @@ describe NewGestionnaire::DossiersController, type: :controller do end end - describe 'follow' do - before { patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id } } + context "when gestionnaire is signed in" do + before { sign_in(gestionnaire) } - it { expect(gestionnaire.followed_dossiers).to match([dossier]) } - it { expect(response).to redirect_to(procedures_url) } - end - describe 'unfollow' do - before do - gestionnaire.followed_dossiers << dossier - patch :unfollow, params: { procedure_id: procedure.id, dossier_id: dossier.id } - gestionnaire.reload + describe 'follow' do + before { patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id } } + + it { expect(gestionnaire.followed_dossiers).to match([dossier]) } + it { expect(response).to redirect_to(procedures_url) } end - it { expect(gestionnaire.followed_dossiers).to match([]) } - it { expect(response).to redirect_to(procedures_url) } - end + describe 'unfollow' do + before do + gestionnaire.followed_dossiers << dossier + patch :unfollow, params: { procedure_id: procedure.id, dossier_id: dossier.id } + gestionnaire.reload + end - describe 'archive' do - before do - patch :archive, params: { procedure_id: procedure.id, dossier_id: dossier.id } - dossier.reload + it { expect(gestionnaire.followed_dossiers).to match([]) } + it { expect(response).to redirect_to(procedures_url) } end - it { expect(dossier.archived).to be true } - it { expect(response).to redirect_to(procedures_url) } - end + describe 'archive' do + before do + patch :archive, params: { procedure_id: procedure.id, dossier_id: dossier.id } + dossier.reload + end - describe 'unarchive' do - before do - dossier.update_attributes(archived: true) - patch :unarchive, params: { procedure_id: procedure.id, dossier_id: dossier.id } - dossier.reload + it { expect(dossier.archived).to be true } + it { expect(response).to redirect_to(procedures_url) } end - it { expect(dossier.archived).to be false } - it { expect(response).to redirect_to(procedures_url) } + describe 'unarchive' do + before do + dossier.update_attributes(archived: true) + patch :unarchive, params: { procedure_id: procedure.id, dossier_id: dossier.id } + dossier.reload + end + + it { expect(dossier.archived).to be false } + it { expect(response).to redirect_to(procedures_url) } + end + end + + describe "#show" do + let(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) } + let(:dossier){ create(:dossier, :replied, procedure: procedure) } + + subject { get :show, params: { procedure_id: procedure.id, dossier_id: dossier.id } } + + context "when gestionnaire is not logged in" do + before { subject } + it { expect(response).to redirect_to(new_user_session_path) } + end + + context "when gestionnaire is logged in" do + before { sign_in(gestionnaire) } + + it do + subject + expect(response).to have_http_status(:success) + end + + context "when gestionnaire is not affected on procedure" do + let(:dossier){ create(:dossier, :replied) } + it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) } + end + end end end From 47857664ebcbbaea930ade6b333de2ead7b4a16c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 16:51:01 +0200 Subject: [PATCH 035/222] Add dossier champs (minimalist version) --- app/views/new_gestionnaire/dossiers/show.html.haml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index fd77534c8..630dd975e 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -3,3 +3,15 @@ .card-title Identité du demandeur - if @dossier.entreprise.present? = render partial: "identite_entreprise", locals: { entreprise: @dossier.entreprise } + + .card.featured + .card-title Construction du dossier + - if @dossier.champs.present? && @dossier.champs.any? + %table.table + %tbody + - @dossier.champs.each do |c| + %tr + %th + = "#{c.libelle} :" + %td + = c.value From 8aed0d7aefe9c614dc2013a0dea01054fe2a7bef Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 17:27:40 +0200 Subject: [PATCH 036/222] Use champ decorator to print dossier details --- app/decorators/champ_decorator.rb | 6 ++++++ app/views/dossiers/_infos_dossier.html.haml | 5 ----- app/views/new_gestionnaire/dossiers/show.html.haml | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/decorators/champ_decorator.rb b/app/decorators/champ_decorator.rb index 8af930c2d..1e1995de7 100644 --- a/app/decorators/champ_decorator.rb +++ b/app/decorators/champ_decorator.rb @@ -6,6 +6,12 @@ class ChampDecorator < Draper::Decorator Date.parse(object.value).strftime("%d/%m/%Y") elsif type_champ == 'checkbox' object.value == 'on' ? 'Oui' : 'Non' + elsif type_champ == 'yes_no' + if object.value == 'true' + 'Oui' + elsif object.value == 'false' + 'Non' + end elsif type_champ == 'multiple_drop_down_list' && object.value.present? JSON.parse(object.value).join(', ') else diff --git a/app/views/dossiers/_infos_dossier.html.haml b/app/views/dossiers/_infos_dossier.html.haml index 4d286fec4..d53fe4e59 100644 --- a/app/views/dossiers/_infos_dossier.html.haml +++ b/app/views/dossiers/_infos_dossier.html.haml @@ -46,11 +46,6 @@ = dossier.text_summary - else Pas de dossier associé - - elsif champ.type_champ == 'yes_no' - - if champ.decorate.value == 'true' - Oui - - elsif champ.decorate.value == 'false' - Non - else = sanitize(champ.decorate.value) diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index 630dd975e..37ba171dc 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -9,7 +9,7 @@ - if @dossier.champs.present? && @dossier.champs.any? %table.table %tbody - - @dossier.champs.each do |c| + - @dossier.champs.decorate.each do |c| %tr %th = "#{c.libelle} :" From 373447a19fdc26559e81b966f6955c100f356b3e Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 6 Jul 2017 17:52:16 +0200 Subject: [PATCH 037/222] Pieces justificatives on dossier page --- app/assets/stylesheets/new_design/common.scss | 5 ++++ .../new_gestionnaire/dossiers/show.html.haml | 25 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/app/assets/stylesheets/new_design/common.scss b/app/assets/stylesheets/new_design/common.scss index 356958032..49d95c02b 100644 --- a/app/assets/stylesheets/new_design/common.scss +++ b/app/assets/stylesheets/new_design/common.scss @@ -1,3 +1,4 @@ +@import "colors"; @import "constants"; @import "mixins"; @import "placeholders"; @@ -14,6 +15,10 @@ h1 { font-weight: bold; } +a { + color: $blue; +} + .container { @include horizontal-padding($default-padding); max-width: $page-width + 2 * $default-padding; diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index 37ba171dc..b747a962f 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -15,3 +15,28 @@ = "#{c.libelle} :" %td = c.value + + - if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? + .card.featured + .card-title Pièces jointes + + %table.table + %tbody + - if @dossier.procedure.cerfa_flag? + %tr + %th Formulaire : + %td + - if @dossier.cerfa_available? + = link_to "Télécharger", @dossier.cerfa.last.content_url, class: "button", target: :blank + - else + Pièce non fournie + + - @dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| + %tr + %th= "#{type_de_piece_justificative.libelle} :" + %td + - pj = @dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id) + - if pj.present? + = link_to "Télécharger", pj.content_url, class: "button", target: :blank + - else + Pièce non fournie From 7bb75c3f56d8d1e77177168a5dfee3d5438f09a5 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 11 Jul 2017 15:55:08 +0200 Subject: [PATCH 038/222] Add identite infos for individual --- .../dossiers/_identite_individual.html.haml | 14 ++++++++++++++ app/views/new_gestionnaire/dossiers/show.html.haml | 3 +++ 2 files changed, 17 insertions(+) create mode 100644 app/views/new_gestionnaire/dossiers/_identite_individual.html.haml diff --git a/app/views/new_gestionnaire/dossiers/_identite_individual.html.haml b/app/views/new_gestionnaire/dossiers/_identite_individual.html.haml new file mode 100644 index 000000000..810ae7e39 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/_identite_individual.html.haml @@ -0,0 +1,14 @@ +%table.table + %tbody + %tr + %th Civilité : + %td= individual.gender + %tr + %th Prénom : + %td= individual.prenom + %tr + %th Nom : + %td= individual.nom + %tr + %th Date de naissance : + %td= individual.birthdate diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index b747a962f..aaf1f87f0 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -4,6 +4,9 @@ - if @dossier.entreprise.present? = render partial: "identite_entreprise", locals: { entreprise: @dossier.entreprise } + - if @dossier.individual.present? + = render partial: "identite_individual", locals: { individual: @dossier.individual } + .card.featured .card-title Construction du dossier - if @dossier.champs.present? && @dossier.champs.any? From 2b0c0567b813338487ba7ba970b83a807dfe8f81 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 11 Jul 2017 16:50:29 +0200 Subject: [PATCH 039/222] Add header section in form table --- app/assets/stylesheets/new_design/table.scss | 7 ++++ .../dossiers/_champs.html.haml | 12 +++++++ .../new_gestionnaire/dossiers/show.html.haml | 15 +++----- app/views/root/patron.html.haml | 2 ++ spec/factories/champ.rb | 8 +++++ spec/factories/entreprise.rb | 6 ++++ spec/factories/type_de_champ_public.rb | 4 +++ .../dossiers/_champs.html.haml_spec.rb | 15 ++++++++ .../dossiers/show.html.haml_spec.rb | 35 +++++++++++++++++++ 9 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 app/views/new_gestionnaire/dossiers/_champs.html.haml create mode 100644 spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb create mode 100644 spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb diff --git a/app/assets/stylesheets/new_design/table.scss b/app/assets/stylesheets/new_design/table.scss index 18e85be56..625dcc5b0 100644 --- a/app/assets/stylesheets/new_design/table.scss +++ b/app/assets/stylesheets/new_design/table.scss @@ -1,3 +1,4 @@ +@import "colors"; @import "constants"; @import "mixins"; @@ -13,6 +14,12 @@ th { text-align: left; + + &.header-section { + color: $blue; + font-weight: bold; + font-size: 20px; + } } td { diff --git a/app/views/new_gestionnaire/dossiers/_champs.html.haml b/app/views/new_gestionnaire/dossiers/_champs.html.haml new file mode 100644 index 000000000..b38792292 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/_champs.html.haml @@ -0,0 +1,12 @@ +%table.table + %tbody + - champs.each do |c| + %tr + - if c.type_champ == "header_section" + %th.header-section{ colspan: 2 } + = c.libelle + - else + %th + = "#{c.libelle} :" + %td + = c.value diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index aaf1f87f0..7bbba6c0f 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -7,17 +7,12 @@ - if @dossier.individual.present? = render partial: "identite_individual", locals: { individual: @dossier.individual } + .backoffice-title Formulaire + .card.featured - .card-title Construction du dossier - - if @dossier.champs.present? && @dossier.champs.any? - %table.table - %tbody - - @dossier.champs.decorate.each do |c| - %tr - %th - = "#{c.libelle} :" - %td - = c.value + - champs = @dossier.ordered_champs.decorate + - if champs.any? + = render partial: "champs", locals: { champs: champs } - if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? .card.featured diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 93cd99a2e..bc9bc852a 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -78,6 +78,8 @@ %tr %th Header 2 %td Table Data 2 + %tr + %th.header-section{ colspan: 2 } Header section %tr %th Header 3 %td Table Data 3 diff --git a/spec/factories/champ.rb b/spec/factories/champ.rb index 630e787ba..07cf128e9 100644 --- a/spec/factories/champ.rb +++ b/spec/factories/champ.rb @@ -1,5 +1,13 @@ FactoryGirl.define do factory :champ do type_de_champ { FactoryGirl.create(:type_de_champ_public) } + + trait :checkbox do + type_de_champ { FactoryGirl.create(:type_de_champ_public, :checkbox) } + end + + trait :header_section do + type_de_champ { FactoryGirl.create(:type_de_champ_public, :header_section) } + end end end diff --git a/spec/factories/entreprise.rb b/spec/factories/entreprise.rb index a90e8cb28..95a2ae53c 100644 --- a/spec/factories/entreprise.rb +++ b/spec/factories/entreprise.rb @@ -10,5 +10,11 @@ FactoryGirl.define do siret_siege_social '44011762001530' code_effectif_entreprise '51' date_creation Time.at(1453976189).to_datetime + + trait :is_association do + after(:create) do |entreprise, _evaluator| + create(:rna_information, entreprise: entreprise) + end + end end end diff --git a/spec/factories/type_de_champ_public.rb b/spec/factories/type_de_champ_public.rb index 3e1acf1e8..76511640a 100644 --- a/spec/factories/type_de_champ_public.rb +++ b/spec/factories/type_de_champ_public.rb @@ -10,6 +10,10 @@ FactoryGirl.define do type_champ 'checkbox' end + trait :header_section do + type_champ 'header_section' + end + trait :type_dossier_link do libelle 'Référence autre dossier' type_champ 'dossier_link' diff --git a/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb b/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb new file mode 100644 index 000000000..3a7ea2c2e --- /dev/null +++ b/spec/views/new_gestionnaire/dossiers/_champs.html.haml_spec.rb @@ -0,0 +1,15 @@ +describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do + before { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs } + + context "there is some champs" do + let(:champ1) { create(:champ, :checkbox, value: "true") } + let(:champ2) { create(:champ, :header_section, value: "Section") } + let(:champs) { [champ1, champ2] } + + it { expect(rendered).to include(champ1.libelle) } + it { expect(rendered).to include(champ1.value) } + + it { expect(rendered).to have_css(".header-section") } + it { expect(rendered).to include(champ2.libelle) } + 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 new file mode 100644 index 000000000..1e4f01b32 --- /dev/null +++ b/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb @@ -0,0 +1,35 @@ +describe 'new_gestionnaire/dossiers/show.html.haml', type: :view do + let(:individual) { nil } + let(:entreprise) { nil } + let(:dossier) { create(:dossier, :replied, entreprise: entreprise, individual: individual) } + + before do + assign(:dossier, dossier) + render + end + + context "when dossier was created by an entreprise" do + let(:entreprise) { create(:entreprise) } + + it { expect(rendered).to include(entreprise.decorate.raison_sociale_or_name) } + it { expect(rendered).to include(entreprise.decorate.siret_siege_social) } + it { expect(rendered).to include(entreprise.decorate.forme_juridique) } + + context "and entreprise is an association" do + let(:entreprise) { create(:entreprise, :is_association) } + + it { expect(rendered).to include(entreprise.rna_information.association_id) } + it { expect(rendered).to include(entreprise.rna_information.titre) } + it { expect(rendered).to include(entreprise.rna_information.objet) } + end + end + + context "when dossier was created by an individual" do + let(:individual) { create(:individual) } + + it { expect(rendered).to include(individual.gender) } + it { expect(rendered).to include(individual.nom) } + it { expect(rendered).to include(individual.prenom) } + it { expect(rendered).to include(individual.birthdate) } + end +end From f41b1b59c063b8384da88ab4d6253f6c63a6e4f7 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 11 Jul 2017 16:56:25 +0200 Subject: [PATCH 040/222] Add tabs partial --- app/views/new_gestionnaire/dossiers/_header.html.haml | 10 ++++++++++ app/views/new_gestionnaire/dossiers/show.html.haml | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 app/views/new_gestionnaire/dossiers/_header.html.haml diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml new file mode 100644 index 000000000..fd94341d7 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -0,0 +1,10 @@ +.container + %ul.tabs + %li + = link_to "Demande", "#", class: ("selected" if request.path == dossier_path(dossier.procedure, dossier)) + %li + = link_to "Instruction", "#" + %li + = link_to "Messagerie", "#" + %li + = link_to "Historique", "#" diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index 7bbba6c0f..585c2b240 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -1,3 +1,5 @@ += render partial: "header", locals: { dossier: @dossier } + .container .card .card-title Identité du demandeur From b555320d46d3dee41da98aa2e51a149c4be79384 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 11 Jul 2017 17:16:54 +0200 Subject: [PATCH 041/222] Add RNA informations --- .../dossiers/_identite_entreprise.html.haml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml b/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml index 6caa8fbba..53eab7732 100644 --- a/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml +++ b/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml @@ -47,3 +47,22 @@ = "#{exercice.dateFinExercice.year} : " = number_to_currency(exercice.ca) %br + - if entreprise.rna_information.present? + %tr + %th Numéro RNA : + %td= entreprise.rna_information.association_id + %tr + %th Titre : + %td= entreprise.rna_information.titre + %tr + %th Objet : + %td= entreprise.rna_information.objet + %tr + %th Date de création : + %td= entreprise.rna_information.date_creation + %tr + %th Date de publication : + %td= entreprise.rna_information.date_publication + %tr + %th Date de déclaration : + %td= entreprise.rna_information.date_declaration From c0eeec82c45943098ea1bc340241e044fd247ec3 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 18 Jul 2017 15:03:04 +0200 Subject: [PATCH 042/222] Add backoffice header to patron --- app/assets/stylesheets/new_design/backoffice.scss | 12 ++++++++++++ app/views/root/patron.html.haml | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/assets/stylesheets/new_design/backoffice.scss b/app/assets/stylesheets/new_design/backoffice.scss index dd7f6dfe2..4b129546c 100644 --- a/app/assets/stylesheets/new_design/backoffice.scss +++ b/app/assets/stylesheets/new_design/backoffice.scss @@ -1,3 +1,4 @@ +@import "colors"; @import "constants"; .backoffice-title { @@ -6,3 +7,14 @@ margin-top: 3 * $default-spacer; margin-bottom: 3 * $default-spacer; } + +.backoffice-header { + background-color: $light-grey; + padding-top: $default-padding; + margin-bottom: 2 * $default-spacer; + border-bottom: 1px solid $border-grey; + + .container { + margin-bottom: -1px; + } +} diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index bc9bc852a..d73bafeb2 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -84,6 +84,19 @@ %th Header 3 %td Table Data 3 + %h2 Header + .backoffice-header + .container + Titre + %ul.tabs + %li + = link_to "Onglet 1", "#", class: "selected" + %li + = link_to "Onglet 2", "#" + %li + = link_to "Onglet 3", "#" + + .container %h2 Layout deux colonnes .two-columns From 9aac9ba7cd5a0a56044cd822efa37a13a9d0e911 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 18 Jul 2017 15:12:55 +0200 Subject: [PATCH 043/222] use backoffice-header in views --- .../new_design/procedures_show.scss | 107 ++++++++---------- .../dossiers/_header.html.haml | 21 ++-- .../procedures/show.html.haml | 4 +- 3 files changed, 62 insertions(+), 70 deletions(-) diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index a6afebc3b..076315ef0 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -3,72 +3,63 @@ @import "constants"; #procedure-show { - .header { - background-color: $light-grey; - padding-top: $default-padding; + .procedure-logo { + margin-right: $default-padding; + } - .container { - display: flex; - } + h1 { + color: $black; + font-size: 22px; + margin-bottom: 2 * $default-padding; + } - .procedure-logo { - margin-right: $default-padding; - } + .dossiers-categories { + li { + display: inline-block; + height: 56px; + width: 130px; + line-height: 17px; + position: relative; + text-align: center; + font-size: 14px; - h1 { - color: $black; - font-size: 22px; - margin-bottom: 2 * $default-padding; - } + a { + color: $black; + } - .dossiers-categories { - li { - display: inline-block; - height: 56px; - width: 130px; - line-height: 17px; - position: relative; - text-align: center; - font-size: 14px; + &::before, + &:last-child::after { + content: ""; + position: absolute; + height: 36px; + width: 1px; + background-color: $border-grey; + margin-right: $default-padding; + } + + &::before { + left: 0px; + } + + &:last-child::after { + right: 0px; + top: 0px; + margin-right: 0px; + } + + &.active { + border-bottom: 2px solid $blue; a { - color: $black; + color: $blue; } + } - &::before, - &:last-child::after { - content: ""; - position: absolute; - height: 36px; - width: 1px; - background-color: $border-grey; - margin-right: $default-padding; - } - - &::before { - left: 0px; - } - - &:last-child::after { - right: 0px; - top: 0px; - margin-right: 0px; - } - - &.active { - border-bottom: 2px solid $blue; - - a { - color: $blue; - } - } - - .dossiers-count { - position: relative; - display: block; - font-size: 16px; - font-weight: bold; - } + .dossiers-count { + position: relative; + display: block; + font-size: 16px; + font-weight: bold; } } } diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index fd94341d7..daa2a55aa 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -1,10 +1,11 @@ -.container - %ul.tabs - %li - = link_to "Demande", "#", class: ("selected" if request.path == dossier_path(dossier.procedure, dossier)) - %li - = link_to "Instruction", "#" - %li - = link_to "Messagerie", "#" - %li - = link_to "Historique", "#" +.backoffice-header + .container + %ul.tabs + %li + = link_to "Demande", "#", class: ("selected" if current_page?(dossier_path(dossier.procedure, dossier))) + %li + = link_to "Instruction", "#" + %li + = link_to "Messagerie", "#" + %li + = link_to "Historique", "#" diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index a8de5fff6..2d4335f4b 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -1,6 +1,6 @@ #procedure-show - .header - .container + .backoffice-header + .container.flex - if @procedure.logo.present? = image_tag @procedure.logo, height: 40, class: 'procedure-logo' From cf63fd6b0472bcd54d791d19f10ff3eef54fe620 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 18 Jul 2017 15:38:31 +0200 Subject: [PATCH 044/222] Add breadcrumbs --- .../stylesheets/new_design/breadcrumb.scss | 28 +++++++++++++++++++ .../dossiers/_header.html.haml | 5 ++++ app/views/root/patron.html.haml | 9 ++++++ 3 files changed, 42 insertions(+) create mode 100644 app/assets/stylesheets/new_design/breadcrumb.scss diff --git a/app/assets/stylesheets/new_design/breadcrumb.scss b/app/assets/stylesheets/new_design/breadcrumb.scss new file mode 100644 index 000000000..055e58c6b --- /dev/null +++ b/app/assets/stylesheets/new_design/breadcrumb.scss @@ -0,0 +1,28 @@ +@import "colors"; +@import "constants"; + +.breadcrumbs { + margin: $default-spacer 0; + + li { + display: inline-block; + font-weight: bold; + font-size: 14px; + + a { + color: $black; + } + + &::after { + content: " > "; + } + + &:last-child { + color: $blue; + + &::after { + content: none; + } + } + } +} diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index daa2a55aa..1c171358b 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -1,5 +1,10 @@ .backoffice-header .container + %ul.breadcrumbs + %li + = link_to dossier.procedure.libelle, procedure_path(dossier.procedure) + %li + = "Dossier n° #{dossier.id}" %ul.tabs %li = link_to "Demande", "#", class: ("selected" if current_page?(dossier_path(dossier.procedure, dossier))) diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index d73bafeb2..0d34b26e9 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -97,6 +97,15 @@ = link_to "Onglet 3", "#" .container + %h2 Breadcrumbs + + %ul.breadcrumbs + %li + = link_to "Procédure 123", "#" + %li + = "Dossier n° 38" + + %h2 Layout deux colonnes .two-columns From 3b3e0403d258165200bb18d94799fed69e863ab9 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 18 Jul 2017 15:39:21 +0200 Subject: [PATCH 045/222] Improve /patron readability --- app/views/root/patron.html.haml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 0d34b26e9..2760b53d1 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -1,8 +1,6 @@ .patron .container - %h1 Patron - - %h2 Formulaires + %h1 Formulaires %form.form %label Nom @@ -13,7 +11,7 @@ %input{ type: "password", value: "12345678" } %input.button{ type: "submit", value: "Envoyer" } - %h2 Boutons + %h1 Boutons %p = link_to ".button", "#", class: "button" @@ -42,7 +40,7 @@ %p = link_to ".button.primary.expand", "#", class: "button primary expand" - %h2 Onglets + %h1 Onglets %ul.tabs %li @@ -52,11 +50,11 @@ %li = link_to "Onglet 3", "#" - %h2 Labels + %h1 Labels %span.label .label - %h2 Cards + %h1 Cards .card .card-title @@ -68,7 +66,7 @@ Titre de la carte mise en avant Et voici le contenu de la carte - %h2 Table + %h1 Table %table.table %tbody @@ -84,7 +82,7 @@ %th Header 3 %td Table Data 3 - %h2 Header + %h1 Header .backoffice-header .container Titre @@ -97,7 +95,7 @@ = link_to "Onglet 3", "#" .container - %h2 Breadcrumbs + %h1 Breadcrumbs %ul.breadcrumbs %li @@ -106,7 +104,7 @@ = "Dossier n° 38" - %h2 Layout deux colonnes + %h1 Layout deux colonnes .two-columns .columns-container From 923a16a8c85ed5a923bfb677db7715dc5b26eb25 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 18 Jul 2017 16:16:14 +0200 Subject: [PATCH 046/222] remove extra line --- spec/controllers/new_gestionnaire/dossiers_controller_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 6d967184a..8ead2c5c0 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -31,7 +31,6 @@ describe NewGestionnaire::DossiersController, type: :controller do context "when gestionnaire is signed in" do before { sign_in(gestionnaire) } - describe 'follow' do before { patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id } } From 7a0d6108e1380e84a2f8e97c94f25dbc0e170268 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 17 Jul 2017 12:26:48 +0200 Subject: [PATCH 047/222] .footer -> %footer --- app/assets/stylesheets/new_design/new_footer.scss | 2 +- app/views/layouts/_new_footer.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/new_design/new_footer.scss b/app/assets/stylesheets/new_design/new_footer.scss index b87df08f1..23185913a 100644 --- a/app/assets/stylesheets/new_design/new_footer.scss +++ b/app/assets/stylesheets/new_design/new_footer.scss @@ -3,7 +3,7 @@ @import "mixins"; @import "placeholders"; -.footer { +footer { @include vertical-padding(72px); background-color: $light-grey; border-top: 1px solid $border-grey; diff --git a/app/views/layouts/_new_footer.html.haml b/app/views/layouts/_new_footer.html.haml index 5bba26b0f..266f73065 100644 --- a/app/views/layouts/_new_footer.html.haml +++ b/app/views/layouts/_new_footer.html.haml @@ -1,4 +1,4 @@ -.footer +%footer .container %ul.footer-columns %li.footer-column From f0777e166f353d915a1580569c56caef37f85d5a Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 17 Jul 2017 14:52:09 +0200 Subject: [PATCH 048/222] Add sticky footer --- .../stylesheets/new_design/_constants.scss | 3 ++ app/assets/stylesheets/new_design/common.scss | 9 +++++ .../stylesheets/new_design/new_footer.scss | 8 ++++ app/views/layouts/new_application.html.haml | 39 ++++++++++--------- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/app/assets/stylesheets/new_design/_constants.scss b/app/assets/stylesheets/new_design/_constants.scss index 39b09ef41..17689108b 100644 --- a/app/assets/stylesheets/new_design/_constants.scss +++ b/app/assets/stylesheets/new_design/_constants.scss @@ -2,3 +2,6 @@ $page-width: 1040px; $default-spacer: 8px; $default-padding: 2 * $default-spacer; + +$footer-height: 267px; +$footer-height-mobile: 531px; diff --git a/app/assets/stylesheets/new_design/common.scss b/app/assets/stylesheets/new_design/common.scss index 49d95c02b..599220d20 100644 --- a/app/assets/stylesheets/new_design/common.scss +++ b/app/assets/stylesheets/new_design/common.scss @@ -10,6 +10,15 @@ body { line-height: 1.42857143; } +.page-wrapper { + position: relative; + padding-bottom: $footer-height; + + @media (max-width: 1000px) { + padding-bottom: $footer-height-mobile; + } +} + h1 { font-size: 36px; font-weight: bold; diff --git a/app/assets/stylesheets/new_design/new_footer.scss b/app/assets/stylesheets/new_design/new_footer.scss index 23185913a..2c414559b 100644 --- a/app/assets/stylesheets/new_design/new_footer.scss +++ b/app/assets/stylesheets/new_design/new_footer.scss @@ -7,6 +7,14 @@ footer { @include vertical-padding(72px); background-color: $light-grey; border-top: 1px solid $border-grey; + position: absolute; + bottom: 0; + width: 100%; + height: $footer-height; + + @media (max-width: 1000px) { + height: $footer-height-mobile; + } } .footer-columns { diff --git a/app/views/layouts/new_application.html.haml b/app/views/layouts/new_application.html.haml index 4db03ec7d..3da4de62d 100644 --- a/app/views/layouts/new_application.html.haml +++ b/app/views/layouts/new_application.html.haml @@ -18,25 +18,26 @@ = stylesheet_link_tag "print", media: "print", "data-turbolinks-track": true %body - = render partial: "layouts/support_navigator_banner" - = render partial: "layouts/ie_lt_10" - #beta{ class:(Rails.env == "production" ? "" : "beta_staging") } - - if Rails.env == "production" - Beta - - else - Env Test + .page-wrapper + = render partial: "layouts/support_navigator_banner" + = render partial: "layouts/ie_lt_10" + #beta{ class:(Rails.env == "production" ? "" : "beta_staging") } + - if Rails.env == "production" + Beta + - else + Env Test - = render partial: "layouts/new_header" - = render partial: "layouts/flash_messages" - = yield + = render partial: "layouts/new_header" + = render partial: "layouts/flash_messages" + = yield - = render partial: "layouts/new_footer" - = render partial: "layouts/google_analytics" - = render partial: "layouts/mailjet_newsletter" - = render partial: "layouts/crisp" + = render partial: "layouts/new_footer" + = render partial: "layouts/google_analytics" + = render partial: "layouts/mailjet_newsletter" + = render partial: "layouts/crisp" - = javascript_include_tag "new_design/application", "data-turbolinks-eval": false - = yield :charts_js - - if Rails.env == "test" - %script{ type: "text/javascript" } - (typeof jQuery !== "undefined") && (jQuery.fx.off = true); + = javascript_include_tag "new_design/application", "data-turbolinks-eval": false + = yield :charts_js + - if Rails.env == "test" + %script{ type: "text/javascript" } + (typeof jQuery !== "undefined") && (jQuery.fx.off = true); From 9753da8fdd4601a19e071170f33bfe038885a137 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 20 Jul 2017 09:52:21 +0200 Subject: [PATCH 049/222] NewDesign Form: move margin from label to input provide beautiful layouts with or without label between inputs --- app/assets/stylesheets/new_design/forms.scss | 6 +----- app/views/root/patron.html.haml | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index e1616d1e7..a04982b7f 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -11,11 +11,6 @@ font-size: 14px; } - label, - input[type=submit] { - margin-top: 24px; - } - label { margin-bottom: 8px; display: inline-block; @@ -28,6 +23,7 @@ width: 100%; border-radius: 4px; border: solid 1px $border-grey; + margin-bottom: 24px; padding: 16px; &:disabled { diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 2760b53d1..5b5bbe7c4 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -5,8 +5,7 @@ %form.form %label Nom %input{ type: "text" } - %label Prénom - %input{ type: "text", placeholder: "ex : Ivan" } + %input{ type: "text", placeholder: "Prénom: Ivan" } %label Mot de passe %input{ type: "password", value: "12345678" } %input.button{ type: "submit", value: "Envoyer" } From 2a8b8d4a010919fad93b4f633be41d7a783e9e8e Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 20 Jul 2017 09:54:05 +0200 Subject: [PATCH 050/222] NewDesign Form: apply design to textarea --- app/assets/stylesheets/new_design/forms.scss | 3 ++- app/views/root/patron.html.haml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index a04982b7f..9b07d4b36 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -18,7 +18,8 @@ input[type=text], input[type=email], - input[type=password] { + input[type=password], + textarea { display: block; width: 100%; border-radius: 4px; diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 5b5bbe7c4..985f7c5bc 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -5,7 +5,7 @@ %form.form %label Nom %input{ type: "text" } - %input{ type: "text", placeholder: "Prénom: Ivan" } + %textarea{ placeholder: "Description de votre projet" } %label Mot de passe %input{ type: "password", value: "12345678" } %input.button{ type: "submit", value: "Envoyer" } From dfe36ceef75957d707a786dfc9ab0ebafbb18bfd Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 20 Jul 2017 10:02:48 +0200 Subject: [PATCH 051/222] NewDesign Form: unify body and input font --- app/assets/stylesheets/new_design/common.scss | 4 +++- app/assets/stylesheets/new_design/forms.scss | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/new_design/common.scss b/app/assets/stylesheets/new_design/common.scss index 599220d20..7855cb076 100644 --- a/app/assets/stylesheets/new_design/common.scss +++ b/app/assets/stylesheets/new_design/common.scss @@ -4,7 +4,9 @@ @import "placeholders"; @import "typography"; -body { +body, +input, +textarea { @extend %new-type; font-size: 16px; line-height: 1.42857143; diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index 9b07d4b36..123f75fe2 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -6,11 +6,6 @@ margin-bottom: 20px; } - label, - input { - font-size: 14px; - } - label { margin-bottom: 8px; display: inline-block; From 9731683b436bb56f77268614169d0e95918c8400 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 20 Jul 2017 10:25:32 +0200 Subject: [PATCH 052/222] Use default-spacer in forms --- app/assets/stylesheets/new_design/forms.scss | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index 123f75fe2..ad7831a0f 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -1,3 +1,4 @@ +@import "constants"; @import "colors"; .form { @@ -7,7 +8,7 @@ } label { - margin-bottom: 8px; + margin-bottom: $default-spacer; display: inline-block; } @@ -19,8 +20,8 @@ width: 100%; border-radius: 4px; border: solid 1px $border-grey; - margin-bottom: 24px; - padding: 16px; + margin-bottom: 4 * $default-spacer; + padding: $default-padding; &:disabled { background-color: $border-grey; From cbd9df8f0c8ce0bbaea6d98bcd0d5505ede47cdd Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 20 Jul 2017 10:33:21 +0200 Subject: [PATCH 053/222] [Fix #552] Disable default style for buttons on iOS --- app/assets/stylesheets/new_design/buttons.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index 187f7444d..b06e60f12 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -10,6 +10,7 @@ background-color: #FFFFFF; color: $black; cursor: pointer; + -webkit-appearance: none; &:hover { background: $light-grey; From 73e6053c192f74f0edc4b22a665668258e46a622 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 20 Jul 2017 10:39:16 +0200 Subject: [PATCH 054/222] Fix input search margin in header --- app/assets/stylesheets/new_design/new_header.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss index 11e0b1f4b..8ffabdea3 100644 --- a/app/assets/stylesheets/new_design/new_header.scss +++ b/app/assets/stylesheets/new_design/new_header.scss @@ -63,10 +63,11 @@ padding-right: 42px; float: right; width: 300px; + margin: 0; } button { - padding: 6px 9px; + padding: 9px; border: none; background: none; cursor: pointer; From 8fdc16d89f346abbd8a796d6e120fcd9b4aa9913 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 20 Jul 2017 10:41:39 +0200 Subject: [PATCH 055/222] Remove old font-size --- app/assets/stylesheets/new_design/auth.scss | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/assets/stylesheets/new_design/auth.scss b/app/assets/stylesheets/new_design/auth.scss index 6f292b928..9e241ecb4 100644 --- a/app/assets/stylesheets/new_design/auth.scss +++ b/app/assets/stylesheets/new_design/auth.scss @@ -59,8 +59,6 @@ $auth-breakpoint: 820px; } .auth-form { - font-size: 14px; - .reset-password { margin-top: 8px; } From 033f08524f465b32f2c01566250689470211c5fd Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 13:13:20 +0200 Subject: [PATCH 056/222] Gestionnaire: refactor follow? --- app/models/gestionnaire.rb | 6 ++---- app/views/backoffice/dossiers/_list.html.haml | 2 +- .../_navbar_backoffice_dossierscontroller_show.html.haml | 2 +- spec/models/gestionnaire_spec.rb | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index cbaa3a6de..682652a91 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -45,10 +45,8 @@ class Gestionnaire < ActiveRecord::Base nil end - def follow? dossier_id - dossier_id = dossier_id.id if dossier_id.class == Dossier - - Follow.where(gestionnaire_id: id, dossier_id: dossier_id).any? + def follow?(dossier) + followed_dossiers.include?(dossier) end def assigned_on_procedure?(procedure_id) diff --git a/app/views/backoffice/dossiers/_list.html.haml b/app/views/backoffice/dossiers/_list.html.haml index 509684096..e0de9c639 100644 --- a/app/views/backoffice/dossiers/_list.html.haml +++ b/app/views/backoffice/dossiers/_list.html.haml @@ -52,7 +52,7 @@ = value %td.center - - if current_gestionnaire.follow?(dossier.id) + - if current_gestionnaire.follow?(dossier) = link_to('Quitter', backoffice_dossier_follow_path(dossier_id: dossier.id), 'data-method' => :put, class: 'btn-sm btn-danger', id: "suivre_dossier_#{dossier.id}") - else = link_to('Suivre', backoffice_dossier_follow_path(dossier_id: dossier.id), 'data-method' => :put, class: 'btn-sm btn-primary', id: "suivre_dossier_#{dossier.id}") diff --git a/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml index 6604a98c1..e8a675677 100644 --- a/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml +++ b/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml @@ -4,7 +4,7 @@ - if current_gestionnaire.assigned_on_procedure?(@facade.dossier.procedure_id) .row .col-xs-12 - - if current_gestionnaire.follow?(@facade.dossier.id) + - if current_gestionnaire.follow?(@facade.dossier) = link_to backoffice_dossier_follow_path(dossier_id: @facade.dossier.id), "data-method" => :put, class: "button-navbar-action", id: "suivre_dossier_#{@facade.dossier.id}" do %i.fa.fa-user-times Ne plus suivre diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index 18b8461d9..af91f0cfd 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -76,7 +76,7 @@ describe Gestionnaire, type: :model do describe '#follow?' do let!(:dossier) { create :dossier, procedure: procedure } - subject { gestionnaire.follow? dossier.id } + subject { gestionnaire.follow?(dossier) } context 'when gestionnaire follow a dossier' do before do From e68f3332c13b3c51b33925c72e6ce66ff080844b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 11:28:14 +0200 Subject: [PATCH 057/222] Gestionnaire: add follow(dossier) method --- app/models/gestionnaire.rb | 6 ++++++ spec/models/gestionnaire_spec.rb | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 682652a91..4e721141a 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -45,6 +45,12 @@ class Gestionnaire < ActiveRecord::Base nil end + def follow(dossier) + return if follow?(dossier) + + followed_dossiers << dossier + end + def follow?(dossier) followed_dossiers.include?(dossier) end diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index af91f0cfd..366c1c493 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -73,6 +73,25 @@ describe Gestionnaire, type: :model do end end + describe 'follow' do + let(:dossier) { create :dossier } + let(:already_followed_dossier) { create :dossier } + + before { gestionnaire.followed_dossiers << already_followed_dossier } + + context 'when a gestionnaire follow a dossier for the first time' do + before { gestionnaire.follow(dossier) } + + it { expect(gestionnaire.follow?(dossier)).to be true } + end + + context 'when a gestionnaire follows a dossier already followed' do + before { gestionnaire.follow(already_followed_dossier) } + + it { expect(gestionnaire.follow?(already_followed_dossier)).to be true } + end + end + describe '#follow?' do let!(:dossier) { create :dossier, procedure: procedure } From 8b2366cb98780e73efd0b75f90a7b33bd76a03d3 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 12:11:33 +0200 Subject: [PATCH 058/222] GestionnaireDossierController: use gestionnaire follow --- app/controllers/new_gestionnaire/dossiers_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 9d314106d..3b9a23eac 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -9,7 +9,7 @@ module NewGestionnaire end def follow - current_gestionnaire.followed_dossiers << dossier + current_gestionnaire.follow(dossier) redirect_back(fallback_location: procedures_url) end From 6cff044a50b9272a8e6affbb51010eb4f0c19c9e Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 15:14:19 +0200 Subject: [PATCH 059/222] NewDossierController: add next_step follow --- app/controllers/new_gestionnaire/dossiers_controller.rb | 1 + .../controllers/new_gestionnaire/dossiers_controller_spec.rb | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 3b9a23eac..065e0f118 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -10,6 +10,7 @@ module NewGestionnaire def follow current_gestionnaire.follow(dossier) + dossier.next_step!('gestionnaire', 'follow') redirect_back(fallback_location: procedures_url) end diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 8ead2c5c0..e149a355c 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -32,7 +32,10 @@ describe NewGestionnaire::DossiersController, type: :controller do before { sign_in(gestionnaire) } describe 'follow' do - before { patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id } } + before do + expect_any_instance_of(Dossier).to receive(:next_step!).with('gestionnaire', 'follow') + patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id } + end it { expect(gestionnaire.followed_dossiers).to match([dossier]) } it { expect(response).to redirect_to(procedures_url) } From f07b6eab531eb5130a937175cebd4620f074e374 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 12:25:43 +0200 Subject: [PATCH 060/222] Follow: use follow instead of toggle_follow_dossier --- app/controllers/commentaires_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/commentaires_controller.rb b/app/controllers/commentaires_controller.rb index 7dd8ac1d0..fbb9532d3 100644 --- a/app/controllers/commentaires_controller.rb +++ b/app/controllers/commentaires_controller.rb @@ -44,9 +44,7 @@ class CommentairesController < ApplicationController end if is_gestionnaire? - unless current_gestionnaire.follow? @commentaire.dossier - current_gestionnaire.toggle_follow_dossier @commentaire.dossier - end + current_gestionnaire.follow(@commentaire.dossier) redirect_to url_for(controller: 'backoffice/dossiers', action: :show, id: params['dossier_id']) else From a7f270bac47c3cb4b30245ab35bfa363b390d14a Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 12:26:16 +0200 Subject: [PATCH 061/222] Follow: user new dossier follow controller instead of backoffice --- app/views/backoffice/dossiers/_list.html.haml | 4 ++-- .../_navbar_backoffice_dossierscontroller_show.html.haml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/backoffice/dossiers/_list.html.haml b/app/views/backoffice/dossiers/_list.html.haml index e0de9c639..5b284ffbd 100644 --- a/app/views/backoffice/dossiers/_list.html.haml +++ b/app/views/backoffice/dossiers/_list.html.haml @@ -53,9 +53,9 @@ %td.center - if current_gestionnaire.follow?(dossier) - = link_to('Quitter', backoffice_dossier_follow_path(dossier_id: dossier.id), 'data-method' => :put, class: 'btn-sm btn-danger', id: "suivre_dossier_#{dossier.id}") + = link_to('Quitter', unfollow_dossier_path(dossier.procedure, dossier), method: :patch, class: 'btn-sm btn-danger', id: "suivre_dossier_#{dossier.id}") - else - = link_to('Suivre', backoffice_dossier_follow_path(dossier_id: dossier.id), 'data-method' => :put, class: 'btn-sm btn-primary', id: "suivre_dossier_#{dossier.id}") + = link_to('Suivre', follow_dossier_path(dossier.procedure, dossier), method: :patch, class: 'btn-sm btn-primary', id: "suivre_dossier_#{dossier.id}") %td.center{ style: "color: #{dossier.total_follow == 0 ? 'red' : ''}" } = dossier.total_follow diff --git a/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml b/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml index e8a675677..378fe9421 100644 --- a/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml +++ b/app/views/layouts/navbars/_navbar_backoffice_dossierscontroller_show.html.haml @@ -5,11 +5,11 @@ .row .col-xs-12 - if current_gestionnaire.follow?(@facade.dossier) - = link_to backoffice_dossier_follow_path(dossier_id: @facade.dossier.id), "data-method" => :put, class: "button-navbar-action", id: "suivre_dossier_#{@facade.dossier.id}" do + = link_to unfollow_dossier_path(@facade.dossier.procedure, @facade.dossier), method: :patch, class: "button-navbar-action", id: "suivre_dossier_#{@facade.dossier.id}" do %i.fa.fa-user-times Ne plus suivre - else - = link_to backoffice_dossier_follow_path(dossier_id: @facade.dossier.id), 'data-method' => :put, class: 'button-navbar-action', id: "suivre_dossier_#{@facade.dossier.id}" do + = link_to follow_dossier_path(@facade.dossier.procedure, @facade.dossier), method: :patch, class: 'button-navbar-action', id: "suivre_dossier_#{@facade.dossier.id}" do %i.fa.fa-user-plus Suivre le dossier .row From 95fbd1824a662314424cacbab202b51ca9f291b7 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 12:27:33 +0200 Subject: [PATCH 062/222] Follow: remove old backoffice follow and toggle_follow --- .../backoffice/dossiers_controller.rb | 9 --- app/models/gestionnaire.rb | 11 ---- config/routes.rb | 1 - .../backoffice/dossiers_controller_spec.rb | 40 ------------- spec/models/gestionnaire_spec.rb | 60 ------------------- 5 files changed, 121 deletions(-) diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index 1cced017a..5556d1ba2 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -145,15 +145,6 @@ class Backoffice::DossiersController < Backoffice::DossiersListController redirect_to backoffice_dossier_path(id: dossier.id) end - def follow - follow = current_gestionnaire.toggle_follow_dossier params[:dossier_id] - - current_gestionnaire.dossiers.find(params[:dossier_id]).next_step! 'gestionnaire', 'follow' - - flash.notice = (follow.class == Follow ? 'Dossier suivi' : 'Dossier relaché') - redirect_to request.referer - end - def reload_smartlisting begin @liste = URI(request.referer).query.split('=').second diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 4e721141a..dccd0cff9 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -34,17 +34,6 @@ class Gestionnaire < ActiveRecord::Base dossiers.where(id: dossier_id).any? end - def toggle_follow_dossier dossier_id - dossier = dossier_id - dossier = Dossier.find(dossier_id) unless dossier_id.class == Dossier - - Follow.create!(dossier: dossier, gestionnaire: self) - rescue ActiveRecord::RecordInvalid - Follow.where(dossier: dossier, gestionnaire: self).delete_all - rescue ActiveRecord::RecordNotFound - nil - end - def follow(dossier) return if follow?(dossier) diff --git a/config/routes.rb b/config/routes.rb index b275f6afe..ab2e727df 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -190,7 +190,6 @@ Rails.application.routes.draw do post 'unarchive' end post 'reopen' => 'dossiers#reopen' - put 'follow' => 'dossiers#follow' resources :commentaires, only: [:index] resources :avis, only: [:create, :update] end diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 37c1249bf..2fa417242 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -369,46 +369,6 @@ describe Backoffice::DossiersController, type: :controller do end end - describe 'PUT #toggle_follow' do - before do - sign_in gestionnaire - end - - subject { put :follow, params: {dossier_id: dossier_id} } - - it { expect(subject.status).to eq 302 } - - context 'when dossier is at state initiated' do - let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } - - before do - subject - dossier.reload - end - - it 'change state for updated' do - expect(dossier.state).to eq 'updated' - end - end - - describe 'flash alert' do - context 'when dossier is not follow by gestionnaire' do - before do - subject - end - it { expect(flash[:notice]).to have_content 'Dossier suivi' } - end - - context 'when dossier is follow by gestionnaire' do - before do - create :follow, gestionnaire_id: gestionnaire.id, dossier_id: dossier.id - subject - end - it { expect(flash[:notice]).to have_content 'Dossier relaché' } - end - end - end - describe 'POST #reopen' do before do dossier.received! diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index 366c1c493..26ed73719 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -13,66 +13,6 @@ describe Gestionnaire, type: :model do create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2 end - describe '#toggle_follow_dossier' do - let!(:dossier) { create :dossier, procedure: procedure } - - subject { gestionnaire.toggle_follow_dossier dossier_id } - - context 'when dossier id not valid' do - let(:dossier_id) { 0 } - - it { expect(subject).to eq nil } - end - - context 'when dossier id is valid' do - let(:dossier_id) { dossier.id } - - context 'when dossier is not follow by gestionnaire' do - it 'value change in database' do - expect { subject }.to change(Follow, :count).by(1) - end - - it { expect(subject).to be_an_instance_of Follow } - end - - context 'when dossier is follow by gestionnaire' do - before do - create :follow, dossier_id: dossier.id, gestionnaire_id: gestionnaire.id - end - - it 'value change in database' do - expect { subject }.to change(Follow, :count).by(-1) - end - - it { expect(subject).to eq 1 } - end - end - - context 'when dossier instance is past' do - let(:dossier_id) { dossier } - - context 'when dossier is not follow by gestionnaire' do - it 'value change in database' do - expect { subject }.to change(Follow, :count).by(1) - end - - it { expect(subject).to be_an_instance_of Follow } - end - - context 'when dossier is follow by gestionnaire' do - before do - create :follow, dossier_id: dossier.id, gestionnaire_id: gestionnaire.id - end - - it 'value change in database' do - expect { subject }.to change(Follow, :count).by(-1) - end - - it { expect(subject).to eq 1 } - end - end - end - describe 'follow' do let(:dossier) { create :dossier } let(:already_followed_dossier) { create :dossier } From b80d6a6a594e131080f491f4592b052ac063265b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 12:28:09 +0200 Subject: [PATCH 063/222] Follow: add flash notice to dossier_controller --- app/controllers/new_gestionnaire/dossiers_controller.rb | 3 +++ spec/controllers/new_gestionnaire/dossiers_controller_spec.rb | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 065e0f118..9a8631f28 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -11,11 +11,14 @@ module NewGestionnaire def follow current_gestionnaire.follow(dossier) dossier.next_step!('gestionnaire', 'follow') + flash.notice = 'Dossier suivi' redirect_back(fallback_location: procedures_url) end def unfollow current_gestionnaire.followed_dossiers.delete(dossier) + flash.notice = "Vous ne suivez plus le dossier nº #{dossier.id}" + redirect_back(fallback_location: procedures_url) end diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index e149a355c..17f7ba97e 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -38,6 +38,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end it { expect(gestionnaire.followed_dossiers).to match([dossier]) } + it { expect(flash.notice).to eq('Dossier suivi') } it { expect(response).to redirect_to(procedures_url) } end @@ -49,6 +50,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end it { expect(gestionnaire.followed_dossiers).to match([]) } + it { expect(flash.notice).to eq("Vous ne suivez plus le dossier nº #{dossier.id}") } it { expect(response).to redirect_to(procedures_url) } end From 86ea47bb0d96e92900ccbddac44ab08777b8050f Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 11:28:52 +0200 Subject: [PATCH 064/222] BackofficeDossierController: follow dossier when receive --- app/controllers/backoffice/dossiers_controller.rb | 1 + spec/controllers/backoffice/dossiers_controller_spec.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index 5556d1ba2..102c71437 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -98,6 +98,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController dossier = Dossier.find(params[:dossier_id]) dossier.received! + current_gestionnaire.follow(dossier) flash.notice = 'Dossier considéré comme reçu.' redirect_to backoffice_dossier_path(id: dossier.id) diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 2fa417242..25ad420e4 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -248,6 +248,11 @@ describe Backoffice::DossiersController, type: :controller do end it { is_expected.to redirect_to backoffice_dossier_path(id: dossier.id) } + + it do + subject + expect(gestionnaire.follow?(dossier)).to be true + end end describe 'POST #process_dossier' do From 97de5b2dd94529ffef35d17b8867c13f0a7bdcf7 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 14:31:31 +0200 Subject: [PATCH 065/222] DossierControllerSpec: remove duplicate test --- spec/controllers/backoffice/dossiers_controller_spec.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 25ad420e4..904c0ce20 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -239,14 +239,6 @@ describe Backoffice::DossiersController, type: :controller do end end - it 'Notification email is send' do - expect(NotificationMailer).to receive(:send_notification) - .with(dossier, kind_of(Mails::ReceivedMail)).and_return(NotificationMailer) - expect(NotificationMailer).to receive(:deliver_now!) - - subject - end - it { is_expected.to redirect_to backoffice_dossier_path(id: dossier.id) } it do From d5535aaaaa7b1688634f87670e4919e57f01fd9c Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 17 Jul 2017 14:34:41 +0200 Subject: [PATCH 066/222] DossierControllerSpec: refactor --- .../backoffice/dossiers_controller_spec.rb | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 904c0ce20..569318b94 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -224,27 +224,13 @@ describe Backoffice::DossiersController, type: :controller do before do dossier.initiated! sign_in gestionnaire + post :receive, params: { dossier_id: dossier_id } + dossier.reload end - subject { post :receive, params: {dossier_id: dossier_id} } - - context 'when it post a receive instruction' do - before do - subject - dossier.reload - end - - it 'change state to received' do - expect(dossier.state).to eq('received') - end - end - - it { is_expected.to redirect_to backoffice_dossier_path(id: dossier.id) } - - it do - subject - expect(gestionnaire.follow?(dossier)).to be true - end + it { expect(dossier.state).to eq('received') } + it { is_expected.to redirect_to backoffice_dossier_path(dossier) } + it { expect(gestionnaire.follow?(dossier)).to be true } end describe 'POST #process_dossier' do From 497f898e1bb8d9b2c05cc4f40dc7be89645894a7 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 19 Jul 2017 11:08:53 +0200 Subject: [PATCH 067/222] NewDesign: add dossier messagerie show --- .../new_design/dossier_messagerie.scss | 23 +++++++++++++++++++ .../new_gestionnaire/dossiers_controller.rb | 4 ++++ .../dossiers/_commentaire_issuer.html.haml | 7 ++++++ .../dossiers/messagerie.html.haml | 11 +++++++++ config/routes.rb | 1 + 5 files changed, 46 insertions(+) create mode 100644 app/assets/stylesheets/new_design/dossier_messagerie.scss create mode 100644 app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/messagerie.html.haml diff --git a/app/assets/stylesheets/new_design/dossier_messagerie.scss b/app/assets/stylesheets/new_design/dossier_messagerie.scss new file mode 100644 index 000000000..28e1aa9ac --- /dev/null +++ b/app/assets/stylesheets/new_design/dossier_messagerie.scss @@ -0,0 +1,23 @@ +@import "colors"; +@import "common"; +@import "constants"; + +#dossier-messagerie { + li { + margin-bottom: 2 * $default-padding; + } + + h2 { + margin-bottom: $default-spacer; + } + + .mail { + font-weight: bold; + } + + .date { + font-size: 12px; + color: $grey; + float: right; + } +} diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 9a8631f28..8f9e1e05c 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -8,6 +8,10 @@ module NewGestionnaire @dossier = dossier end + def messagerie + @dossier = dossier + end + def follow current_gestionnaire.follow(dossier) dossier.next_step!('gestionnaire', 'follow') diff --git a/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml b/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml new file mode 100644 index 000000000..4704526d7 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml @@ -0,0 +1,7 @@ +- case commentaire.email +- when current_gestionnaire.email + Vous +- when 'contact@tps.apientreprise.fr' + Mail automatique +- else + commentaire.email diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml new file mode 100644 index 000000000..56f59ad73 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -0,0 +1,11 @@ += render partial: "header", locals: { dossier: @dossier } + +#dossier-messagerie.container + %ul + - @dossier.commentaires.each do |commentaire| + %li + %h2 + %span.mail + = render partial: 'commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } + %span.date= I18n.l(commentaire.created_at.localtime, format: '%d/%m/%y') + %p= sanitize(commentaire.body) diff --git a/config/routes.rb b/config/routes.rb index ab2e727df..d13051e55 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -242,6 +242,7 @@ Rails.application.routes.draw do resources :dossiers, only: [:show], param: :dossier_id do member do get 'attestation' + get 'messagerie' patch 'follow' patch 'unfollow' patch 'archive' From 983c17fdcf8b1413aecbc0970ffbb15bd2e5329e Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 19 Jul 2017 15:19:40 +0200 Subject: [PATCH 068/222] NewDesign: Dossier add dossier and messagerie link in header --- app/views/new_gestionnaire/dossiers/_header.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 1c171358b..9e503420f 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -7,10 +7,10 @@ = "Dossier n° #{dossier.id}" %ul.tabs %li - = link_to "Demande", "#", class: ("selected" if current_page?(dossier_path(dossier.procedure, dossier))) + = link_to "Demande", dossier_path(dossier.procedure, dossier), class: ("selected" if current_page?(dossier_path(dossier.procedure, dossier))) %li = link_to "Instruction", "#" %li - = link_to "Messagerie", "#" + = link_to "Messagerie", messagerie_dossier_path(dossier.procedure, dossier), class: current_page?(messagerie_dossier_path(dossier.procedure, dossier)) ? 'selected' : nil %li = link_to "Historique", "#" From 3a8e84b128da2261b58bfe3ec5284b4999b78632 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 19 Jul 2017 11:23:31 +0200 Subject: [PATCH 069/222] NewDesign: add guest label to message --- app/assets/stylesheets/new_design/dossier_messagerie.scss | 4 ++++ app/views/new_gestionnaire/dossiers/messagerie.html.haml | 2 ++ 2 files changed, 6 insertions(+) diff --git a/app/assets/stylesheets/new_design/dossier_messagerie.scss b/app/assets/stylesheets/new_design/dossier_messagerie.scss index 28e1aa9ac..6bf4aae51 100644 --- a/app/assets/stylesheets/new_design/dossier_messagerie.scss +++ b/app/assets/stylesheets/new_design/dossier_messagerie.scss @@ -15,9 +15,13 @@ font-weight: bold; } + .guest, .date { font-size: 12px; color: $grey; + } + + .date { float: right; } } diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index 56f59ad73..65bfc1477 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -7,5 +7,7 @@ %h2 %span.mail = render partial: 'commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } + - if ![current_gestionnaire.email, @dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email) + %span.guest Invité %span.date= I18n.l(commentaire.created_at.localtime, format: '%d/%m/%y') %p= sanitize(commentaire.body) From 3ecc4f1327bc5f60894a1a9e13c015aebb543b01 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 20 Jul 2017 14:23:16 +0200 Subject: [PATCH 070/222] NewDesign: add person icon to message --- app/assets/images/icons/blue-person.svg | 1 + app/assets/images/icons/mail.svg | 1 + .../new_design/dossier_messagerie.scss | 10 ++++++++++ .../dossiers/_commentaire_icon.html.haml | 7 +++++++ .../dossiers/messagerie.html.haml | 17 ++++++++++------- 5 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 app/assets/images/icons/blue-person.svg create mode 100644 app/assets/images/icons/mail.svg create mode 100644 app/views/new_gestionnaire/dossiers/_commentaire_icon.html.haml diff --git a/app/assets/images/icons/blue-person.svg b/app/assets/images/icons/blue-person.svg new file mode 100644 index 000000000..a5693cac9 --- /dev/null +++ b/app/assets/images/icons/blue-person.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/icons/mail.svg b/app/assets/images/icons/mail.svg new file mode 100644 index 000000000..7a84b97da --- /dev/null +++ b/app/assets/images/icons/mail.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/new_design/dossier_messagerie.scss b/app/assets/stylesheets/new_design/dossier_messagerie.scss index 6bf4aae51..606c7c67e 100644 --- a/app/assets/stylesheets/new_design/dossier_messagerie.scss +++ b/app/assets/stylesheets/new_design/dossier_messagerie.scss @@ -4,9 +4,19 @@ #dossier-messagerie { li { + display: flex; + align-items: flex-start; margin-bottom: 2 * $default-padding; } + .right { + width: 100%; + } + + .person-icon { + margin-right: $default-spacer; + } + h2 { margin-bottom: $default-spacer; } diff --git a/app/views/new_gestionnaire/dossiers/_commentaire_icon.html.haml b/app/views/new_gestionnaire/dossiers/_commentaire_icon.html.haml new file mode 100644 index 000000000..c4574b676 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/_commentaire_icon.html.haml @@ -0,0 +1,7 @@ +- case commentaire.email +- when current_gestionnaire.email + = image_tag('icons/account-circle.svg', class: 'person-icon') +- when 'contact@tps.apientreprise.fr' + = image_tag('icons/mail.svg', class: 'person-icon') +- else + = image_tag('icons/blue-person.svg', class: 'person-icon') diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index 65bfc1477..35b4796aa 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -4,10 +4,13 @@ %ul - @dossier.commentaires.each do |commentaire| %li - %h2 - %span.mail - = render partial: 'commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } - - if ![current_gestionnaire.email, @dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email) - %span.guest Invité - %span.date= I18n.l(commentaire.created_at.localtime, format: '%d/%m/%y') - %p= sanitize(commentaire.body) + = render partial: 'commentaire_icon', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } + + .right + %h2 + %span.mail + = render partial: 'commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } + - if ![current_gestionnaire.email, @dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email) + %span.guest Invité + %span.date= I18n.l(commentaire.created_at.localtime, format: '%d/%m/%y') + %p= sanitize(commentaire.body) From 714b2a5f08fd9331750b2fdca72601e4f7234d38 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 19 Jul 2017 14:04:49 +0200 Subject: [PATCH 071/222] NewDesign: gestionnaire can add a new commentaire --- .../new_design/dossier_messagerie.scss | 9 +++++++++ .../new_gestionnaire/dossiers_controller.rb | 9 +++++++++ .../dossiers/messagerie.html.haml | 4 ++++ config/routes.rb | 1 + .../dossiers_controller_spec.rb | 19 +++++++++++++++++++ 5 files changed, 42 insertions(+) diff --git a/app/assets/stylesheets/new_design/dossier_messagerie.scss b/app/assets/stylesheets/new_design/dossier_messagerie.scss index 606c7c67e..6cf4b29be 100644 --- a/app/assets/stylesheets/new_design/dossier_messagerie.scss +++ b/app/assets/stylesheets/new_design/dossier_messagerie.scss @@ -34,4 +34,13 @@ .date { float: right; } + + form { + overflow: hidden; + } + + .send { + float: right; + margin-bottom: $default-padding; + } } diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 8f9e1e05c..30be1c62d 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -36,10 +36,19 @@ module NewGestionnaire redirect_back(fallback_location: procedures_url) end + def create_commentaire + Commentaire.create(commentaire_params.merge(email: current_gestionnaire.email, dossier: dossier)) + redirect_to messagerie_dossier_path(dossier.procedure, dossier) + end + private def dossier current_gestionnaire.dossiers.find(params[:dossier_id]) end + + def commentaire_params + params.require(:commentaire).permit(:body) + end end end diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index 35b4796aa..1754f5b9d 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -14,3 +14,7 @@ %span.guest Invité %span.date= I18n.l(commentaire.created_at.localtime, format: '%d/%m/%y') %p= sanitize(commentaire.body) + + = form_for(Commentaire.new, url: commentaire_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' }) do |f| + = f.text_area :body, class: 'new-commentaire', rows: 5, placeholder: 'Répondre ici', required: true + = f.submit 'Envoyer', class: 'button send' diff --git a/config/routes.rb b/config/routes.rb index d13051e55..b06d50f4d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -247,6 +247,7 @@ Rails.application.routes.draw do patch 'unfollow' patch 'archive' patch 'unarchive' + post 'commentaire' => 'dossiers#create_commentaire' end end end diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 17f7ba97e..b8f9ea4cb 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -101,4 +101,23 @@ describe NewGestionnaire::DossiersController, type: :controller do end end end + + describe "commentaire" do + let(:saved_commentaire) { dossier.commentaires.first } + + before do + sign_in(gestionnaire) + + post :create_commentaire, params: { + procedure_id: procedure.id, + dossier_id: dossier.id, + commentaire: { body: 'body' } + } + end + + it { expect(saved_commentaire.body).to eq('body') } + it { expect(saved_commentaire.email).to eq(gestionnaire.email) } + it { expect(saved_commentaire.dossier).to eq(dossier) } + it { expect(response).to redirect_to(messagerie_dossier_path(dossier.procedure, dossier)) } + end end From 0d27ca3bca8beaf1804957f8a9be6e265139623b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 20 Jul 2017 14:17:12 +0200 Subject: [PATCH 072/222] Commentaire: use scope to order commentaires association --- app/models/commentaire.rb | 2 ++ app/views/new_gestionnaire/dossiers/messagerie.html.haml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/commentaire.rb b/app/models/commentaire.rb index d62e87eac..cf88b094a 100644 --- a/app/models/commentaire.rb +++ b/app/models/commentaire.rb @@ -4,6 +4,8 @@ class Commentaire < ActiveRecord::Base belongs_to :piece_justificative + scope :ordered, -> { order(created_at: :asc) } + after_create :notify def header diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index 1754f5b9d..8036e10d4 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -2,7 +2,7 @@ #dossier-messagerie.container %ul - - @dossier.commentaires.each do |commentaire| + - @dossier.commentaires.ordered.each do |commentaire| %li = render partial: 'commentaire_icon', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } From 877f64599dd225bf42931141bbd21ae29ec546b9 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 24 Jul 2017 09:46:13 +0200 Subject: [PATCH 073/222] Form: add send button on the right --- .../stylesheets/new_design/dossier_messagerie.scss | 9 --------- app/assets/stylesheets/new_design/forms.scss | 7 +++++++ app/views/root/patron.html.haml | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/new_design/dossier_messagerie.scss b/app/assets/stylesheets/new_design/dossier_messagerie.scss index 6cf4b29be..606c7c67e 100644 --- a/app/assets/stylesheets/new_design/dossier_messagerie.scss +++ b/app/assets/stylesheets/new_design/dossier_messagerie.scss @@ -34,13 +34,4 @@ .date { float: right; } - - form { - overflow: hidden; - } - - .send { - float: right; - margin-bottom: $default-padding; - } } diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index ad7831a0f..50a56c464 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -2,6 +2,8 @@ @import "colors"; .form { + overflow: hidden; + h1 { text-align: center; margin-bottom: 20px; @@ -27,4 +29,9 @@ background-color: $border-grey; } } + + .send { + float: right; + margin-bottom: $default-padding; + } } diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 985f7c5bc..1c417081c 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -8,7 +8,7 @@ %textarea{ placeholder: "Description de votre projet" } %label Mot de passe %input{ type: "password", value: "12345678" } - %input.button{ type: "submit", value: "Envoyer" } + %input.button.send{ type: "submit", value: "Envoyer" } %h1 Boutons From 3b7244675d7ee53fa0f406fa22637e7c25880eed Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 24 Jul 2017 10:01:53 +0200 Subject: [PATCH 074/222] Css: add .width-100 utility class --- app/assets/stylesheets/new_design/dossier_messagerie.scss | 4 ---- app/assets/stylesheets/new_design/utils.scss | 4 ++++ app/views/new_gestionnaire/dossiers/messagerie.html.haml | 2 +- app/views/new_gestionnaire/procedures/show.html.haml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/new_design/dossier_messagerie.scss b/app/assets/stylesheets/new_design/dossier_messagerie.scss index 606c7c67e..087c1ff48 100644 --- a/app/assets/stylesheets/new_design/dossier_messagerie.scss +++ b/app/assets/stylesheets/new_design/dossier_messagerie.scss @@ -9,10 +9,6 @@ margin-bottom: 2 * $default-padding; } - .right { - width: 100%; - } - .person-icon { margin-right: $default-spacer; } diff --git a/app/assets/stylesheets/new_design/utils.scss b/app/assets/stylesheets/new_design/utils.scss index 2880cfe30..91e3fed99 100644 --- a/app/assets/stylesheets/new_design/utils.scss +++ b/app/assets/stylesheets/new_design/utils.scss @@ -21,3 +21,7 @@ .hidden { display: none; } + +.width-100 { + width: 100%; +} diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index 8036e10d4..6a076f49c 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -6,7 +6,7 @@ %li = render partial: 'commentaire_icon', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } - .right + .width-100 %h2 %span.mail = render partial: 'commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 2d4335f4b..0de5523d0 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -4,7 +4,7 @@ - if @procedure.logo.present? = image_tag @procedure.logo, height: 40, class: 'procedure-logo' - .right + .width-100 %h1= @procedure.libelle %ul.dossiers-categories %li{ class: (@statut == 'a-suivre') ? 'active' : nil }> From 2aa8c1d272e8ed77d2b113cf2b0c8be68a00d618 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 24 Jul 2017 09:53:43 +0200 Subject: [PATCH 075/222] Messagerie: remove useless class --- app/views/new_gestionnaire/dossiers/messagerie.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index 6a076f49c..e16cb8e3f 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -16,5 +16,5 @@ %p= sanitize(commentaire.body) = form_for(Commentaire.new, url: commentaire_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' }) do |f| - = f.text_area :body, class: 'new-commentaire', rows: 5, placeholder: 'Répondre ici', required: true + = f.text_area :body, rows: 5, placeholder: 'Répondre ici', required: true = f.submit 'Envoyer', class: 'button send' From 55a4f1288f948e6f10cc121844245ba256b860ef Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 19 Jul 2017 12:23:53 +0200 Subject: [PATCH 076/222] Fix a gestionnaire test --- spec/models/gestionnaire_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index 26ed73719..7bd13c5a3 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -319,7 +319,7 @@ describe Gestionnaire, type: :model do expect_any_instance_of(Procedure).to receive(:procedure_overview).and_return(procedure_overview) end - it { expect(gestionnaire.last_week_overview[:procedure_overviews]).to match([procedure_overview]) } + it { expect(gestionnaire2.last_week_overview[:procedure_overviews]).to match([procedure_overview]) } end context 'when a procedure not published was active with no notifications' do From 7ff77108035d9846192afe3030920a1c7d9b54d5 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 18 Jul 2017 15:26:33 +0200 Subject: [PATCH 077/222] =?UTF-8?q?A=20gestionnaire=20can=20only=20see=20p?= =?UTF-8?q?roc=C3=A9dures=20publi=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/gestionnaire.rb | 2 +- .../backoffice/dossiers/procedure_controller_spec.rb | 2 +- spec/controllers/backoffice/dossiers_controller_spec.rb | 8 ++++---- .../new_gestionnaire/dossiers_controller_spec.rb | 6 +++--- .../new_gestionnaire/procedures_controller_spec.rb | 2 +- spec/controllers/root_controller_spec.rb | 2 +- spec/facades/dossiers_list_facades_spec.rb | 4 ++-- spec/factories/dossier.rb | 2 +- spec/features/backoffice/add_commentaire_spec.rb | 2 +- spec/features/backoffice/connection_spec.rb | 2 +- spec/features/backoffice/flux_de_commentaires_spec.rb | 2 +- spec/features/backoffice/index_show_procedure_spec.rb | 4 ++-- .../lateral_page_pref_list_dossier_backoffice_spec.rb | 2 +- ...page_pref_list_dossier_by_procedure_backoffice_spec.rb | 2 +- spec/features/backoffice/navigate_to_dossier_spec.rb | 4 ++-- spec/features/backoffice/search_file_spec.rb | 2 +- spec/models/gestionnaire_spec.rb | 6 +++--- spec/models/search_spec.rb | 4 ++-- spec/services/accompagnateur_service_spec.rb | 2 +- spec/views/backoffice/dossiers/index_html.haml_spec.rb | 2 +- 20 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index dccd0cff9..98588bc32 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -7,7 +7,7 @@ class Gestionnaire < ActiveRecord::Base has_one :preference_smart_listing_page, dependent: :destroy has_many :assign_to, dependent: :destroy - has_many :procedures, through: :assign_to + has_many :procedures, -> { publiees_ou_archivees }, through: :assign_to has_many :dossiers, -> { state_not_brouillon }, through: :procedures has_many :followed_dossiers, through: :follows, source: :dossier has_many :follows diff --git a/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb b/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb index 411e53121..6c1da0b3e 100644 --- a/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers/procedure_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Backoffice::Dossiers::ProcedureController, type: :controller do let(:gestionnaire) { create :gestionnaire } - let(:procedure) { create :procedure } + let(:procedure) { create :procedure, :published } let(:archived) { false } let(:dossier) { create :dossier, procedure: procedure, archived: archived, state: 'initiated'} diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 569318b94..4b09e776e 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -4,8 +4,8 @@ describe Backoffice::DossiersController, type: :controller do before do @request.env['HTTP_REFERER'] = TPS::Application::URL end - let(:procedure) { create :procedure } - let(:procedure2) { create :procedure } + let(:procedure) { create :procedure, :published } + let(:procedure2) { create :procedure, :published } let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: :initiated) } let(:dossier2) { create(:dossier, :with_entreprise, procedure: procedure2, state: :initiated) } @@ -38,8 +38,8 @@ describe Backoffice::DossiersController, type: :controller do context 'when gestionnaire is assign to many proceudure' do before do - create :assign_to, procedure: create(:procedure), gestionnaire: gestionnaire - create :assign_to, procedure: create(:procedure), gestionnaire: gestionnaire + create :assign_to, procedure: create(:procedure, :published), gestionnaire: gestionnaire + create :assign_to, procedure: create(:procedure, :published), gestionnaire: gestionnaire end it { expect(gestionnaire.procedures.count).to eq 3 } diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index b8f9ea4cb..5ff72010d 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe NewGestionnaire::DossiersController, type: :controller do let(:gestionnaire) { create(:gestionnaire) } - let(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) } + let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } let(:dossier) { create(:dossier, :replied, procedure: procedure) } describe 'attestation' do @@ -11,7 +11,7 @@ describe NewGestionnaire::DossiersController, type: :controller do context 'when a dossier has an attestation' do let(:fake_pdf) { double(read: 'pdf content') } let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) } - let!(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) } + let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) } it 'returns the attestation pdf' do @@ -77,7 +77,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end describe "#show" do - let(:procedure) { create(:procedure, gestionnaires: [gestionnaire]) } + let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } let(:dossier){ create(:dossier, :replied, procedure: procedure) } subject { get :show, params: { procedure_id: procedure.id, dossier_id: dossier.id } } diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index 1ba23a167..ac228d79f 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -68,7 +68,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do subject end - it { expect(assigns(:procedures)).to include(procedure1, procedure2, procedure3) } + it { expect(assigns(:procedures)).to include(procedure1, procedure2) } end context "with dossiers" do diff --git a/spec/controllers/root_controller_spec.rb b/spec/controllers/root_controller_spec.rb index 4ea5e837b..f39c348db 100644 --- a/spec/controllers/root_controller_spec.rb +++ b/spec/controllers/root_controller_spec.rb @@ -20,7 +20,7 @@ describe RootController, type: :controller do context 'when gestionnaire is affect to a procedure' do before do - create :assign_to, procedure: (create :procedure), gestionnaire: gestionnaire + create :assign_to, procedure: (create :procedure, :published), gestionnaire: gestionnaire end it { expect(subject).to redirect_to(backoffice_dossiers_procedure_path(id: Procedure.all.first.id)) } diff --git a/spec/facades/dossiers_list_facades_spec.rb b/spec/facades/dossiers_list_facades_spec.rb index 08ca0c878..98f19254f 100644 --- a/spec/facades/dossiers_list_facades_spec.rb +++ b/spec/facades/dossiers_list_facades_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe DossiersListFacades do let(:gestionnaire) { create :gestionnaire } - let(:procedure) { create :procedure, libelle: 'Ma procédure' } - let(:procedure_2) { create :procedure, libelle: 'Ma seconde procédure' } + let(:procedure) { create :procedure, :published, libelle: 'Ma procédure' } + let(:procedure_2) { create :procedure, :published, libelle: 'Ma seconde procédure' } let!(:preference) { create :preference_list_dossier, gestionnaire: gestionnaire, diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index 52c3ecc5b..62c6c6dc0 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -5,7 +5,7 @@ FactoryGirl.define do before(:create) do |dossier, _evaluator| unless dossier.procedure - procedure = create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private) + procedure = create(:procedure, :published, :with_two_type_de_piece_justificative, :with_type_de_champ, :with_type_de_champ_private) dossier.procedure = procedure end end diff --git a/spec/features/backoffice/add_commentaire_spec.rb b/spec/features/backoffice/add_commentaire_spec.rb index 4a02c93c8..007966589 100644 --- a/spec/features/backoffice/add_commentaire_spec.rb +++ b/spec/features/backoffice/add_commentaire_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'add commentaire on backoffice' do - let(:procedure) { create(:procedure) } + let(:procedure) { create(:procedure, :published) } let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') } let(:dossier_id) { dossier.id } let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') } diff --git a/spec/features/backoffice/connection_spec.rb b/spec/features/backoffice/connection_spec.rb index 10252b367..65a20af26 100644 --- a/spec/features/backoffice/connection_spec.rb +++ b/spec/features/backoffice/connection_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'when gestionnaire come to /backoffice and is not authenticated' do - let(:procedure) { create(:procedure) } + let(:procedure) { create(:procedure, :published) } let!(:dossier) { create(:dossier, procedure: procedure) } before do visit backoffice_path diff --git a/spec/features/backoffice/flux_de_commentaires_spec.rb b/spec/features/backoffice/flux_de_commentaires_spec.rb index f2eef84f0..87247e8ad 100644 --- a/spec/features/backoffice/flux_de_commentaires_spec.rb +++ b/spec/features/backoffice/flux_de_commentaires_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'backoffice: flux de commentaires' do - let(:procedure) { create(:procedure) } + let(:procedure) { create(:procedure, :published) } let(:gestionnaire) { create(:gestionnaire) } let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') } let(:dossier_id) { dossier.id } diff --git a/spec/features/backoffice/index_show_procedure_spec.rb b/spec/features/backoffice/index_show_procedure_spec.rb index ef0eade1a..fc6e60d47 100644 --- a/spec/features/backoffice/index_show_procedure_spec.rb +++ b/spec/features/backoffice/index_show_procedure_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' feature 'As an Accompagnateur I can navigate and use each functionnality around procedures and their dossiers' do let(:user) { create(:user) } let(:gestionnaire) { create(:gestionnaire) } - let(:procedure_1) { create(:procedure, :with_type_de_champ, libelle: 'procedure 1') } - let(:procedure_2) { create(:procedure, :with_type_de_champ, libelle: 'procedure 2') } + let(:procedure_1) { create(:procedure, :published, :with_type_de_champ, libelle: 'procedure 1') } + let(:procedure_2) { create(:procedure, :published, :with_type_de_champ, libelle: 'procedure 2') } before 'Assign procedures to Accompagnateur and generating dossiers for each' do create :assign_to, gestionnaire: gestionnaire, procedure: procedure_1 diff --git a/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb b/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb index 9e7ff7289..54168c166 100644 --- a/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb +++ b/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature 'usage of pref list dossier lateral panel', js: true do let(:administrateur) { create(:administrateur) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) } - let(:procedure) { create(:procedure, administrateur: administrateur) } + let(:procedure) { create(:procedure, :published, administrateur: administrateur) } before do create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') diff --git a/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb b/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb index 79dd816ac..9f4178f50 100644 --- a/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb +++ b/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature 'usage of pref list dossier lateral panel by procedure', js: true do let(:administrateur) { create(:administrateur) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) } - let(:procedure) { create(:procedure, :with_type_de_champ, administrateur: administrateur) } + let(:procedure) { create(:procedure, :published, :with_type_de_champ, administrateur: administrateur) } before do create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') diff --git a/spec/features/backoffice/navigate_to_dossier_spec.rb b/spec/features/backoffice/navigate_to_dossier_spec.rb index 8dcd90533..aa2750b6b 100644 --- a/spec/features/backoffice/navigate_to_dossier_spec.rb +++ b/spec/features/backoffice/navigate_to_dossier_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' feature 'on backoffice page', js: true do let(:administrateur) { create(:administrateur) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) } - let(:procedure) { create(:procedure, administrateur: administrateur) } - let(:procedure_individual) { create :procedure, libelle: 'procedure individual', administrateur: administrateur, for_individual: true } + let(:procedure) { create(:procedure, :published, administrateur: administrateur) } + let(:procedure_individual) { create :procedure, :published, libelle: 'procedure individual', administrateur: administrateur, for_individual: true } let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') } let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'updated' } diff --git a/spec/features/backoffice/search_file_spec.rb b/spec/features/backoffice/search_file_spec.rb index 42ecf5655..d284671cd 100644 --- a/spec/features/backoffice/search_file_spec.rb +++ b/spec/features/backoffice/search_file_spec.rb @@ -11,7 +11,7 @@ feature 'search file on gestionnaire backoffice' do context 'when gestionnaire is logged in' do context 'when he click on search button' do let(:terms) { '' } - let!(:procedure) { create(:procedure, administrateur: administrateur) } + let!(:procedure) { create(:procedure, :published, administrateur: administrateur) } before do create :assign_to, gestionnaire: gestionnaire, procedure: procedure diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index 7bd13c5a3..319f2fa4d 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' describe Gestionnaire, type: :model do let(:admin) { create :administrateur } - let!(:procedure) { create :procedure, administrateur: admin } - let!(:procedure_2) { create :procedure, administrateur: admin } - let!(:procedure_3) { create :procedure, administrateur: admin } + let!(:procedure) { create :procedure, :published, administrateur: admin } + let!(:procedure_2) { create :procedure, :published, administrateur: admin } + let!(:procedure_3) { create :procedure, :published, administrateur: admin } let(:gestionnaire) { create :gestionnaire, procedure_filter: procedure_filter, administrateurs: [admin] } let(:procedure_filter) { nil } let!(:procedure_assign) { create :assign_to, gestionnaire: gestionnaire, procedure: procedure } diff --git a/spec/models/search_spec.rb b/spec/models/search_spec.rb index ba760cdd6..dd46ea750 100644 --- a/spec/models/search_spec.rb +++ b/spec/models/search_spec.rb @@ -19,8 +19,8 @@ describe Search do create :assign_to, gestionnaire: gestionnaire_2, procedure: procedure_2 end - let(:procedure_1) { create(:procedure, administrateur: administrateur_1) } - let(:procedure_2) { create(:procedure, administrateur: administrateur_2) } + let(:procedure_1) { create(:procedure, :published, administrateur: administrateur_1) } + let(:procedure_2) { create(:procedure, :published, administrateur: administrateur_2) } let!(:dossier_0) { create(:dossier, state: 'draft', procedure: procedure_1, user: create(:user, email: 'brouillon@clap.fr')) } let!(:dossier_1) { create(:dossier, state: 'initiated', procedure: procedure_1, user: create(:user, email: 'contact@test.com')) } diff --git a/spec/services/accompagnateur_service_spec.rb b/spec/services/accompagnateur_service_spec.rb index ae6fbb016..e8a550949 100644 --- a/spec/services/accompagnateur_service_spec.rb +++ b/spec/services/accompagnateur_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe AccompagnateurService do - let(:procedure) { create :procedure } + let(:procedure) { create :procedure, :published } let(:accompagnateur) { create :gestionnaire } let(:accompagnateur_service) { AccompagnateurService.new accompagnateur, procedure, to} diff --git a/spec/views/backoffice/dossiers/index_html.haml_spec.rb b/spec/views/backoffice/dossiers/index_html.haml_spec.rb index 307fa0113..539e2c4f9 100644 --- a/spec/views/backoffice/dossiers/index_html.haml_spec.rb +++ b/spec/views/backoffice/dossiers/index_html.haml_spec.rb @@ -4,7 +4,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do let(:administrateur) { create(:administrateur) } let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) } - let!(:procedure) { create(:procedure, administrateur: administrateur) } + let!(:procedure) { create(:procedure, :published, administrateur: administrateur) } let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated').decorate } let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, procedure: procedure, state: 'replied').decorate } From 091fa1d099e9d6570d8992116ef1bacd23e5a106 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 18 Jul 2017 15:18:10 +0200 Subject: [PATCH 078/222] =?UTF-8?q?Order=20a=20Gestionnaire=E2=80=99s=20pr?= =?UTF-8?q?ocedures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First display the procédures publiées, sorted by publication date, and then the procédures archivées, sorted by archiving date --- app/controllers/new_gestionnaire/procedures_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index dfe750eb2..56d2fee29 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -5,7 +5,7 @@ module NewGestionnaire before_action :ensure_ownership!, except: [:index] def index - @procedures = current_gestionnaire.procedures + @procedures = current_gestionnaire.procedures.order(archived_at: :desc, published_at: :desc) dossiers = current_gestionnaire.dossiers.state_not_brouillon @dossiers_count_per_procedure = dossiers.all_state.group(:procedure_id).reorder(nil).count From b4a1f4f248341d0d272cedc0753fa7dad30c76f8 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Tue, 18 Jul 2017 15:18:54 +0200 Subject: [PATCH 079/222] Remove a useless scope call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A gestionnaire’s dossiers are already filtered so that the brouillon ones do not appear --- app/controllers/new_gestionnaire/procedures_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index 56d2fee29..d806ee2d8 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -7,7 +7,7 @@ module NewGestionnaire def index @procedures = current_gestionnaire.procedures.order(archived_at: :desc, published_at: :desc) - dossiers = current_gestionnaire.dossiers.state_not_brouillon + dossiers = current_gestionnaire.dossiers @dossiers_count_per_procedure = dossiers.all_state.group(:procedure_id).reorder(nil).count @dossiers_a_suivre_count_per_procedure = dossiers.without_followers.en_cours.group(:procedure_id).reorder(nil).count @dossiers_archived_count_per_procedure = dossiers.archived.group(:procedure_id).count From bdaa51c5cc36ff3e39395a20bf6a304197c87800 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 24 Jul 2017 17:11:15 +0200 Subject: [PATCH 080/222] Move old js in a directory to avoid conflicts with require_tree --- app/assets/javascripts/application.js | 2 +- app/assets/javascripts/{ => old_design}/action_btn_rules.js | 0 app/assets/javascripts/{ => old_design}/address_typeahead.js | 0 app/assets/javascripts/{ => old_design}/admin.js | 0 .../javascripts/{ => old_design}/admin_procedures_modal.js | 0 app/assets/javascripts/{ => old_design}/archive.js | 0 app/assets/javascripts/{ => old_design}/bootstrap_wysihtml5.js | 0 app/assets/javascripts/{ => old_design}/carte/cadastre.js | 0 app/assets/javascripts/{ => old_design}/carte/carte.js | 0 app/assets/javascripts/{ => old_design}/carte/qp.js | 0 app/assets/javascripts/{ => old_design}/cgu.js | 0 app/assets/javascripts/{ => old_design}/default_data_block.js | 0 app/assets/javascripts/{ => old_design}/description.js | 0 .../javascripts/{ => old_design}/dossier_commentaires_modal.js | 0 app/assets/javascripts/{ => old_design}/dossiers.js | 0 app/assets/javascripts/{ => old_design}/dossiers_list_filter.js | 0 app/assets/javascripts/{ => old_design}/dossiers_list_link.js | 0 app/assets/javascripts/{ => old_design}/franceconnect_kit.js | 0 .../javascripts/{ => old_design}/gestionnaire_dossier_modal.js | 0 app/assets/javascripts/{ => old_design}/new-description.js | 0 app/assets/javascripts/{ => old_design}/pref_list_dossier.js | 0 app/assets/javascripts/{ => old_design}/procedure.js | 0 app/assets/javascripts/{ => old_design}/search.js | 0 app/assets/javascripts/{ => old_design}/start.js | 0 app/assets/javascripts/{ => old_design}/user/description.js | 0 25 files changed, 1 insertion(+), 1 deletion(-) rename app/assets/javascripts/{ => old_design}/action_btn_rules.js (100%) rename app/assets/javascripts/{ => old_design}/address_typeahead.js (100%) rename app/assets/javascripts/{ => old_design}/admin.js (100%) rename app/assets/javascripts/{ => old_design}/admin_procedures_modal.js (100%) rename app/assets/javascripts/{ => old_design}/archive.js (100%) rename app/assets/javascripts/{ => old_design}/bootstrap_wysihtml5.js (100%) rename app/assets/javascripts/{ => old_design}/carte/cadastre.js (100%) rename app/assets/javascripts/{ => old_design}/carte/carte.js (100%) rename app/assets/javascripts/{ => old_design}/carte/qp.js (100%) rename app/assets/javascripts/{ => old_design}/cgu.js (100%) rename app/assets/javascripts/{ => old_design}/default_data_block.js (100%) rename app/assets/javascripts/{ => old_design}/description.js (100%) rename app/assets/javascripts/{ => old_design}/dossier_commentaires_modal.js (100%) rename app/assets/javascripts/{ => old_design}/dossiers.js (100%) rename app/assets/javascripts/{ => old_design}/dossiers_list_filter.js (100%) rename app/assets/javascripts/{ => old_design}/dossiers_list_link.js (100%) rename app/assets/javascripts/{ => old_design}/franceconnect_kit.js (100%) rename app/assets/javascripts/{ => old_design}/gestionnaire_dossier_modal.js (100%) rename app/assets/javascripts/{ => old_design}/new-description.js (100%) rename app/assets/javascripts/{ => old_design}/pref_list_dossier.js (100%) rename app/assets/javascripts/{ => old_design}/procedure.js (100%) rename app/assets/javascripts/{ => old_design}/search.js (100%) rename app/assets/javascripts/{ => old_design}/start.js (100%) rename app/assets/javascripts/{ => old_design}/user/description.js (100%) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index f17bf80df..d5ce61307 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -15,7 +15,7 @@ //= require turbolinks //= require highcharts //= require chartkick -//= require_tree . +//= require_tree ./old_design //= require bootstrap-sprockets //= require bootstrap-datepicker/core //= require bootstrap-datepicker/locales/bootstrap-datepicker.fr.js diff --git a/app/assets/javascripts/action_btn_rules.js b/app/assets/javascripts/old_design/action_btn_rules.js similarity index 100% rename from app/assets/javascripts/action_btn_rules.js rename to app/assets/javascripts/old_design/action_btn_rules.js diff --git a/app/assets/javascripts/address_typeahead.js b/app/assets/javascripts/old_design/address_typeahead.js similarity index 100% rename from app/assets/javascripts/address_typeahead.js rename to app/assets/javascripts/old_design/address_typeahead.js diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/old_design/admin.js similarity index 100% rename from app/assets/javascripts/admin.js rename to app/assets/javascripts/old_design/admin.js diff --git a/app/assets/javascripts/admin_procedures_modal.js b/app/assets/javascripts/old_design/admin_procedures_modal.js similarity index 100% rename from app/assets/javascripts/admin_procedures_modal.js rename to app/assets/javascripts/old_design/admin_procedures_modal.js diff --git a/app/assets/javascripts/archive.js b/app/assets/javascripts/old_design/archive.js similarity index 100% rename from app/assets/javascripts/archive.js rename to app/assets/javascripts/old_design/archive.js diff --git a/app/assets/javascripts/bootstrap_wysihtml5.js b/app/assets/javascripts/old_design/bootstrap_wysihtml5.js similarity index 100% rename from app/assets/javascripts/bootstrap_wysihtml5.js rename to app/assets/javascripts/old_design/bootstrap_wysihtml5.js diff --git a/app/assets/javascripts/carte/cadastre.js b/app/assets/javascripts/old_design/carte/cadastre.js similarity index 100% rename from app/assets/javascripts/carte/cadastre.js rename to app/assets/javascripts/old_design/carte/cadastre.js diff --git a/app/assets/javascripts/carte/carte.js b/app/assets/javascripts/old_design/carte/carte.js similarity index 100% rename from app/assets/javascripts/carte/carte.js rename to app/assets/javascripts/old_design/carte/carte.js diff --git a/app/assets/javascripts/carte/qp.js b/app/assets/javascripts/old_design/carte/qp.js similarity index 100% rename from app/assets/javascripts/carte/qp.js rename to app/assets/javascripts/old_design/carte/qp.js diff --git a/app/assets/javascripts/cgu.js b/app/assets/javascripts/old_design/cgu.js similarity index 100% rename from app/assets/javascripts/cgu.js rename to app/assets/javascripts/old_design/cgu.js diff --git a/app/assets/javascripts/default_data_block.js b/app/assets/javascripts/old_design/default_data_block.js similarity index 100% rename from app/assets/javascripts/default_data_block.js rename to app/assets/javascripts/old_design/default_data_block.js diff --git a/app/assets/javascripts/description.js b/app/assets/javascripts/old_design/description.js similarity index 100% rename from app/assets/javascripts/description.js rename to app/assets/javascripts/old_design/description.js diff --git a/app/assets/javascripts/dossier_commentaires_modal.js b/app/assets/javascripts/old_design/dossier_commentaires_modal.js similarity index 100% rename from app/assets/javascripts/dossier_commentaires_modal.js rename to app/assets/javascripts/old_design/dossier_commentaires_modal.js diff --git a/app/assets/javascripts/dossiers.js b/app/assets/javascripts/old_design/dossiers.js similarity index 100% rename from app/assets/javascripts/dossiers.js rename to app/assets/javascripts/old_design/dossiers.js diff --git a/app/assets/javascripts/dossiers_list_filter.js b/app/assets/javascripts/old_design/dossiers_list_filter.js similarity index 100% rename from app/assets/javascripts/dossiers_list_filter.js rename to app/assets/javascripts/old_design/dossiers_list_filter.js diff --git a/app/assets/javascripts/dossiers_list_link.js b/app/assets/javascripts/old_design/dossiers_list_link.js similarity index 100% rename from app/assets/javascripts/dossiers_list_link.js rename to app/assets/javascripts/old_design/dossiers_list_link.js diff --git a/app/assets/javascripts/franceconnect_kit.js b/app/assets/javascripts/old_design/franceconnect_kit.js similarity index 100% rename from app/assets/javascripts/franceconnect_kit.js rename to app/assets/javascripts/old_design/franceconnect_kit.js diff --git a/app/assets/javascripts/gestionnaire_dossier_modal.js b/app/assets/javascripts/old_design/gestionnaire_dossier_modal.js similarity index 100% rename from app/assets/javascripts/gestionnaire_dossier_modal.js rename to app/assets/javascripts/old_design/gestionnaire_dossier_modal.js diff --git a/app/assets/javascripts/new-description.js b/app/assets/javascripts/old_design/new-description.js similarity index 100% rename from app/assets/javascripts/new-description.js rename to app/assets/javascripts/old_design/new-description.js diff --git a/app/assets/javascripts/pref_list_dossier.js b/app/assets/javascripts/old_design/pref_list_dossier.js similarity index 100% rename from app/assets/javascripts/pref_list_dossier.js rename to app/assets/javascripts/old_design/pref_list_dossier.js diff --git a/app/assets/javascripts/procedure.js b/app/assets/javascripts/old_design/procedure.js similarity index 100% rename from app/assets/javascripts/procedure.js rename to app/assets/javascripts/old_design/procedure.js diff --git a/app/assets/javascripts/search.js b/app/assets/javascripts/old_design/search.js similarity index 100% rename from app/assets/javascripts/search.js rename to app/assets/javascripts/old_design/search.js diff --git a/app/assets/javascripts/start.js b/app/assets/javascripts/old_design/start.js similarity index 100% rename from app/assets/javascripts/start.js rename to app/assets/javascripts/old_design/start.js diff --git a/app/assets/javascripts/user/description.js b/app/assets/javascripts/old_design/user/description.js similarity index 100% rename from app/assets/javascripts/user/description.js rename to app/assets/javascripts/old_design/user/description.js From 373d9999fccaa572f5973e5e08738103e7652e2e Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 24 Jul 2017 20:04:41 +0200 Subject: [PATCH 081/222] Add map for gestionnaire --- .../javascripts/new_design/application.js | 1 + .../javascripts/new_design/carte/cadastre.js | 10 + .../javascripts/new_design/carte/carte.js | 59 ++ .../carte/quartiers_prioritaires.js | 10 + app/assets/stylesheets/new_design/map.scss | 4 + .../new_design/new_application.scss | 1 + .../new_gestionnaire/dossiers_controller.rb | 16 + .../new_gestionnaire/dossiers/_map.html.haml | 22 + .../new_gestionnaire/dossiers/show.html.haml | 3 + config/routes.rb | 3 + vendor/assets/javascripts/leaflet.1.1.0.js | 6 + vendor/assets/stylesheets/leaflet.1.1.0.css | 631 ++++++++++++++++++ 12 files changed, 766 insertions(+) create mode 100644 app/assets/javascripts/new_design/carte/cadastre.js create mode 100644 app/assets/javascripts/new_design/carte/carte.js create mode 100644 app/assets/javascripts/new_design/carte/quartiers_prioritaires.js create mode 100644 app/assets/stylesheets/new_design/map.scss create mode 100644 app/views/new_gestionnaire/dossiers/_map.html.haml create mode 100644 vendor/assets/javascripts/leaflet.1.1.0.js create mode 100644 vendor/assets/stylesheets/leaflet.1.1.0.css diff --git a/app/assets/javascripts/new_design/application.js b/app/assets/javascripts/new_design/application.js index 700bc74fb..62606accb 100644 --- a/app/assets/javascripts/new_design/application.js +++ b/app/assets/javascripts/new_design/application.js @@ -13,6 +13,7 @@ //= require jquery //= require jquery_ujs //= require turbolinks +//= require leaflet.1.1.0 //= require highcharts //= require chartkick //= require_tree . diff --git a/app/assets/javascripts/new_design/carte/cadastre.js b/app/assets/javascripts/new_design/carte/cadastre.js new file mode 100644 index 000000000..40d4ad764 --- /dev/null +++ b/app/assets/javascripts/new_design/carte/cadastre.js @@ -0,0 +1,10 @@ +function drawCadastre (map) { + drawLayerWithItems(map, dossierCadastres, { + fillColor: '#8A6D3B', + weight: 2, + opacity: 0.7, + color: '#8A6D3B', + dashArray: '3', + fillOpacity: 0.5 + }); +} diff --git a/app/assets/javascripts/new_design/carte/carte.js b/app/assets/javascripts/new_design/carte/carte.js new file mode 100644 index 000000000..61266bf51 --- /dev/null +++ b/app/assets/javascripts/new_design/carte/carte.js @@ -0,0 +1,59 @@ +function initCarto() { + if ($("#map").length > 0) { + var position = getPosition() || defaultGestionnairePosition(); + + var map = L.map('map', { + scrollWheelZoom: false + }).setView([position.lat, position.lon], position.zoom); + + L.tileLayer('http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors' + }).addTo(map); + + // draw external polygons + drawCadastre(map); + drawQuartiersPrioritaires(map); + + // draw user polygon + drawUserSelection(map); + } +} + +$(document).on('turbolinks:load', initCarto); + +function drawUserSelection(map) { + var polygon = L.polygon(dossierJsonLatLngs, { color: 'red', zIndex: 3 }).addTo(map); + map.fitBounds(polygon.getBounds()); +} + +function defaultGestionnairePosition() { + var LON = '2.428462'; + var LAT = '46.538192'; + return { lon: LON, lat: LAT, zoom: 5 } +} + +function getPosition() { + var position; + + $.ajax({ + url: getPositionUrl, + dataType: 'json', + async: false + }).done(function (data) { + position = data + }); + + return position; +} + +function drawLayerWithItems(map, items, style) { + if (Array.isArray(items) && items.length > 0) { + var layer = new L.GeoJSON(); + + items.forEach(function (item) { + layer.addData(item.geometry); + }); + + layer.setStyle(style).addTo(map); + } +} diff --git a/app/assets/javascripts/new_design/carte/quartiers_prioritaires.js b/app/assets/javascripts/new_design/carte/quartiers_prioritaires.js new file mode 100644 index 000000000..e97b25763 --- /dev/null +++ b/app/assets/javascripts/new_design/carte/quartiers_prioritaires.js @@ -0,0 +1,10 @@ +function drawQuartiersPrioritaires (map) { + drawLayerWithItems(map, dossierQuartiersPrioritaires, { + fillColor: '#31708F', + weight: 2, + opacity: 0.7, + color: '#31708F', + dashArray: '3', + fillOpacity: 0.5 + }); +} diff --git a/app/assets/stylesheets/new_design/map.scss b/app/assets/stylesheets/new_design/map.scss new file mode 100644 index 000000000..dde4e1494 --- /dev/null +++ b/app/assets/stylesheets/new_design/map.scss @@ -0,0 +1,4 @@ +#map { + height: 400px; + margin-bottom: 16px; +} diff --git a/app/assets/stylesheets/new_design/new_application.scss b/app/assets/stylesheets/new_design/new_application.scss index 82fb5fc2a..9735dc8fc 100644 --- a/app/assets/stylesheets/new_design/new_application.scss +++ b/app/assets/stylesheets/new_design/new_application.scss @@ -3,4 +3,5 @@ // = require ./common // = require ./utils // = require ./fonts +// = require leaflet.1.1.0 // = require_tree . diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 30be1c62d..c2e622386 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -41,6 +41,22 @@ module NewGestionnaire redirect_to messagerie_dossier_path(dossier.procedure, dossier) end + def position + etablissement = dossier.etablissement + point = Carto::Geocodeur.convert_adresse_to_point(etablissement.geo_adresse) unless etablissement.nil? + + lon = "2.428462" + lat = "46.538192" + zoom = "13" + + unless point.nil? + lon = point.x.to_s + lat = point.y.to_s + end + + render json: { lon: lon, lat: lat, zoom: zoom, dossier_id: params[:dossier_id] } + end + private def dossier diff --git a/app/views/new_gestionnaire/dossiers/_map.html.haml b/app/views/new_gestionnaire/dossiers/_map.html.haml new file mode 100644 index 000000000..47becb044 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/_map.html.haml @@ -0,0 +1,22 @@ +.card.featured + .card-title Cartographie + #map + + - if dossier.quartier_prioritaires.any? + .card-title Quartiers prioritaires + %ul + - dossier.quartier_prioritaires.each do |q| + %li= q.nom + + - if dossier.cadastres.any? + .card-title Parcelles cadastrales + %ul + - dossier.cadastres.each do |p| + %li + = "Parcelle n° #{p.numero} - Feuille #{p.code_arr} #{p.section} #{p.feuille}" + +:javascript + var getPositionUrl = "#{position_dossier_path(dossier.procedure, dossier)}"; + var dossierJsonLatLngs = #{dossier.json_latlngs}; + var dossierCadastres = #{dossier.cadastres.to_json}; + var dossierQuartiersPrioritaires = #{dossier.quartier_prioritaires.to_json}; diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index 585c2b240..7e2a6521f 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -16,6 +16,9 @@ - if champs.any? = render partial: "champs", locals: { champs: champs } + - if @dossier.procedure.module_api_carto.present? + = render partial: "map", locals: { dossier: @dossier } + - if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? .card.featured .card-title Pièces jointes diff --git a/config/routes.rb b/config/routes.rb index b06d50f4d..66c9975d0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -248,6 +248,9 @@ Rails.application.routes.draw do patch 'archive' patch 'unarchive' post 'commentaire' => 'dossiers#create_commentaire' + scope :carte do + get 'position' + end end end end diff --git a/vendor/assets/javascripts/leaflet.1.1.0.js b/vendor/assets/javascripts/leaflet.1.1.0.js new file mode 100644 index 000000000..4c4b8a63d --- /dev/null +++ b/vendor/assets/javascripts/leaflet.1.1.0.js @@ -0,0 +1,6 @@ +!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i(t.L=t.L||{})}(this,function(t){"use strict";function i(t){var i,e,n,o;for(e=1,n=arguments.length;e=0}function I(t,i,e,n){return"touchstart"===i?O(t,e,n):"touchmove"===i?W(t,e,n):"touchend"===i&&H(t,e,n),this}function A(t,i,e){var n=t["_leaflet_"+i+e];return"touchstart"===i?t.removeEventListener(ue,n,!1):"touchmove"===i?t.removeEventListener(le,n,!1):"touchend"===i&&(t.removeEventListener(ce,n,!1),t.removeEventListener(_e,n,!1)),this}function O(t,i,n){var o=e(function(t){if("mouse"!==t.pointerType&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE){if(!(de.indexOf(t.target.tagName)<0))return;$(t)}j(t,i)});t["_leaflet_touchstart"+n]=o,t.addEventListener(ue,o,!1),me||(document.documentElement.addEventListener(ue,R,!0),document.documentElement.addEventListener(le,D,!0),document.documentElement.addEventListener(ce,N,!0),document.documentElement.addEventListener(_e,N,!0),me=!0)}function R(t){pe[t.pointerId]=t,fe++}function D(t){pe[t.pointerId]&&(pe[t.pointerId]=t)}function N(t){delete pe[t.pointerId],fe--}function j(t,i){t.touches=[];for(var e in pe)t.touches.push(pe[e]);t.changedTouches=[t],i(t)}function W(t,i,e){var n=function(t){(t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&"mouse"!==t.pointerType||0!==t.buttons)&&j(t,i)};t["_leaflet_touchmove"+e]=n,t.addEventListener(le,n,!1)}function H(t,i,e){var n=function(t){j(t,i)};t["_leaflet_touchend"+e]=n,t.addEventListener(ce,n,!1),t.addEventListener(_e,n,!1)}function F(t,i,e){function n(t){var i;if(te){if(!Ai||"mouse"===t.pointerType)return;i=fe}else i=t.touches.length;if(!(i>1)){var e=Date.now(),n=e-(s||e);r=t.touches?t.touches[0]:t,a=n>0&&n<=h,s=e}}function o(t){if(a&&!r.cancelBubble){if(te){if(!Ai||"mouse"===t.pointerType)return;var e,n,o={};for(n in r)e=r[n],o[n]=e&&e.bind?e.bind(r):e;r=o}r.type="dblclick",i(r),s=null}}var s,r,a=!1,h=250;return t[ye+ge+e]=n,t[ye+ve+e]=o,t[ye+"dblclick"+e]=i,t.addEventListener(ge,n,!1),t.addEventListener(ve,o,!1),t.addEventListener("dblclick",i,!1),this}function U(t,i){var e=t[ye+ge+i],n=t[ye+ve+i],o=t[ye+"dblclick"+i];return t.removeEventListener(ge,e,!1),t.removeEventListener(ve,n,!1),Ai||t.removeEventListener("dblclick",o,!1),this}function V(t,i,e,n){if("object"==typeof i)for(var o in i)q(t,o,i[o],e);else{i=u(i);for(var s=0,r=i.length;s100&&n<500||t.target._simulatedClick&&!t._simulated?void Q(t):(zi=e,void i(t))}function rt(t){return"string"==typeof t?document.getElementById(t):t}function at(t,i){var e=t.style[i]||t.currentStyle&&t.currentStyle[i];if((!e||"auto"===e)&&document.defaultView){var n=document.defaultView.getComputedStyle(t,null);e=n?n[i]:null}return"auto"===e?null:e}function ht(t,i,e){var n=document.createElement(t);return n.className=i||"",e&&e.appendChild(n),n}function ut(t){var i=t.parentNode;i&&i.removeChild(t)}function lt(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function ct(t){var i=t.parentNode;i.lastChild!==t&&i.appendChild(t)}function _t(t){var i=t.parentNode;i.firstChild!==t&&i.insertBefore(t,i.firstChild)}function dt(t,i){if(void 0!==t.classList)return t.classList.contains(i);var e=gt(t);return e.length>0&&new RegExp("(^|\\s)"+i+"(\\s|$)").test(e)}function pt(t,i){if(void 0!==t.classList)for(var e=u(i),n=0,o=e.length;nh&&(s=r,h=a);h>e&&(i[s]=1,Bt(t,i,e,n,s),Bt(t,i,e,s,o))}function It(t,i){for(var e=[t[0]],n=1,o=0,s=t.length;ni&&(e.push(t[n]),o=n);return oi.max.x&&(e|=2),t.yi.max.y&&(e|=8),e}function Dt(t,i){var e=i.x-t.x,n=i.y-t.y;return e*e+n*n}function Nt(t,i,e,n){var o,s=i.x,r=i.y,a=e.x-s,h=e.y-r,u=a*a+h*h;return u>0&&(o=((t.x-s)*a+(t.y-r)*h)/u,o>1?(s=e.x,r=e.y):o>0&&(s+=a*o,r+=h*o)),a=t.x-s,h=t.y-r,n?a*a+h*h:new x(s,r)}function jt(t){return!mi(t[0])||"object"!=typeof t[0][0]&&"undefined"!=typeof t[0][0]}function Wt(t,i,e){var n,o,s,r,a,h,u,l,c,_=[1,4,2,8];for(o=0,u=t.length;o=this.min.x&&e.x<=this.max.x&&i.y>=this.min.y&&e.y<=this.max.y},intersects:function(t){t=b(t);var i=this.min,e=this.max,n=t.min,o=t.max,s=o.x>=i.x&&n.x<=e.x,r=o.y>=i.y&&n.y<=e.y;return s&&r},overlaps:function(t){t=b(t);var i=this.min,e=this.max,n=t.min,o=t.max,s=o.x>i.x&&n.xi.y&&n.y=n.lat&&e.lat<=o.lat&&i.lng>=n.lng&&e.lng<=o.lng},intersects:function(t){t=z(t);var i=this._southWest,e=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>=i.lat&&n.lat<=e.lat,r=o.lng>=i.lng&&n.lng<=e.lng;return s&&r},overlaps:function(t){t=z(t);var i=this._southWest,e=this._northEast,n=t.getSouthWest(),o=t.getNorthEast(),s=o.lat>i.lat&&n.lati.lng&&n.lng1,se=function(){return!!document.createElement("canvas").getContext}(),re=!(!document.createElementNS||!S("svg").createSVGRect),ae=!re&&function(){try{var t=document.createElement("div");t.innerHTML='';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(t){return!1}}(),he=(Object.freeze||Object)({ie:Bi,ielt9:Ii,edge:Ai,webkit:Oi,android:Ri,android23:Di,opera:Ni,chrome:ji,gecko:Wi,safari:Hi,phantom:Fi,opera12:Ui,win:Vi,ie3d:Gi,webkit3d:qi,gecko3d:Ki,any3d:Yi,mobile:Xi,mobileWebkit:Ji,mobileWebkit3d:$i,msPointer:Qi,pointer:te,touch:ie,mobileOpera:ee,mobileGecko:ne,retina:oe,canvas:se,svg:re,vml:ae}),ue=Qi?"MSPointerDown":"pointerdown",le=Qi?"MSPointerMove":"pointermove",ce=Qi?"MSPointerUp":"pointerup",_e=Qi?"MSPointerCancel":"pointercancel",de=["INPUT","SELECT","OPTION"],pe={},me=!1,fe=0,ge=Qi?"MSPointerDown":te?"pointerdown":"touchstart",ve=Qi?"MSPointerUp":te?"pointerup":"touchend",ye="_leaflet_",xe="_leaflet_events",we=Vi&&ji?2*window.devicePixelRatio:Wi?window.devicePixelRatio:1,Le={},Pe=(Object.freeze||Object)({on:V,off:G,stopPropagation:Y,disableScrollPropagation:X,disableClickPropagation:J,preventDefault:$,stop:Q,getMousePosition:tt,getWheelDelta:it,fakeStop:et,skipped:nt,isExternalTarget:ot,addListener:V,removeListener:G}),be=xt(["transform","WebkitTransform","OTransform","MozTransform","msTransform"]),Te=xt(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),ze="webkitTransition"===Te||"OTransition"===Te?Te+"End":"transitionend";if("onselectstart"in document)Mi=function(){V(window,"selectstart",$)},Ci=function(){G(window,"selectstart",$)};else{var Me=xt(["userSelect","WebkitUserSelect","OUserSelect","MozUserSelect","msUserSelect"]);Mi=function(){if(Me){var t=document.documentElement.style;Zi=t[Me],t[Me]="none"}},Ci=function(){Me&&(document.documentElement.style[Me]=Zi,Zi=void 0)}}var Ce,Ze,Ee=(Object.freeze||Object)({TRANSFORM:be,TRANSITION:Te,TRANSITION_END:ze,get:rt,getStyle:at,create:ht,remove:ut,empty:lt,toFront:ct,toBack:_t,hasClass:dt,addClass:pt,removeClass:mt,setClass:ft,getClass:gt,setOpacity:vt,testProp:xt,setTransform:wt,setPosition:Lt,getPosition:Pt,disableTextSelection:Mi,enableTextSelection:Ci,disableImageDrag:bt,enableImageDrag:Tt,preventOutline:zt,restoreOutline:Mt}),Se=Li.extend({run:function(t,i,e,n){this.stop(),this._el=t,this._inProgress=!0,this._duration=e||.25,this._easeOutPower=1/Math.max(n||.5,.2),this._startPos=Pt(t),this._offset=i.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=f(this._animate,this),this._step()},_step:function(t){var i=+new Date-this._startTime,e=1e3*this._duration;ithis.options.maxZoom?this.setZoom(t):this},panInsideBounds:function(t,i){this._enforcingBounds=!0;var e=this.getCenter(),n=this._limitCenter(e,this._zoom,z(t));return e.equals(n)||this.panTo(n,i),this._enforcingBounds=!1,this},invalidateSize:function(t){if(!this._loaded)return this;t=i({animate:!1,pan:!0},t===!0?{animate:!0}:t);var n=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var o=this.getSize(),s=n.divideBy(2).round(),r=o.divideBy(2).round(),a=s.subtract(r);return a.x||a.y?(t.animate&&t.pan?this.panBy(a):(t.pan&&this._rawPanBy(a),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(e(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:n,newSize:o})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){if(t=this._locateOptions=i({timeout:1e4,watch:!1},t),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var n=e(this._handleGeolocationResponse,this),o=e(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(n,o,t):navigator.geolocation.getCurrentPosition(n,o,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var i=t.code,e=t.message||(1===i?"permission denied":2===i?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:i,message:"Geolocation error: "+e+"."})},_handleGeolocationResponse:function(t){var i=t.coords.latitude,e=t.coords.longitude,n=new M(i,e),o=n.toBounds(t.coords.accuracy),s=this._locateOptions;if(s.setView){var r=this.getBoundsZoom(o);this.setView(n,s.maxZoom?Math.min(r,s.maxZoom):r)}var a={latlng:n,bounds:o,timestamp:t.timestamp};for(var h in t.coords)"number"==typeof t.coords[h]&&(a[h]=t.coords[h]);this.fire("locationfound",a)},addHandler:function(t,i){if(!i)return this;var e=this[t]=new i(this);return this._handlers.push(e),this.options[t]&&e.enable(),this},remove:function(){if(this._initEvents(!0),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=void 0,this._containerId=void 0}ut(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._clearHandlers(),this._loaded&&this.fire("unload");var t;for(t in this._layers)this._layers[t].remove();for(t in this._panes)ut(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(t,i){var e="leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),n=ht("div",e,i||this._mapPane);return t&&(this._panes[t]=n),n},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds(),i=this.unproject(t.getBottomLeft()),e=this.unproject(t.getTopRight());return new T(i,e)},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,i,e){t=z(t),e=w(e||[0,0]);var n=this.getZoom()||0,o=this.getMinZoom(),s=this.getMaxZoom(),r=t.getNorthWest(),a=t.getSouthEast(),h=this.getSize().subtract(e),u=b(this.project(a,n),this.project(r,n)).getSize(),l=Yi?this.options.zoomSnap:1,c=h.x/u.x,_=h.y/u.y,d=i?Math.max(c,_):Math.min(c,_);return n=this.getScaleZoom(d,n),l&&(n=Math.round(n/(l/100))*(l/100),n=i?Math.ceil(n/l)*l:Math.floor(n/l)*l),Math.max(o,Math.min(s,n))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new x(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,i){var e=this._getTopLeftPoint(t,i);return new P(e,e.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(void 0===t?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,i){var e=this.options.crs;return i=void 0===i?this._zoom:i,e.scale(t)/e.scale(i)},getScaleZoom:function(t,i){var e=this.options.crs;i=void 0===i?this._zoom:i;var n=e.zoom(t*e.scale(i));return isNaN(n)?1/0:n},project:function(t,i){return i=void 0===i?this._zoom:i,this.options.crs.latLngToPoint(C(t),i)},unproject:function(t,i){return i=void 0===i?this._zoom:i,this.options.crs.pointToLatLng(w(t),i)},layerPointToLatLng:function(t){var i=w(t).add(this.getPixelOrigin());return this.unproject(i)},latLngToLayerPoint:function(t){var i=this.project(C(t))._round();return i._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(C(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(z(t))},distance:function(t,i){return this.options.crs.distance(C(t),C(i))},containerPointToLayerPoint:function(t){return w(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return w(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var i=this.containerPointToLayerPoint(w(t));return this.layerPointToLatLng(i)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(C(t)))},mouseEventToContainerPoint:function(t){return tt(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var i=this._container=rt(t);if(!i)throw new Error("Map container not found.");if(i._leaflet_id)throw new Error("Map container is already initialized.");V(i,"scroll",this._onScroll,this),this._containerId=n(i)},_initLayout:function(){var t=this._container;this._fadeAnimated=this.options.fadeAnimation&&Yi,pt(t,"leaflet-container"+(ie?" leaflet-touch":"")+(oe?" leaflet-retina":"")+(Ii?" leaflet-oldie":"")+(Hi?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var i=at(t,"position");"absolute"!==i&&"relative"!==i&&"fixed"!==i&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Lt(this._mapPane,new x(0,0)),this.createPane("tilePane"),this.createPane("shadowPane"),this.createPane("overlayPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(pt(t.markerPane,"leaflet-zoom-hide"),pt(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,i){Lt(this._mapPane,new x(0,0));var e=!this._loaded;this._loaded=!0,i=this._limitZoom(i),this.fire("viewprereset");var n=this._zoom!==i;this._moveStart(n)._move(t,i)._moveEnd(n),this.fire("viewreset"),e&&this.fire("load")},_moveStart:function(t){return t&&this.fire("zoomstart"),this.fire("movestart")},_move:function(t,i,e){void 0===i&&(i=this._zoom);var n=this._zoom!==i;return this._zoom=i,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),(n||e&&e.pinch)&&this.fire("zoom",e),this.fire("move",e)},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return g(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){Lt(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(t){this._targets={},this._targets[n(this._container)]=this;var i=t?G:V;i(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress",this._handleDOMEvent,this),this.options.trackResize&&i(window,"resize",this._onResize,this),Yi&&this.options.transform3DLimit&&(t?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){g(this._resizeRequest),this._resizeRequest=f(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,i){for(var e,o=[],s="mouseout"===i||"mouseover"===i,r=t.target||t.srcElement,a=!1;r;){if(e=this._targets[n(r)],e&&("click"===i||"preclick"===i)&&!t._simulated&&this._draggableMoved(e)){a=!0;break}if(e&&e.listens(i,!0)){if(s&&!ot(r,t))break;if(o.push(e),s)break}if(r===this._container)break;r=r.parentNode}return o.length||a||s||!ot(r,t)||(o=[this]),o},_handleDOMEvent:function(t){if(this._loaded&&!nt(t)){var i=t.type;"mousedown"!==i&&"keypress"!==i||zt(t.target||t.srcElement),this._fireDOMEvent(t,i)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,e,n){if("click"===t.type){var o=i({},t);o.type="preclick",this._fireDOMEvent(o,o.type,n)}if(!t._stopped&&(n=(n||[]).concat(this._findEventTargets(t,e)),n.length)){var s=n[0];"contextmenu"===e&&s.listens(e,!0)&&$(t);var r={originalEvent:t};if("keypress"!==t.type){var a=s.options&&"icon"in s.options;r.containerPoint=a?this.latLngToContainerPoint(s.getLatLng()):this.mouseEventToContainerPoint(t),r.layerPoint=this.containerPointToLayerPoint(r.containerPoint),r.latlng=a?s.getLatLng():this.layerPointToLatLng(r.layerPoint)}for(var h=0;h0?Math.round(t-i)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(i))},_limitZoom:function(t){var i=this.getMinZoom(),e=this.getMaxZoom(),n=Yi?this.options.zoomSnap:1;return n&&(t=Math.round(t/n)*n),Math.max(i,Math.min(e,t))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){mt(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,i){var e=this._getCenterOffset(t)._floor();return!((i&&i.animate)!==!0&&!this.getSize().contains(e))&&(this.panBy(e,i),!0)},_createAnimProxy:function(){var t=this._proxy=ht("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(t),this.on("zoomanim",function(t){var i=be,e=this._proxy.style[i];wt(this._proxy,this.project(t.center,t.zoom),this.getZoomScale(t.zoom,1)),e===this._proxy.style[i]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",function(){var t=this.getCenter(),i=this.getZoom();wt(this._proxy,this.project(t,i),this.getZoomScale(i,1))},this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){ut(this._proxy),delete this._proxy},_catchTransitionEnd:function(t){this._animatingZoom&&t.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,i,e){if(this._animatingZoom)return!0;if(e=e||{},!this._zoomAnimated||e.animate===!1||this._nothingToAnimate()||Math.abs(i-this._zoom)>this.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(i),o=this._getCenterOffset(t)._divideBy(1-1/n);return!(e.animate!==!0&&!this.getSize().contains(o))&&(f(function(){this._moveStart(!0)._animateZoom(t,i,!0)},this),!0)},_animateZoom:function(t,i,n,o){n&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=i,pt(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:i,noUpdate:o}),setTimeout(e(this._onZoomTransitionEnd,this),250)},_onZoomTransitionEnd:function(){this._animatingZoom&&(mt(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom),f(function(){this._moveEnd(!0)},this))}}),Be=v.extend({options:{position:"topright"},initialize:function(t){l(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var i=this._map;return i&&i.removeControl(this),this.options.position=t,i&&i.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var i=this._container=this.onAdd(t),e=this.getPosition(),n=t._controlCorners[e];return pt(i,"leaflet-control"),e.indexOf("bottom")!==-1?n.insertBefore(i,n.firstChild):n.appendChild(i),this},remove:function(){return this._map?(ut(this._container),this.onRemove&&this.onRemove(this._map),this._map=null,this):this},_refocusOnMap:function(t){this._map&&t&&t.screenX>0&&t.screenY>0&&this._map.getContainer().focus()}}),Ie=function(t){return new Be(t)};ke.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.remove(),this},_initControlPos:function(){function t(t,o){var s=e+t+" "+e+o;i[t+o]=ht("div",s,n)}var i=this._controlCorners={},e="leaflet-",n=this._controlContainer=ht("div",e+"control-container",this._container);t("top","left"),t("top","right"),t("bottom","left"),t("bottom","right")},_clearControlPos:function(){for(var t in this._controlCorners)ut(this._controlCorners[t]);ut(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Ae=Be.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(t,i,e,n){return e1,this._baseLayersList.style.display=t?"":"none"),this._separator.style.display=i&&t?"":"none",this},_onLayerChange:function(t){this._handlingClick||this._update();var i=this._getLayer(n(t.target)),e=i.overlay?"add"===t.type?"overlayadd":"overlayremove":"add"===t.type?"baselayerchange":null;e&&this._map.fire(e,i)},_createRadioElement:function(t,i){var e='",n=document.createElement("div");return n.innerHTML=e,n.firstChild},_addItem:function(t){var i,e=document.createElement("label"),o=this._map.hasLayer(t.layer);t.overlay?(i=document.createElement("input"),i.type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=o):i=this._createRadioElement("leaflet-base-layers",o),this._layerControlInputs.push(i),i.layerId=n(t.layer),V(i,"click",this._onInputClick,this);var s=document.createElement("span");s.innerHTML=" "+t.name;var r=document.createElement("div");e.appendChild(r),r.appendChild(i),r.appendChild(s);var a=t.overlay?this._overlaysList:this._baseLayersList;return a.appendChild(e),this._checkDisabledLayers(),e},_onInputClick:function(){var t,i,e,n=this._layerControlInputs,o=[],s=[];this._handlingClick=!0;for(var r=n.length-1;r>=0;r--)t=n[r],i=this._getLayer(t.layerId).layer,e=this._map.hasLayer(i),t.checked&&!e?o.push(i):!t.checked&&e&&s.push(i);for(r=0;r=0;o--)t=e[o],i=this._getLayer(t.layerId).layer,t.disabled=void 0!==i.options.minZoom&&ni.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expand:function(){return this.expand()},_collapse:function(){return this.collapse()}}),Oe=function(t,i,e){return new Ae(t,i,e)},Re=Be.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"−",zoomOutTitle:"Zoom out"},onAdd:function(t){var i="leaflet-control-zoom",e=ht("div",i+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,i+"-in",e,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,i+"-out",e,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),e},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,i,e,n,o){var s=ht("a",e,n);return s.innerHTML=t,s.href="#",s.title=i,s.setAttribute("role","button"),s.setAttribute("aria-label",i),J(s),V(s,"click",Q),V(s,"click",o,this),V(s,"click",this._refocusOnMap,this),s},_updateDisabled:function(){var t=this._map,i="leaflet-disabled";mt(this._zoomInButton,i),mt(this._zoomOutButton,i),(this._disabled||t._zoom===t.getMinZoom())&&pt(this._zoomOutButton,i),(this._disabled||t._zoom===t.getMaxZoom())&&pt(this._zoomInButton,i)}});ke.mergeOptions({zoomControl:!0}),ke.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new Re,this.addControl(this.zoomControl))});var De=function(t){return new Re(t)},Ne=Be.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var i="leaflet-control-scale",e=ht("div",i),n=this.options;return this._addScales(n,i+"-line",e),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),e},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,i,e){t.metric&&(this._mScale=ht("div",i,e)),t.imperial&&(this._iScale=ht("div",i,e))},_update:function(){var t=this._map,i=t.getSize().y/2,e=t.distance(t.containerPointToLatLng([0,i]),t.containerPointToLatLng([this.options.maxWidth,i]));this._updateScales(e)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var i=this._getRoundNum(t),e=i<1e3?i+" m":i/1e3+" km";this._updateScale(this._mScale,e,i/t)},_updateImperial:function(t){var i,e,n,o=3.2808399*t;o>5280?(i=o/5280,e=this._getRoundNum(i),this._updateScale(this._iScale,e+" mi",e/i)):(n=this._getRoundNum(o),this._updateScale(this._iScale,n+" ft",n/o))},_updateScale:function(t,i,e){t.style.width=Math.round(this.options.maxWidth*e)+"px",t.innerHTML=i},_getRoundNum:function(t){var i=Math.pow(10,(Math.floor(t)+"").length-1),e=t/i;return e=e>=10?10:e>=5?5:e>=3?3:e>=2?2:1,i*e}}),je=function(t){return new Ne(t)},We=Be.extend({options:{position:"bottomright",prefix:'Leaflet'},initialize:function(t){l(this,t),this._attributions={}},onAdd:function(t){t.attributionControl=this,this._container=ht("div","leaflet-control-attribution"),J(this._container);for(var i in t._layers)t._layers[i].getAttribution&&this.addAttribution(t._layers[i].getAttribution());return this._update(),this._container},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t?(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update(),this):this},removeAttribution:function(t){return t?(this._attributions[t]&&(this._attributions[t]--,this._update()),this):this},_update:function(){if(this._map){var t=[];for(var i in this._attributions)this._attributions[i]&&t.push(i);var e=[];this.options.prefix&&e.push(this.options.prefix),t.length&&e.push(t.join(", ")),this._container.innerHTML=e.join(" | ")}}});ke.mergeOptions({attributionControl:!0}),ke.addInitHook(function(){this.options.attributionControl&&(new We).addTo(this)});var He=function(t){return new We(t)};Be.Layers=Ae,Be.Zoom=Re,Be.Scale=Ne,Be.Attribution=We,Ie.layers=Oe,Ie.zoom=De,Ie.scale=je,Ie.attribution=He;var Fe,Ue=v.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}}),Ve={Events:wi},Ge=!1,qe=ie?"touchstart mousedown":"mousedown",Ke={mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},Ye={mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"},Xe=Li.extend({options:{clickTolerance:3},initialize:function(t,i,e,n){l(this,n),this._element=t,this._dragStartTarget=i||t,this._preventOutline=e},enable:function(){this._enabled||(V(this._dragStartTarget,qe,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(L.Draggable._dragging===this&&this.finishDrag(),G(this._dragStartTarget,qe,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){if(!t._simulated&&this._enabled&&(this._moved=!1,!dt(this._element,"leaflet-zoom-anim")&&!(Ge||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||(Ge=this,this._preventOutline&&zt(this._element),bt(),Mi(),this._moving)))){this.fire("down");var i=t.touches?t.touches[0]:t;this._startPoint=new x(i.clientX,i.clientY),V(document,Ye[t.type],this._onMove,this),V(document,Ke[t.type],this._onUp,this)}},_onMove:function(t){if(!t._simulated&&this._enabled){if(t.touches&&t.touches.length>1)return void(this._moved=!0);var i=t.touches&&1===t.touches.length?t.touches[0]:t,e=new x(i.clientX,i.clientY),n=e.subtract(this._startPoint);(n.x||n.y)&&(Math.abs(n.x)+Math.abs(n.y)1e-7;h++)i=s*Math.sin(a),i=Math.pow((1-i)/(1+i),s/2),u=Math.PI/2-2*Math.atan(r*i)-a,a+=u;return new M(a*e,t.x*e/n)}},en=(Object.freeze||Object)({LonLat:Qe,Mercator:tn,SphericalMercator:Ti}),nn=i({},bi,{code:"EPSG:3395",projection:tn,transformation:function(){var t=.5/(Math.PI*tn.R);return E(t,.5,-t,.5)}()}),on=i({},bi,{code:"EPSG:4326",projection:Qe,transformation:E(1/180,1,-1/180,.5)}),sn=i({},Pi,{projection:Qe,transformation:E(1,0,-1,0),scale:function(t){return Math.pow(2,t)},zoom:function(t){return Math.log(t)/Math.LN2},distance:function(t,i){var e=i.lng-t.lng,n=i.lat-t.lat;return Math.sqrt(e*e+n*n)},infinite:!0});Pi.Earth=bi,Pi.EPSG3395=nn,Pi.EPSG3857=Ei,Pi.EPSG900913=Si,Pi.EPSG4326=on,Pi.Simple=sn;var rn=Li.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(t){return t.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(t){return t&&t.removeLayer(this),this},getPane:function(t){return this._map.getPane(t?this.options[t]||t:this.options.pane)},addInteractiveTarget:function(t){ +return this._map._targets[n(t)]=this,this},removeInteractiveTarget:function(t){return delete this._map._targets[n(t)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(t){var i=t.target;if(i.hasLayer(this)){if(this._map=i,this._zoomAnimated=i._zoomAnimated,this.getEvents){var e=this.getEvents();i.on(e,this),this.once("remove",function(){i.off(e,this)},this)}this.onAdd(i),this.getAttribution&&i.attributionControl&&i.attributionControl.addAttribution(this.getAttribution()),this.fire("add"),i.fire("layeradd",{layer:this})}}});ke.include({addLayer:function(t){var i=n(t);return this._layers[i]?this:(this._layers[i]=t,t._mapToAdd=this,t.beforeAdd&&t.beforeAdd(this),this.whenReady(t._layerAdd,t),this)},removeLayer:function(t){var i=n(t);return this._layers[i]?(this._loaded&&t.onRemove(this),t.getAttribution&&this.attributionControl&&this.attributionControl.removeAttribution(t.getAttribution()),delete this._layers[i],this._loaded&&(this.fire("layerremove",{layer:t}),t.fire("remove")),t._map=t._mapToAdd=null,this):this},hasLayer:function(t){return!!t&&n(t)in this._layers},eachLayer:function(t,i){for(var e in this._layers)t.call(i,this._layers[e]);return this},_addLayers:function(t){t=t?mi(t)?t:[t]:[];for(var i=0,e=t.length;ithis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()i)return r=(n-i)/e,this._map.layerPointToLatLng([s.x-r*(s.x-o.x),s.y-r*(s.y-o.y)])},getBounds:function(){return this._bounds},addLatLng:function(t,i){return i=i||this._defaultShape(),t=C(t),i.push(t),this._bounds.extend(t),this.redraw()},_setLatLngs:function(t){this._bounds=new T,this._latlngs=this._convertLatLngs(t)},_defaultShape:function(){return jt(this._latlngs)?this._latlngs:this._latlngs[0]},_convertLatLngs:function(t){for(var i=[],e=jt(t),n=0,o=t.length;n=2&&i[0]instanceof M&&i[0].equals(i[e-1])&&i.pop(),i},_setLatLngs:function(t){vn.prototype._setLatLngs.call(this,t),jt(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return jt(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var t=this._renderer._bounds,i=this.options.weight,e=new x(i,i);if(t=new P(t.min.subtract(e),t.max.add(e)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(t)){if(this.options.noClip)return void(this._parts=this._rings);for(var n,o=0,s=this._rings.length;ot.y!=n.y>t.y&&t.x<(n.x-e.x)*(t.y-e.y)/(n.y-e.y)+e.x&&(u=!u);return u||vn.prototype._containsPoint.call(this,t,!0)}}),xn=un.extend({initialize:function(t,i){l(this,i),this._layers={},t&&this.addData(t)},addData:function(t){var i,e,n,o=mi(t)?t:t.features;if(o){for(i=0,e=o.length;io?(i.height=o+"px",pt(t,s)):mt(t,s),this._containerWidth=this._container.offsetWidth},_animateZoom:function(t){var i=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),e=this._getAnchor();Lt(this._container,i.add(e))},_adjustPan:function(){if(!(!this.options.autoPan||this._map._panAnim&&this._map._panAnim._inProgress)){var t=this._map,i=parseInt(at(this._container,"marginBottom"),10)||0,e=this._container.offsetHeight+i,n=this._containerWidth,o=new x(this._containerLeft,-e-this._containerBottom);o._add(Pt(this._container));var s=t.layerPointToContainerPoint(o),r=w(this.options.autoPanPadding),a=w(this.options.autoPanPaddingTopLeft||r),h=w(this.options.autoPanPaddingBottomRight||r),u=t.getSize(),l=0,c=0;s.x+n+h.x>u.x&&(l=s.x+n-u.x+h.x),s.x-l-a.x<0&&(l=s.x-a.x),s.y+e+h.y>u.y&&(c=s.y+e-u.y+h.y),s.y-c-a.y<0&&(c=s.y-a.y),(l||c)&&t.fire("autopanstart").panBy([l,c])}},_onCloseButtonClick:function(t){this._close(),Q(t)},_getAnchor:function(){return w(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Cn=function(t,i){return new Mn(t,i)};ke.mergeOptions({closePopupOnClick:!0}),ke.include({openPopup:function(t,i,e){return t instanceof Mn||(t=new Mn(e).setContent(t)),i&&t.setLatLng(i),this.hasLayer(t)?this:(this._popup&&this._popup.options.autoClose&&this.closePopup(),this._popup=t,this.addLayer(t))},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&this.removeLayer(t),this}}),rn.include({bindPopup:function(t,i){return t instanceof Mn?(l(t,i),this._popup=t,t._source=this):(this._popup&&!i||(this._popup=new Mn(i,this)),this._popup.setContent(t)),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t,i){if(t instanceof rn||(i=t,t=this),t instanceof un)for(var e in this._layers){t=this._layers[e];break}return i||(i=t.getCenter?t.getCenter():t.getLatLng()),this._popup&&this._map&&(this._popup._source=t,this._popup.update(),this._map.openPopup(this._popup,i)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(t){return this._popup&&(this._popup._map?this.closePopup():this.openPopup(t)),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var i=t.layer||t.target;if(this._popup&&this._map)return Q(t),i instanceof mn?void this.openPopup(t.layer||t.target,t.latlng):void(this._map.hasLayer(this._popup)&&this._popup._source===i?this.closePopup():this.openPopup(i,t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var Zn=zn.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,interactive:!1,opacity:.9},onAdd:function(t){zn.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&this._source.fire("tooltipopen",{tooltip:this},!0)},onRemove:function(t){zn.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&this._source.fire("tooltipclose",{tooltip:this},!0)},getEvents:function(){var t=zn.prototype.getEvents.call(this);return ie&&!this.options.permanent&&(t.preclick=this._close),t},_close:function(){this._map&&this._map.closeTooltip(this)},_initLayout:function(){var t="leaflet-tooltip",i=t+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=ht("div",i)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var i=this._map,e=this._container,n=i.latLngToContainerPoint(i.getCenter()),o=i.layerPointToContainerPoint(t),s=this.options.direction,r=e.offsetWidth,a=e.offsetHeight,h=w(this.options.offset),u=this._getAnchor();"top"===s?t=t.add(w(-r/2+h.x,-a+h.y+u.y,!0)):"bottom"===s?t=t.subtract(w(r/2-h.x,-h.y,!0)):"center"===s?t=t.subtract(w(r/2+h.x,a/2-u.y+h.y,!0)):"right"===s||"auto"===s&&o.xthis.options.maxZoom||en&&this._retainParent(o,s,r,n))},_retainChildren:function(t,i,e,n){for(var o=2*t;o<2*t+2;o++)for(var s=2*i;s<2*i+2;s++){var r=new x(o,s);r.z=e+1;var a=this._tileCoordsToKey(r),h=this._tiles[a];h&&h.active?h.retain=!0:(h&&h.loaded&&(h.retain=!0),e+1this.options.maxZoom||void 0!==this.options.minZoom&&o1)return void this._setView(t,e);for(var c=o.min.y;c<=o.max.y;c++)for(var _=o.min.x;_<=o.max.x;_++){var d=new x(_,c);d.z=this._tileZoom,this._isValidTile(d)&&(this._tiles[this._tileCoordsToKey(d)]||r.push(d))}if(r.sort(function(t,i){return t.distanceTo(s)-i.distanceTo(s)}),0!==r.length){this._loading||(this._loading=!0,this.fire("loading"));var p=document.createDocumentFragment();for(_=0;_e.max.x)||!i.wrapLat&&(t.ye.max.y))return!1}if(!this.options.bounds)return!0;var n=this._tileCoordsToBounds(t);return z(this.options.bounds).overlaps(n)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToBounds:function(t){var i=this._map,e=this.getTileSize(),n=t.scaleBy(e),o=n.add(e),s=i.unproject(n,t.z),r=i.unproject(o,t.z),a=new T(s,r);return this.options.noWrap||i.wrapLatLngBounds(a),a},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var i=t.split(":"),e=new x(+i[0],+i[1]);return e.z=+i[2],e},_removeTile:function(t){var i=this._tiles[t];i&&(ut(i.el),delete this._tiles[t],this.fire("tileunload",{tile:i.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){pt(t,"leaflet-tile");var i=this.getTileSize();t.style.width=i.x+"px",t.style.height=i.y+"px",t.onselectstart=r,t.onmousemove=r,Ii&&this.options.opacity<1&&vt(t,this.options.opacity),Ri&&!Di&&(t.style.WebkitBackfaceVisibility="hidden")},_addTile:function(t,i){var n=this._getTilePos(t),o=this._tileCoordsToKey(t),s=this.createTile(this._wrapCoords(t),e(this._tileReady,this,t));this._initTile(s),this.createTile.length<2&&f(e(this._tileReady,this,t,null,s)),Lt(s,n),this._tiles[o]={el:s,coords:t,current:!0},i.appendChild(s),this.fire("tileloadstart",{tile:s,coords:t})},_tileReady:function(t,i,n){if(this._map){i&&this.fire("tileerror",{error:i,tile:n,coords:t});var o=this._tileCoordsToKey(t);n=this._tiles[o],n&&(n.loaded=+new Date,this._map._fadeAnimated?(vt(n.el,0),g(this._fadeFrame),this._fadeFrame=f(this._updateOpacity,this)):(n.active=!0,this._pruneTiles()),i||(pt(n.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:n.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Ii||!this._map._fadeAnimated?f(this._pruneTiles,this):setTimeout(e(this._pruneTiles,this),250)))}},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var i=new x(this._wrapX?s(t.x,this._wrapX):t.x,this._wrapY?s(t.y,this._wrapY):t.y);return i.z=t.z,i},_pxBoundsToTileRange:function(t){var i=this.getTileSize();return new P(t.min.unscaleBy(i).floor(),t.max.unscaleBy(i).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}}),Bn=kn.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1},initialize:function(t,i){this._url=t,i=l(this,i),i.detectRetina&&oe&&i.maxZoom>0&&(i.tileSize=Math.floor(i.tileSize/2),i.zoomReverse?(i.zoomOffset--,i.minZoom++):(i.zoomOffset++,i.maxZoom--),i.minZoom=Math.max(0,i.minZoom)),"string"==typeof i.subdomains&&(i.subdomains=i.subdomains.split("")),Ri||this.on("tileunload",this._onTileRemove)},setUrl:function(t,i){return this._url=t,i||this.redraw(),this},createTile:function(t,i){var n=document.createElement("img");return V(n,"load",e(this._tileOnLoad,this,i,n)),V(n,"error",e(this._tileOnError,this,i,n)),this.options.crossOrigin&&(n.crossOrigin=""),n.alt="",n.setAttribute("role","presentation"),n.src=this.getTileUrl(t),n},getTileUrl:function(t){var e={r:oe?"@2x":"",s:this._getSubdomain(t),x:t.x,y:t.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var n=this._globalTileRange.max.y-t.y;this.options.tms&&(e.y=n),e["-y"]=n}return _(this._url,i(e,this.options))},_tileOnLoad:function(t,i){Ii?setTimeout(e(t,this,null,i),0):t(null,i)},_tileOnError:function(t,i,e){var n=this.options.errorTileUrl;n&&i.src!==n&&(i.src=n),t(e,i)},_onTileRemove:function(t){t.tile.onload=null},_getZoomForUrl:function(){var t=this._tileZoom,i=this.options.maxZoom,e=this.options.zoomReverse,n=this.options.zoomOffset;return e&&(t=i-t),t+n},_getSubdomain:function(t){var i=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[i]},_abortLoading:function(){var t,i;for(t in this._tiles)this._tiles[t].coords.z!==this._tileZoom&&(i=this._tiles[t].el,i.onload=r,i.onerror=r,i.complete||(i.src=fi,ut(i)))}}),In=Bn.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(t,e){this._url=t;var n=i({},this.defaultWmsParams);for(var o in e)o in this.options||(n[o]=e[o]);e=l(this,e),n.width=n.height=e.tileSize*(e.detectRetina&&oe?2:1),this.wmsParams=n},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var i=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[i]=this._crs.code,Bn.prototype.onAdd.call(this,t)},getTileUrl:function(t){var i=this._tileCoordsToBounds(t),e=this._crs.project(i.getNorthWest()),n=this._crs.project(i.getSouthEast()),o=(this._wmsVersion>=1.3&&this._crs===on?[n.y,e.x,e.y,n.x]:[e.x,n.y,n.x,e.y]).join(","),s=Bn.prototype.getTileUrl.call(this,t);return s+c(this.wmsParams,s,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+o},setParams:function(t,e){return i(this.wmsParams,t),e||this.redraw(),this}});Bn.WMS=In,si.wms=ri;var An=rn.extend({options:{padding:.1},initialize:function(t){l(this,t),n(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),this._zoomAnimated&&pt(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var t={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(t.zoomanim=this._onAnimZoom),t},_onAnimZoom:function(t){this._updateTransform(t.center,t.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(t,i){var e=this._map.getZoomScale(i,this._zoom),n=Pt(this._container),o=this._map.getSize().multiplyBy(.5+this.options.padding),s=this._map.project(this._center,i),r=this._map.project(t,i),a=r.subtract(s),h=o.multiplyBy(-e).add(n).add(o).subtract(a);Yi?wt(this._container,h,e):Lt(this._container,h)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var t in this._layers)this._layers[t]._reset()},_onZoomEnd:function(){for(var t in this._layers)this._layers[t]._project()},_updatePaths:function(){for(var t in this._layers)this._layers[t]._update()},_update:function(){var t=this.options.padding,i=this._map.getSize(),e=this._map.containerPointToLayerPoint(i.multiplyBy(-t)).round();this._bounds=new P(e,e.add(i.multiplyBy(1+2*t)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),On=An.extend({getEvents:function(){var t=An.prototype.getEvents.call(this);return t.viewprereset=this._onViewPreReset,t},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){An.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var t=this._container=document.createElement("canvas");V(t,"mousemove",o(this._onMouseMove,32,this),this),V(t,"click dblclick mousedown mouseup contextmenu",this._onClick,this),V(t,"mouseout",this._handleMouseOut,this),this._ctx=t.getContext("2d")},_destroyContainer:function(){delete this._ctx,ut(this._container),G(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var t;this._redrawBounds=null;for(var i in this._layers)t=this._layers[i],t._update();this._redraw()}},_update:function(){if(!this._map._animatingZoom||!this._bounds){this._drawnLayers={},An.prototype._update.call(this);var t=this._bounds,i=this._container,e=t.getSize(),n=oe?2:1;Lt(i,t.min),i.width=n*e.x,i.height=n*e.y,i.style.width=e.x+"px",i.style.height=e.y+"px",oe&&this._ctx.scale(2,2),this._ctx.translate(-t.min.x,-t.min.y),this.fire("update")}},_reset:function(){An.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(t){this._updateDashArray(t),this._layers[n(t)]=t;var i=t._order={layer:t,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=i),this._drawLast=i,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(t){this._requestRedraw(t)},_removePath:function(t){var i=t._order,e=i.next,n=i.prev;e?e.prev=n:this._drawLast=n,n?n.next=e:this._drawFirst=e,delete t._order,delete this._layers[L.stamp(t)],this._requestRedraw(t)},_updatePath:function(t){this._extendRedrawBounds(t),t._project(),t._update(),this._requestRedraw(t)},_updateStyle:function(t){this._updateDashArray(t),this._requestRedraw(t)},_updateDashArray:function(t){if(t.options.dashArray){var i,e=t.options.dashArray.split(","),n=[];for(i=0;i')}}catch(t){return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),Dn={_initContainer:function(){this._container=ht("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(An.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var i=t._container=Rn("shape");pt(i,"leaflet-vml-shape "+(this.options.className||"")),i.coordsize="1 1",t._path=Rn("path"),i.appendChild(t._path),this._updateStyle(t),this._layers[n(t)]=t},_addPath:function(t){var i=t._container;this._container.appendChild(i),t.options.interactive&&t.addInteractiveTarget(i)},_removePath:function(t){var i=t._container;ut(i),t.removeInteractiveTarget(i),delete this._layers[n(t)]},_updateStyle:function(t){var i=t._stroke,e=t._fill,n=t.options,o=t._container;o.stroked=!!n.stroke,o.filled=!!n.fill,n.stroke?(i||(i=t._stroke=Rn("stroke")),o.appendChild(i),i.weight=n.weight+"px",i.color=n.color,i.opacity=n.opacity,n.dashArray?i.dashStyle=mi(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):i.dashStyle="",i.endcap=n.lineCap.replace("butt","flat"),i.joinstyle=n.lineJoin):i&&(o.removeChild(i),t._stroke=null),n.fill?(e||(e=t._fill=Rn("fill")),o.appendChild(e),e.color=n.fillColor||n.color,e.opacity=n.fillOpacity):e&&(o.removeChild(e),t._fill=null)},_updateCircle:function(t){var i=t._point.round(),e=Math.round(t._radius),n=Math.round(t._radiusY||e);this._setPath(t,t._empty()?"M0 0":"AL "+i.x+","+i.y+" "+e+","+n+" 0,23592600")},_setPath:function(t,i){t._path.v=i},_bringToFront:function(t){ct(t._container)},_bringToBack:function(t){_t(t._container)}},Nn=ae?Rn:S,jn=An.extend({getEvents:function(){var t=An.prototype.getEvents.call(this);return t.zoomstart=this._onZoomStart,t},_initContainer:function(){this._container=Nn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=Nn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){ut(this._container),G(this._container),delete this._container,delete this._rootGroup},_onZoomStart:function(){this._update()},_update:function(){if(!this._map._animatingZoom||!this._bounds){An.prototype._update.call(this);var t=this._bounds,i=t.getSize(),e=this._container;this._svgSize&&this._svgSize.equals(i)||(this._svgSize=i,e.setAttribute("width",i.x),e.setAttribute("height",i.y)),Lt(e,t.min),e.setAttribute("viewBox",[t.min.x,t.min.y,i.x,i.y].join(" ")),this.fire("update")}},_initPath:function(t){var i=t._path=Nn("path");t.options.className&&pt(i,t.options.className),t.options.interactive&&pt(i,"leaflet-interactive"),this._updateStyle(t),this._layers[n(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){ut(t._path),t.removeInteractiveTarget(t._path),delete this._layers[n(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var i=t._path,e=t.options;i&&(e.stroke?(i.setAttribute("stroke",e.color),i.setAttribute("stroke-opacity",e.opacity),i.setAttribute("stroke-width",e.weight),i.setAttribute("stroke-linecap",e.lineCap),i.setAttribute("stroke-linejoin",e.lineJoin),e.dashArray?i.setAttribute("stroke-dasharray",e.dashArray):i.removeAttribute("stroke-dasharray"),e.dashOffset?i.setAttribute("stroke-dashoffset",e.dashOffset):i.removeAttribute("stroke-dashoffset")):i.setAttribute("stroke","none"),e.fill?(i.setAttribute("fill",e.fillColor||e.color),i.setAttribute("fill-opacity",e.fillOpacity),i.setAttribute("fill-rule",e.fillRule||"evenodd")):i.setAttribute("fill","none"))},_updatePoly:function(t,i){this._setPath(t,k(t._parts,i))},_updateCircle:function(t){var i=t._point,e=t._radius,n=t._radiusY||e,o="a"+e+","+n+" 0 1,0 ",s=t._empty()?"M0 0":"M"+(i.x-e)+","+i.y+o+2*e+",0 "+o+2*-e+",0 ";this._setPath(t,s)},_setPath:function(t,i){t._path.setAttribute("d",i)},_bringToFront:function(t){ct(t._path)},_bringToBack:function(t){_t(t._path)}});ae&&jn.include(Dn),ke.include({getRenderer:function(t){var i=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer;return i||(i=this._renderer=this.options.preferCanvas&&ai()||hi()),this.hasLayer(i)||this.addLayer(i),i},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var i=this._paneRenderers[t];return void 0===i&&(i=jn&&hi({pane:t})||On&&ai({pane:t}),this._paneRenderers[t]=i),i}});var Wn=yn.extend({initialize:function(t,i){yn.prototype.initialize.call(this,this._boundsToLatLngs(t),i)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return t=z(t),[t.getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});jn.create=Nn,jn.pointsToPath=k,xn.geometryToLayer=Kt,xn.coordsToLatLng=Yt,xn.coordsToLatLngs=Xt,xn.latLngToCoords=Jt,xn.latLngsToCoords=$t,xn.getFeature=Qt,xn.asFeature=ti,ke.mergeOptions({boxZoom:!0});var Hn=Ue.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){V(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){G(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){ut(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){return!(!t.shiftKey||1!==t.which&&1!==t.button)&&(this._clearDeferredResetState(),this._resetState(),Mi(),bt(),this._startPoint=this._map.mouseEventToContainerPoint(t),void V(document,{contextmenu:Q,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this))},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=ht("div","leaflet-zoom-box",this._container),pt(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var i=new P(this._point,this._startPoint),e=i.getSize();Lt(this._box,i.min),this._box.style.width=e.x+"px",this._box.style.height=e.y+"px"},_finish:function(){this._moved&&(ut(this._box),mt(this._container,"leaflet-crosshair")),Ci(),Tt(),G(document,{contextmenu:Q,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if((1===t.which||1===t.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(e(this._resetState,this),0);var i=new T(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(i).fire("boxzoomend",{boxZoomBounds:i})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}});ke.addInitHook("addHandler","boxZoom",Hn),ke.mergeOptions({doubleClickZoom:!0});var Fn=Ue.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var i=this._map,e=i.getZoom(),n=i.options.zoomDelta,o=t.originalEvent.shiftKey?e-n:e+n;"center"===i.options.doubleClickZoom?i.setZoom(o):i.setZoomAround(t.containerPoint,o)}});ke.addInitHook("addHandler","doubleClickZoom",Fn),ke.mergeOptions({dragging:!0,inertia:!Di,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Un=Ue.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new Xe(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}pt(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){mt(this._map._container,"leaflet-grab"),mt(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t=this._map;if(t._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var i=z(this._map.options.maxBounds);this._offsetLimit=b(this._map.latLngToContainerPoint(i.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(i.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){if(this._map.options.inertia){var i=this._lastTime=+new Date,e=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(e),this._times.push(i),i-this._times[0]>50&&(this._positions.shift(),this._times.shift())}this._map.fire("move",t).fire("drag",t)},_onZoomEnd:function(){var t=this._map.getSize().divideBy(2),i=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=i.subtract(t).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(t,i){return t-(t-i)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var t=this._draggable._newPos.subtract(this._draggable._startPos),i=this._offsetLimit;t.xi.max.x&&(t.x=this._viscousLimit(t.x,i.max.x)),t.y>i.max.y&&(t.y=this._viscousLimit(t.y,i.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,i=Math.round(t/2),e=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-i+e)%t+i-e,s=(n+i+e)%t-i-e,r=Math.abs(o+e)0?s:-s))-i;this._delta=0,this._startTime=null,r&&("center"===t.options.scrollWheelZoom?t.setZoom(i+r):t.setZoomAround(this._lastMousePos,i+r))}});ke.addInitHook("addHandler","scrollWheelZoom",Gn),ke.mergeOptions({tap:!0,tapTolerance:15});var qn=Ue.extend({addHooks:function(){V(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){G(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(t.touches){if($(t),this._fireClick=!0,t.touches.length>1)return this._fireClick=!1,void clearTimeout(this._holdTimeout);var i=t.touches[0],n=i.target;this._startPos=this._newPos=new x(i.clientX,i.clientY),n.tagName&&"a"===n.tagName.toLowerCase()&&pt(n,"leaflet-active"),this._holdTimeout=setTimeout(e(function(){this._isTapValid()&&(this._fireClick=!1,this._onUp(),this._simulateEvent("contextmenu",i))},this),1e3),this._simulateEvent("mousedown",i),V(document,{touchmove:this._onMove,touchend:this._onUp},this)}},_onUp:function(t){if(clearTimeout(this._holdTimeout),G(document,{touchmove:this._onMove,touchend:this._onUp},this),this._fireClick&&t&&t.changedTouches){var i=t.changedTouches[0],e=i.target;e&&e.tagName&&"a"===e.tagName.toLowerCase()&&mt(e,"leaflet-active"),this._simulateEvent("mouseup",i),this._isTapValid()&&this._simulateEvent("click",i)}},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_onMove:function(t){var i=t.touches[0];this._newPos=new x(i.clientX,i.clientY),this._simulateEvent("mousemove",i)},_simulateEvent:function(t,i){var e=document.createEvent("MouseEvents");e._simulated=!0,i.target._simulatedClick=!0,e.initMouseEvent(t,!0,!0,window,1,i.screenX,i.screenY,i.clientX,i.clientY,!1,!1,!1,!1,0,null),i.target.dispatchEvent(e)}});ie&&!te&&ke.addInitHook("addHandler","tap",qn),ke.mergeOptions({touchZoom:ie&&!Di,bounceAtZoomLimits:!0});var Kn=Ue.extend({addHooks:function(){pt(this._map._container,"leaflet-touch-zoom"),V(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){mt(this._map._container,"leaflet-touch-zoom"),G(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var i=this._map;if(t.touches&&2===t.touches.length&&!i._animatingZoom&&!this._zooming){var e=i.mouseEventToContainerPoint(t.touches[0]),n=i.mouseEventToContainerPoint(t.touches[1]);this._centerPoint=i.getSize()._divideBy(2),this._startLatLng=i.containerPointToLatLng(this._centerPoint),"center"!==i.options.touchZoom&&(this._pinchStartLatLng=i.containerPointToLatLng(e.add(n)._divideBy(2))),this._startDist=e.distanceTo(n),this._startZoom=i.getZoom(),this._moved=!1,this._zooming=!0,i._stop(),V(document,"touchmove",this._onTouchMove,this),V(document,"touchend",this._onTouchEnd,this),$(t)}},_onTouchMove:function(t){if(t.touches&&2===t.touches.length&&this._zooming){var i=this._map,n=i.mouseEventToContainerPoint(t.touches[0]),o=i.mouseEventToContainerPoint(t.touches[1]),s=n.distanceTo(o)/this._startDist;if(this._zoom=i.getScaleZoom(s,this._startZoom),!i.options.bounceAtZoomLimits&&(this._zoomi.getMaxZoom()&&s>1)&&(this._zoom=i._limitZoom(this._zoom)),"center"===i.options.touchZoom){if(this._center=this._startLatLng,1===s)return}else{var r=n._add(o)._divideBy(2)._subtract(this._centerPoint);if(1===s&&0===r.x&&0===r.y)return;this._center=i.unproject(i.project(this._pinchStartLatLng,this._zoom).subtract(r),this._zoom)}this._moved||(i._moveStart(!0),this._moved=!0),g(this._animRequest);var a=e(i._move,i,this._center,this._zoom,{pinch:!0,round:!1});this._animRequest=f(a,this,!0),$(t)}},_onTouchEnd:function(){return this._moved&&this._zooming?(this._zooming=!1,g(this._animRequest),G(document,"touchmove",this._onTouchMove),G(document,"touchend",this._onTouchEnd),void(this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom)))):void(this._zooming=!1)}});ke.addInitHook("addHandler","touchZoom",Kn),ke.BoxZoom=Hn,ke.DoubleClickZoom=Fn,ke.Drag=Un,ke.Keyboard=Vn,ke.ScrollWheelZoom=Gn,ke.Tap=qn,ke.TouchZoom=Kn;var Yn=window.L;window.L=t,t.version=ci,t.noConflict=li,t.Control=Be,t.control=Ie,t.Browser=he,t.Evented=Li,t.Mixin=Ve,t.Util=xi,t.Class=v,t.Handler=Ue,t.extend=i,t.bind=e,t.stamp=n,t.setOptions=l,t.DomEvent=Pe,t.DomUtil=Ee,t.PosAnimation=Se,t.Draggable=Xe,t.LineUtil=Je,t.PolyUtil=$e,t.Point=x,t.point=w,t.Bounds=P,t.bounds=b,t.Transformation=Z,t.transformation=E,t.Projection=en,t.LatLng=M,t.latLng=C,t.LatLngBounds=T,t.latLngBounds=z,t.CRS=Pi,t.GeoJSON=xn,t.geoJSON=ii,t.geoJson=Ln,t.Layer=rn,t.LayerGroup=an,t.layerGroup=hn,t.FeatureGroup=un,t.featureGroup=ln,t.ImageOverlay=Pn,t.imageOverlay=bn,t.VideoOverlay=Tn,t.videoOverlay=ei,t.DivOverlay=zn,t.Popup=Mn,t.popup=Cn,t.Tooltip=Zn,t.tooltip=En,t.Icon=cn,t.icon=Ht,t.DivIcon=Sn,t.divIcon=ni,t.Marker=pn,t.marker=Ft,t.TileLayer=Bn,t.tileLayer=si,t.GridLayer=kn,t.gridLayer=oi,t.SVG=jn,t.svg=hi,t.Renderer=An,t.Canvas=On,t.canvas=ai,t.Path=mn,t.CircleMarker=fn,t.circleMarker=Ut,t.Circle=gn,t.circle=Vt,t.Polyline=vn,t.polyline=Gt,t.Polygon=yn,t.polygon=qt,t.Rectangle=Wn,t.rectangle=ui,t.Map=ke,t.map=Ct}); +//# sourceMappingURL=leaflet.js.map diff --git a/vendor/assets/stylesheets/leaflet.1.1.0.css b/vendor/assets/stylesheets/leaflet.1.1.0.css new file mode 100644 index 000000000..41126abde --- /dev/null +++ b/vendor/assets/stylesheets/leaflet.1.1.0.css @@ -0,0 +1,631 @@ +/* required styles */ + +.leaflet-pane, +.leaflet-tile, +.leaflet-marker-icon, +.leaflet-marker-shadow, +.leaflet-tile-container, +.leaflet-pane > svg, +.leaflet-pane > canvas, +.leaflet-zoom-box, +.leaflet-image-layer, +.leaflet-layer { + position: absolute; + left: 0; + top: 0; + } +.leaflet-container { + overflow: hidden; + } +.leaflet-tile, +.leaflet-marker-icon, +.leaflet-marker-shadow { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + -webkit-user-drag: none; + } +/* Safari renders non-retina tile on retina better with this, but Chrome is worse */ +.leaflet-safari .leaflet-tile { + image-rendering: -webkit-optimize-contrast; + } +/* hack that prevents hw layers "stretching" when loading new tiles */ +.leaflet-safari .leaflet-tile-container { + width: 1600px; + height: 1600px; + -webkit-transform-origin: 0 0; + } +.leaflet-marker-icon, +.leaflet-marker-shadow { + display: block; + } +/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */ +/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */ +.leaflet-container .leaflet-overlay-pane svg, +.leaflet-container .leaflet-marker-pane img, +.leaflet-container .leaflet-shadow-pane img, +.leaflet-container .leaflet-tile-pane img, +.leaflet-container img.leaflet-image-layer { + max-width: none !important; + } + +.leaflet-container.leaflet-touch-zoom { + -ms-touch-action: pan-x pan-y; + touch-action: pan-x pan-y; + } +.leaflet-container.leaflet-touch-drag { + -ms-touch-action: pinch-zoom; + } +.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom { + -ms-touch-action: none; + touch-action: none; +} +.leaflet-container { + -webkit-tap-highlight-color: transparent; +} +.leaflet-container a { + -webkit-tap-highlight-color: rgba(51, 181, 229, 0.4); +} +.leaflet-tile { + filter: inherit; + visibility: hidden; + } +.leaflet-tile-loaded { + visibility: inherit; + } +.leaflet-zoom-box { + width: 0; + height: 0; + -moz-box-sizing: border-box; + box-sizing: border-box; + z-index: 800; + } +/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ +.leaflet-overlay-pane svg { + -moz-user-select: none; + } + +.leaflet-pane { z-index: 400; } + +.leaflet-tile-pane { z-index: 200; } +.leaflet-overlay-pane { z-index: 400; } +.leaflet-shadow-pane { z-index: 500; } +.leaflet-marker-pane { z-index: 600; } +.leaflet-tooltip-pane { z-index: 650; } +.leaflet-popup-pane { z-index: 700; } + +.leaflet-map-pane canvas { z-index: 100; } +.leaflet-map-pane svg { z-index: 200; } + +.leaflet-vml-shape { + width: 1px; + height: 1px; + } +.lvml { + behavior: url(#default#VML); + display: inline-block; + position: absolute; + } + + +/* control positioning */ + +.leaflet-control { + position: relative; + z-index: 800; + pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ + pointer-events: auto; + } +.leaflet-top, +.leaflet-bottom { + position: absolute; + z-index: 1000; + pointer-events: none; + } +.leaflet-top { + top: 0; + } +.leaflet-right { + right: 0; + } +.leaflet-bottom { + bottom: 0; + } +.leaflet-left { + left: 0; + } +.leaflet-control { + float: left; + clear: both; + } +.leaflet-right .leaflet-control { + float: right; + } +.leaflet-top .leaflet-control { + margin-top: 10px; + } +.leaflet-bottom .leaflet-control { + margin-bottom: 10px; + } +.leaflet-left .leaflet-control { + margin-left: 10px; + } +.leaflet-right .leaflet-control { + margin-right: 10px; + } + + +/* zoom and fade animations */ + +.leaflet-fade-anim .leaflet-tile { + will-change: opacity; + } +.leaflet-fade-anim .leaflet-popup { + opacity: 0; + -webkit-transition: opacity 0.2s linear; + -moz-transition: opacity 0.2s linear; + -o-transition: opacity 0.2s linear; + transition: opacity 0.2s linear; + } +.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { + opacity: 1; + } +.leaflet-zoom-animated { + -webkit-transform-origin: 0 0; + -ms-transform-origin: 0 0; + transform-origin: 0 0; + } +.leaflet-zoom-anim .leaflet-zoom-animated { + will-change: transform; + } +.leaflet-zoom-anim .leaflet-zoom-animated { + -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); + -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); + -o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1); + transition: transform 0.25s cubic-bezier(0,0,0.25,1); + } +.leaflet-zoom-anim .leaflet-tile, +.leaflet-pan-anim .leaflet-tile { + -webkit-transition: none; + -moz-transition: none; + -o-transition: none; + transition: none; + } + +.leaflet-zoom-anim .leaflet-zoom-hide { + visibility: hidden; + } + + +/* cursors */ + +.leaflet-interactive { + cursor: pointer; + } +.leaflet-grab { + cursor: -webkit-grab; + cursor: -moz-grab; + } +.leaflet-crosshair, +.leaflet-crosshair .leaflet-interactive { + cursor: crosshair; + } +.leaflet-popup-pane, +.leaflet-control { + cursor: auto; + } +.leaflet-dragging .leaflet-grab, +.leaflet-dragging .leaflet-grab .leaflet-interactive, +.leaflet-dragging .leaflet-marker-draggable { + cursor: move; + cursor: -webkit-grabbing; + cursor: -moz-grabbing; + } + +/* marker & overlays interactivity */ +.leaflet-marker-icon, +.leaflet-marker-shadow, +.leaflet-image-layer, +.leaflet-pane > svg path, +.leaflet-tile-container { + pointer-events: none; + } + +.leaflet-marker-icon.leaflet-interactive, +.leaflet-image-layer.leaflet-interactive, +.leaflet-pane > svg path.leaflet-interactive { + pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ + pointer-events: auto; + } + +/* visual tweaks */ + +.leaflet-container { + background: #ddd; + outline: 0; + } +.leaflet-container a { + color: #0078A8; + } +.leaflet-container a.leaflet-active { + outline: 2px solid orange; + } +.leaflet-zoom-box { + border: 2px dotted #38f; + background: rgba(255,255,255,0.5); + } + + +/* general typography */ +.leaflet-container { + font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; + } + + +/* general toolbar styles */ + +.leaflet-bar { + box-shadow: 0 1px 5px rgba(0,0,0,0.65); + border-radius: 4px; + } +.leaflet-bar a, +.leaflet-bar a:hover { + background-color: #fff; + border-bottom: 1px solid #ccc; + width: 26px; + height: 26px; + line-height: 26px; + display: block; + text-align: center; + text-decoration: none; + color: black; + } +.leaflet-bar a, +.leaflet-control-layers-toggle { + background-position: 50% 50%; + background-repeat: no-repeat; + display: block; + } +.leaflet-bar a:hover { + background-color: #f4f4f4; + } +.leaflet-bar a:first-child { + border-top-left-radius: 4px; + border-top-right-radius: 4px; + } +.leaflet-bar a:last-child { + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + border-bottom: none; + } +.leaflet-bar a.leaflet-disabled { + cursor: default; + background-color: #f4f4f4; + color: #bbb; + } + +.leaflet-touch .leaflet-bar a { + width: 30px; + height: 30px; + line-height: 30px; + } +.leaflet-touch .leaflet-bar a:first-child { + border-top-left-radius: 2px; + border-top-right-radius: 2px; + } +.leaflet-touch .leaflet-bar a:last-child { + border-bottom-left-radius: 2px; + border-bottom-right-radius: 2px; + } + +/* zoom control */ + +.leaflet-control-zoom-in, +.leaflet-control-zoom-out { + font: bold 18px 'Lucida Console', Monaco, monospace; + text-indent: 1px; + } + +.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out { + font-size: 22px; + } + + +/* layers control */ + +.leaflet-control-layers { + box-shadow: 0 1px 5px rgba(0,0,0,0.4); + background: #fff; + border-radius: 5px; + } +.leaflet-control-layers-toggle { + background-image: url(images/layers.png); + width: 36px; + height: 36px; + } +.leaflet-retina .leaflet-control-layers-toggle { + background-image: url(images/layers-2x.png); + background-size: 26px 26px; + } +.leaflet-touch .leaflet-control-layers-toggle { + width: 44px; + height: 44px; + } +.leaflet-control-layers .leaflet-control-layers-list, +.leaflet-control-layers-expanded .leaflet-control-layers-toggle { + display: none; + } +.leaflet-control-layers-expanded .leaflet-control-layers-list { + display: block; + position: relative; + } +.leaflet-control-layers-expanded { + padding: 6px 10px 6px 6px; + color: #333; + background: #fff; + } +.leaflet-control-layers-scrollbar { + overflow-y: scroll; + padding-right: 5px; + } +.leaflet-control-layers-selector { + margin-top: 2px; + position: relative; + top: 1px; + } +.leaflet-control-layers label { + display: block; + } +.leaflet-control-layers-separator { + height: 0; + border-top: 1px solid #ddd; + margin: 5px -10px 5px -6px; + } + +/* Default icon URLs */ +.leaflet-default-icon-path { + background-image: url(images/marker-icon.png); + } + + +/* attribution and scale controls */ + +.leaflet-container .leaflet-control-attribution { + background: #fff; + background: rgba(255, 255, 255, 0.7); + margin: 0; + } +.leaflet-control-attribution, +.leaflet-control-scale-line { + padding: 0 5px; + color: #333; + } +.leaflet-control-attribution a { + text-decoration: none; + } +.leaflet-control-attribution a:hover { + text-decoration: underline; + } +.leaflet-container .leaflet-control-attribution, +.leaflet-container .leaflet-control-scale { + font-size: 11px; + } +.leaflet-left .leaflet-control-scale { + margin-left: 5px; + } +.leaflet-bottom .leaflet-control-scale { + margin-bottom: 5px; + } +.leaflet-control-scale-line { + border: 2px solid #777; + border-top: none; + line-height: 1.1; + padding: 2px 5px 1px; + font-size: 11px; + white-space: nowrap; + overflow: hidden; + -moz-box-sizing: border-box; + box-sizing: border-box; + + background: #fff; + background: rgba(255, 255, 255, 0.5); + } +.leaflet-control-scale-line:not(:first-child) { + border-top: 2px solid #777; + border-bottom: none; + margin-top: -2px; + } +.leaflet-control-scale-line:not(:first-child):not(:last-child) { + border-bottom: 2px solid #777; + } + +.leaflet-touch .leaflet-control-attribution, +.leaflet-touch .leaflet-control-layers, +.leaflet-touch .leaflet-bar { + box-shadow: none; + } +.leaflet-touch .leaflet-control-layers, +.leaflet-touch .leaflet-bar { + border: 2px solid rgba(0,0,0,0.2); + background-clip: padding-box; + } + + +/* popup */ + +.leaflet-popup { + position: absolute; + text-align: center; + margin-bottom: 20px; + } +.leaflet-popup-content-wrapper { + padding: 1px; + text-align: left; + border-radius: 12px; + } +.leaflet-popup-content { + margin: 13px 19px; + line-height: 1.4; + } +.leaflet-popup-content p { + margin: 18px 0; + } +.leaflet-popup-tip-container { + width: 40px; + height: 20px; + position: absolute; + left: 50%; + margin-left: -20px; + overflow: hidden; + pointer-events: none; + } +.leaflet-popup-tip { + width: 17px; + height: 17px; + padding: 1px; + + margin: -10px auto 0; + + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + } +.leaflet-popup-content-wrapper, +.leaflet-popup-tip { + background: white; + color: #333; + box-shadow: 0 3px 14px rgba(0,0,0,0.4); + } +.leaflet-container a.leaflet-popup-close-button { + position: absolute; + top: 0; + right: 0; + padding: 4px 4px 0 0; + border: none; + text-align: center; + width: 18px; + height: 14px; + font: 16px/14px Tahoma, Verdana, sans-serif; + color: #c3c3c3; + text-decoration: none; + font-weight: bold; + background: transparent; + } +.leaflet-container a.leaflet-popup-close-button:hover { + color: #999; + } +.leaflet-popup-scrolled { + overflow: auto; + border-bottom: 1px solid #ddd; + border-top: 1px solid #ddd; + } + +.leaflet-oldie .leaflet-popup-content-wrapper { + zoom: 1; + } +.leaflet-oldie .leaflet-popup-tip { + width: 24px; + margin: 0 auto; + + -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; + filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); + } +.leaflet-oldie .leaflet-popup-tip-container { + margin-top: -1px; + } + +.leaflet-oldie .leaflet-control-zoom, +.leaflet-oldie .leaflet-control-layers, +.leaflet-oldie .leaflet-popup-content-wrapper, +.leaflet-oldie .leaflet-popup-tip { + border: 1px solid #999; + } + + +/* div icon */ + +.leaflet-div-icon { + background: #fff; + border: 1px solid #666; + } + + +/* Tooltip */ +/* Base styles for the element that has a tooltip */ +.leaflet-tooltip { + position: absolute; + padding: 6px; + background-color: #fff; + border: 1px solid #fff; + border-radius: 3px; + color: #222; + white-space: nowrap; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + pointer-events: none; + box-shadow: 0 1px 3px rgba(0,0,0,0.4); + } +.leaflet-tooltip.leaflet-clickable { + cursor: pointer; + pointer-events: auto; + } +.leaflet-tooltip-top:before, +.leaflet-tooltip-bottom:before, +.leaflet-tooltip-left:before, +.leaflet-tooltip-right:before { + position: absolute; + pointer-events: none; + border: 6px solid transparent; + background: transparent; + content: ""; + } + +/* Directions */ + +.leaflet-tooltip-bottom { + margin-top: 6px; +} +.leaflet-tooltip-top { + margin-top: -6px; +} +.leaflet-tooltip-bottom:before, +.leaflet-tooltip-top:before { + left: 50%; + margin-left: -6px; + } +.leaflet-tooltip-top:before { + bottom: 0; + margin-bottom: -12px; + border-top-color: #fff; + } +.leaflet-tooltip-bottom:before { + top: 0; + margin-top: -12px; + margin-left: -6px; + border-bottom-color: #fff; + } +.leaflet-tooltip-left { + margin-left: -6px; +} +.leaflet-tooltip-right { + margin-left: 6px; +} +.leaflet-tooltip-left:before, +.leaflet-tooltip-right:before { + top: 50%; + margin-top: -6px; + } +.leaflet-tooltip-left:before { + right: 0; + margin-right: -12px; + border-left-color: #fff; + } +.leaflet-tooltip-right:before { + left: 0; + margin-left: -12px; + border-right-color: #fff; + } From bc07082d1752dc428aad33c4237da80070654ca1 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 25 Jul 2017 12:26:11 +0200 Subject: [PATCH 082/222] Init js namespace one time --- app/assets/javascripts/new_design/application.js | 1 + app/assets/javascripts/new_design/header.js | 2 -- app/assets/javascripts/new_design/init.js | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/new_design/init.js diff --git a/app/assets/javascripts/new_design/application.js b/app/assets/javascripts/new_design/application.js index 62606accb..14e94dc84 100644 --- a/app/assets/javascripts/new_design/application.js +++ b/app/assets/javascripts/new_design/application.js @@ -10,6 +10,7 @@ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details // about supported directives. // +//= require ./init //= require jquery //= require jquery_ujs //= require turbolinks diff --git a/app/assets/javascripts/new_design/header.js b/app/assets/javascripts/new_design/header.js index 903b0ff96..479190296 100644 --- a/app/assets/javascripts/new_design/header.js +++ b/app/assets/javascripts/new_design/header.js @@ -1,5 +1,3 @@ -window.TPS = window.TPS || {}; - $(document).on("click", "body", function () { $(".header-menu").removeClass("open fade-in-down"); }); diff --git a/app/assets/javascripts/new_design/init.js b/app/assets/javascripts/new_design/init.js new file mode 100644 index 000000000..4e62f8a6e --- /dev/null +++ b/app/assets/javascripts/new_design/init.js @@ -0,0 +1,2 @@ +// namespace +window.TPS = window.TPS || {}; From f6bc9ec852ab4eb7bf9fccf4bc918ce0be044d8a Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 24 Jul 2017 11:45:03 +0200 Subject: [PATCH 083/222] DossierControllerSpec: rename describe (add #) --- .../new_gestionnaire/dossiers_controller_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 5ff72010d..7f72a9f43 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -5,7 +5,7 @@ describe NewGestionnaire::DossiersController, type: :controller do let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } let(:dossier) { create(:dossier, :replied, procedure: procedure) } - describe 'attestation' do + describe '#attestation' do before { sign_in(gestionnaire) } context 'when a dossier has an attestation' do @@ -31,7 +31,7 @@ describe NewGestionnaire::DossiersController, type: :controller do context "when gestionnaire is signed in" do before { sign_in(gestionnaire) } - describe 'follow' do + describe '#follow' do before do expect_any_instance_of(Dossier).to receive(:next_step!).with('gestionnaire', 'follow') patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id } @@ -42,7 +42,7 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(response).to redirect_to(procedures_url) } end - describe 'unfollow' do + describe '#unfollow' do before do gestionnaire.followed_dossiers << dossier patch :unfollow, params: { procedure_id: procedure.id, dossier_id: dossier.id } @@ -54,7 +54,7 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(response).to redirect_to(procedures_url) } end - describe 'archive' do + describe '#archive' do before do patch :archive, params: { procedure_id: procedure.id, dossier_id: dossier.id } dossier.reload @@ -64,7 +64,7 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(response).to redirect_to(procedures_url) } end - describe 'unarchive' do + describe '#unarchive' do before do dossier.update_attributes(archived: true) patch :unarchive, params: { procedure_id: procedure.id, dossier_id: dossier.id } @@ -102,7 +102,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end end - describe "commentaire" do + describe "#create_commentaire" do let(:saved_commentaire) { dossier.commentaires.first } before do From 9c2e71afa39b9fad05b0b36012882587b3d0c4ab Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 25 Jul 2017 14:33:03 +0200 Subject: [PATCH 084/222] Form: add various champs html and style --- app/assets/stylesheets/new_design/common.scss | 3 +- .../stylesheets/new_design/dossier-link.scss | 17 +++++ app/assets/stylesheets/new_design/forms.scss | 63 ++++++++++++++++++- app/controllers/root_controller.rb | 36 +++++++++++ app/models/drop_down_list.rb | 4 ++ .../dossiers/champs/_address.html.haml | 7 +++ .../dossiers/champs/_champ_label.html.haml | 1 + .../dossiers/champs/_checkbox.html.haml | 8 +++ .../dossiers/champs/_civilite.html.haml | 10 +++ .../dossiers/champs/_date.html.haml | 7 +++ .../dossiers/champs/_datetime.html.haml | 21 +++++++ .../dossiers/champs/_departements.html.haml | 4 ++ .../dossiers/champs/_dossier_link.html.haml | 22 +++++++ .../dossiers/champs/_drop_down_list.html.haml | 8 +++ .../dossiers/champs/_email.html.haml | 7 +++ .../dossiers/champs/_engagement.html.haml | 8 +++ .../dossiers/champs/_explication.html.haml | 2 + .../dossiers/champs/_header_section.html.haml | 2 + .../champs/_multiple_drop_down_list.html.haml | 8 +++ .../dossiers/champs/_number.html.haml | 7 +++ .../dossiers/champs/_pays.html.haml | 4 ++ .../dossiers/champs/_phone.html.haml | 7 +++ .../dossiers/champs/_regions.html.haml | 4 ++ .../dossiers/champs/_text.html.haml | 7 +++ .../dossiers/champs/_textarea.html.haml | 7 +++ .../dossiers/champs/_yes_no.html.haml | 10 +++ app/views/root/patron.html.haml | 6 +- 27 files changed, 282 insertions(+), 8 deletions(-) create mode 100644 app/assets/stylesheets/new_design/dossier-link.scss create mode 100644 app/views/new_gestionnaire/dossiers/champs/_address.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_date.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_departements.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_dossier_link.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_drop_down_list.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_email.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_explication.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_header_section.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_multiple_drop_down_list.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_number.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_pays.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_phone.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_regions.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_text.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/champs/_yes_no.html.haml diff --git a/app/assets/stylesheets/new_design/common.scss b/app/assets/stylesheets/new_design/common.scss index 7855cb076..b4e213382 100644 --- a/app/assets/stylesheets/new_design/common.scss +++ b/app/assets/stylesheets/new_design/common.scss @@ -6,7 +6,8 @@ body, input, -textarea { +textarea, +select { @extend %new-type; font-size: 16px; line-height: 1.42857143; diff --git a/app/assets/stylesheets/new_design/dossier-link.scss b/app/assets/stylesheets/new_design/dossier-link.scss new file mode 100644 index 000000000..5cb9aaa6e --- /dev/null +++ b/app/assets/stylesheets/new_design/dossier-link.scss @@ -0,0 +1,17 @@ +@import "constants"; +@import "colors"; + +.dossier-link { + .help-block > p { + margin-top: - $default-padding; + margin-bottom: 2 * $default-padding; + } + + .text-info { + color: $blue; + } + + .text-warning { + color: $dark-red; + } +} diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index 50a56c464..14f8d13cb 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -17,12 +17,15 @@ input[type=text], input[type=email], input[type=password], - textarea { + input[type=date], + input[type=number], + input[type=tel], + textarea, + select { display: block; - width: 100%; border-radius: 4px; border: solid 1px $border-grey; - margin-bottom: 4 * $default-spacer; + margin-bottom: 2 * $default-padding; padding: $default-padding; &:disabled { @@ -30,6 +33,60 @@ } } + input[type=text], + input[type=email], + input[type=password], + input[type=date], + input[type=number], + input[type=tel], + textarea { + width: 100%; + } + + input[type=email], + input[type=number], + input[type=tel], { + max-width: 500px; + } + + input[type=checkbox], + input[type=radio] { + margin-bottom: 2 * $default-padding; + } + + input[type=date] { + max-width: 180px; + } + + .datetime { + input[type=date] { + display: inline-block; + } + + select { + display: inline-block; + } + } + + .header-section { + color: #4393F3; + font-weight: bold; + font-size: 20px; + margin-bottom: 2 * $default-padding; + } + + .explication-libelle { + font-weight: bold; + font-size: 20px; + margin-bottom: $default-padding; + } + + .explication { + background-color: $light-grey; + padding: $default-padding; + margin-bottom: 2 * $default-padding; + } + .send { float: right; margin-bottom: $default-padding; diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index b65437fa7..8d5cfec18 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -32,5 +32,41 @@ class RootController < ApplicationController end def patron + @all_champs = TypeDeChamp.type_champs + .map { |name, _| TypeDeChamp.new(type_champ: name, libelle: name) } + .map { |type_de_champ| Champ.new(type_de_champ: type_de_champ) } + .map.with_index do |champ, i| + champ.id = i + champ + end + + @all_champs + .select { |champ| champ.type_champ == 'header_section' } + .each { |champ| champ.type_de_champ.libelle = 'un super titre de section' } + + @all_champs + .select { |champ| %w(drop_down_list multiple_drop_down_list).include?(champ.type_champ) } + .each do |champ| + champ.type_de_champ.drop_down_list = DropDownList.new(type_de_champ: champ.type_de_champ) + champ.drop_down_list.value = +"option A +option B +-- avant l'option C -- +option C" + champ.value = '["option B", "option C"]' + end + + type_champ_values = { + 'date': '2016-07-26', + 'datetime': '26/07/2016 07:35', + 'textarea': 'Une description de mon projet', + 'explication': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In erat mauris, faucibus quis pharetra sit amet, pretium ac libero. Etiam vehicula eleifend bibendum. Morbi gravida metus ut sapien condimentum sodales mollis augue sodales. Vestibulum quis quam at sem placerat aliquet', + } + + type_champ_values.each do |(type_champ, value)| + @all_champs + .select { |champ| champ.type_champ == type_champ.to_s } + .each { |champ| champ.value = value } + end end end diff --git a/app/models/drop_down_list.rb b/app/models/drop_down_list.rb index 979112f4c..150bebb73 100644 --- a/app/models/drop_down_list.rb +++ b/app/models/drop_down_list.rb @@ -14,6 +14,10 @@ class DropDownList < ActiveRecord::Base champ.object.value.blank? ? [] : multiple ? JSON.parse(champ.object.value) : [champ.object.value] end + def selected_options_without_decorator(champ) + champ.value.blank? ? [] : multiple ? JSON.parse(champ.value) : [champ.value] + end + def multiple type_de_champ.type_champ == 'multiple_drop_down_list' end diff --git a/app/views/new_gestionnaire/dossiers/champs/_address.html.haml b/app/views/new_gestionnaire/dossiers/champs/_address.html.haml new file mode 100644 index 000000000..34f1ce5e9 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_address.html.haml @@ -0,0 +1,7 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%input{ type: 'text', + name: "champs['#{champ.id}']", + id: "champs_#{champ.id}", + placeholder: champ.libelle, + value: champ.value } diff --git a/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml b/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml new file mode 100644 index 000000000..e99954f45 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml @@ -0,0 +1 @@ +%label{ for: :"champs_#{champ.id}" }>= champ.libelle diff --git a/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml b/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml new file mode 100644 index 000000000..5722da3bc --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml @@ -0,0 +1,8 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%input{ type: 'checkbox', + name: "champs['#{champ.id}']", + id: "champs_#{champ.id}", + checked: ('checked' if champ.value == 'on') } + +%br diff --git a/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml b/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml new file mode 100644 index 000000000..734cf98ac --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml @@ -0,0 +1,10 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%div + %label + = radio_button_tag "champs['#{champ.id}']", "M.", champ.value == 'Mme' ? false : true + Monsieur + + %label + = radio_button_tag "champs['#{champ.id}']", "Mme", champ.value == 'Mme' + Madame diff --git a/app/views/new_gestionnaire/dossiers/champs/_date.html.haml b/app/views/new_gestionnaire/dossiers/champs/_date.html.haml new file mode 100644 index 000000000..fc8e807ce --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_date.html.haml @@ -0,0 +1,7 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%input{ name: "champs['#{champ.id}']", + placeholder: "JJ/MM/AAAA", + id: "champs_#{champ.id}", + value: champ.value, + type: "date" } diff --git a/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml b/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml new file mode 100644 index 000000000..4819347a3 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml @@ -0,0 +1,21 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +.datetime + %input{ name: "champs['#{champ.id}']", + placeholder: champ.libelle, + id: "champs_#{champ.id}", + value: (champ.value.split(/[ ][0-9]*:[0-9]*/).first unless champ.value.nil?), + type: 'date' } + + %select{ name: "time_hour['#{champ.id}']", id: "time_hour_#{champ.id}" } + - (0..23).each do |num| + - num = "%.2i" %num + %option{ value: num, selected: (:selected if champ.same_hour?(num)) } + = num + h + %select{ name: "time_minute['#{champ.id}']", id: "time_minute_#{champ.id}" } + - (0..55).step(5) do |num| + - num = "%.2i" %num + %option{ value: num, selected: (:selected if champ.same_minute?(num)) } + = num + min diff --git a/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml b/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml new file mode 100644 index 000000000..8ef409bed --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml @@ -0,0 +1,4 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + += select_tag("champs['#{champ.id}']", + options_for_select(Champ.departements, selected: champ.value)) diff --git a/app/views/new_gestionnaire/dossiers/champs/_dossier_link.html.haml b/app/views/new_gestionnaire/dossiers/champs/_dossier_link.html.haml new file mode 100644 index 000000000..647ab8d9e --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_dossier_link.html.haml @@ -0,0 +1,22 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +- dossier = Dossier.find_by(id: champ.value) +- show_text_summary = dossier.present? +- show_warning = !show_text_summary && champ.value.present? +- text_summary = dossier.try(:text_summary) + +.dossier-link + %input{ name: "champs['#{ champ.id }']", + placeholder: "Numéro de dossier", + id: "champs_#{ champ.id }", + value: champ.value, + type: 'number', + 'autocomplete' => 'off', + 'data-type' => 'dossier-link' } + + .help-block + %p.text-info{ style: show_text_summary ? nil : 'display: none;' } + %span.dossier-text-summary= text_summary + + %p.text-warning{ style: show_warning ? nil : 'display: none;' } + Ce dossier est inconnu 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 new file mode 100644 index 000000000..c915b1797 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_drop_down_list.html.haml @@ -0,0 +1,8 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +- if champ.drop_down_list && champ.drop_down_list.options.any? + = select_tag("champs['#{champ.id}']", + options_for_select(champ.drop_down_list.options, + selected: champ.drop_down_list.selected_options_without_decorator(champ), + disabled: champ.drop_down_list.disabled_options), + multiple: false) diff --git a/app/views/new_gestionnaire/dossiers/champs/_email.html.haml b/app/views/new_gestionnaire/dossiers/champs/_email.html.haml new file mode 100644 index 000000000..727d092e4 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_email.html.haml @@ -0,0 +1,7 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%input{ type: 'email', + name: "champs['#{champ.id}']", + id: "champs_#{champ.id}", + placeholder: champ.libelle, + value: champ.value } diff --git a/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml b/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml new file mode 100644 index 000000000..5722da3bc --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml @@ -0,0 +1,8 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%input{ type: 'checkbox', + name: "champs['#{champ.id}']", + id: "champs_#{champ.id}", + checked: ('checked' if champ.value == 'on') } + +%br diff --git a/app/views/new_gestionnaire/dossiers/champs/_explication.html.haml b/app/views/new_gestionnaire/dossiers/champs/_explication.html.haml new file mode 100644 index 000000000..0baedbbae --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_explication.html.haml @@ -0,0 +1,2 @@ +%h2.explication-libelle= champ.libelle +%p.explication= champ.value diff --git a/app/views/new_gestionnaire/dossiers/champs/_header_section.html.haml b/app/views/new_gestionnaire/dossiers/champs/_header_section.html.haml new file mode 100644 index 000000000..16c6c6c9f --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_header_section.html.haml @@ -0,0 +1,2 @@ +%h2.header-section + = champ.libelle 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 new file mode 100644 index 000000000..2ca3fabed --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_multiple_drop_down_list.html.haml @@ -0,0 +1,8 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +- if champ.drop_down_list && champ.drop_down_list.options.any? + = select_tag("champs['#{champ.id}']", + options_for_select(champ.drop_down_list.options, + selected: champ.drop_down_list.selected_options_without_decorator(champ), + disabled: champ.drop_down_list.disabled_options), + multiple: true) diff --git a/app/views/new_gestionnaire/dossiers/champs/_number.html.haml b/app/views/new_gestionnaire/dossiers/champs/_number.html.haml new file mode 100644 index 000000000..dd66c4e8f --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_number.html.haml @@ -0,0 +1,7 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%input{ type: 'number', + name: "champs['#{champ.id}']", + id: "champs_#{champ.id}", + placeholder: champ.libelle, + value: champ.value } diff --git a/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml b/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml new file mode 100644 index 000000000..96962d7dc --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml @@ -0,0 +1,4 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + += select_tag("champs['#{champ.id}']", + options_for_select(Champ.pays, selected: champ.value)) diff --git a/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml b/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml new file mode 100644 index 000000000..fcc6e043e --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml @@ -0,0 +1,7 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%input{ type: 'tel', + name: "champs['#{champ.id}']", + id: "champs_#{champ.id}", + placeholder: champ.libelle, + value: champ.value } diff --git a/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml b/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml new file mode 100644 index 000000000..ad4cf5531 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml @@ -0,0 +1,4 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + += select_tag("champs['#{champ.id}']", + options_for_select(Champ.regions, selected: champ.value)) diff --git a/app/views/new_gestionnaire/dossiers/champs/_text.html.haml b/app/views/new_gestionnaire/dossiers/champs/_text.html.haml new file mode 100644 index 000000000..34f1ce5e9 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_text.html.haml @@ -0,0 +1,7 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%input{ type: 'text', + name: "champs['#{champ.id}']", + id: "champs_#{champ.id}", + placeholder: champ.libelle, + value: champ.value } diff --git a/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml b/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml new file mode 100644 index 000000000..4f057c115 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml @@ -0,0 +1,7 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%textarea{ name: "champs['#{champ.id}']", + placeholder: champ.description, + id: "champs_#{champ.id}", + row: '6' } + = sanitize(champ.value) diff --git a/app/views/new_gestionnaire/dossiers/champs/_yes_no.html.haml b/app/views/new_gestionnaire/dossiers/champs/_yes_no.html.haml new file mode 100644 index 000000000..802595b19 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/champs/_yes_no.html.haml @@ -0,0 +1,10 @@ += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } + +%div + %label + = radio_button_tag "champs['#{champ.id}']", "true", champ.value == 'true' + Oui + + %label + = radio_button_tag "champs['#{champ.id}']", "false", champ.value == 'false' + Non diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 1c417081c..762c9a6a0 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -3,10 +3,8 @@ %h1 Formulaires %form.form - %label Nom - %input{ type: "text" } - %textarea{ placeholder: "Description de votre projet" } - %label Mot de passe + - @all_champs.each do |champ| + = render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}", locals: { champ: champ } %input{ type: "password", value: "12345678" } %input.button.send{ type: "submit", value: "Envoyer" } From e0bd42032ae0f1ed3f20473900816ab8d8893335 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 25 Jul 2017 14:33:03 +0200 Subject: [PATCH 085/222] Form: style select --- app/assets/images/icons/chevron-down.svg | 1 + app/assets/stylesheets/new_design/forms.scss | 23 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 app/assets/images/icons/chevron-down.svg diff --git a/app/assets/images/icons/chevron-down.svg b/app/assets/images/icons/chevron-down.svg new file mode 100644 index 000000000..22a1562fd --- /dev/null +++ b/app/assets/images/icons/chevron-down.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index 14f8d13cb..1f8d9702c 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -58,6 +58,29 @@ max-width: 180px; } + select { + // hack found here: https://stackoverflow.com/questions/1895476/how-to-style-a-select-dropdown-with-css-only-without-javascript + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + background: image-url("icons/chevron-down.svg") no-repeat; + background-size: 14px; + background-position: right 10px center; + padding-right: 3 * $default-spacer; + + // CAUTION: IE hackery ahead + &::-ms-expand { + display: none; // remove default arrow in IE 10 and 11 */ + } + + // target Internet Explorer 9 to undo the custom arrow */ + @media screen and (min-width:0\0) { + select { + background: none\9; + } + } + } + .datetime { input[type=date] { display: inline-block; From 62894175ae3c24285e67505c96fc8901dbef10d5 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 26 Jul 2017 14:33:48 +0200 Subject: [PATCH 086/222] DossierControllerSpec: refactor by remove sign_in test logic As this test belongs to ProcedureControllerSpec --- .../dossiers_controller_spec.rb | 98 +++++++------------ 1 file changed, 36 insertions(+), 62 deletions(-) diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 7f72a9f43..c1e5ac4c2 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -5,9 +5,9 @@ describe NewGestionnaire::DossiersController, type: :controller do let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } let(:dossier) { create(:dossier, :replied, procedure: procedure) } - describe '#attestation' do - before { sign_in(gestionnaire) } + before { sign_in(gestionnaire) } + describe '#attestation' do context 'when a dossier has an attestation' do let(:fake_pdf) { double(read: 'pdf content') } let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) } @@ -28,86 +28,60 @@ describe NewGestionnaire::DossiersController, type: :controller do end end - context "when gestionnaire is signed in" do - before { sign_in(gestionnaire) } - - describe '#follow' do - before do - expect_any_instance_of(Dossier).to receive(:next_step!).with('gestionnaire', 'follow') - patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id } - end - - it { expect(gestionnaire.followed_dossiers).to match([dossier]) } - it { expect(flash.notice).to eq('Dossier suivi') } - it { expect(response).to redirect_to(procedures_url) } + describe '#follow' do + before do + expect_any_instance_of(Dossier).to receive(:next_step!).with('gestionnaire', 'follow') + patch :follow, params: { procedure_id: procedure.id, dossier_id: dossier.id } end - describe '#unfollow' do - before do - gestionnaire.followed_dossiers << dossier - patch :unfollow, params: { procedure_id: procedure.id, dossier_id: dossier.id } - gestionnaire.reload - end + it { expect(gestionnaire.followed_dossiers).to match([dossier]) } + it { expect(flash.notice).to eq('Dossier suivi') } + it { expect(response).to redirect_to(procedures_url) } + end - it { expect(gestionnaire.followed_dossiers).to match([]) } - it { expect(flash.notice).to eq("Vous ne suivez plus le dossier nº #{dossier.id}") } - it { expect(response).to redirect_to(procedures_url) } + describe '#unfollow' do + before do + gestionnaire.followed_dossiers << dossier + patch :unfollow, params: { procedure_id: procedure.id, dossier_id: dossier.id } + gestionnaire.reload end - describe '#archive' do - before do - patch :archive, params: { procedure_id: procedure.id, dossier_id: dossier.id } - dossier.reload - end + it { expect(gestionnaire.followed_dossiers).to match([]) } + it { expect(flash.notice).to eq("Vous ne suivez plus le dossier nº #{dossier.id}") } + it { expect(response).to redirect_to(procedures_url) } + end - it { expect(dossier.archived).to be true } - it { expect(response).to redirect_to(procedures_url) } + describe '#archive' do + before do + patch :archive, params: { procedure_id: procedure.id, dossier_id: dossier.id } + dossier.reload end - describe '#unarchive' do - before do - dossier.update_attributes(archived: true) - patch :unarchive, params: { procedure_id: procedure.id, dossier_id: dossier.id } - dossier.reload - end + it { expect(dossier.archived).to be true } + it { expect(response).to redirect_to(procedures_url) } + end - it { expect(dossier.archived).to be false } - it { expect(response).to redirect_to(procedures_url) } + describe '#unarchive' do + before do + dossier.update_attributes(archived: true) + patch :unarchive, params: { procedure_id: procedure.id, dossier_id: dossier.id } + dossier.reload end + + it { expect(dossier.archived).to be false } + it { expect(response).to redirect_to(procedures_url) } end describe "#show" do - let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } - let(:dossier){ create(:dossier, :replied, procedure: procedure) } + before { get :show, params: { procedure_id: procedure.id, dossier_id: dossier.id } } - subject { get :show, params: { procedure_id: procedure.id, dossier_id: dossier.id } } - - context "when gestionnaire is not logged in" do - before { subject } - it { expect(response).to redirect_to(new_user_session_path) } - end - - context "when gestionnaire is logged in" do - before { sign_in(gestionnaire) } - - it do - subject - expect(response).to have_http_status(:success) - end - - context "when gestionnaire is not affected on procedure" do - let(:dossier){ create(:dossier, :replied) } - it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) } - end - end + it { expect(response).to have_http_status(:success) } end describe "#create_commentaire" do let(:saved_commentaire) { dossier.commentaires.first } before do - sign_in(gestionnaire) - post :create_commentaire, params: { procedure_id: procedure.id, dossier_id: dossier.id, From 509b378567e54fb0fbd4f9be51d7a26e8aa97a93 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 26 Jul 2017 13:22:25 +0200 Subject: [PATCH 087/222] Form: add select2 form multiple select --- .../javascripts/new_design/application.js | 1 + .../champs/multiple_drop_down_list.js | 3 ++ app/assets/stylesheets/new_design/forms.scss | 28 ++++++++++++++++++- .../new_design/new_application.scss | 1 + .../champs/_multiple_drop_down_list.html.haml | 3 +- 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/new_design/champs/multiple_drop_down_list.js diff --git a/app/assets/javascripts/new_design/application.js b/app/assets/javascripts/new_design/application.js index 14e94dc84..c80a10aab 100644 --- a/app/assets/javascripts/new_design/application.js +++ b/app/assets/javascripts/new_design/application.js @@ -17,4 +17,5 @@ //= require leaflet.1.1.0 //= require highcharts //= require chartkick +//= require select2 //= require_tree . diff --git a/app/assets/javascripts/new_design/champs/multiple_drop_down_list.js b/app/assets/javascripts/new_design/champs/multiple_drop_down_list.js new file mode 100644 index 000000000..f76aa5913 --- /dev/null +++ b/app/assets/javascripts/new_design/champs/multiple_drop_down_list.js @@ -0,0 +1,3 @@ +document.addEventListener('turbolinks:load', function() { + $('select.select2').select2(); +}); diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index 1f8d9702c..dac5857fe 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -58,7 +58,8 @@ max-width: 180px; } - select { + select, + .select2-selection { // hack found here: https://stackoverflow.com/questions/1895476/how-to-style-a-select-dropdown-with-css-only-without-javascript -webkit-appearance: none; -moz-appearance: none; @@ -81,6 +82,31 @@ } } + .select2 { + min-width: 50%; + } + + .select2-container { + display: block; + margin-bottom: 2 * $default-padding; + + &.select2-container--focus { + .select2-selection { + border-color: $border-grey; + } + } + + // scss-lint:disable SelectorFormat + .select2-selection__rendered { + padding: $default-padding; + } + + .select2-selection__choice { + background-color: #FFFFFF; + } + // scss-lint:enable + } + .datetime { input[type=date] { display: inline-block; diff --git a/app/assets/stylesheets/new_design/new_application.scss b/app/assets/stylesheets/new_design/new_application.scss index 9735dc8fc..d1bcfc077 100644 --- a/app/assets/stylesheets/new_design/new_application.scss +++ b/app/assets/stylesheets/new_design/new_application.scss @@ -4,4 +4,5 @@ // = require ./utils // = require ./fonts // = require leaflet.1.1.0 +// = require select2 // = require_tree . 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 2ca3fabed..248fb1932 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 @@ -5,4 +5,5 @@ options_for_select(champ.drop_down_list.options, selected: champ.drop_down_list.selected_options_without_decorator(champ), disabled: champ.drop_down_list.disabled_options), - multiple: true) + multiple: true, + class: 'select2') From 2fd486c1a3f528d6a33989d06ae9ed41cb8b14bb Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 26 Jul 2017 12:41:23 +0200 Subject: [PATCH 088/222] Form: add pseudo native form validation --- app/assets/javascripts/new_design/form_validation.js | 8 ++++++++ app/assets/stylesheets/new_design/forms.scss | 11 +++++++++++ app/views/root/patron.html.haml | 1 + 3 files changed, 20 insertions(+) create mode 100644 app/assets/javascripts/new_design/form_validation.js diff --git a/app/assets/javascripts/new_design/form_validation.js b/app/assets/javascripts/new_design/form_validation.js new file mode 100644 index 000000000..8eef828af --- /dev/null +++ b/app/assets/javascripts/new_design/form_validation.js @@ -0,0 +1,8 @@ +$(document).on('blur keydown', 'input, textarea', function() { + $(this).addClass('touched'); +}); + +$(document).on('click', 'input[type="submit"]:not([formnovalidate])', function() { + var $form = $(this).closest('form'); + $('input, textarea', $form).addClass('touched'); +}); diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index dac5857fe..f07b8a9bc 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -58,6 +58,17 @@ max-width: 180px; } + input:invalid, + textarea:invalid { + box-shadow: none; + } + + input.touched:invalid, + textarea.touched:invalid { + border-color: $dark-red; + box-shadow: 0px 0px 5px $dark-red; + } + select, .select2-selection { // hack found here: https://stackoverflow.com/questions/1895476/how-to-style-a-select-dropdown-with-css-only-without-javascript diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 762c9a6a0..f86987216 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -7,6 +7,7 @@ = render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}", locals: { champ: champ } %input{ type: "password", value: "12345678" } %input.button.send{ type: "submit", value: "Envoyer" } + %input.button.send{ type: "submit", value: "Enregistrer un brouillon (formnovalidate)", formnovalidate: true } %h1 Boutons From 80023e4f7f0356d617548de08861ac2aa6c1615c Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 26 Jul 2017 12:41:58 +0200 Subject: [PATCH 089/222] Form: remove form overflow to improve box shadow on input error --- app/assets/stylesheets/new_design/forms.scss | 11 ++++++----- .../new_gestionnaire/dossiers/messagerie.html.haml | 3 ++- app/views/root/patron.html.haml | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index f07b8a9bc..cf3ace506 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -2,8 +2,6 @@ @import "colors"; .form { - overflow: hidden; - h1 { text-align: center; margin-bottom: 20px; @@ -147,8 +145,11 @@ margin-bottom: 2 * $default-padding; } - .send { - float: right; - margin-bottom: $default-padding; + .send-wrapper { + text-align: right; + + .send { + margin-bottom: $default-padding; + } } } diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index e16cb8e3f..7d2176901 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -17,4 +17,5 @@ = form_for(Commentaire.new, url: commentaire_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' }) do |f| = f.text_area :body, rows: 5, placeholder: 'Répondre ici', required: true - = f.submit 'Envoyer', class: 'button send' + .send-wrapper + = f.submit 'Envoyer', class: 'button send' diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index f86987216..1de270904 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -6,8 +6,9 @@ - @all_champs.each do |champ| = render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}", locals: { champ: champ } %input{ type: "password", value: "12345678" } - %input.button.send{ type: "submit", value: "Envoyer" } - %input.button.send{ type: "submit", value: "Enregistrer un brouillon (formnovalidate)", formnovalidate: true } + .send-wrapper + %input.button.send{ type: "submit", value: "Enregistrer un brouillon (formnovalidate)", formnovalidate: true } + %input.button.send{ type: "submit", value: "Envoyer" } %h1 Boutons From 1a485f173e5d194c0f6e946d53d165ec250d42d7 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 27 Jul 2017 11:09:28 +0200 Subject: [PATCH 090/222] Form: add required --- app/controllers/root_controller.rb | 2 +- .../new_gestionnaire/dossiers/champs/_address.html.haml | 3 ++- .../dossiers/champs/_champ_label.html.haml | 2 +- .../new_gestionnaire/dossiers/champs/_checkbox.html.haml | 3 ++- app/views/new_gestionnaire/dossiers/champs/_date.html.haml | 3 ++- .../new_gestionnaire/dossiers/champs/_datetime.html.haml | 7 ++++--- .../dossiers/champs/_dossier_link.html.haml | 3 ++- .../new_gestionnaire/dossiers/champs/_email.html.haml | 3 ++- .../new_gestionnaire/dossiers/champs/_engagement.html.haml | 3 ++- .../new_gestionnaire/dossiers/champs/_number.html.haml | 3 ++- .../new_gestionnaire/dossiers/champs/_phone.html.haml | 3 ++- app/views/new_gestionnaire/dossiers/champs/_text.html.haml | 3 ++- .../new_gestionnaire/dossiers/champs/_textarea.html.haml | 3 ++- 13 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 8d5cfec18..0bb093d67 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -33,7 +33,7 @@ class RootController < ApplicationController def patron @all_champs = TypeDeChamp.type_champs - .map { |name, _| TypeDeChamp.new(type_champ: name, libelle: name) } + .map { |name, _| TypeDeChamp.new(type_champ: name, libelle: name, mandatory: true) } .map { |type_de_champ| Champ.new(type_de_champ: type_de_champ) } .map.with_index do |champ, i| champ.id = i diff --git a/app/views/new_gestionnaire/dossiers/champs/_address.html.haml b/app/views/new_gestionnaire/dossiers/champs/_address.html.haml index 34f1ce5e9..e42aa8584 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_address.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_address.html.haml @@ -4,4 +4,5 @@ name: "champs['#{champ.id}']", id: "champs_#{champ.id}", placeholder: champ.libelle, - value: champ.value } + value: champ.value, + required: champ.mandatory } 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 e99954f45..7807b7c6a 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml @@ -1 +1 @@ -%label{ for: :"champs_#{champ.id}" }>= champ.libelle +%label{ for: :"champs_#{champ.id}" }> #{champ.libelle} #{champ.mandatory ? '*' : nil} diff --git a/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml b/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml index 5722da3bc..09600b354 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml @@ -3,6 +3,7 @@ %input{ type: 'checkbox', name: "champs['#{champ.id}']", id: "champs_#{champ.id}", - checked: ('checked' if champ.value == 'on') } + checked: ('checked' if champ.value == 'on'), + required: champ.mandatory } %br diff --git a/app/views/new_gestionnaire/dossiers/champs/_date.html.haml b/app/views/new_gestionnaire/dossiers/champs/_date.html.haml index fc8e807ce..0e8060144 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_date.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_date.html.haml @@ -4,4 +4,5 @@ placeholder: "JJ/MM/AAAA", id: "champs_#{champ.id}", value: champ.value, - type: "date" } + type: "date", + required: champ.mandatory } diff --git a/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml b/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml index 4819347a3..8704e17bc 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml @@ -5,15 +5,16 @@ placeholder: champ.libelle, id: "champs_#{champ.id}", value: (champ.value.split(/[ ][0-9]*:[0-9]*/).first unless champ.value.nil?), - type: 'date' } + type: 'date', + required: champ.mandatory } - %select{ name: "time_hour['#{champ.id}']", id: "time_hour_#{champ.id}" } + %select{ name: "time_hour['#{champ.id}']", id: "time_hour_#{champ.id}", required: champ.mandatory } - (0..23).each do |num| - num = "%.2i" %num %option{ value: num, selected: (:selected if champ.same_hour?(num)) } = num h - %select{ name: "time_minute['#{champ.id}']", id: "time_minute_#{champ.id}" } + %select{ name: "time_minute['#{champ.id}']", id: "time_minute_#{champ.id}", required: champ.mandatory } - (0..55).step(5) do |num| - num = "%.2i" %num %option{ value: num, selected: (:selected if champ.same_minute?(num)) } 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 647ab8d9e..8ecf58dc3 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_dossier_link.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_dossier_link.html.haml @@ -12,7 +12,8 @@ value: champ.value, type: 'number', 'autocomplete' => 'off', - 'data-type' => 'dossier-link' } + 'data-type' => 'dossier-link', + required: champ.mandatory } .help-block %p.text-info{ style: show_text_summary ? nil : 'display: none;' } diff --git a/app/views/new_gestionnaire/dossiers/champs/_email.html.haml b/app/views/new_gestionnaire/dossiers/champs/_email.html.haml index 727d092e4..6684b7865 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_email.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_email.html.haml @@ -4,4 +4,5 @@ name: "champs['#{champ.id}']", id: "champs_#{champ.id}", placeholder: champ.libelle, - value: champ.value } + value: champ.value, + required: champ.mandatory } diff --git a/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml b/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml index 5722da3bc..09600b354 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml @@ -3,6 +3,7 @@ %input{ type: 'checkbox', name: "champs['#{champ.id}']", id: "champs_#{champ.id}", - checked: ('checked' if champ.value == 'on') } + checked: ('checked' if champ.value == 'on'), + required: champ.mandatory } %br diff --git a/app/views/new_gestionnaire/dossiers/champs/_number.html.haml b/app/views/new_gestionnaire/dossiers/champs/_number.html.haml index dd66c4e8f..5e2b61e8d 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_number.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_number.html.haml @@ -4,4 +4,5 @@ name: "champs['#{champ.id}']", id: "champs_#{champ.id}", placeholder: champ.libelle, - value: champ.value } + value: champ.value, + required: champ.mandatory } diff --git a/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml b/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml index fcc6e043e..c1bbfd1ce 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml @@ -4,4 +4,5 @@ name: "champs['#{champ.id}']", id: "champs_#{champ.id}", placeholder: champ.libelle, - value: champ.value } + value: champ.value, + required: champ.mandatory } diff --git a/app/views/new_gestionnaire/dossiers/champs/_text.html.haml b/app/views/new_gestionnaire/dossiers/champs/_text.html.haml index 34f1ce5e9..e42aa8584 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_text.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_text.html.haml @@ -4,4 +4,5 @@ name: "champs['#{champ.id}']", id: "champs_#{champ.id}", placeholder: champ.libelle, - value: champ.value } + value: champ.value, + required: champ.mandatory } diff --git a/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml b/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml index 4f057c115..37c5e031d 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml @@ -3,5 +3,6 @@ %textarea{ name: "champs['#{champ.id}']", placeholder: champ.description, id: "champs_#{champ.id}", - row: '6' } + row: '6', + required: champ.mandatory } = sanitize(champ.value) From 1b427668366f19c63c8541ef4816c9b5fedee736 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 26 Jul 2017 12:09:21 +0200 Subject: [PATCH 091/222] Form: add address auto complete --- .../javascripts/new_design/application.js | 1 + .../javascripts/new_design/champs/address.js | 27 +++++++++++++++++++ app/assets/stylesheets/new_design/forms.scss | 17 +++++++++++- .../new_design/new_application.scss | 1 + .../dossiers/champs/_address.html.haml | 1 + 5 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/new_design/champs/address.js diff --git a/app/assets/javascripts/new_design/application.js b/app/assets/javascripts/new_design/application.js index c80a10aab..56b132233 100644 --- a/app/assets/javascripts/new_design/application.js +++ b/app/assets/javascripts/new_design/application.js @@ -18,4 +18,5 @@ //= require highcharts //= require chartkick //= require select2 +//= require typeahead.bundle //= require_tree . diff --git a/app/assets/javascripts/new_design/champs/address.js b/app/assets/javascripts/new_design/champs/address.js new file mode 100644 index 000000000..7b9339b9e --- /dev/null +++ b/app/assets/javascripts/new_design/champs/address.js @@ -0,0 +1,27 @@ +(function () { + var display = 'label'; + + var bloodhound = new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.obj.whitespace(display), + queryTokenizer: Bloodhound.tokenizers.whitespace, + + remote: { + url: '/ban/search?request=%QUERY', + wildcard: '%QUERY' + } + }); + + bloodhound.initialize(); + + var bindTypeahead = function() { + $("input[data-address='true']").typeahead({ + minLength: 1 + }, { + display: display, + source: bloodhound, + limit: 5 + }); + }; + + document.addEventListener('turbolinks:load', bindTypeahead); +})(); diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index cf3ace506..043585de6 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -12,7 +12,7 @@ display: inline-block; } - input[type=text], + input[type=text]:not([data-address='true']), input[type=email], input[type=password], input[type=date], @@ -116,6 +116,21 @@ // scss-lint:enable } + .twitter-typeahead { + margin-bottom: 2 * $default-padding; + } + + input.tt-input, + input.tt-hint { + border-radius: 4px; + border: solid 1px $border-grey; + padding: $default-padding; + } + + input.tt-hint { + color: $grey; + } + .datetime { input[type=date] { display: inline-block; diff --git a/app/assets/stylesheets/new_design/new_application.scss b/app/assets/stylesheets/new_design/new_application.scss index d1bcfc077..e575f56c5 100644 --- a/app/assets/stylesheets/new_design/new_application.scss +++ b/app/assets/stylesheets/new_design/new_application.scss @@ -5,4 +5,5 @@ // = require ./fonts // = require leaflet.1.1.0 // = require select2 +// = require typeahead // = require_tree . diff --git a/app/views/new_gestionnaire/dossiers/champs/_address.html.haml b/app/views/new_gestionnaire/dossiers/champs/_address.html.haml index e42aa8584..af9fb84c2 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_address.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_address.html.haml @@ -1,6 +1,7 @@ = render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } %input{ type: 'text', + 'data-address': 'true', name: "champs['#{champ.id}']", id: "champs_#{champ.id}", placeholder: champ.libelle, From 9f890d1ea7a329b2406d1d314b1f76d19f0a99cd Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 26 Jul 2017 12:58:00 +0200 Subject: [PATCH 092/222] Form: import dossier_link js in new design --- .../new_design/champs/dossier_link.js | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 app/assets/javascripts/new_design/champs/dossier_link.js diff --git a/app/assets/javascripts/new_design/champs/dossier_link.js b/app/assets/javascripts/new_design/champs/dossier_link.js new file mode 100644 index 000000000..3b32782c4 --- /dev/null +++ b/app/assets/javascripts/new_design/champs/dossier_link.js @@ -0,0 +1,36 @@ +(function() { + var showNotFound = function() { + $('.dossier-link .text-info').hide(); + $('.dossier-link .text-warning').show(); + }; + + var showData = function(data) { + $('.dossier-link .dossier-text-summary').text(data.textSummary); + $('.dossier-link .text-info').show(); + $('.dossier-link .text-warning').hide(); + }; + + var hideEverything = function() { + $('.dossier-link .text-info').hide(); + $('.dossier-link .text-warning').hide(); + }; + + var fetchProcedureLibelle = function(e) { + var dossierId = $(e.target).val(); + if(dossierId) { + $.get('/users/dossiers/' + dossierId + '/text_summary') + .done(showData) + .fail(showNotFound); + } else { + hideEverything(); + } + }; + + var timeOut = null; + var debounceFetchProcedureLibelle = function(e) { + if(timeOut){ clearTimeout(timeOut); } + timeOut = setTimeout(function() { fetchProcedureLibelle(e); }, 300); + }; + + $(document).on('input', '[data-type=dossier-link]', debounceFetchProcedureLibelle); +})(); From d780ab1c904ca056554301f0c6c85461b0d666e2 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 31 Jul 2017 18:00:43 +0200 Subject: [PATCH 093/222] Avoid n+1 because of user.email --- app/controllers/new_gestionnaire/procedures_controller.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index d806ee2d8..fab1883cb 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -27,19 +27,21 @@ module NewGestionnaire @a_suivre_dossiers = procedure .dossiers + .includes(:user) .without_followers .en_cours @followed_dossiers = current_gestionnaire .followed_dossiers + .includes(:user) .where(procedure: @procedure) .en_cours - @termines_dossiers = procedure.dossiers.termine + @termines_dossiers = procedure.dossiers.includes(:user).termine - @all_state_dossiers = procedure.dossiers.all_state + @all_state_dossiers = procedure.dossiers.includes(:user).all_state - @archived_dossiers = procedure.dossiers.archived + @archived_dossiers = procedure.dossiers.includes(:user).archived @statut = params[:statut].present? ? params[:statut] : 'a-suivre' From f3f2b6acc266c48df56d332fff43c3d1752bf286 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 31 Jul 2017 18:35:34 +0200 Subject: [PATCH 094/222] Avoid n+1 because of gestionnaire.follows?(dossier) --- app/controllers/new_gestionnaire/procedures_controller.rb | 5 +++++ .../new_gestionnaire/procedures/_dossier_actions.html.haml | 2 +- app/views/new_gestionnaire/procedures/show.html.haml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index fab1883cb..29f67e685 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -37,6 +37,11 @@ module NewGestionnaire .where(procedure: @procedure) .en_cours + @followed_dossiers_id = current_gestionnaire + .followed_dossiers + .where(procedure: @procedure) + .pluck(:id) + @termines_dossiers = procedure.dossiers.includes(:user).termine @all_state_dossiers = procedure.dossiers.includes(:user).all_state diff --git a/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml b/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml index 608671c6e..d61410fce 100644 --- a/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml +++ b/app/views/new_gestionnaire/procedures/_dossier_actions.html.haml @@ -1,5 +1,5 @@ - if dossier.en_construction_ou_instruction? - - if current_gestionnaire.follow?(dossier) + - if dossier_is_followed = link_to unfollow_dossier_path(procedure, dossier), method: :patch, class: 'button' do %i.unfollow> ne plus suivre diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 0de5523d0..1c983751f 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -47,6 +47,6 @@ %td.status-col = link_to(dossier_path(@procedure, dossier), class: 'big-link') do = render partial: 'status', locals: { dossier: dossier } - %td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier } + %td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) } - else %h2 Aucun dossier From 32c83dd7a5ffac3c501ef663acb8c2cfbb31956d Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 27 Jul 2017 14:53:18 +0200 Subject: [PATCH 095/222] Add label variations to /patron --- app/assets/stylesheets/new_design/labels.scss | 25 +++++++++++++++++++ .../new_design/procedures_show.scss | 24 ------------------ app/views/root/patron.html.haml | 5 ++++ 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/app/assets/stylesheets/new_design/labels.scss b/app/assets/stylesheets/new_design/labels.scss index a623d900f..5c9de758c 100644 --- a/app/assets/stylesheets/new_design/labels.scss +++ b/app/assets/stylesheets/new_design/labels.scss @@ -5,7 +5,32 @@ display: inline-block; padding: 4px $default-spacer; background: $grey; + border: 1px solid transparent; color: #FFFFFF; border-radius: 4px; font-size: 12px; + + &.instruction { + background-color: #FFFFFF; + color: $blue; + border: 1px solid $blue; + } + + &.construction { + background-color: #FFFFFF; + color: $black; + border: 1px solid $black; + } + + &.closed { + background-color: $green; + } + + &.refused { + background-color: $dark-red; + } + + &.without-continuation { + background-color: $black; + } } diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index 076315ef0..e0e82c79e 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -127,30 +127,6 @@ .label { width: 110px; text-align: center; - - &.instruction { - background-color: #FFFFFF; - color: $blue; - border: 1px solid $blue; - } - - &.construction { - background-color: #FFFFFF; - color: $black; - border: 1px solid $black; - } - - &.closed { - background-color: $green; - } - - &.refused { - background-color: $dark-red; - } - - &.without-continuation { - background-color: $black; - } } .button { diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 1de270904..944142523 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -52,6 +52,11 @@ %h1 Labels %span.label .label + %span.label.instruction .label.instruction + %span.label.construction .label.construction + %span.label.closed .label.closed + %span.label.refused .label.refused + %span.label.without-continuation .label.without-continuation %h1 Cards From 42a87920719324907e55a6551e547996af443358 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 27 Jul 2017 16:16:14 +0200 Subject: [PATCH 096/222] Add icons to patron + new icon folder --- app/assets/stylesheets/new_design/icons.scss | 8 ++++++++ app/views/root/patron.html.haml | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/app/assets/stylesheets/new_design/icons.scss b/app/assets/stylesheets/new_design/icons.scss index 4c4841270..0f15821f4 100644 --- a/app/assets/stylesheets/new_design/icons.scss +++ b/app/assets/stylesheets/new_design/icons.scss @@ -1,5 +1,9 @@ i { display: inline-block; + width: 24px; + height: 24px; + background-size: 24px 24px; + vertical-align: bottom; &.follow { background-image: image-url("icons/follow-folder.svg"); @@ -16,4 +20,8 @@ i { &.unarchive { background-image: image-url("icons/unarchive.svg"); } + + &.folder { + background-image: image-url("icons/folder.svg"); + } } diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 944142523..383c520c1 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -1,5 +1,13 @@ .patron .container + %h1 Icones + + %i.follow + %i.unfollow + %i.archive + %i.unarchive + %i.folder + %h1 Formulaires %form.form From c05c1ae72d4e13e7a76e70f75b6ed34683502bc5 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 31 Jul 2017 14:00:28 +0200 Subject: [PATCH 097/222] Fix sticky footer --- app/assets/stylesheets/new_design/common.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/new_design/common.scss b/app/assets/stylesheets/new_design/common.scss index b4e213382..fc2345111 100644 --- a/app/assets/stylesheets/new_design/common.scss +++ b/app/assets/stylesheets/new_design/common.scss @@ -16,6 +16,7 @@ select { .page-wrapper { position: relative; padding-bottom: $footer-height; + min-height: 100%; @media (max-width: 1000px) { padding-bottom: $footer-height-mobile; From 74c71a3776a1eb894b0fb19f8d39f580963caa57 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 2 Aug 2017 14:56:08 +0200 Subject: [PATCH 098/222] Form: use rails form helper --- app/controllers/root_controller.rb | 12 ++++++---- app/models/dossier.rb | 2 ++ .../dossiers/champs/_address.html.haml | 9 +++---- .../dossiers/champs/_champ_label.html.haml | 2 +- .../dossiers/champs/_checkbox.html.haml | 11 ++++----- .../dossiers/champs/_civilite.html.haml | 6 ++--- .../dossiers/champs/_date.html.haml | 10 ++++---- .../dossiers/champs/_datetime.html.haml | 24 ++++--------------- .../dossiers/champs/_departements.html.haml | 7 +++--- .../dossiers/champs/_dossier_link.html.haml | 13 ++++------ .../dossiers/champs/_drop_down_list.html.haml | 12 ++++------ .../dossiers/champs/_email.html.haml | 9 +++---- .../dossiers/champs/_engagement.html.haml | 11 ++++----- .../champs/_multiple_drop_down_list.html.haml | 12 +++++----- .../dossiers/champs/_number.html.haml | 9 +++---- .../dossiers/champs/_pays.html.haml | 7 +++--- .../dossiers/champs/_phone.html.haml | 9 +++---- .../dossiers/champs/_regions.html.haml | 7 +++--- .../dossiers/champs/_text.html.haml | 9 +++---- .../dossiers/champs/_textarea.html.haml | 11 ++++----- .../dossiers/champs/_yes_no.html.haml | 6 ++--- app/views/root/patron.html.haml | 16 ++++++++----- 22 files changed, 92 insertions(+), 122 deletions(-) diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 0bb093d67..6837a259e 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -32,19 +32,19 @@ class RootController < ApplicationController end def patron - @all_champs = TypeDeChamp.type_champs + all_champs = TypeDeChamp.type_champs .map { |name, _| TypeDeChamp.new(type_champ: name, libelle: name, mandatory: true) } - .map { |type_de_champ| Champ.new(type_de_champ: type_de_champ) } + .map { |type_de_champ| ChampPublic.new(type_de_champ: type_de_champ) } .map.with_index do |champ, i| champ.id = i champ end - @all_champs + all_champs .select { |champ| champ.type_champ == 'header_section' } .each { |champ| champ.type_de_champ.libelle = 'un super titre de section' } - @all_champs + all_champs .select { |champ| %w(drop_down_list multiple_drop_down_list).include?(champ.type_champ) } .each do |champ| champ.type_de_champ.drop_down_list = DropDownList.new(type_de_champ: champ.type_de_champ) @@ -64,9 +64,11 @@ option C" } type_champ_values.each do |(type_champ, value)| - @all_champs + all_champs .select { |champ| champ.type_champ == type_champ.to_s } .each { |champ| champ.value = value } end + + @dossier = Dossier.new(champs: all_champs) end end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index d96e90b1a..fd0a1279a 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -43,6 +43,8 @@ class Dossier < ActiveRecord::Base belongs_to :procedure belongs_to :user + accepts_nested_attributes_for :champs + default_scope { where(hidden_at: nil) } scope :state_brouillon, -> { where(state: BROUILLON) } scope :state_not_brouillon, -> { where.not(state: BROUILLON) } diff --git a/app/views/new_gestionnaire/dossiers/champs/_address.html.haml b/app/views/new_gestionnaire/dossiers/champs/_address.html.haml index af9fb84c2..c0707410f 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_address.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_address.html.haml @@ -1,9 +1,6 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -%input{ type: 'text', += form.text_field :value, 'data-address': 'true', - name: "champs['#{champ.id}']", - id: "champs_#{champ.id}", placeholder: champ.libelle, - value: champ.value, - required: champ.mandatory } + required: champ.mandatory 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 7807b7c6a..b2e5960e4 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml @@ -1 +1 @@ -%label{ for: :"champs_#{champ.id}" }> #{champ.libelle} #{champ.mandatory ? '*' : nil} += form.label :value, "#{champ.libelle} #{champ.mandatory ? '*' : nil}" diff --git a/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml b/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml index 09600b354..2668405ba 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_checkbox.html.haml @@ -1,9 +1,8 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -%input{ type: 'checkbox', - name: "champs['#{champ.id}']", - id: "champs_#{champ.id}", - checked: ('checked' if champ.value == 'on'), - required: champ.mandatory } += form.check_box :value, + { required: champ.mandatory }, + 'on', + 'off' %br diff --git a/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml b/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml index 734cf98ac..01952292d 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_civilite.html.haml @@ -1,10 +1,10 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } %div %label - = radio_button_tag "champs['#{champ.id}']", "M.", champ.value == 'Mme' ? false : true + = form.radio_button :value, 'M.' Monsieur %label - = radio_button_tag "champs['#{champ.id}']", "Mme", champ.value == 'Mme' + = form.radio_button :value, 'Mme.' Madame diff --git a/app/views/new_gestionnaire/dossiers/champs/_date.html.haml b/app/views/new_gestionnaire/dossiers/champs/_date.html.haml index 0e8060144..5bdd4ad45 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_date.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_date.html.haml @@ -1,8 +1,6 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -%input{ name: "champs['#{champ.id}']", - placeholder: "JJ/MM/AAAA", - id: "champs_#{champ.id}", += form.date_field :value, value: champ.value, - type: "date", - required: champ.mandatory } + placeholder: 'JJ/MM/AAAA', + required: champ.mandatory diff --git a/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml b/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml index 8704e17bc..4dabb6705 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_datetime.html.haml @@ -1,22 +1,6 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } + +- parsed_value = champ.value.present? ? DateTime.parse(champ.value) : DateTime.now .datetime - %input{ name: "champs['#{champ.id}']", - placeholder: champ.libelle, - id: "champs_#{champ.id}", - value: (champ.value.split(/[ ][0-9]*:[0-9]*/).first unless champ.value.nil?), - type: 'date', - required: champ.mandatory } - - %select{ name: "time_hour['#{champ.id}']", id: "time_hour_#{champ.id}", required: champ.mandatory } - - (0..23).each do |num| - - num = "%.2i" %num - %option{ value: num, selected: (:selected if champ.same_hour?(num)) } - = num - h - %select{ name: "time_minute['#{champ.id}']", id: "time_minute_#{champ.id}", required: champ.mandatory } - - (0..55).step(5) do |num| - - num = "%.2i" %num - %option{ value: num, selected: (:selected if champ.same_minute?(num)) } - = num - min + = form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5) diff --git a/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml b/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml index 8ef409bed..c16358e58 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_departements.html.haml @@ -1,4 +1,5 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -= select_tag("champs['#{champ.id}']", - options_for_select(Champ.departements, selected: champ.value)) += form.select :value, + Champ.departements, + required: champ.mandatory 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 8ecf58dc3..54c9d9b12 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: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } - dossier = Dossier.find_by(id: champ.value) - show_text_summary = dossier.present? @@ -6,14 +6,11 @@ - text_summary = dossier.try(:text_summary) .dossier-link - %input{ name: "champs['#{ champ.id }']", + = form.number_field :value, placeholder: "Numéro de dossier", - id: "champs_#{ champ.id }", - value: champ.value, - type: 'number', - 'autocomplete' => 'off', - 'data-type' => 'dossier-link', - required: champ.mandatory } + autocomplete: 'off', + 'data-type': 'dossier-link', + required: champ.mandatory .help-block %p.text-info{ style: show_text_summary ? nil : 'display: none;' } 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 c915b1797..c629a8cc8 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,8 +1,6 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -- if champ.drop_down_list && champ.drop_down_list.options.any? - = select_tag("champs['#{champ.id}']", - options_for_select(champ.drop_down_list.options, - selected: champ.drop_down_list.selected_options_without_decorator(champ), - disabled: champ.drop_down_list.disabled_options), - multiple: false) += form.select :value, + champ.drop_down_list.options, + disabled: champ.drop_down_list.disabled_options, + required: champ.mandatory diff --git a/app/views/new_gestionnaire/dossiers/champs/_email.html.haml b/app/views/new_gestionnaire/dossiers/champs/_email.html.haml index 6684b7865..c9819de88 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_email.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_email.html.haml @@ -1,8 +1,5 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -%input{ type: 'email', - name: "champs['#{champ.id}']", - id: "champs_#{champ.id}", += form.email_field :value, placeholder: champ.libelle, - value: champ.value, - required: champ.mandatory } + required: champ.mandatory diff --git a/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml b/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml index 09600b354..2668405ba 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_engagement.html.haml @@ -1,9 +1,8 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -%input{ type: 'checkbox', - name: "champs['#{champ.id}']", - id: "champs_#{champ.id}", - checked: ('checked' if champ.value == 'on'), - required: champ.mandatory } += form.check_box :value, + { required: champ.mandatory }, + 'on', + 'off' %br 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 248fb1932..5f0fb9439 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,9 +1,9 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } - if champ.drop_down_list && champ.drop_down_list.options.any? - = select_tag("champs['#{champ.id}']", - options_for_select(champ.drop_down_list.options, - selected: champ.drop_down_list.selected_options_without_decorator(champ), - disabled: champ.drop_down_list.disabled_options), + = form.select :value, + champ.drop_down_list.options, + { selected: champ.drop_down_list.selected_options_without_decorator(champ), + disabled: champ.drop_down_list.disabled_options }, multiple: true, - class: 'select2') + class: 'select2' diff --git a/app/views/new_gestionnaire/dossiers/champs/_number.html.haml b/app/views/new_gestionnaire/dossiers/champs/_number.html.haml index 5e2b61e8d..c9bcb8eae 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_number.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_number.html.haml @@ -1,8 +1,5 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -%input{ type: 'number', - name: "champs['#{champ.id}']", - id: "champs_#{champ.id}", += form.number_field :value, placeholder: champ.libelle, - value: champ.value, - required: champ.mandatory } + required: champ.mandatory diff --git a/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml b/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml index 96962d7dc..cad18df07 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_pays.html.haml @@ -1,4 +1,5 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -= select_tag("champs['#{champ.id}']", - options_for_select(Champ.pays, selected: champ.value)) += form.select :value, + Champ.pays, + required: champ.mandatory diff --git a/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml b/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml index c1bbfd1ce..e42dbfad1 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_phone.html.haml @@ -1,8 +1,5 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -%input{ type: 'tel', - name: "champs['#{champ.id}']", - id: "champs_#{champ.id}", += form.phone_field :value, placeholder: champ.libelle, - value: champ.value, - required: champ.mandatory } + required: champ.mandatory diff --git a/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml b/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml index ad4cf5531..eb9ffaf8d 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_regions.html.haml @@ -1,4 +1,5 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -= select_tag("champs['#{champ.id}']", - options_for_select(Champ.regions, selected: champ.value)) += form.select :value, + Champ.regions, + required: champ.mandatory diff --git a/app/views/new_gestionnaire/dossiers/champs/_text.html.haml b/app/views/new_gestionnaire/dossiers/champs/_text.html.haml index e42aa8584..2e34ffa6c 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_text.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_text.html.haml @@ -1,8 +1,5 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -%input{ type: 'text', - name: "champs['#{champ.id}']", - id: "champs_#{champ.id}", += form.text_field :value, placeholder: champ.libelle, - value: champ.value, - required: champ.mandatory } + required: champ.mandatory diff --git a/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml b/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml index 37c5e031d..88c5803aa 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_textarea.html.haml @@ -1,8 +1,7 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -%textarea{ name: "champs['#{champ.id}']", += form.text_area :value, + row: 6, placeholder: champ.description, - id: "champs_#{champ.id}", - row: '6', - required: champ.mandatory } - = sanitize(champ.value) + required: champ.mandatory, + value: sanitize(champ.value) 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 802595b19..9e9207f86 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_yes_no.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_yes_no.html.haml @@ -1,10 +1,10 @@ -= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { champ: champ } += render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } %div %label - = radio_button_tag "champs['#{champ.id}']", "true", champ.value == 'true' + = form.radio_button :value, true Oui %label - = radio_button_tag "champs['#{champ.id}']", "false", champ.value == 'false' + = form.radio_button :value, false Non diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 383c520c1..a0c61bb4c 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -11,12 +11,16 @@ %h1 Formulaires %form.form - - @all_champs.each do |champ| - = render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}", locals: { champ: champ } - %input{ type: "password", value: "12345678" } - .send-wrapper - %input.button.send{ type: "submit", value: "Enregistrer un brouillon (formnovalidate)", formnovalidate: true } - %input.button.send{ type: "submit", value: "Envoyer" } + = 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 } + + %input{ type: "password", value: "12345678" } + .send-wrapper + = f.submit 'Enregistrer un brouillon (formnovalidate)', formnovalidate: true, class: 'button send' + = f.submit 'Envoyer', class: 'button send' %h1 Boutons From d4bbcdf6823cb3fed53ca4cf4c21153b6303f1a2 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 27 Jul 2017 20:54:02 +0200 Subject: [PATCH 099/222] Champ: add before save logic to serialize datetime and dropdownlist fields --- app/models/champ.rb | 29 +++++++++++++++++++ spec/models/champ_spec.rb | 59 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/app/models/champ.rb b/app/models/champ.rb index 58ad82378..e509751c7 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -6,6 +6,9 @@ class Champ < ActiveRecord::Base delegate :libelle, :type_champ, :order_place, :mandatory, :description, :drop_down_list, to: :type_de_champ before_save :format_date_to_iso, if: Proc.new { type_champ == 'date' } + before_save :serialize_datetime_if_needed, if: Proc.new { type_champ == 'datetime' } + before_save :multiple_select_to_string, if: Proc.new { type_champ == 'multiple_drop_down_list' } + after_save :internal_notification, if: Proc.new { !dossier.nil? } def mandatory? @@ -65,9 +68,35 @@ class Champ < ActiveRecord::Base self.value = date end + def serialize_datetime_if_needed + if (value =~ /=>/).present? + date = begin + hash_date = YAML.safe_load(value.gsub('=>', ': ')) + year, month, day, hour, minute = hash_date.values_at(1,2,3,4,5) + DateTime.new(year, month, day, hour, minute).strftime("%d/%m/%Y %H:%M") + rescue + nil + end + + self.value = date + end + end + def internal_notification unless dossier.state == 'draft' NotificationService.new('champs', self.dossier.id, self.libelle).notify end end + + def multiple_select_to_string + if value.present? + json = JSON.parse(value) + if json == [''] + self.value = nil + else + json = json - [''] + self.value = json.to_s + end + end + end end diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb index 868001afc..4769a6e7f 100644 --- a/spec/models/champ_spec.rb +++ b/spec/models/champ_spec.rb @@ -4,4 +4,63 @@ describe Champ do require 'models/champ_shared_example.rb' it_should_behave_like "champ_spec" + + describe '#serialize_datetime_if_needed' do + let(:type_de_champ) { TypeDeChamp.new(type_champ: 'datetime') } + let(:champ) { Champ.new(type_de_champ: type_de_champ, value: value) } + + before { champ.save } + + # when using the old form, and the ChampsService Class + # TODO: to remove + context 'when the value is already serialized' do + let(:value) { '12/01/2017 10:23' } + + it { expect(champ.value).to eq(value) } + end + + context 'when the value is not already serialized' do + let(:value) { '{ 1=>2017, 2=>01, 3=>12, 4=>10, 5=>23 }' } + + it { expect(champ.value).to eq('12/01/2017 10:23') } + end + end + + describe '#multiple_select_to_string' do + let(:type_de_champ) { TypeDeChamp.new(type_champ: 'multiple_drop_down_list') } + let(:champ) { Champ.new(type_de_champ: type_de_champ, value: value) } + + before { champ.save } + + # when using the old form, and the ChampsService Class + # TODO: to remove + context 'when the value is already deserialized' do + let(:value) { '["1", "2"]' } + + it { expect(champ.value).to eq(value) } + + context 'when the value is nil' do + let(:value) { nil } + + it { expect(champ.value).to eq(value) } + end + end + + # for explanation for the "" entry, see + # https://apidock.com/rails/ActionView/Helpers/FormOptionsHelper/select + # GOTCHA + context 'when the value is not already deserialized' do + context 'when a choice is selected' do + let(:value) { '["", "1", "2"]' } + + it { expect(champ.value).to eq('["1", "2"]') } + end + + context 'when all choices are removed' do + let(:value) { '[""]' } + + it { expect(champ.value).to eq(nil) } + end + end + end end From 46c144146cadaa5d1284af1e2d1b925e82e10d4d Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 2 Aug 2017 15:29:12 +0200 Subject: [PATCH 100/222] Form: add description --- app/assets/stylesheets/new_design/forms.scss | 11 +++++++++-- app/controllers/root_controller.rb | 4 +++- .../dossiers/champs/_champ_label.html.haml | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index 043585de6..9b5c7bc72 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -8,8 +8,15 @@ } label { - margin-bottom: $default-spacer; - display: inline-block; + margin-bottom: $default-padding; + display: block; + + .notice { + font-size: 14px; + display: block; + margin-top: $default-spacer; + color: $grey; + } } input[type=text]:not([data-address='true']), diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 6837a259e..981e53fed 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -32,8 +32,10 @@ class RootController < ApplicationController end def patron + description = 'a not so long description' + all_champs = TypeDeChamp.type_champs - .map { |name, _| TypeDeChamp.new(type_champ: name, libelle: name, mandatory: true) } + .map { |name, _| TypeDeChamp.new(type_champ: name, libelle: name, description: description, mandatory: true) } .map { |type_de_champ| ChampPublic.new(type_de_champ: type_de_champ) } .map.with_index do |champ, i| champ.id = i 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 b2e5960e4..b6dc5e579 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml @@ -1 +1,4 @@ -= form.label :value, "#{champ.libelle} #{champ.mandatory ? '*' : nil}" += form.label :value do + #{champ.libelle} #{champ.mandatory ? '*' : nil} + - if champ.description.present? + %span.notice= champ.description From 9d7066d3c38b710cedb8dbfe36ab495a169106bf Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 2 Aug 2017 15:30:42 +0200 Subject: [PATCH 101/222] Form: display mandatory star in red --- app/assets/stylesheets/new_design/forms.scss | 4 ++++ .../new_gestionnaire/dossiers/champs/_champ_label.html.haml | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/forms.scss b/app/assets/stylesheets/new_design/forms.scss index 9b5c7bc72..759b8b643 100644 --- a/app/assets/stylesheets/new_design/forms.scss +++ b/app/assets/stylesheets/new_design/forms.scss @@ -11,6 +11,10 @@ margin-bottom: $default-padding; display: block; + .mandatory { + color: $dark-red; + } + .notice { font-size: 14px; display: block; 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 b6dc5e579..000439a3a 100644 --- a/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml +++ b/app/views/new_gestionnaire/dossiers/champs/_champ_label.html.haml @@ -1,4 +1,6 @@ = form.label :value do - #{champ.libelle} #{champ.mandatory ? '*' : nil} + #{champ.libelle} + - if champ.mandatory + %span.mandatory * - if champ.description.present? %span.notice= champ.description From f03d8ef909578bda91996d1d6afc59d419eda7aa Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 19 Jul 2017 16:53:31 +0200 Subject: [PATCH 102/222] NewDesign: add dossier instruction view --- .../new_design/dossier_instruction.scss | 17 +++++++++++++++++ .../new_gestionnaire/dossiers_controller.rb | 4 ++++ .../new_gestionnaire/dossiers/_header.html.haml | 2 +- .../dossiers/instruction.html.haml | 6 ++++++ config/routes.rb | 1 + 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/assets/stylesheets/new_design/dossier_instruction.scss create mode 100644 app/views/new_gestionnaire/dossiers/instruction.html.haml diff --git a/app/assets/stylesheets/new_design/dossier_instruction.scss b/app/assets/stylesheets/new_design/dossier_instruction.scss new file mode 100644 index 000000000..bfa5ceb20 --- /dev/null +++ b/app/assets/stylesheets/new_design/dossier_instruction.scss @@ -0,0 +1,17 @@ +@import "colors"; +@import "common"; +@import "constants"; + +#dossier-instruction { + h1 { + font-size: 18px; + font-weight: bold; + margin-bottom: $default-padding; + } + + .avis-notice { + font-size: 12px; + color: $grey; + margin-bottom: 2 * $default-padding; + } +} diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index c2e622386..6b37461f9 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -12,6 +12,10 @@ module NewGestionnaire @dossier = dossier end + def instruction + @dossier = dossier + end + def follow current_gestionnaire.follow(dossier) dossier.next_step!('gestionnaire', 'follow') diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 9e503420f..f7aa7eda2 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -9,7 +9,7 @@ %li = link_to "Demande", dossier_path(dossier.procedure, dossier), class: ("selected" if current_page?(dossier_path(dossier.procedure, dossier))) %li - = link_to "Instruction", "#" + = link_to "Instruction", instruction_dossier_path(dossier.procedure, dossier), class: current_page?(instruction_dossier_path(dossier.procedure, dossier)) ? 'selected' : nil %li = link_to "Messagerie", messagerie_dossier_path(dossier.procedure, dossier), class: current_page?(messagerie_dossier_path(dossier.procedure, dossier)) ? 'selected' : nil %li diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml new file mode 100644 index 000000000..4323c8afa --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -0,0 +1,6 @@ += render partial: "header", locals: { dossier: @dossier } + +#dossier-instruction.container + %section + %h1 Inviter une personne à donner son avis + %p.avis-notice Elle pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais elle ne pourra le modifier. diff --git a/config/routes.rb b/config/routes.rb index 66c9975d0..1b8eb1f22 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -243,6 +243,7 @@ Rails.application.routes.draw do member do get 'attestation' get 'messagerie' + get 'instruction' patch 'follow' patch 'unfollow' patch 'archive' From 2923d4448bdc8c40f006f24aa593052d8f4703f3 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 28 Aug 2017 14:16:13 +0200 Subject: [PATCH 103/222] NewDesign: can ask a new avis --- .../new_design/dossier_instruction.scss | 4 ++++ .../new_gestionnaire/dossiers_controller.rb | 9 +++++++++ .../dossiers/instruction.html.haml | 6 ++++++ config/routes.rb | 1 + .../dossiers_controller_spec.rb | 18 ++++++++++++++++++ 5 files changed, 38 insertions(+) diff --git a/app/assets/stylesheets/new_design/dossier_instruction.scss b/app/assets/stylesheets/new_design/dossier_instruction.scss index bfa5ceb20..68edfe61c 100644 --- a/app/assets/stylesheets/new_design/dossier_instruction.scss +++ b/app/assets/stylesheets/new_design/dossier_instruction.scss @@ -14,4 +14,8 @@ color: $grey; margin-bottom: 2 * $default-padding; } + + input[type=email] { + max-width: 500px; + } } diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 6b37461f9..af7eeaa7f 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -61,6 +61,11 @@ module NewGestionnaire render json: { lon: lon, lat: lat, zoom: zoom, dossier_id: params[:dossier_id] } end + def create_avis + Avis.create(avis_params.merge(claimant: current_gestionnaire, dossier: dossier)) + redirect_to instruction_dossier_path(dossier.procedure, dossier) + end + private def dossier @@ -70,5 +75,9 @@ module NewGestionnaire def commentaire_params params.require(:commentaire).permit(:body) end + + def avis_params + params.require(:avis).permit(:email, :introduction) + end end end diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml index 4323c8afa..62c654281 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -4,3 +4,9 @@ %section %h1 Inviter une personne à donner son avis %p.avis-notice Elle pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais elle ne pourra le modifier. + + = form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f| + = f.email_field :email, placeholder: 'Adresse email', required: true + = f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true + .send-wrapper + = f.submit 'Demander un avis', class: 'button send' diff --git a/config/routes.rb b/config/routes.rb index 1b8eb1f22..ca60cdae1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -252,6 +252,7 @@ Rails.application.routes.draw do scope :carte do get 'position' end + post 'avis' => 'dossiers#create_avis' end end end diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index c1e5ac4c2..946a4e5aa 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -94,4 +94,22 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(saved_commentaire.dossier).to eq(dossier) } it { expect(response).to redirect_to(messagerie_dossier_path(dossier.procedure, dossier)) } end + + describe "#create_avis" do + let(:saved_avis) { dossier.avis.first } + + before do + post :create_avis, params: { + procedure_id: procedure.id, + dossier_id: dossier.id, + avis: { email: 'email@a.com', introduction: 'intro' } + } + end + + it { expect(saved_avis.email).to eq('email@a.com') } + it { expect(saved_avis.introduction).to eq('intro') } + it { expect(saved_avis.dossier).to eq(dossier) } + it { expect(saved_avis.claimant).to eq(gestionnaire) } + it { expect(response).to redirect_to(instruction_dossier_path(dossier.procedure, dossier)) } + end end From b94fc7c132e7f192878567e6fb62bb12186191bd Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 26 Jul 2017 11:22:04 +0200 Subject: [PATCH 104/222] NewDesign: list of avis --- app/assets/images/icons/bubble.svg | 1 + .../new_design/dossier_instruction.scss | 50 +++++++++++++++++++ .../dossiers/instruction.html.haml | 25 ++++++++++ 3 files changed, 76 insertions(+) create mode 100644 app/assets/images/icons/bubble.svg diff --git a/app/assets/images/icons/bubble.svg b/app/assets/images/icons/bubble.svg new file mode 100644 index 000000000..d423f2f4b --- /dev/null +++ b/app/assets/images/icons/bubble.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/new_design/dossier_instruction.scss b/app/assets/stylesheets/new_design/dossier_instruction.scss index 68edfe61c..6a4ec475c 100644 --- a/app/assets/stylesheets/new_design/dossier_instruction.scss +++ b/app/assets/stylesheets/new_design/dossier_instruction.scss @@ -18,4 +18,54 @@ input[type=email] { max-width: 500px; } + + .avis { + .title { + margin-bottom: $default-padding; + + .count { + display: inline-block; + width: 20px; + height: 20px; + border-radius: 10px; + border: 1px solid $grey; + text-align: center; + font-size: 12px; + font-weight: normal; + margin-left: 8px; + } + } + + .one-avis { + border-top: 1px solid $grey; + padding: $default-padding 0; + + h2 { + font-weight: bold; + margin-bottom: $default-spacer; + + span { + font-weight: normal; + } + } + + .answer { + margin-top: $default-padding; + } + + .avis-icon { + margin-right: $default-spacer; + } + } + + .date, + .waiting { + font-size: 12px; + color: $grey; + } + + .date { + float: right; + } + } } diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml index 62c654281..7cc345d3b 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -10,3 +10,28 @@ = f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true .send-wrapper = f.submit 'Demander un avis', class: 'button send' + + - if @dossier.avis.present? + %section.avis + %h1.title + Avis des invités + %span.count= @dossier.avis.count + + %ul + - @dossier.avis.each do |avis| + %li.one-avis + %h2.claimant + = (avis.claimant.email == current_gestionnaire.email) ? 'Vous' : avis.claimant.email + %span.date Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y')} + %p= avis.introduction + + .answer.flex.align-start + = image_tag 'icons/bubble.svg', class: 'avis-icon' + .width-100 + %h2.gestionnaire + = avis.gestionnaire.email + - if avis.answer.present? + %span.date Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y')} + - else + %span.waiting En attente de réponse + %p= avis.answer From 3e5d0dce6ac1648f0b7bb9acdec4d2489043051b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 2 Aug 2017 15:33:23 +0200 Subject: [PATCH 105/222] NewDesign: can add annotations --- .../new_gestionnaire/dossiers_controller.rb | 10 ++++ app/models/dossier.rb | 1 + .../dossiers/instruction.html.haml | 13 ++++++ config/routes.rb | 1 + .../dossiers_controller_spec.rb | 46 +++++++++++++++++++ 5 files changed, 71 insertions(+) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index af7eeaa7f..e76364587 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -66,6 +66,12 @@ module NewGestionnaire redirect_to instruction_dossier_path(dossier.procedure, dossier) end + def update_annotations + dossier = current_gestionnaire.dossiers.includes(champs_private: :type_de_champ).find(params[:dossier_id]) + dossier.update_attributes(champs_private_params) + redirect_to instruction_dossier_path(dossier.procedure, dossier) + end + private def dossier @@ -79,5 +85,9 @@ module NewGestionnaire def avis_params params.require(:avis).permit(:email, :introduction) end + + def champs_private_params + params.require(:dossier).permit(champs_private_attributes: [:id, :value, value: []]) + end end end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index fd0a1279a..3c91b9bc7 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -44,6 +44,7 @@ class Dossier < ActiveRecord::Base belongs_to :user accepts_nested_attributes_for :champs + accepts_nested_attributes_for :champs_private default_scope { where(hidden_at: nil) } scope :state_brouillon, -> { where(state: BROUILLON) } diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml index 7cc345d3b..652eda87a 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -35,3 +35,16 @@ - else %span.waiting En attente de réponse %p= avis.answer + + - if @dossier.ordered_champs_private.present? + %section + %h1.private-annotations Annotations privées + .card.featured + = 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 } + + .send-wrapper + = f.submit 'Sauvegarder', class: 'button send' diff --git a/config/routes.rb b/config/routes.rb index ca60cdae1..6d45eaa11 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -248,6 +248,7 @@ Rails.application.routes.draw do patch 'unfollow' patch 'archive' patch 'unarchive' + patch 'annotations' => 'dossiers#update_annotations' post 'commentaire' => 'dossiers#create_commentaire' scope :carte do get 'position' diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 946a4e5aa..032cc83e9 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -112,4 +112,50 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(saved_avis.claimant).to eq(gestionnaire) } it { expect(response).to redirect_to(instruction_dossier_path(dossier.procedure, dossier)) } end + + describe "#update_annotations" do + let(:champ_multiple_drop_down_list) do + type_de_champ = TypeDeChamp.create(type_champ: 'multiple_drop_down_list', libelle: 'libelle') + ChampPrivate.create(type_de_champ: type_de_champ) + end + + let(:champ_datetime) do + type_de_champ = TypeDeChamp.create(type_champ: 'datetime', libelle: 'libelle') + ChampPrivate.create(type_de_champ: type_de_champ) + end + + let(:dossier) do + create(:dossier, :replied, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_datetime]) + end + + before do + patch :update_annotations, params: { + procedure_id: procedure.id, + dossier_id: dossier.id, + dossier: { + champs_private_attributes: { + '0': { + id: champ_multiple_drop_down_list.id, + value: ['', 'un', 'deux'] + }, + '1': { + id: champ_datetime.id, + 'value(1i)': 2019, + 'value(2i)': 12, + 'value(3i)': 21, + 'value(4i)': 13, + 'value(5i)': 17 + } + } + } + } + + champ_multiple_drop_down_list.reload + champ_datetime.reload + end + + it { expect(champ_multiple_drop_down_list.value).to eq('["un", "deux"]') } + it { expect(champ_datetime.value).to eq('21/12/2019 13:17') } + it { expect(response).to redirect_to(instruction_dossier_path(dossier.procedure, dossier)) } + end end From 49a656db76729048d631572daa1dddec94b22d72 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 28 Aug 2017 16:44:06 +0200 Subject: [PATCH 106/222] New_design: make the procedure list more awesome --- app/views/new_gestionnaire/procedures/index.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index 953091bc0..014063f7f 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -4,11 +4,11 @@ %ul.procedure-list - @procedures.each do |p| %li.procedure-item.flex.align-start - - if p.logo.present? - = image_tag p.logo, class: "procedure-logo" .procedure-details %p.procedure-title + - if p.logo.present? + = image_tag p.logo, class: "procedure-logo" = link_to(p.libelle, procedure_path(p)) %ul.procedure-stats.flex From 08aa2ac524f7fb11083d5158133c84aff685994b Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Wed, 16 Aug 2017 17:48:03 +0200 Subject: [PATCH 107/222] Redesign the tabs so that they look more like tabs --- .../new_design/procedures_show.scss | 56 ++++++++++--------- .../procedures/show.html.haml | 10 ++-- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index e0e82c79e..fb96da7ba 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -16,50 +16,52 @@ .dossiers-categories { li { display: inline-block; - height: 56px; - width: 130px; - line-height: 17px; + line-height: 36px; position: relative; text-align: center; font-size: 14px; + padding-left: 20px; + padding-right: 20px; + border-radius: 3px 3px 0 0; + border: 1px solid transparent; a { color: $black; } - &::before, - &:last-child::after { - content: ""; - position: absolute; - height: 36px; - width: 1px; - background-color: $border-grey; - margin-right: $default-padding; - } - - &::before { - left: 0px; - } - - &:last-child::after { - right: 0px; - top: 0px; - margin-right: 0px; - } - &.active { - border-bottom: 2px solid $blue; + background-color: white; + border-top: 1px solid $border-grey; + border-left: 1px solid $border-grey; + border-right: 1px solid $border-grey; a { color: $blue; } + + .dossiers-count { + color: $blue; + } + } + + &:hover { + a { + color: $blue; + } + + .dossiers-count { + color: $blue; + } } .dossiers-count { - position: relative; - display: block; - font-size: 16px; + background-color: rgba(0,0,0,0.08); + padding-left: 5px; + padding-right: 5px; + border-radius: 100px; font-weight: bold; + color: rgba(0,0,0,0.6); + font-size: 14px; } } } diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 1c983751f..59cc92663 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -9,28 +9,28 @@ %ul.dossiers-categories %li{ class: (@statut == 'a-suivre') ? 'active' : nil }> = link_to(procedure_path(@procedure, statut: 'a-suivre')) do - %span.dossiers-count= @a_suivre_dossiers.count à suivre + %span.dossiers-count= @a_suivre_dossiers.count %li{ class: (@statut == 'suivis') ? 'active' : nil }> = link_to(procedure_path(@procedure, statut: 'suivis')) do - %span.dossiers-count= @followed_dossiers.count = t('pluralize.followed', count: @followed_dossiers.count) + %span.dossiers-count= @followed_dossiers.count %li{ class: (@statut == 'traites') ? 'active' : nil }> = link_to(procedure_path(@procedure, statut: 'traites')) do - %span.dossiers-count= @termines_dossiers.count = t('pluralize.processed', count: @termines_dossiers.count) + %span.dossiers-count= @termines_dossiers.count %li{ class: (@statut == 'tous') ? 'active' : nil }> = link_to(procedure_path(@procedure, statut: 'tous')) do - %span.dossiers-count= @all_state_dossiers.count tous les dossiers + %span.dossiers-count= @all_state_dossiers.count %li{ class: (@statut == 'archives') ? 'active' : nil }> = link_to(procedure_path(@procedure, statut: 'archives')) do - %span.dossiers-count= @archived_dossiers.count = t('pluralize.archived', count: @archived_dossiers.count) + %span.dossiers-count= @archived_dossiers.count .container - if @dossiers.present? From 7af3f90197f6c611351233a4fd439731ce22b34d Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 28 Aug 2017 10:46:27 +0200 Subject: [PATCH 108/222] Rename header-left-menu to header-tabs --- app/assets/stylesheets/new_design/new_header.scss | 2 +- app/views/layouts/_new_header.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss index 8ffabdea3..41320b3fe 100644 --- a/app/assets/stylesheets/new_design/new_header.scss +++ b/app/assets/stylesheets/new_design/new_header.scss @@ -25,7 +25,7 @@ margin-right: 4 * $default-spacer; } -.header-left-menu { +.header-tabs { li { display: inline-block; } diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index e8fab8fb4..f05f4b060 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -6,7 +6,7 @@ %img{ src: image_url("header/logo-tps.svg") } - if gestionnaire_signed_in? - %ul.header-left-menu + %ul.header-tabs %li = link_to "Procédures", procedures_path, class: "active" From 7c1eed760ad35f9502e52b875d5d75c820c47475 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 28 Aug 2017 10:48:44 +0200 Subject: [PATCH 109/222] Remove from patron a case that does not exist We never use tabs somewhere else than in a header --- app/views/root/patron.html.haml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index a0c61bb4c..5b6093075 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -51,16 +51,6 @@ %p = link_to ".button.primary.expand", "#", class: "button primary expand" - %h1 Onglets - - %ul.tabs - %li - = link_to "Onglet 1", "#", class: "selected" - %li - = link_to "Onglet 2", "#" - %li - = link_to "Onglet 3", "#" - %h1 Labels %span.label .label From cc54fec629cf2be4c36301939dd495e2a6720279 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 28 Aug 2017 10:50:48 +0200 Subject: [PATCH 110/222] Redesign the tabs so that they look more like tabs --- app/assets/stylesheets/new_design/_tabs.scss | 36 +++++++++++++------ .../dossiers/_header.html.haml | 12 +++---- app/views/root/patron.html.haml | 4 +-- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/app/assets/stylesheets/new_design/_tabs.scss b/app/assets/stylesheets/new_design/_tabs.scss index 205256ce8..446830629 100644 --- a/app/assets/stylesheets/new_design/_tabs.scss +++ b/app/assets/stylesheets/new_design/_tabs.scss @@ -4,19 +4,35 @@ .tabs { li { display: inline-block; - margin-right: 40px; - } + line-height: 36px; + position: relative; + text-align: center; + font-size: 14px; + border-radius: 3px 3px 0 0; + border: 1px solid transparent; - a { - @include vertical-padding(14px); - display: block; - color: $black; - font-size: 22px; + a { + display: block; + padding-left: 20px; + padding-right: 20px; + color: $black; + } + + &.active { + background-color: #FFFFFF; + border-top: 1px solid $border-grey; + border-left: 1px solid $border-grey; + border-right: 1px solid $border-grey; + + a { + color: $blue; + } + } - &.selected, &:hover { - border-bottom: 2px solid $blue; - padding-bottom: 12px; + a { + color: $blue; + } } } } diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index f7aa7eda2..7e9ff2d64 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -6,11 +6,11 @@ %li = "Dossier n° #{dossier.id}" %ul.tabs - %li - = link_to "Demande", dossier_path(dossier.procedure, dossier), class: ("selected" if current_page?(dossier_path(dossier.procedure, dossier))) - %li - = link_to "Instruction", instruction_dossier_path(dossier.procedure, dossier), class: current_page?(instruction_dossier_path(dossier.procedure, dossier)) ? 'selected' : nil - %li - = link_to "Messagerie", messagerie_dossier_path(dossier.procedure, dossier), class: current_page?(messagerie_dossier_path(dossier.procedure, dossier)) ? 'selected' : nil + %li{ class: ("active" if current_page?(dossier_path(dossier.procedure, dossier))) } + = link_to "Demande", dossier_path(dossier.procedure, dossier) + %li{ class: current_page?(instruction_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } + = link_to "Instruction", instruction_dossier_path(dossier.procedure, dossier) + %li{ class: current_page?(messagerie_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } + = link_to "Messagerie", messagerie_dossier_path(dossier.procedure, dossier) %li = link_to "Historique", "#" diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 5b6093075..7398e17ca 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -93,8 +93,8 @@ .container Titre %ul.tabs - %li - = link_to "Onglet 1", "#", class: "selected" + %li{ class: "active" } + = link_to "Onglet 1", "#" %li = link_to "Onglet 2", "#" %li From 93cb2ec118656e5f3c0b6c0d45e84b0c7a0a9fff Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 28 Aug 2017 10:51:40 +0200 Subject: [PATCH 111/222] Add badge support to tabs --- app/assets/stylesheets/new_design/_tabs.scss | 18 ++++++++++++++++++ app/views/root/patron.html.haml | 10 ++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/new_design/_tabs.scss b/app/assets/stylesheets/new_design/_tabs.scss index 446830629..3a3e23441 100644 --- a/app/assets/stylesheets/new_design/_tabs.scss +++ b/app/assets/stylesheets/new_design/_tabs.scss @@ -27,12 +27,30 @@ a { color: $blue; } + + .badge { + color: $blue; + } } &:hover { a { color: $blue; } + + .badge { + color: $blue; + } + } + + .badge { + background-color: rgba(0, 0, 0, 0.08); + padding-left: 5px; + padding-right: 5px; + border-radius: 100px; + font-weight: bold; + color: rgba(0, 0, 0, 0.6); + font-size: 14px; } } } diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 7398e17ca..03912e26f 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -93,12 +93,14 @@ .container Titre %ul.tabs - %li{ class: "active" } - = link_to "Onglet 1", "#" + %li.active + = link_to "Onglet actif", "#" %li - = link_to "Onglet 2", "#" + = link_to "Onglet inactif", "#" %li - = link_to "Onglet 3", "#" + = link_to "#" do + Onglet avec badge + %span.badge 2 .container %h1 Breadcrumbs From 590c5721069ac364f1a05c6590d3276a89c3b32b Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 28 Aug 2017 10:52:25 +0200 Subject: [PATCH 112/222] Use .tabs instead of .dossier-categories in procedures#show --- .../new_design/procedures_show.scss | 53 ------------------- .../procedures/show.html.haml | 12 ++--- 2 files changed, 6 insertions(+), 59 deletions(-) diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index fb96da7ba..914f65fa1 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -13,59 +13,6 @@ margin-bottom: 2 * $default-padding; } - .dossiers-categories { - li { - display: inline-block; - line-height: 36px; - position: relative; - text-align: center; - font-size: 14px; - padding-left: 20px; - padding-right: 20px; - border-radius: 3px 3px 0 0; - border: 1px solid transparent; - - a { - color: $black; - } - - &.active { - background-color: white; - border-top: 1px solid $border-grey; - border-left: 1px solid $border-grey; - border-right: 1px solid $border-grey; - - a { - color: $blue; - } - - .dossiers-count { - color: $blue; - } - } - - &:hover { - a { - color: $blue; - } - - .dossiers-count { - color: $blue; - } - } - - .dossiers-count { - background-color: rgba(0,0,0,0.08); - padding-left: 5px; - padding-right: 5px; - border-radius: 100px; - font-weight: bold; - color: rgba(0,0,0,0.6); - font-size: 14px; - } - } - } - .dossiers-table { margin: (2 * $default-padding) auto; width: 100%; diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 59cc92663..3f70ac732 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -6,31 +6,31 @@ .width-100 %h1= @procedure.libelle - %ul.dossiers-categories + %ul.tabs %li{ class: (@statut == 'a-suivre') ? 'active' : nil }> = link_to(procedure_path(@procedure, statut: 'a-suivre')) do à suivre - %span.dossiers-count= @a_suivre_dossiers.count + %span.badge= @a_suivre_dossiers.count %li{ class: (@statut == 'suivis') ? 'active' : nil }> = link_to(procedure_path(@procedure, statut: 'suivis')) do = t('pluralize.followed', count: @followed_dossiers.count) - %span.dossiers-count= @followed_dossiers.count + %span.badge= @followed_dossiers.count %li{ class: (@statut == 'traites') ? 'active' : nil }> = link_to(procedure_path(@procedure, statut: 'traites')) do = t('pluralize.processed', count: @termines_dossiers.count) - %span.dossiers-count= @termines_dossiers.count + %span.badge= @termines_dossiers.count %li{ class: (@statut == 'tous') ? 'active' : nil }> = link_to(procedure_path(@procedure, statut: 'tous')) do tous les dossiers - %span.dossiers-count= @all_state_dossiers.count + %span.badge= @all_state_dossiers.count %li{ class: (@statut == 'archives') ? 'active' : nil }> = link_to(procedure_path(@procedure, statut: 'archives')) do = t('pluralize.archived', count: @archived_dossiers.count) - %span.dossiers-count= @archived_dossiers.count + %span.badge= @archived_dossiers.count .container - if @dossiers.present? From 0eb7ea23cc697f917a6859e740c295018670370f Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 28 Aug 2017 10:54:14 +0200 Subject: [PATCH 113/222] Unify class conditionals in the gestionnaire dossier header --- app/views/new_gestionnaire/dossiers/_header.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 7e9ff2d64..01d750f9e 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -6,7 +6,7 @@ %li = "Dossier n° #{dossier.id}" %ul.tabs - %li{ class: ("active" if current_page?(dossier_path(dossier.procedure, dossier))) } + %li{ class: current_page?(dossier_path(dossier.procedure, dossier)) ? 'active' : nil } = link_to "Demande", dossier_path(dossier.procedure, dossier) %li{ class: current_page?(instruction_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } = link_to "Instruction", instruction_dossier_path(dossier.procedure, dossier) From faf2d2814b4983eadf92f9daf28e1d28fb46a49c Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 29 Aug 2017 10:38:48 +0200 Subject: [PATCH 114/222] Champ: fix indentation --- app/models/champ.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/champ.rb b/app/models/champ.rb index e509751c7..03882a670 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -71,9 +71,9 @@ class Champ < ActiveRecord::Base def serialize_datetime_if_needed if (value =~ /=>/).present? date = begin - hash_date = YAML.safe_load(value.gsub('=>', ': ')) - year, month, day, hour, minute = hash_date.values_at(1,2,3,4,5) - DateTime.new(year, month, day, hour, minute).strftime("%d/%m/%Y %H:%M") + hash_date = YAML.safe_load(value.gsub('=>', ': ')) + year, month, day, hour, minute = hash_date.values_at(1,2,3,4,5) + DateTime.new(year, month, day, hour, minute).strftime("%d/%m/%Y %H:%M") rescue nil end From 1e61f1388b35faafa5f1ba0f97297f0fcc665d9e Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 31 Jul 2017 10:40:20 +0200 Subject: [PATCH 115/222] Move layout configuration on gestionnaire controller --- app/controllers/new_gestionnaire/gestionnaire_controller.rb | 2 ++ app/controllers/new_gestionnaire/procedures_controller.rb | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/new_gestionnaire/gestionnaire_controller.rb b/app/controllers/new_gestionnaire/gestionnaire_controller.rb index 76ef0b937..c675f9566 100644 --- a/app/controllers/new_gestionnaire/gestionnaire_controller.rb +++ b/app/controllers/new_gestionnaire/gestionnaire_controller.rb @@ -1,5 +1,7 @@ module NewGestionnaire class GestionnaireController < ApplicationController + layout "new_application" + before_action :authenticate_gestionnaire! end end diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index 29f67e685..cbcd67085 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -1,7 +1,5 @@ module NewGestionnaire class ProceduresController < GestionnaireController - layout "new_application" - before_action :ensure_ownership!, except: [:index] def index From 9b95a4732f53ab123f47ef883862490cad0e0969 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 27 Jul 2017 15:30:25 +0200 Subject: [PATCH 116/222] Add a .vertical class to tables because this is not the default layout --- app/assets/stylesheets/new_design/table.scss | 25 +++++++++++-------- .../dossiers/_champs.html.haml | 2 +- .../dossiers/_identite_entreprise.html.haml | 2 +- .../dossiers/_identite_individual.html.haml | 2 +- .../new_gestionnaire/dossiers/show.html.haml | 2 +- app/views/root/patron.html.haml | 4 ++- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/new_design/table.scss b/app/assets/stylesheets/new_design/table.scss index 625dcc5b0..a15ed16a6 100644 --- a/app/assets/stylesheets/new_design/table.scss +++ b/app/assets/stylesheets/new_design/table.scss @@ -4,25 +4,28 @@ .table { width: 100%; - font-size: 14px; - line-height: 22px; th, td { @include vertical-padding($default-spacer) } - th { - text-align: left; + &.vertical { + font-size: 14px; + line-height: 22px; - &.header-section { - color: $blue; + th { + text-align: left; + + &.header-section { + color: $blue; + font-weight: bold; + font-size: 20px; + } + } + + td { font-weight: bold; - font-size: 20px; } } - - td { - font-weight: bold; - } } diff --git a/app/views/new_gestionnaire/dossiers/_champs.html.haml b/app/views/new_gestionnaire/dossiers/_champs.html.haml index b38792292..b7c125c92 100644 --- a/app/views/new_gestionnaire/dossiers/_champs.html.haml +++ b/app/views/new_gestionnaire/dossiers/_champs.html.haml @@ -1,4 +1,4 @@ -%table.table +%table.table.vertical %tbody - champs.each do |c| %tr diff --git a/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml b/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml index 53eab7732..bbb5ba9d9 100644 --- a/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml +++ b/app/views/new_gestionnaire/dossiers/_identite_entreprise.html.haml @@ -2,7 +2,7 @@ - etablissement = entreprise.etablissement %h4= entreprise.raison_sociale_or_name -%table.table +%table.table.vertical %tbody %tr %th SIRET : diff --git a/app/views/new_gestionnaire/dossiers/_identite_individual.html.haml b/app/views/new_gestionnaire/dossiers/_identite_individual.html.haml index 810ae7e39..1f41ecd17 100644 --- a/app/views/new_gestionnaire/dossiers/_identite_individual.html.haml +++ b/app/views/new_gestionnaire/dossiers/_identite_individual.html.haml @@ -1,4 +1,4 @@ -%table.table +%table.table.vertical %tbody %tr %th Civilité : diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index 7e2a6521f..afd17d86b 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -23,7 +23,7 @@ .card.featured .card-title Pièces jointes - %table.table + %table.table.vertical %tbody - if @dossier.procedure.cerfa_flag? %tr diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 03912e26f..87d0b83a7 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -74,7 +74,9 @@ %h1 Table - %table.table + %h2 Vertical layout (.table.vertical) + + %table.table.vertical %tbody %tr %th Header 1 From d268151e046fa5db92bd25734e9811c861c77236 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 27 Jul 2017 16:02:35 +0200 Subject: [PATCH 117/222] Improve default table style --- app/assets/stylesheets/new_design/table.scss | 23 ++++++++++++++++---- app/views/root/patron.html.haml | 13 +++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/new_design/table.scss b/app/assets/stylesheets/new_design/table.scss index a15ed16a6..9ba645254 100644 --- a/app/assets/stylesheets/new_design/table.scss +++ b/app/assets/stylesheets/new_design/table.scss @@ -2,20 +2,35 @@ @import "constants"; @import "mixins"; -.table { +.table { // TODO : tester de remplacer par l'élément table uniquement width: 100%; - th, + tbody tr { + border-top: 1px solid $border-grey; + } + td { - @include vertical-padding($default-spacer) + @include vertical-padding($default-spacer); + vertical-align: middle; + } + + th { + text-align: left; + font-weight: bold; + padding: (3 * $default-spacer) 2px; } &.vertical { font-size: 14px; line-height: 22px; + tr { + border-top: none; + } + th { - text-align: left; + @include vertical-padding($default-spacer); + font-weight: normal; &.header-section { color: $blue; diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 87d0b83a7..3841acddc 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -74,6 +74,19 @@ %h1 Table + %table.table + %thead + %tr + %th Header 1 + %th Header 2 + %tbody + %tr + %td Table Data 1 + %td Table Data 2 + %tr + %td Table Data 3 + %td Table Data 4 + %h2 Vertical layout (.table.vertical) %table.table.vertical From 7e09bd71e4b96e669d88bb7c3109fa6ccc50b9e4 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 27 Jul 2017 16:27:29 +0200 Subject: [PATCH 118/222] Add hoverable tables --- app/assets/stylesheets/new_design/table.scss | 6 ++++++ app/views/root/patron.html.haml | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/assets/stylesheets/new_design/table.scss b/app/assets/stylesheets/new_design/table.scss index 9ba645254..43b37eb77 100644 --- a/app/assets/stylesheets/new_design/table.scss +++ b/app/assets/stylesheets/new_design/table.scss @@ -20,6 +20,12 @@ padding: (3 * $default-spacer) 2px; } + &.hoverable { + tbody tr:hover { + background: $light-grey; + } + } + &.vertical { font-size: 14px; line-height: 22px; diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 3841acddc..91a8bb3d0 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -87,6 +87,21 @@ %td Table Data 3 %td Table Data 4 + %h2 Hoverable (.table.hoverable) + + %table.table.hoverable + %thead + %tr + %th Header 1 + %th Header 2 + %tbody + %tr + %td Table Data 1 + %td Table Data 2 + %tr + %td Table Data 3 + %td Table Data 4 + %h2 Vertical layout (.table.vertical) %table.table.vertical From f5ca774e4039059be2b78a51bbcacf8b1991b344 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 28 Aug 2017 14:26:37 +0200 Subject: [PATCH 119/222] Add new style .dossiers-table --- .../new_design/dossiers_table.scss | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/assets/stylesheets/new_design/dossiers_table.scss diff --git a/app/assets/stylesheets/new_design/dossiers_table.scss b/app/assets/stylesheets/new_design/dossiers_table.scss new file mode 100644 index 000000000..2cf894805 --- /dev/null +++ b/app/assets/stylesheets/new_design/dossiers_table.scss @@ -0,0 +1,33 @@ +@import "colors"; +@import "constants"; + +.table.dossiers-table { + td { + padding: 0; + } + + .cell-link { + color: $black; + padding: (3 * $default-spacer) 2px; + display: block; + } + + i.folder { + margin-right: $default-spacer; + } + + .number-col, + .status-col { + width: 130px; + } + + .status-col span { + width: 110px; + text-align: center; + } + + .follow-col { + width: 200px; + text-align: center; + } +} From c74bf5dd8f5ec012a8541f8c1839f3b19474fe72 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 31 Jul 2017 15:01:26 +0200 Subject: [PATCH 120/222] Dossier index use .dossiers-table class --- .../new_design/procedures_show.scss | 69 +------------------ .../procedures/show.html.haml | 31 +++++---- 2 files changed, 19 insertions(+), 81 deletions(-) diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index 914f65fa1..c69942023 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -14,74 +14,7 @@ } .dossiers-table { - margin: (2 * $default-padding) auto; - width: 100%; - - tr { - border-bottom: 1px solid $border-grey; - - &:last-child { - border-bottom: none; - } - - &:hover { - background-color: $light-grey; - } - - &:first-child { - &:hover { - background: #FFFFFF; - } - } - } - - th { - font-weight: bold; - padding: (1.5 * $default-padding) 2px; - text-align: left; - } - - td { - vertical-align: middle; - } - - .number-col { - width: 130px; - - a::before { - content: ""; - background-image: image-url("icons/folder.svg"); - display: inline-block; - width: 24px; - height: 24px; - margin: 0 $default-spacer; - } - } - - .big-link { - color: $black; - display: flex; - align-items: center; - padding: (1.5 * $default-padding) 2px; - } - - .status-col { - width: 200px; - } - - .follow-col { - width: 200px; - } - - .label { - width: 110px; - text-align: center; - } - - .button { - width: 180px; - text-align: center; - } + margin: (3 * $default-spacer) auto; } h2 { diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 3f70ac732..497fcfdd9 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -34,19 +34,24 @@ .container - if @dossiers.present? - %table.dossiers-table - %tr - %th.number-col Nº dossier - %th Demandeur - %th.status-col Statut - %th.follow-col - - @dossiers.each do |dossier| + %table.table.dossiers-table.hoverable + %thead %tr - %td.number-col= link_to(dossier.id, dossier_path(@procedure, dossier), class: 'big-link') - %td= link_to(dossier.user.email, dossier_path(@procedure, dossier), class: 'big-link') - %td.status-col - = link_to(dossier_path(@procedure, dossier), class: 'big-link') do - = render partial: 'status', locals: { dossier: dossier } - %td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) } + %th.number-col Nº dossier + %th Demandeur + %th.status-col Statut + %th.follow-col + %tbody + - @dossiers.each do |dossier| + %tr + %td.number-col + = link_to(dossier_path(@procedure, dossier), class: 'cell-link') do + %i.folder + = dossier.id + %td= link_to(dossier.user.email, dossier_path(@procedure, dossier), class: 'cell-link') + %td.status-col + = link_to(dossier_path(@procedure, dossier), class: 'cell-link') do + = render partial: 'status', locals: { dossier: dossier } + %td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) } - else %h2 Aucun dossier From bf97a111f901e063d3ac33198b2a3fe36be1d699 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 31 Jul 2017 11:58:52 +0200 Subject: [PATCH 121/222] Old recherche with new design --- .../new_gestionnaire/recherches_controller.rb | 23 +++++++++++ app/views/layouts/_new_header.haml | 2 +- .../recherches/index.html.haml | 27 ++++++++++++ config/routes.rb | 1 + .../recherches_controller_spec.rb | 41 +++++++++++++++++++ 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 app/controllers/new_gestionnaire/recherches_controller.rb create mode 100644 app/views/new_gestionnaire/recherches/index.html.haml create mode 100644 spec/controllers/new_gestionnaire/recherches_controller_spec.rb diff --git a/app/controllers/new_gestionnaire/recherches_controller.rb b/app/controllers/new_gestionnaire/recherches_controller.rb new file mode 100644 index 000000000..d0d493805 --- /dev/null +++ b/app/controllers/new_gestionnaire/recherches_controller.rb @@ -0,0 +1,23 @@ +module NewGestionnaire + class RecherchesController < GestionnaireController + def index + @search_terms = params[:q] + + # exact id match? + if @search_terms.to_i != 0 + @dossiers = current_gestionnaire.dossiers.where(id: @search_terms.to_i) + end + + @dossiers = Dossier.none if @dossiers.nil? + + # full text search + if @dossiers.empty? + @dossiers = Search.new( + gestionnaire: current_gestionnaire, + query: @search_terms, + page: params[:page] + ).results + end + end + end +end diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index f05f4b060..df3b68634 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -14,7 +14,7 @@ - if gestionnaire_signed_in? %li .header-search - = form_tag backoffice_dossiers_search_url, method: :get, class: "form" do + = form_tag recherche_path, method: :get, class: "form" do = text_field_tag "q", "#{@search_terms unless @search_terms.nil?}", placeholder: "Rechercher" %button{ title: "Rechercher" } = image_tag "icons/search-blue.svg" diff --git a/app/views/new_gestionnaire/recherches/index.html.haml b/app/views/new_gestionnaire/recherches/index.html.haml new file mode 100644 index 000000000..0c665ac1d --- /dev/null +++ b/app/views/new_gestionnaire/recherches/index.html.haml @@ -0,0 +1,27 @@ +.container + .backoffice-title + Résultat de la recherche : + = pluralize(@dossiers.count, "dossier trouvé", "dossiers trouvés") + + - if @dossiers.present? + %table.table.dossiers-table.hoverable + %thead + %tr + %th Nº + %th Procédure + %th Demandeur + %th Statut + %tbody + - @dossiers.each do |dossier| + %tr + %td.number-col + = link_to(dossier_path(dossier.procedure, dossier), class: 'cell-link') do + %i.folder> + = dossier.id + %td= link_to(dossier.procedure.libelle, dossier_path(dossier.procedure, dossier), class: 'cell-link') + %td= link_to(dossier.user.email, dossier_path(dossier.procedure, dossier), class: 'cell-link') + %td.status-col + = link_to(dossier_path(dossier.procedure, dossier), class: 'cell-link') do + = render partial: 'new_gestionnaire/procedures/status', locals: { dossier: dossier } + - else + %h2 Aucun dossier correspondant à votre recherche n'a été trouvé diff --git a/config/routes.rb b/config/routes.rb index 6d45eaa11..83adc5228 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -258,6 +258,7 @@ Rails.application.routes.draw do end end end + get "recherche" => "recherches#index" end apipie diff --git a/spec/controllers/new_gestionnaire/recherches_controller_spec.rb b/spec/controllers/new_gestionnaire/recherches_controller_spec.rb new file mode 100644 index 000000000..f7147c73d --- /dev/null +++ b/spec/controllers/new_gestionnaire/recherches_controller_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe NewGestionnaire::RecherchesController, type: :controller do + let(:dossier) { create(:dossier, :replied) } + let(:dossier2) { create(:dossier, :replied, procedure: dossier.procedure) } + let(:gestionnaire) { create(:gestionnaire) } + + before { gestionnaire.procedures << dossier2.procedure } + + describe 'GET #index' do + before { sign_in gestionnaire } + + subject { get :index, params: { q: query } } + + describe 'by id' do + context 'when gestionnaire own the dossier' do + let(:query) { dossier.id } + + it { is_expected.to have_http_status(200) } + + it 'returns the expected dossier' do + subject + expect(assigns(:dossiers).count).to eq(1) + expect(assigns(:dossiers).first.id).to eq(dossier.id) + end + end + + context 'when gestionnaire do not own the dossier' do + let(:dossier3) { create(:dossier, :replied) } + let(:query) { dossier3.id } + + it { is_expected.to have_http_status(200) } + + it 'does not return the dossier' do + subject + expect(assigns(:dossiers).count).to eq(0) + end + end + end + end +end From b8a75621e33e246e9104ee1bec28edab5a167a4a Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Mon, 28 Aug 2017 17:54:48 +0200 Subject: [PATCH 122/222] New_design: add design switch button --- .../stylesheets/new_design/new_header.scss | 5 +++++ app/assets/stylesheets/search.scss | 17 ++++++++++++++++- app/views/layouts/_new_header.haml | 2 ++ .../layouts/left_panels/_search_area.html.haml | 3 +++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss index 41320b3fe..14db1913d 100644 --- a/app/assets/stylesheets/new_design/new_header.scss +++ b/app/assets/stylesheets/new_design/new_header.scss @@ -28,6 +28,7 @@ .header-tabs { li { display: inline-block; + padding: $default-padding; } a { @@ -39,6 +40,10 @@ color: $blue; border-bottom: 2px solid $blue; } + + &:not(.active):hover { + background-color: $light-grey; + } } } diff --git a/app/assets/stylesheets/search.scss b/app/assets/stylesheets/search.scss index 26e91409a..17514154a 100644 --- a/app/assets/stylesheets/search.scss +++ b/app/assets/stylesheets/search.scss @@ -1,6 +1,21 @@ +.new-design-button { + color: #FFFFFF; + display: block; + font-size: 20px; + margin: 16px 0; + padding: 8px; + text-align: center; + border: 1px solid #FFFFFF; + border-radius: 15px; + + &:hover { + background-color: #668ABD; + color: #FFFFFF; + } +} + #search-block { margin: 15px 10px 0 10px; - height: 30px; } #search-button { diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index df3b68634..321d29ff3 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -9,6 +9,8 @@ %ul.header-tabs %li = link_to "Procédures", procedures_path, class: "active" + %li + = link_to "Ancienne interface", backoffice_dossiers_path %ul.header-right-content - if gestionnaire_signed_in? diff --git a/app/views/layouts/left_panels/_search_area.html.haml b/app/views/layouts/left_panels/_search_area.html.haml index c957bb425..7126593f8 100644 --- a/app/views/layouts/left_panels/_search_area.html.haml +++ b/app/views/layouts/left_panels/_search_area.html.haml @@ -1,3 +1,6 @@ +- if gestionnaire_signed_in? + = link_to 'nouvelle interface', procedures_path, class: 'new-design-button' + #search-area = form_tag(backoffice_dossiers_search_url, method: :get) do .input-group From 1a1bc461f7371022add9569ccf7d7794701b92ea Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 29 Aug 2017 11:17:43 +0200 Subject: [PATCH 123/222] ProfileSwitch: change link to stay in the old design part --- app/views/layouts/_switch_devise_profile_module.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_switch_devise_profile_module.html.haml b/app/views/layouts/_switch_devise_profile_module.html.haml index b8b0de852..ab51a0053 100644 --- a/app/views/layouts/_switch_devise_profile_module.html.haml +++ b/app/views/layouts/_switch_devise_profile_module.html.haml @@ -12,7 +12,7 @@ Usager - if gestionnaire_signed_in? %li - = link_to(procedures_path) do + = link_to(backoffice_dossiers_path) do %i.fa.fa-user   Accompagnateur From b531f85f97c15249c12ca49f27d9170f0618b49e Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 29 Aug 2017 15:10:58 +0200 Subject: [PATCH 124/222] Add new icons for dossier action button --- app/assets/images/icons/accept.svg | 1 + app/assets/images/icons/close.svg | 1 + app/assets/images/icons/edit-folder-blue.svg | 1 + app/assets/images/icons/in-progress-blue.svg | 1 + .../images/icons/without-continuation.svg | 1 + app/assets/stylesheets/new_design/icons.scss | 20 +++++++++++++++++++ app/views/root/patron.html.haml | 5 +++++ 7 files changed, 30 insertions(+) create mode 100644 app/assets/images/icons/accept.svg create mode 100644 app/assets/images/icons/close.svg create mode 100644 app/assets/images/icons/edit-folder-blue.svg create mode 100644 app/assets/images/icons/in-progress-blue.svg create mode 100644 app/assets/images/icons/without-continuation.svg diff --git a/app/assets/images/icons/accept.svg b/app/assets/images/icons/accept.svg new file mode 100644 index 000000000..71fde1f5e --- /dev/null +++ b/app/assets/images/icons/accept.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/icons/close.svg b/app/assets/images/icons/close.svg new file mode 100644 index 000000000..ddb477bd9 --- /dev/null +++ b/app/assets/images/icons/close.svg @@ -0,0 +1 @@ +ic_close_circle_white \ No newline at end of file diff --git a/app/assets/images/icons/edit-folder-blue.svg b/app/assets/images/icons/edit-folder-blue.svg new file mode 100644 index 000000000..1c4e0d187 --- /dev/null +++ b/app/assets/images/icons/edit-folder-blue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/icons/in-progress-blue.svg b/app/assets/images/icons/in-progress-blue.svg new file mode 100644 index 000000000..29d7b574e --- /dev/null +++ b/app/assets/images/icons/in-progress-blue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/icons/without-continuation.svg b/app/assets/images/icons/without-continuation.svg new file mode 100644 index 000000000..8c33fa2af --- /dev/null +++ b/app/assets/images/icons/without-continuation.svg @@ -0,0 +1 @@ +sans-suite \ No newline at end of file diff --git a/app/assets/stylesheets/new_design/icons.scss b/app/assets/stylesheets/new_design/icons.scss index 0f15821f4..924ce4961 100644 --- a/app/assets/stylesheets/new_design/icons.scss +++ b/app/assets/stylesheets/new_design/icons.scss @@ -24,4 +24,24 @@ i { &.folder { background-image: image-url("icons/folder.svg"); } + + &.accept { + background-image: image-url("icons/accept.svg"); + } + + &.close { + background-image: image-url("icons/close.svg"); + } + + &.without-continuation { + background-image: image-url("icons/without-continuation.svg"); + } + + &.edit { + background-image: image-url("icons/edit-folder-blue.svg"); + } + + &.in-progress { + background-image: image-url("icons/in-progress-blue.svg"); + } } diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 91a8bb3d0..e13f0e31d 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -7,6 +7,11 @@ %i.archive %i.unarchive %i.folder + %i.accept + %i.close + %i.without-continuation + %i.edit + %i.in-progress %h1 Formulaires From 4716d405742ee52057b432abb00a376ed7b362ef Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 29 Aug 2017 17:23:39 +0200 Subject: [PATCH 125/222] Resize icon in button does not apply on dropdown --- app/assets/stylesheets/new_design/buttons.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index b06e60f12..7c3867f95 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -47,7 +47,7 @@ width: 100%; } - i { + > i { width: 18px; height: 18px; background-size: 18px 18px; From 4a94ce1e168bf12149fca1376a5971e048e0061a Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 30 Aug 2017 15:04:18 +0200 Subject: [PATCH 126/222] Fix line-height for buttons --- app/assets/stylesheets/new_design/buttons.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index 7c3867f95..dac2a4cd9 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -7,6 +7,7 @@ border-radius: 30px; border: 1px solid $border-grey; font-size: 14px; + line-height: 20px; background-color: #FFFFFF; color: $black; cursor: pointer; @@ -40,6 +41,7 @@ &.large { font-size: 18px; + line-height: 26px; padding: 15px 32px; } From 7441410fffe98591dbc48fb886373f4ea62c3e50 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 30 Aug 2017 15:40:08 +0200 Subject: [PATCH 127/222] Hide outline on buttons --- app/assets/stylesheets/new_design/buttons.scss | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index dac2a4cd9..cefd5dd7a 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -18,6 +18,11 @@ text-decoration: none; } + &:active, + &:focus { + outline: none; + } + &.primary { color: #FFFFFF; border-color: $blue; From 3e4ba4715d2f3bb21427dda79474d514e98bb969 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 30 Aug 2017 15:31:51 +0200 Subject: [PATCH 128/222] Fix carte bug if user has not draw on map --- app/assets/javascripts/new_design/carte/carte.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/new_design/carte/carte.js b/app/assets/javascripts/new_design/carte/carte.js index 61266bf51..27ed444ab 100644 --- a/app/assets/javascripts/new_design/carte/carte.js +++ b/app/assets/javascripts/new_design/carte/carte.js @@ -22,8 +22,10 @@ function initCarto() { $(document).on('turbolinks:load', initCarto); function drawUserSelection(map) { - var polygon = L.polygon(dossierJsonLatLngs, { color: 'red', zIndex: 3 }).addTo(map); - map.fitBounds(polygon.getBounds()); + if (dossierJsonLatLngs.length > 0) { + var polygon = L.polygon(dossierJsonLatLngs, { color: 'red', zIndex: 3 }).addTo(map); + map.fitBounds(polygon.getBounds()); + } } function defaultGestionnairePosition() { From 3e93d21bf511822928a053923704f504a38e7a8e Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 30 Aug 2017 11:12:58 +0200 Subject: [PATCH 129/222] Procedure Index: add notification icon --- .../stylesheets/new_design/notifications.scss | 9 +++++++ .../new_design/procedure_list.scss | 6 +++++ .../new_gestionnaire/procedures_controller.rb | 2 ++ app/models/gestionnaire.rb | 8 ++++++ .../procedures/index.html.haml | 2 ++ spec/models/gestionnaire_spec.rb | 26 +++++++++++++++++++ 6 files changed, 53 insertions(+) create mode 100644 app/assets/stylesheets/new_design/notifications.scss diff --git a/app/assets/stylesheets/new_design/notifications.scss b/app/assets/stylesheets/new_design/notifications.scss new file mode 100644 index 000000000..d9e6a9931 --- /dev/null +++ b/app/assets/stylesheets/new_design/notifications.scss @@ -0,0 +1,9 @@ +@import "colors"; + +span.notifications { + position: absolute; + width: 8px; + height: 8px; + border-radius: 4px; + background-color: $orange; +} diff --git a/app/assets/stylesheets/new_design/procedure_list.scss b/app/assets/stylesheets/new_design/procedure_list.scss index a69dec297..54bb342ea 100644 --- a/app/assets/stylesheets/new_design/procedure_list.scss +++ b/app/assets/stylesheets/new_design/procedure_list.scss @@ -40,6 +40,7 @@ min-height: 36px; border-left: 1px solid $border-grey; width: 90px; + position: relative; &:last-child { border-right: 1px solid $border-grey; @@ -60,5 +61,10 @@ color: $grey; } } + + .notifications { + top: 3px; + right: 18px; + } } } diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index cbcd67085..bea36455d 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -18,6 +18,8 @@ module NewGestionnaire .group(:procedure_id) .reorder(nil) .count + + @notifications_count_per_procedure = current_gestionnaire.notifications_count_per_procedure end def show diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 98588bc32..931ab09d2 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -93,6 +93,14 @@ class Gestionnaire < ActiveRecord::Base Notification.unread.where(dossier_id: followed_dossiers_id).select(:dossier_id).distinct(:dossier_id).count end + def notifications_count_per_procedure + followed_dossiers + .joins(:notifications) + .where(notifications: { already_read: false }) + .group('procedure_id') + .count + end + def dossiers_with_notifications_count notifications.pluck(:dossier_id).uniq.count end diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index 014063f7f..6bb74b2bf 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -19,6 +19,8 @@ .stats-legend à suivre %li + - if @notifications_count_per_procedure[p.id].present? + %span.notifications{ 'aria-label': "notifications" } - followed_count = @followed_dossiers_count_per_procedure[p.id] || 0 .stats-number = followed_count diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index 319f2fa4d..25d490fd1 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -356,4 +356,30 @@ describe Gestionnaire, type: :model do it { expect(subject).to be false } end end + + describe '#notifications_count_per_procedure' do + subject { gestionnaire.notifications_count_per_procedure } + + let(:dossier_with_unread_notification) do + create(:dossier, notifications: [Notification.create(type_notif: 'champs', already_read: false)]) + end + + let(:dossier_with_no_unread_notification) do + create(:dossier, notifications: [Notification.create(type_notif: 'champs', already_read: true)]) + end + + before { gestionnaire.followed_dossiers << followed_dossier } + + context 'when a followed dossier has unread notification' do + let(:followed_dossier) { dossier_with_unread_notification } + + it { is_expected.to eq({ dossier_with_unread_notification.procedure.id => 1 }) } + end + + context 'when a followed dossier has unread notification' do + let(:followed_dossier) { dossier_with_no_unread_notification } + + it { is_expected.to eq({ }) } + end + end end From fbd16b8c756b2e7106a6818d916446842f6ab89b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 30 Aug 2017 15:31:17 +0200 Subject: [PATCH 130/222] Procedure show: add notification icon --- app/assets/stylesheets/new_design/_tabs.scss | 5 +++++ .../new_design/dossiers_table.scss | 6 ++++++ .../new_gestionnaire/procedures_controller.rb | 2 +- app/models/dossier.rb | 21 ++++++++++--------- .../procedures/show.html.haml | 6 ++++++ 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/new_design/_tabs.scss b/app/assets/stylesheets/new_design/_tabs.scss index 3a3e23441..9583e917e 100644 --- a/app/assets/stylesheets/new_design/_tabs.scss +++ b/app/assets/stylesheets/new_design/_tabs.scss @@ -52,5 +52,10 @@ color: rgba(0, 0, 0, 0.6); font-size: 14px; } + + .notifications { + top: 3px; + right: 3px; + } } } diff --git a/app/assets/stylesheets/new_design/dossiers_table.scss b/app/assets/stylesheets/new_design/dossiers_table.scss index 2cf894805..e0a29a808 100644 --- a/app/assets/stylesheets/new_design/dossiers_table.scss +++ b/app/assets/stylesheets/new_design/dossiers_table.scss @@ -14,6 +14,12 @@ i.folder { margin-right: $default-spacer; + position: relative; + + .notifications { + top: 0px; + right: -10px; + } } .number-col, diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index bea36455d..0dcd55db4 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -33,7 +33,7 @@ module NewGestionnaire @followed_dossiers = current_gestionnaire .followed_dossiers - .includes(:user) + .includes(:user, :notifications) .where(procedure: @procedure) .en_cours diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 3c91b9bc7..b8e7530f4 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -64,16 +64,17 @@ class Dossier < ActiveRecord::Base scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) } - scope :all_state, -> { not_archived.state_not_brouillon.order_by_updated_at(:asc) } - scope :nouveaux, -> { not_archived.state_nouveaux.order_by_updated_at(:asc) } - scope :ouvert, -> { not_archived.state_ouvert.order_by_updated_at(:asc) } - scope :waiting_for_gestionnaire, -> { not_archived.state_waiting_for_gestionnaire.order_by_updated_at(:asc) } - scope :waiting_for_user, -> { not_archived.state_waiting_for_user.order_by_updated_at(:asc) } - scope :a_instruire, -> { not_archived.state_a_instruire.order_by_updated_at(:asc) } - scope :termine, -> { not_archived.state_termine.order_by_updated_at(:asc) } - scope :downloadable, -> { state_not_brouillon.order_by_updated_at(:asc) } - scope :en_cours, -> { not_archived.state_en_construction_ou_instruction.order_by_updated_at(:asc) } - scope :without_followers, -> { includes(:follows).where(follows: { id: nil }) } + scope :all_state, -> { not_archived.state_not_brouillon.order_by_updated_at(:asc) } + scope :nouveaux, -> { not_archived.state_nouveaux.order_by_updated_at(:asc) } + scope :ouvert, -> { not_archived.state_ouvert.order_by_updated_at(:asc) } + scope :waiting_for_gestionnaire, -> { not_archived.state_waiting_for_gestionnaire.order_by_updated_at(:asc) } + scope :waiting_for_user, -> { not_archived.state_waiting_for_user.order_by_updated_at(:asc) } + scope :a_instruire, -> { not_archived.state_a_instruire.order_by_updated_at(:asc) } + scope :termine, -> { not_archived.state_termine.order_by_updated_at(:asc) } + scope :downloadable, -> { state_not_brouillon.order_by_updated_at(:asc) } + scope :en_cours, -> { not_archived.state_en_construction_ou_instruction.order_by_updated_at(:asc) } + scope :without_followers, -> { includes(:follows).where(follows: { id: nil }) } + scope :with_unread_notifications, -> { where(notifications: { already_read: false }) } accepts_nested_attributes_for :individual diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 497fcfdd9..c3ecf838b 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -13,6 +13,8 @@ %span.badge= @a_suivre_dossiers.count %li{ class: (@statut == 'suivis') ? 'active' : nil }> + - if @followed_dossiers.with_unread_notifications.present? + %span.notifications{ 'aria-label': 'notifications' } = link_to(procedure_path(@procedure, statut: 'suivis')) do = t('pluralize.followed', count: @followed_dossiers.count) %span.badge= @followed_dossiers.count @@ -23,6 +25,8 @@ %span.badge= @termines_dossiers.count %li{ class: (@statut == 'tous') ? 'active' : nil }> + - if @followed_dossiers.with_unread_notifications.present? + %span.notifications{ 'aria-label': 'notifications' } = link_to(procedure_path(@procedure, statut: 'tous')) do tous les dossiers %span.badge= @all_state_dossiers.count @@ -47,6 +51,8 @@ %td.number-col = link_to(dossier_path(@procedure, dossier), class: 'cell-link') do %i.folder + - if @followed_dossiers.with_unread_notifications.include?(dossier) + %span.notifications{ 'aria-label': 'notifications' } = dossier.id %td= link_to(dossier.user.email, dossier_path(@procedure, dossier), class: 'cell-link') %td.status-col From a298c48e8f79316a3f44c27f58bbf0b7ae2d41f1 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 30 Aug 2017 15:31:36 +0200 Subject: [PATCH 131/222] Dossier: add notification icon --- .../new_gestionnaire/dossiers_controller.rb | 3 +++ app/models/dossier.rb | 10 +++++++ app/models/notification.rb | 22 +++++++++++++++- .../dossiers/_header.html.haml | 7 +++++ .../dossiers_controller_spec.rb | 26 ++++++++++++++++--- 5 files changed, 64 insertions(+), 4 deletions(-) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index e76364587..cc35adbd3 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -6,14 +6,17 @@ module NewGestionnaire def show @dossier = dossier + dossier.notifications.demande.mark_as_read end def messagerie @dossier = dossier + dossier.notifications.messagerie.mark_as_read end def instruction @dossier = dossier + dossier.notifications.instruction.mark_as_read end def follow diff --git a/app/models/dossier.rb b/app/models/dossier.rb index b8e7530f4..0c30adc50 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -104,6 +104,16 @@ class Dossier < ActiveRecord::Base pieces_justificatives.where(type_de_piece_justificative_id: type_id).count > 0 end + def notifications_summary + unread_notifications = notifications.unread + + { + demande: unread_notifications.select(&:demande?).present?, + instruction: unread_notifications.select(&:instruction?).present?, + messagerie: unread_notifications.select(&:messagerie?).present? + } + end + def retrieve_last_piece_justificative_by_type(type) pieces_justificatives.where(type_de_piece_justificative_id: type).last end diff --git a/app/models/notification.rb b/app/models/notification.rb index 53d8af02d..b2cd552fe 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -8,7 +8,27 @@ class Notification < ActiveRecord::Base avis: 'avis' } + DEMANDE = %w(cerfa piece_justificative champs submitted) + INSTRUCTION = %w(avis) + MESSAGERIE = %w(commentaire) + belongs_to :dossier - scope :unread, -> { where(already_read: false) } + scope :unread, -> { where(already_read: false) } + scope :demande, -> { where(type_notif: DEMANDE) } + scope :instruction, -> { where(type_notif: INSTRUCTION) } + scope :messagerie, -> { where(type_notif: MESSAGERIE) } + scope :mark_as_read, -> { update_all(already_read: true) } + + def demande? + Notification::DEMANDE.include?(type_notif) + end + + def instruction? + Notification::INSTRUCTION.include?(type_notif) + end + + def messagerie? + Notification::MESSAGERIE.include?(type_notif) + end end diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 01d750f9e..914c46e1e 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -6,11 +6,18 @@ %li = "Dossier n° #{dossier.id}" %ul.tabs + - notifications_summary = dossier.notifications_summary %li{ class: current_page?(dossier_path(dossier.procedure, dossier)) ? 'active' : nil } + - if notifications_summary[:demande] + %span.notifications{ 'aria-label': 'notifications' } = link_to "Demande", dossier_path(dossier.procedure, dossier) %li{ class: current_page?(instruction_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } + - if notifications_summary[:instruction] + %span.notifications{ 'aria-label': 'notifications' } = link_to "Instruction", instruction_dossier_path(dossier.procedure, dossier) %li{ class: current_page?(messagerie_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } + - if notifications_summary[:messagerie] + %span.notifications{ 'aria-label': 'notifications' } = link_to "Messagerie", messagerie_dossier_path(dossier.procedure, dossier) %li = link_to "Historique", "#" diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 032cc83e9..084a52ed2 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -72,10 +72,30 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(response).to redirect_to(procedures_url) } end - describe "#show" do - before { get :show, params: { procedure_id: procedure.id, dossier_id: dossier.id } } + describe '#show #messagerie #instruction' do + before do + dossier.notifications = %w(champs avis commentaire).map{ |type| Notification.create!(type_notif: type) } + get method, params: { procedure_id: procedure.id, dossier_id: dossier.id } + dossier.notifications.each(&:reload) + end - it { expect(response).to have_http_status(:success) } + context '#show' do + let(:method) { :show } + it { expect(dossier.notifications.map(&:already_read)).to match([true, false, false]) } + it { expect(response).to have_http_status(:success) } + end + + context '#instruction' do + let(:method) { :instruction } + it { expect(dossier.notifications.map(&:already_read)).to match([false, true, false]) } + it { expect(response).to have_http_status(:success) } + end + + context '#messagerie' do + let(:method) { :messagerie } + it { expect(dossier.notifications.map(&:already_read)).to match([false, false, true]) } + it { expect(response).to have_http_status(:success) } + end end describe "#create_commentaire" do From 485a1ceb0034831ad51337457a3004f7def3688b Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 31 Aug 2017 15:29:24 +0200 Subject: [PATCH 132/222] [Fix #663] Menu header should be above every element --- app/assets/stylesheets/new_design/new_header.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss index 14db1913d..2a717e5c8 100644 --- a/app/assets/stylesheets/new_design/new_header.scss +++ b/app/assets/stylesheets/new_design/new_header.scss @@ -108,6 +108,7 @@ border: 1px solid $border-grey; min-width: 270px; max-width: 340px; + z-index: 10; &.open { display: block; From d6e17493d5645300d7ec7941b66ed57ff7e83aa3 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 5 Sep 2017 15:01:43 +0200 Subject: [PATCH 133/222] [Fix #694] Commentaire email should be displayed --- .../new_gestionnaire/dossiers/_commentaire_issuer.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml b/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml index 4704526d7..160a00d7c 100644 --- a/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml +++ b/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml @@ -4,4 +4,4 @@ - when 'contact@tps.apientreprise.fr' Mail automatique - else - commentaire.email + = commentaire.email From 3f67d29a1856137bf2fefa9e47a6a8cd5c23224c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 5 Sep 2017 15:03:01 +0200 Subject: [PATCH 134/222] Mail => Email --- .../new_gestionnaire/dossiers/_commentaire_issuer.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml b/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml index 160a00d7c..7c16510bd 100644 --- a/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml +++ b/app/views/new_gestionnaire/dossiers/_commentaire_issuer.html.haml @@ -2,6 +2,6 @@ - when current_gestionnaire.email Vous - when 'contact@tps.apientreprise.fr' - Mail automatique + Email automatique - else = commentaire.email From c713518ac17f805d4a508c84ac1036304b4007c1 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 5 Sep 2017 16:31:32 +0200 Subject: [PATCH 135/222] [Fix #494] If super-admin is connected, add an link in the header menu --- app/assets/images/icons/super-admin.svg | 1 + app/views/layouts/_new_header.haml | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 app/assets/images/icons/super-admin.svg diff --git a/app/assets/images/icons/super-admin.svg b/app/assets/images/icons/super-admin.svg new file mode 100644 index 000000000..bb9584ed5 --- /dev/null +++ b/app/assets/images/icons/super-admin.svg @@ -0,0 +1 @@ +Shape \ No newline at end of file diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index 321d29ff3..07ebc2c16 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -27,7 +27,11 @@ %li .menu-item{ title: current_email } = current_email - + - if administration_signed_in? + %li + = link_to administrations_path, class: "menu-item menu-link" do + = image_tag "icons/super-admin.svg" + Passer en super-admin - if SwitchDeviseProfileService.new(warden).multiple_devise_profile_connect? - if user_signed_in? %li From 059a0b961bac500165d49420ad26606adbf09d16 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 2 Aug 2017 16:20:01 +0200 Subject: [PATCH 136/222] Action button for construction state --- app/assets/javascripts/new_design/buttons.js | 11 +++ .../stylesheets/new_design/buttons.scss | 78 +++++++++++++++++++ .../backoffice/dossiers_controller.rb | 12 ++- .../dossiers/_header.html.haml | 13 ++-- .../dossiers/_state_button.html.haml | 17 ++++ .../backoffice/dossiers_controller_spec.rb | 2 +- 6 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 app/assets/javascripts/new_design/buttons.js create mode 100644 app/views/new_gestionnaire/dossiers/_state_button.html.haml diff --git a/app/assets/javascripts/new_design/buttons.js b/app/assets/javascripts/new_design/buttons.js new file mode 100644 index 000000000..3e134c807 --- /dev/null +++ b/app/assets/javascripts/new_design/buttons.js @@ -0,0 +1,11 @@ +$(document).on("click", "body", function () { + $(".button.dropdown").removeClass("open"); +}); + +$(document).on("click", ".button.dropdown", function(event) { + event.stopPropagation(); + var $target = $(event.target); + if($target.hasClass("button", "dropdown")){ + $target.toggleClass("open"); + } +}); diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index cefd5dd7a..0f991fb24 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -61,6 +61,84 @@ vertical-align: middle; margin-right: $default-spacer; } + + &.dropdown { + position: relative; + + &::after { + content: "▾"; + margin-left: $default-spacer; + font-weight: bold; + } + + .dropdown-content { + display: none; + } + + &.open { + .dropdown-content { + display: block; + } + } + } +} + +.dropdown-content { + border: 1px solid $border-grey; + background: #FFFFFF; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); + position: absolute; + right: 0; + top: 5 * $default-spacer; + cursor: default; +} + +.dropdown-items { + li { + display: flex; + padding: 2 * $default-spacer; + color: $grey; + border-bottom: 1px solid $border-grey; + font-size: 12px; + min-width: 300px; + cursor: pointer; + + &.selected { + cursor: default; + + h4 { + color: $blue; + } + } + + &.selected, + &:hover { + background: $light-grey; + } + + &:last-child { + border-bottom: none; + } + + a { + display: flex; + color: $grey; + } + + i { + flex-shrink: 0; + } + + div { + padding-left: $default-spacer; + } + } + + h4 { + font-size: 14px; + color: $black; + margin-bottom: $default-spacer; + } } .link { diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index 102c71437..12596fbef 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -99,9 +99,9 @@ class Backoffice::DossiersController < Backoffice::DossiersListController dossier.received! current_gestionnaire.follow(dossier) - flash.notice = 'Dossier considéré comme reçu.' + flash.notice = 'Dossier passé en instruction.' - redirect_to backoffice_dossier_path(id: dossier.id) + redirect_to_dossier(dossier) end def process_dossier @@ -187,6 +187,14 @@ class Backoffice::DossiersController < Backoffice::DossiersListController private + def redirect_to_dossier(dossier) + if URI(request.referer).path == dossier_path(dossier.procedure, dossier) + redirect_to dossier_path(dossier.procedure, dossier) + else + redirect_to backoffice_dossier_path(id: dossier.id) + end + end + def check_attestation_emailable(dossier) if dossier&.attestation&.emailable? == false human_size = number_to_human_size(dossier.attestation.pdf.size) diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 914c46e1e..a9aee4284 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -1,10 +1,13 @@ .backoffice-header .container - %ul.breadcrumbs - %li - = link_to dossier.procedure.libelle, procedure_path(dossier.procedure) - %li - = "Dossier n° #{dossier.id}" + .flex.justify-between + %ul.breadcrumbs + %li + = link_to dossier.procedure.libelle, procedure_path(dossier.procedure) + %li + = "Dossier nº #{dossier.id}" + %div + = render partial: "state_button", locals: { dossier: dossier } %ul.tabs - notifications_summary = dossier.notifications_summary %li{ class: current_page?(dossier_path(dossier.procedure, dossier)) ? 'active' : nil } diff --git a/app/views/new_gestionnaire/dossiers/_state_button.html.haml b/app/views/new_gestionnaire/dossiers/_state_button.html.haml new file mode 100644 index 000000000..4f8bcbedf --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/_state_button.html.haml @@ -0,0 +1,17 @@ +- if dossier.en_construction? + %span.button.primary.dropdown + = dossier.decorate.display_state + .dropdown-content.fade-in-down + %ul.dropdown-items + - if dossier.en_construction? + %li.selected + %i.edit + .description + %h4 En construction + Vous permettez à l'usager de modifier ses réponses au formulaire + %li + = link_to backoffice_dossier_receive_path(dossier), method: :post, data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do + %i.in-progress + .description + %h4 Passer en instruction + L'usager ne pourra plus modifier le formulaire diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index 4b09e776e..a80d31b0e 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -367,7 +367,7 @@ describe Backoffice::DossiersController, type: :controller do expect(dossier.state).to eq('replied') end - it { is_expected.to redirect_to backoffice_dossiers_path } + it { is_expected.to redirect_to backoffice_dossier_path(id: dossier_id) } end describe 'POST #archive' do From feda7213f99d14fc9fa14d2b1ac2597f0d0ca3f6 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 30 Aug 2017 17:28:58 +0200 Subject: [PATCH 137/222] Action button for instruction state --- .../javascripts/new_design/state_button.js | 9 ++++ .../stylesheets/new_design/motivation.scss | 29 +++++++++++ .../backoffice/dossiers_controller.rb | 6 +-- .../dossiers/_state_button.html.haml | 52 ++++++++++++++++++- 4 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 app/assets/javascripts/new_design/state_button.js create mode 100644 app/assets/stylesheets/new_design/motivation.scss diff --git a/app/assets/javascripts/new_design/state_button.js b/app/assets/javascripts/new_design/state_button.js new file mode 100644 index 000000000..71e32310e --- /dev/null +++ b/app/assets/javascripts/new_design/state_button.js @@ -0,0 +1,9 @@ +TPS.acceptDossier = function () { + $(".motivation").show(); + $(".dropdown-items").hide(); +} + +TPS.motivationCancel = function () { + $(".motivation").hide(); + $(".dropdown-items").show(); +} diff --git a/app/assets/stylesheets/new_design/motivation.scss b/app/assets/stylesheets/new_design/motivation.scss new file mode 100644 index 000000000..e8e91d334 --- /dev/null +++ b/app/assets/stylesheets/new_design/motivation.scss @@ -0,0 +1,29 @@ +@import "colors"; +@import "constants"; + +.motivation { + display: none; + padding: $default-padding; + color: $black; + width: 450px; + + h3 { + font-size: 22px; + margin-bottom: $default-spacer * 2; + + i { + vertical-align: sub; + margin-right: $default-spacer; + } + } + + textarea { + margin-bottom: $default-spacer; + } + + .help { + color: $grey; + font-size: 11px; + margin-bottom: $default-spacer * 2; + } +} diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index 12596fbef..b0f07d5b5 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -143,7 +143,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController NotificationMailer.send_notification(dossier, template, attestation_pdf).deliver_now! - redirect_to backoffice_dossier_path(id: dossier.id) + redirect_to_dossier(dossier) end def reload_smartlisting @@ -180,9 +180,9 @@ class Backoffice::DossiersController < Backoffice::DossiersListController create_dossier_facade params[:dossier_id] @facade.dossier.replied! - flash.notice = 'Dossier réouvert.' + flash.notice = 'Dossier repassé en construction.' - redirect_to backoffice_dossiers_path + redirect_to_dossier(@facade.dossier) end private diff --git a/app/views/new_gestionnaire/dossiers/_state_button.html.haml b/app/views/new_gestionnaire/dossiers/_state_button.html.haml index 4f8bcbedf..1151226ab 100644 --- a/app/views/new_gestionnaire/dossiers/_state_button.html.haml +++ b/app/views/new_gestionnaire/dossiers/_state_button.html.haml @@ -1,4 +1,4 @@ -- if dossier.en_construction? +- if dossier.en_construction? || dossier.en_instruction? %span.button.primary.dropdown = dossier.decorate.display_state .dropdown-content.fade-in-down @@ -15,3 +15,53 @@ .description %h4 Passer en instruction L'usager ne pourra plus modifier le formulaire + + - if dossier.en_instruction? + %li + = link_to backoffice_dossier_reopen_path(dossier), method: :post, data: { confirm: "Confirmer vous la réouverture de ce dossier ?" } do + %i.edit + .description + %h4 Repasser en construction + Vous permettrez à l'usager de modifier ses réponses au formulaire + %li.selected + %i.in-progress + .description + %h4 En instruction + L'usager ne peut modifer son dossier pendant l'instruction + %li{ onclick: "TPS.acceptDossier();" } + %i.accept + .description + %h4 Accepter + L'usager sera notifié que son dossier a été accepté + %li + = link_to backoffice_dossier_process_dossier_path(dossier, process_action: "without_continuation"), method: :post, data: { confirm: "Confirmer vous le classement sans suite de ce dossier ?" } do + %i.without-continuation + .description + %h4 Classer sans suite + L'usager ne recevra aucune notification + %li + = link_to backoffice_dossier_process_dossier_path(dossier, process_action: "refuse"), method: :post, data: { confirm: "Confirmer vous le refus de ce dossier ?" } do + %i.close + .description + %h4 Refuser + L'usager sera notifié que son dossier a été refusé + .motivation + %h3 + %i.accept + Accepter le dossier + = "nº #{dossier.id}" + + = form_tag(backoffice_dossier_process_dossier_url(dossier.id), method: :post, class: "form") do + = text_area :dossier, :motivation, class: "motivation-text-area", placeholder: "Rédigez votre motivation ici (facultative)" + %p.help + L'acceptation du dossier envoie automatiquement une attestation à l'usager. + .text-right + %span.button{ onclick: "TPS.motivationCancel();" } Annuler + = button_tag "Valider la décision", name: :process_action, value: "close", class: 'button primary', title: 'Accepter', data: { confirm: "Accepter ce dossier ?" } + +- elsif dossier.closed? + %span.label.closed Accepté +- elsif dossier.refused? + %span.label.refused Refusé +- elsif dossier.without_continuation? + %span.label.without-continuation Sans suite From 4e526c5fa93dc2f20c058f29f2f58adb9d219917 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 31 Aug 2017 14:27:25 +0200 Subject: [PATCH 138/222] Add action button for follow and archive --- app/views/new_gestionnaire/dossiers/_header.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index a9aee4284..7266fb7e9 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -8,6 +8,7 @@ = "Dossier nº #{dossier.id}" %div = render partial: "state_button", locals: { dossier: dossier } + = render partial: "new_gestionnaire/procedures/dossier_actions", locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: current_gestionnaire&.follow?(dossier) } %ul.tabs - notifications_summary = dossier.notifications_summary %li{ class: current_page?(dossier_path(dossier.procedure, dossier)) ? 'active' : nil } From 62c893d704d225a8e71f98431a84e3357aa6c93f Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 5 Sep 2017 17:34:07 +0200 Subject: [PATCH 139/222] Procedure Index: increase link size to the whole line and apply same style as the dossier index --- .../new_design/procedure_list.scss | 25 ++++-- .../procedures/index.html.haml | 84 +++++++++---------- 2 files changed, 58 insertions(+), 51 deletions(-) diff --git a/app/assets/stylesheets/new_design/procedure_list.scss b/app/assets/stylesheets/new_design/procedure_list.scss index 54bb342ea..09db9808e 100644 --- a/app/assets/stylesheets/new_design/procedure_list.scss +++ b/app/assets/stylesheets/new_design/procedure_list.scss @@ -1,14 +1,28 @@ @import "colors"; +@import "constants"; @import "mixins"; .procedure-list { .procedure-item { - @include vertical-padding(24px); border-bottom: 1px solid $border-grey; &:last-child { border-bottom: none; } + + a { + @include vertical-padding(24px); + color: $black; + width: 100%; + + &:hover { + background-color: $light-grey; + + .procedure-title { + text-decoration: underline; + } + } + } } .procedure-logo { @@ -21,14 +35,7 @@ min-height: 40px; font-size: 20px; margin-bottom: 16px; - - a { - color: $black; - - &:hover { - color: $blue; - } - } + padding-left: $default-spacer; } .procedure-status { diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index 6bb74b2bf..8477051c3 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -4,47 +4,47 @@ %ul.procedure-list - @procedures.each do |p| %li.procedure-item.flex.align-start + = link_to(procedure_path(p)) do + .procedure-details + %p.procedure-title + - if p.logo.present? + = image_tag p.logo, class: "procedure-logo" + #{p.libelle} - .procedure-details - %p.procedure-title - - if p.logo.present? - = image_tag p.logo, class: "procedure-logo" - = link_to(p.libelle, procedure_path(p)) + %ul.procedure-stats.flex + %li + - a_suivre_count = @dossiers_a_suivre_count_per_procedure[p.id] || 0 + .stats-number + = a_suivre_count + .stats-legend + à suivre + %li + - if @notifications_count_per_procedure[p.id].present? + %span.notifications{ 'aria-label': "notifications" } + - followed_count = @followed_dossiers_count_per_procedure[p.id] || 0 + .stats-number + = followed_count + .stats-legend + = t('pluralize.followed', count: followed_count) + %li + - termines_count = @dossiers_termines_count_per_procedure[p.id] || 0 + .stats-number + = termines_count + .stats-legend + = t('pluralize.processed', count: termines_count) + %li + - dossier_count = @dossiers_count_per_procedure[p.id] || 0 + .stats-number + = dossier_count + .stats-legend + = t('pluralize.case', count: dossier_count) + %li + - archived_count = @dossiers_archived_count_per_procedure[p.id] || 0 + .stats-number + = archived_count + .stats-legend + = t('pluralize.archived', count: archived_count) - %ul.procedure-stats.flex - %li - - a_suivre_count = @dossiers_a_suivre_count_per_procedure[p.id] || 0 - .stats-number - = a_suivre_count - .stats-legend - à suivre - %li - - if @notifications_count_per_procedure[p.id].present? - %span.notifications{ 'aria-label': "notifications" } - - followed_count = @followed_dossiers_count_per_procedure[p.id] || 0 - .stats-number - = followed_count - .stats-legend - = t('pluralize.followed', count: followed_count) - %li - - termines_count = @dossiers_termines_count_per_procedure[p.id] || 0 - .stats-number - = termines_count - .stats-legend - = t('pluralize.processed', count: termines_count) - %li - - dossier_count = @dossiers_count_per_procedure[p.id] || 0 - .stats-number - = dossier_count - .stats-legend - = t('pluralize.case', count: dossier_count) - %li - - archived_count = @dossiers_archived_count_per_procedure[p.id] || 0 - .stats-number - = archived_count - .stats-legend - = t('pluralize.archived', count: archived_count) - - - if p.archivee? - .procedure-status - %span.label Archivée + - if p.archivee? + .procedure-status + %span.label Archivée From 719b848e79d0b012fedfd1468ad8bd6f19df7637 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 6 Sep 2017 14:36:09 +0200 Subject: [PATCH 140/222] Fix search test that fails randomly --- spec/controllers/backoffice/dossiers_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index a80d31b0e..befeac817 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -212,8 +212,8 @@ describe Backoffice::DossiersController, type: :controller do expect(response).to have_http_status(200) end - it 'returns nothing' do - expect(assigns(:dossiers).count).to eq(0) + it 'does not return the dossier' do + expect(assigns(:dossiers).pluck(:id)).not_to include(dossier2_id) end end end From bd9536faac58a7632781dda80c3eb8629fbcff7a Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 6 Sep 2017 17:41:54 +0200 Subject: [PATCH 141/222] Header: improve padding --- app/assets/stylesheets/new_design/new_header.scss | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss index 2a717e5c8..44f169298 100644 --- a/app/assets/stylesheets/new_design/new_header.scss +++ b/app/assets/stylesheets/new_design/new_header.scss @@ -28,11 +28,10 @@ .header-tabs { li { display: inline-block; - padding: $default-padding; } a { - @include vertical-padding(23px); + padding: 23px $default-padding; font-size: 18px; color: $black; From bbb1f77adadda9f6a740d31adb877a4a2370dbe3 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 6 Sep 2017 17:06:03 +0200 Subject: [PATCH 142/222] Messagerie: extract css for reuse --- .../new_design/{dossier_messagerie.scss => messagerie.scss} | 2 +- app/views/new_gestionnaire/dossiers/messagerie.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename app/assets/stylesheets/new_design/{dossier_messagerie.scss => messagerie.scss} (94%) diff --git a/app/assets/stylesheets/new_design/dossier_messagerie.scss b/app/assets/stylesheets/new_design/messagerie.scss similarity index 94% rename from app/assets/stylesheets/new_design/dossier_messagerie.scss rename to app/assets/stylesheets/new_design/messagerie.scss index 087c1ff48..a9bc70038 100644 --- a/app/assets/stylesheets/new_design/dossier_messagerie.scss +++ b/app/assets/stylesheets/new_design/messagerie.scss @@ -2,7 +2,7 @@ @import "common"; @import "constants"; -#dossier-messagerie { +.messagerie { li { display: flex; align-items: flex-start; diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index 7d2176901..85a3d2248 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -1,6 +1,6 @@ = render partial: "header", locals: { dossier: @dossier } -#dossier-messagerie.container +.messagerie.container %ul - @dossier.commentaires.ordered.each do |commentaire| %li From c93feb27f06e5446646b016dc5d0502971146519 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 6 Sep 2017 14:08:03 +0200 Subject: [PATCH 143/222] Avis style: extract class to avis.scss file for reuse in patron and avis --- app/assets/stylesheets/new_design/avis.scss | 73 +++++++++++++++++++ .../new_design/dossier_instruction.scss | 60 --------------- .../dossiers/instruction.html.haml | 4 +- app/views/root/patron.html.haml | 31 ++++++++ 4 files changed, 106 insertions(+), 62 deletions(-) create mode 100644 app/assets/stylesheets/new_design/avis.scss diff --git a/app/assets/stylesheets/new_design/avis.scss b/app/assets/stylesheets/new_design/avis.scss new file mode 100644 index 000000000..e2ebc5675 --- /dev/null +++ b/app/assets/stylesheets/new_design/avis.scss @@ -0,0 +1,73 @@ +@import "colors"; +@import "common"; +@import "constants"; + +.ask-avis { + h1 { + font-size: 18px; + font-weight: bold; + margin-bottom: $default-padding; + } + + .avis-notice { + font-size: 12px; + color: $grey; + margin-bottom: 2 * $default-padding; + } + + input[type=email] { + max-width: 500px; + } +} + +.list-avis { + .title { + font-size: 18px; + font-weight: bold; + margin-bottom: $default-padding; + + .count { + display: inline-block; + width: 20px; + height: 20px; + border-radius: 10px; + border: 1px solid $grey; + text-align: center; + font-size: 12px; + font-weight: normal; + margin-left: 8px; + } + } + + .one-avis { + border-top: 1px solid $grey; + padding: $default-padding 0; + + h2 { + font-weight: bold; + margin-bottom: $default-spacer; + + span { + font-weight: normal; + } + } + + .answer { + margin-top: $default-padding; + } + + .avis-icon { + margin-right: $default-spacer; + } + } + + .date, + .waiting { + font-size: 12px; + color: $grey; + } + + .date { + float: right; + } +} diff --git a/app/assets/stylesheets/new_design/dossier_instruction.scss b/app/assets/stylesheets/new_design/dossier_instruction.scss index 6a4ec475c..9a0747fb8 100644 --- a/app/assets/stylesheets/new_design/dossier_instruction.scss +++ b/app/assets/stylesheets/new_design/dossier_instruction.scss @@ -8,64 +8,4 @@ font-weight: bold; margin-bottom: $default-padding; } - - .avis-notice { - font-size: 12px; - color: $grey; - margin-bottom: 2 * $default-padding; - } - - input[type=email] { - max-width: 500px; - } - - .avis { - .title { - margin-bottom: $default-padding; - - .count { - display: inline-block; - width: 20px; - height: 20px; - border-radius: 10px; - border: 1px solid $grey; - text-align: center; - font-size: 12px; - font-weight: normal; - margin-left: 8px; - } - } - - .one-avis { - border-top: 1px solid $grey; - padding: $default-padding 0; - - h2 { - font-weight: bold; - margin-bottom: $default-spacer; - - span { - font-weight: normal; - } - } - - .answer { - margin-top: $default-padding; - } - - .avis-icon { - margin-right: $default-spacer; - } - } - - .date, - .waiting { - font-size: 12px; - color: $grey; - } - - .date { - float: right; - } - } } diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml index 652eda87a..09d04380f 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -1,7 +1,7 @@ = render partial: "header", locals: { dossier: @dossier } #dossier-instruction.container - %section + %section.ask-avis %h1 Inviter une personne à donner son avis %p.avis-notice Elle pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais elle ne pourra le modifier. @@ -12,7 +12,7 @@ = f.submit 'Demander un avis', class: 'button send' - if @dossier.avis.present? - %section.avis + %section.list-avis %h1.title Avis des invités %span.count= @dossier.avis.count diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index e13f0e31d..588a9f448 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -155,3 +155,34 @@ Insérer ici le contenu de la colonne 1 .column Insérer ici le contenu de la colonne 2 + + .container + %section.ask-avis + %h1 Inviter une personne à donner son avis + %p.avis-notice Elle pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais elle ne pourra le modifier. + + = form_for Avis.new, url: '/', html: { class: 'form' } do |f| + = f.email_field :email, placeholder: 'Adresse email', required: true + = f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true + .send-wrapper + = f.submit 'Demander un avis', class: 'button send' + + %section.list-avis + %h1.title + Avis des invités + %span.count 1 + + %ul + %li.one-avis + %h2.claimant + Vous + %span.date Demande d'avis envoyée le 12/01/2012 + %p Bonjour, merci de me donner votre avis sur ce dossier. + + .answer.flex.align-start + = image_tag 'icons/bubble.svg', class: 'avis-icon' + .width-100 + %h2.gestionnaire + gestionnnaire@tps.com + %span.date Réponse donnée le 13/01/2012 + %p Je donne un avis favorable From c9f69e9693160b99e5a50e4edbe49646b7cc3464 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 7 Sep 2017 10:30:40 +0200 Subject: [PATCH 144/222] Avis Style: replace bubble image tag by the i tag --- app/assets/stylesheets/new_design/icons.scss | 4 ++++ app/views/new_gestionnaire/dossiers/instruction.html.haml | 2 +- app/views/root/patron.html.haml | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/new_design/icons.scss b/app/assets/stylesheets/new_design/icons.scss index 924ce4961..a22cd9afd 100644 --- a/app/assets/stylesheets/new_design/icons.scss +++ b/app/assets/stylesheets/new_design/icons.scss @@ -44,4 +44,8 @@ i { &.in-progress { background-image: image-url("icons/in-progress-blue.svg"); } + + &.bubble { + background-image: image-url("icons/bubble.svg"); + } } diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml index 09d04380f..016abc911 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -26,7 +26,7 @@ %p= avis.introduction .answer.flex.align-start - = image_tag 'icons/bubble.svg', class: 'avis-icon' + %i.bubble.avis-icon .width-100 %h2.gestionnaire = avis.gestionnaire.email diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 588a9f448..5d295de01 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -12,6 +12,7 @@ %i.without-continuation %i.edit %i.in-progress + %i.bubble %h1 Formulaires @@ -180,7 +181,7 @@ %p Bonjour, merci de me donner votre avis sur ce dossier. .answer.flex.align-start - = image_tag 'icons/bubble.svg', class: 'avis-icon' + %i.bubble.avis-icon .width-100 %h2.gestionnaire gestionnnaire@tps.com From 11386a04eeeac6c932bdb41b8075589607f21e2c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 7 Sep 2017 11:44:39 +0200 Subject: [PATCH 145/222] Remove history link --- app/views/new_gestionnaire/dossiers/_header.html.haml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 7266fb7e9..46dcf1265 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -23,5 +23,3 @@ - if notifications_summary[:messagerie] %span.notifications{ 'aria-label': 'notifications' } = link_to "Messagerie", messagerie_dossier_path(dossier.procedure, dossier) - %li - = link_to "Historique", "#" From 39c556f70ea07af9e0e05549d428d55fdca65bd3 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 7 Sep 2017 14:05:02 +0200 Subject: [PATCH 146/222] Enable Rack mini profiler, on every environment --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fbaba5b73..524746fec 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base before_action :authorize_request_for_profiler def authorize_request_for_profiler - if Rails.env.production? && administration_signed_in? + if administration_signed_in? Rack::MiniProfiler.authorize_request end end From 0b832a873c098314c3d084044be0dd72372d0ea8 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 7 Sep 2017 16:50:02 +0200 Subject: [PATCH 147/222] Search: replace placeholder to 'Rechercher un dossier' --- app/views/layouts/_new_header.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index 07ebc2c16..1b9d7c703 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -17,7 +17,7 @@ %li .header-search = form_tag recherche_path, method: :get, class: "form" do - = text_field_tag "q", "#{@search_terms unless @search_terms.nil?}", placeholder: "Rechercher" + = text_field_tag "q", "#{@search_terms unless @search_terms.nil?}", placeholder: "Rechercher un dossier" %button{ title: "Rechercher" } = image_tag "icons/search-blue.svg" %li From d943874144a4db773705a629ea60309e1dd48dc7 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Fri, 8 Sep 2017 10:16:27 +0200 Subject: [PATCH 148/222] Carto: display carto only when needed --- app/views/new_gestionnaire/dossiers/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index afd17d86b..5e3592a03 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -16,7 +16,7 @@ - if champs.any? = render partial: "champs", locals: { champs: champs } - - if @dossier.procedure.module_api_carto.present? + - if @dossier.procedure.use_api_carto = render partial: "map", locals: { dossier: @dossier } - if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? From e5150da6c380f333cdcf204b53b3b38ef2ddeb07 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 7 Sep 2017 18:35:56 +0200 Subject: [PATCH 149/222] Breadcrumbs: fix margin bottom --- app/assets/stylesheets/new_design/breadcrumb.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/breadcrumb.scss b/app/assets/stylesheets/new_design/breadcrumb.scss index 055e58c6b..a1692a871 100644 --- a/app/assets/stylesheets/new_design/breadcrumb.scss +++ b/app/assets/stylesheets/new_design/breadcrumb.scss @@ -2,7 +2,7 @@ @import "constants"; .breadcrumbs { - margin: $default-spacer 0; + margin: $default-spacer 0 3 * $default-spacer; li { display: inline-block; From c2d042eb99fc8beb53f04666192b354ea21d7292 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 7 Sep 2017 18:14:45 +0200 Subject: [PATCH 150/222] Dossier show: display cards champ if needed --- app/views/new_gestionnaire/dossiers/show.html.haml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index 5e3592a03..af34e2cd7 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -11,9 +11,9 @@ .backoffice-title Formulaire - .card.featured - - champs = @dossier.ordered_champs.decorate - - if champs.any? + - champs = @dossier.ordered_champs.decorate + - if champs.any? + .card.featured = render partial: "champs", locals: { champs: champs } - if @dossier.procedure.use_api_carto From d9e532684f8367853f209dce05c8b0c067e7e3c4 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 7 Sep 2017 18:06:24 +0200 Subject: [PATCH 151/222] Login: fix remember me checkbox and forget password link --- app/assets/stylesheets/new_design/auth.scss | 8 +++++++- app/views/users/sessions/new.html.haml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/new_design/auth.scss b/app/assets/stylesheets/new_design/auth.scss index 9e241ecb4..87f29d6ea 100644 --- a/app/assets/stylesheets/new_design/auth.scss +++ b/app/assets/stylesheets/new_design/auth.scss @@ -1,4 +1,5 @@ @import "colors"; +@import "constants"; @import "placeholders"; @import "mixins"; @@ -60,7 +61,12 @@ $auth-breakpoint: 820px; .auth-form { .reset-password { - margin-top: 8px; + margin-top: - 3 * $default-spacer; + margin-bottom: $default-spacer; + } + + .remember-me { + display: inline-block; } .separation { diff --git a/app/views/users/sessions/new.html.haml b/app/views/users/sessions/new.html.haml index 2c66cc6af..e140cf563 100644 --- a/app/views/users/sessions/new.html.haml +++ b/app/views/users/sessions/new.html.haml @@ -38,7 +38,7 @@ - if devise_mapping.rememberable? = f.check_box :remember_me, as: :boolean - = f.label :remember_me, "Se souvenir de moi" + = f.label :remember_me, "Se souvenir de moi", class: 'remember-me' = f.submit "Se connecter", class: "button large primary expand" From fbd82a87db61109a08122e34f196e6035d5ff2c7 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 8 Sep 2017 11:01:31 +0200 Subject: [PATCH 152/222] Improve tests reliability --- .../description_controller_shared_example.rb | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/spec/controllers/users/description_controller_shared_example.rb b/spec/controllers/users/description_controller_shared_example.rb index f61a12773..90d101cef 100644 --- a/spec/controllers/users/description_controller_shared_example.rb +++ b/spec/controllers/users/description_controller_shared_example.rb @@ -223,38 +223,44 @@ shared_examples 'description_controller_spec' do describe 'Sauvegarde des champs' do let(:champs_dossier) { dossier.champs } - let(:dossier_champs_first) { 'test value' } + let(:dossier_text_value) { 'test value' } let(:dossier_date_value) { '23/06/2016' } let(:dossier_hour_value) { '17' } let(:dossier_minute_value) { '00' } + let(:dossier_datetime_champ_id) { dossier.champs.find { |c| c.type_champ == "datetime" }.id } + let(:dossier_text_champ_id) { dossier.champs.find { |c| c.type_champ == "text" }.id } + let(:params) { + { + dossier_id: dossier_id, + champs: { + "'#{dossier_text_champ_id}'" => dossier_text_value, # PARFOIS ce putain de champ est associé à un type datetime, et en plus parfois l'ordre n'est pas le bon + "'#{dossier_datetime_champ_id}'" => dossier_date_value + }, + time_hour: { + "'#{dossier_datetime_champ_id}'" => dossier_hour_value, + }, + time_minute: { + "'#{dossier_datetime_champ_id}'" => dossier_minute_value, + } + } + } before do - post :update, params: {dossier_id: dossier_id, - champs: { - "'#{dossier.champs.first.id}'" => dossier_champs_first, - "'#{dossier.champs.second.id}'" => dossier_date_value - }, - time_hour: { - "'#{dossier.champs.second.id}'" => dossier_hour_value, - }, - time_minute: { - "'#{dossier.champs.second.id}'" => dossier_minute_value, - } - } + post :update, params: params dossier.reload end - it { expect(dossier.champs.first.value).to eq(dossier_champs_first) } + it { expect(dossier.champs.find(dossier_text_champ_id).value).to eq(dossier_text_value) } it { expect(response).to redirect_to users_dossier_recapitulatif_path } context 'when champs is type_de_champ datetime' do - it { expect(dossier.champs.second.value).to eq(dossier_date_value + ' ' + dossier_hour_value + ':' + dossier_minute_value) } + it { expect(dossier.champs.find(dossier_datetime_champ_id).value).to eq(dossier_date_value + ' ' + dossier_hour_value + ':' + dossier_minute_value) } end context 'when champs value is empty' do - let(:dossier_champs_first) { '' } + let(:dossier_text_value) { '' } - it { expect(dossier.champs.first.value).to eq(dossier_champs_first) } + it { expect(dossier.champs.find(dossier_text_champ_id).value).to eq(dossier_text_value) } it { expect(response).to redirect_to users_dossier_recapitulatif_path } context 'when champs is mandatory' do From dd2d666347acbd1cb2d2d7b1dca9f9943bc372f1 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 8 Sep 2017 14:46:25 +0200 Subject: [PATCH 153/222] Limit long breadcrumbs, by truncating procedure name --- app/views/new_gestionnaire/dossiers/_header.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 46dcf1265..d464b6a14 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -3,7 +3,7 @@ .flex.justify-between %ul.breadcrumbs %li - = link_to dossier.procedure.libelle, procedure_path(dossier.procedure) + = link_to dossier.procedure.libelle.truncate_words(10), procedure_path(dossier.procedure), title: dossier.procedure.libelle %li = "Dossier nº #{dossier.id}" %div From 31dd45617aa3c5e3e6cc91004a7d1f230828871f Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 8 Sep 2017 14:24:57 +0200 Subject: [PATCH 154/222] PJ download button should be clear when PJ is available --- app/views/new_gestionnaire/dossiers/show.html.haml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/new_gestionnaire/dossiers/show.html.haml b/app/views/new_gestionnaire/dossiers/show.html.haml index af34e2cd7..516d2c520 100644 --- a/app/views/new_gestionnaire/dossiers/show.html.haml +++ b/app/views/new_gestionnaire/dossiers/show.html.haml @@ -30,7 +30,8 @@ %th Formulaire : %td - if @dossier.cerfa_available? - = link_to "Télécharger", @dossier.cerfa.last.content_url, class: "button", target: :blank + Pièce fournie - + = link_to "Consulter", @dossier.cerfa.last.content_url, class: "link", target: :blank - else Pièce non fournie @@ -40,6 +41,7 @@ %td - pj = @dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id) - if pj.present? - = link_to "Télécharger", pj.content_url, class: "button", target: :blank + Pièce fournie - + = link_to "Consulter", pj.content_url, class: "link", target: :blank - else Pièce non fournie From a4ea5ddcee2f3e74befa7402257046fa1990f046 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 12 Sep 2017 16:01:48 +0200 Subject: [PATCH 155/222] When changing dossier state do not switch the UI --- app/controllers/backoffice/dossiers_controller.rb | 2 +- .../new_gestionnaire/dossiers/_state_button.html.haml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index b0f07d5b5..e25fc8275 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -188,7 +188,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController private def redirect_to_dossier(dossier) - if URI(request.referer).path == dossier_path(dossier.procedure, dossier) + if params[:new_ui] # TODO delete new_ui when old UI is no longer used redirect_to dossier_path(dossier.procedure, dossier) else redirect_to backoffice_dossier_path(id: dossier.id) diff --git a/app/views/new_gestionnaire/dossiers/_state_button.html.haml b/app/views/new_gestionnaire/dossiers/_state_button.html.haml index 1151226ab..402766709 100644 --- a/app/views/new_gestionnaire/dossiers/_state_button.html.haml +++ b/app/views/new_gestionnaire/dossiers/_state_button.html.haml @@ -10,7 +10,7 @@ %h4 En construction Vous permettez à l'usager de modifier ses réponses au formulaire %li - = link_to backoffice_dossier_receive_path(dossier), method: :post, data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do + = link_to backoffice_dossier_receive_path(dossier, new_ui: true), method: :post, data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do %i.in-progress .description %h4 Passer en instruction @@ -18,7 +18,7 @@ - if dossier.en_instruction? %li - = link_to backoffice_dossier_reopen_path(dossier), method: :post, data: { confirm: "Confirmer vous la réouverture de ce dossier ?" } do + = link_to backoffice_dossier_reopen_path(dossier, new_ui: true), method: :post, data: { confirm: "Confirmer vous la réouverture de ce dossier ?" } do %i.edit .description %h4 Repasser en construction @@ -34,13 +34,13 @@ %h4 Accepter L'usager sera notifié que son dossier a été accepté %li - = link_to backoffice_dossier_process_dossier_path(dossier, process_action: "without_continuation"), method: :post, data: { confirm: "Confirmer vous le classement sans suite de ce dossier ?" } do + = link_to backoffice_dossier_process_dossier_path(dossier, process_action: "without_continuation", new_ui: true), method: :post, data: { confirm: "Confirmer vous le classement sans suite de ce dossier ?" } do %i.without-continuation .description %h4 Classer sans suite L'usager ne recevra aucune notification %li - = link_to backoffice_dossier_process_dossier_path(dossier, process_action: "refuse"), method: :post, data: { confirm: "Confirmer vous le refus de ce dossier ?" } do + = link_to backoffice_dossier_process_dossier_path(dossier, process_action: "refuse", new_ui: true), method: :post, data: { confirm: "Confirmer vous le refus de ce dossier ?" } do %i.close .description %h4 Refuser @@ -51,7 +51,7 @@ Accepter le dossier = "nº #{dossier.id}" - = form_tag(backoffice_dossier_process_dossier_url(dossier.id), method: :post, class: "form") do + = form_tag(backoffice_dossier_process_dossier_url(dossier.id, new_ui: true), method: :post, class: "form") do = text_area :dossier, :motivation, class: "motivation-text-area", placeholder: "Rédigez votre motivation ici (facultative)" %p.help L'acceptation du dossier envoie automatiquement une attestation à l'usager. From 31995c270c68acfa97fa07a9a9a778633afe6377 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 12 Sep 2017 17:02:45 +0200 Subject: [PATCH 156/222] [Fix #721] If an avis is created with uppercase email, downcase it before save --- app/controllers/backoffice/avis_controller.rb | 2 +- app/models/avis.rb | 7 ++++++ spec/models/avis_spec.rb | 22 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/controllers/backoffice/avis_controller.rb b/app/controllers/backoffice/avis_controller.rb index 5817e0c81..3ed67fa9e 100644 --- a/app/controllers/backoffice/avis_controller.rb +++ b/app/controllers/backoffice/avis_controller.rb @@ -7,7 +7,7 @@ class Backoffice::AvisController < ApplicationController avis = Avis.new(create_params.merge(claimant: current_gestionnaire, dossier: dossier)) if avis.save - flash[:notice] = "Votre demande d'avis a bien été envoyée à #{create_params[:email]}" + flash[:notice] = "Votre demande d'avis a bien été envoyée à #{avis.email}" end redirect_to backoffice_dossier_path(dossier) diff --git a/app/models/avis.rb b/app/models/avis.rb index 89e29c5a3..9d2253a2f 100644 --- a/app/models/avis.rb +++ b/app/models/avis.rb @@ -3,6 +3,7 @@ class Avis < ApplicationRecord belongs_to :gestionnaire belongs_to :claimant, class_name: 'Gestionnaire' + before_save :downcase_email before_create :try_to_assign_gestionnaire after_create :notify_gestionnaire @@ -27,6 +28,12 @@ class Avis < ApplicationRecord private + def downcase_email + if email.present? + email.downcase! + end + end + def notify_gestionnaire AvisMailer.avis_invitation(self).deliver_now end diff --git a/spec/models/avis_spec.rb b/spec/models/avis_spec.rb index cb8de8cce..0dd7ef2ac 100644 --- a/spec/models/avis_spec.rb +++ b/spec/models/avis_spec.rb @@ -117,4 +117,26 @@ RSpec.describe Avis, type: :model do it { expect(avis.email).to eq(email) } end end + + describe "#downcase_email" do + subject { Avis.create(claimant: claimant, email: email, dossier: create(:dossier), gestionnaire: create(:gestionnaire)) } + + context "when there is no email" do + let(:email) { nil } + + it { expect(subject.email).to be_nil } + end + + context "when the email is in lowercase" do + let(:email) { "toto@tps.fr" } + + it { expect(subject.email).to eq("toto@tps.fr") } + end + + context "when the email is not in lowercase" do + let(:email) { "TOTO@tps.fr" } + + it { expect(subject.email).to eq("toto@tps.fr") } + end + end end From f46adfd5a0fa14a36e874972b87a03349fb509f9 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 13 Sep 2017 11:23:03 +0200 Subject: [PATCH 157/222] Fix test that fails randomly --- spec/features/users/dossier_edition_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/features/users/dossier_edition_spec.rb b/spec/features/users/dossier_edition_spec.rb index 238a7c3d9..d2b5062f1 100644 --- a/spec/features/users/dossier_edition_spec.rb +++ b/spec/features/users/dossier_edition_spec.rb @@ -39,10 +39,11 @@ feature 'As a User I want to edit a dossier I own' do page.find_by_id('maj_infos').trigger('click') expect(page).to have_current_path(users_dossier_description_path(dossier.id.to_s), only_path: true) - fill_in "champs_#{dossier.champs.order(:id).first.id.to_s}", with: 'Contenu du champ 1' + champ_id = dossier.champs.order(:id).first.id + fill_in "champs_#{champ_id.to_s}", with: 'Contenu du champ 1' page.find_by_id('modification_terminee').click expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier.id.to_s), only_path: true) - expect(page.find("#champ-#{dossier.champs.order(:id).first.id}-value").text).to eq('Contenu du champ 1') + expect(page.find("#champ-#{champ_id}-value").text).to eq('Contenu du champ 1') end end end From 530998dad5d562da8ee846c790c09fab91b65846 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 13 Sep 2017 11:42:41 +0200 Subject: [PATCH 158/222] If gestionnaire is known on avis, use his email --- app/controllers/backoffice/avis_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/backoffice/avis_controller.rb b/app/controllers/backoffice/avis_controller.rb index 3ed67fa9e..ec76c663a 100644 --- a/app/controllers/backoffice/avis_controller.rb +++ b/app/controllers/backoffice/avis_controller.rb @@ -7,7 +7,7 @@ class Backoffice::AvisController < ApplicationController avis = Avis.new(create_params.merge(claimant: current_gestionnaire, dossier: dossier)) if avis.save - flash[:notice] = "Votre demande d'avis a bien été envoyée à #{avis.email}" + flash[:notice] = "Votre demande d'avis a bien été envoyée à #{avis.email_to_display}" end redirect_to backoffice_dossier_path(dossier) From 3fa300d1b6156eeaf2b1dc27d8fdc8e5de6150a6 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 8 Sep 2017 14:52:52 +0200 Subject: [PATCH 159/222] Date format on commentaire should be 13:30 le 31/01/2017 --- app/views/new_gestionnaire/dossiers/messagerie.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index 85a3d2248..3fee708de 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -12,7 +12,7 @@ = render partial: 'commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } - if ![current_gestionnaire.email, @dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email) %span.guest Invité - %span.date= I18n.l(commentaire.created_at.localtime, format: '%d/%m/%y') + %span.date= I18n.l(commentaire.created_at.localtime, format: '%H:%M le %d/%m/%Y') %p= sanitize(commentaire.body) = form_for(Commentaire.new, url: commentaire_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' }) do |f| From 3cbfd2709fe74968b29d93d90cc836e5bda0bd1c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 8 Sep 2017 15:04:31 +0200 Subject: [PATCH 160/222] Add disable_with on comment creation --- app/views/new_gestionnaire/dossiers/messagerie.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index 3fee708de..32db9b20c 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -18,4 +18,4 @@ = form_for(Commentaire.new, url: commentaire_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' }) do |f| = f.text_area :body, rows: 5, placeholder: 'Répondre ici', required: true .send-wrapper - = f.submit 'Envoyer', class: 'button send' + = f.submit 'Envoyer', class: 'button send', data: { disable_with: "Envoi..." } From bdf754c0d839e4847326e99be47733f440e68d79 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 8 Sep 2017 16:54:25 +0200 Subject: [PATCH 161/222] Automatically scroll to the last message --- app/assets/javascripts/new_design/messagerie.js | 8 ++++++++ app/assets/stylesheets/new_design/messagerie.scss | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 app/assets/javascripts/new_design/messagerie.js diff --git a/app/assets/javascripts/new_design/messagerie.js b/app/assets/javascripts/new_design/messagerie.js new file mode 100644 index 000000000..1b8d1d324 --- /dev/null +++ b/app/assets/javascripts/new_design/messagerie.js @@ -0,0 +1,8 @@ +TPS.scrollMessagerie = function () { + var $ul = $(".messagerie ul").first(); + if($ul.length) { + $ul.scrollTop($ul.prop('scrollHeight')); + } +}; + +document.addEventListener("turbolinks:load", TPS.scrollMessagerie); diff --git a/app/assets/stylesheets/new_design/messagerie.scss b/app/assets/stylesheets/new_design/messagerie.scss index a9bc70038..d597ac165 100644 --- a/app/assets/stylesheets/new_design/messagerie.scss +++ b/app/assets/stylesheets/new_design/messagerie.scss @@ -3,6 +3,14 @@ @import "constants"; .messagerie { + ul { + max-height: 350px; + overflow-y: scroll; + border: 1px solid $border-grey; + padding: 2 * $default-spacer; + margin-bottom: $default-spacer; + } + li { display: flex; align-items: flex-start; From 581da1921e97c3fc3ed7f75252787b9b97ca84fa Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 8 Sep 2017 17:17:19 +0200 Subject: [PATCH 162/222] Add a flash message after comment is created --- app/controllers/new_gestionnaire/dossiers_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index cc35adbd3..99ce6f033 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -45,6 +45,7 @@ module NewGestionnaire def create_commentaire Commentaire.create(commentaire_params.merge(email: current_gestionnaire.email, dossier: dossier)) + flash.notice = "Message envoyé" redirect_to messagerie_dossier_path(dossier.procedure, dossier) end From 9c8061d5a45f869ca6d2f2e2154d111842742e3c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 12 Sep 2017 15:27:57 +0200 Subject: [PATCH 163/222] Show pieces justificatives in messagerie --- app/assets/images/icons/attachment.svg | 1 + app/assets/stylesheets/new_design/icons.scss | 4 ++++ app/assets/stylesheets/new_design/messagerie.scss | 4 ++++ app/views/new_gestionnaire/dossiers/messagerie.html.haml | 5 +++++ app/views/root/patron.html.haml | 1 + 5 files changed, 15 insertions(+) create mode 100644 app/assets/images/icons/attachment.svg diff --git a/app/assets/images/icons/attachment.svg b/app/assets/images/icons/attachment.svg new file mode 100644 index 000000000..75d78782d --- /dev/null +++ b/app/assets/images/icons/attachment.svg @@ -0,0 +1 @@ +Shape \ No newline at end of file diff --git a/app/assets/stylesheets/new_design/icons.scss b/app/assets/stylesheets/new_design/icons.scss index a22cd9afd..fe7d8add2 100644 --- a/app/assets/stylesheets/new_design/icons.scss +++ b/app/assets/stylesheets/new_design/icons.scss @@ -48,4 +48,8 @@ i { &.bubble { background-image: image-url("icons/bubble.svg"); } + + &.attachment { + background-image: image-url("icons/attachment.svg"); + } } diff --git a/app/assets/stylesheets/new_design/messagerie.scss b/app/assets/stylesheets/new_design/messagerie.scss index d597ac165..eb5901dfe 100644 --- a/app/assets/stylesheets/new_design/messagerie.scss +++ b/app/assets/stylesheets/new_design/messagerie.scss @@ -38,4 +38,8 @@ .date { float: right; } + + .attachment-link { + margin-top: $default-spacer; + } } diff --git a/app/views/new_gestionnaire/dossiers/messagerie.html.haml b/app/views/new_gestionnaire/dossiers/messagerie.html.haml index 32db9b20c..96699c81c 100644 --- a/app/views/new_gestionnaire/dossiers/messagerie.html.haml +++ b/app/views/new_gestionnaire/dossiers/messagerie.html.haml @@ -14,6 +14,11 @@ %span.guest Invité %span.date= I18n.l(commentaire.created_at.localtime, format: '%H:%M le %d/%m/%Y') %p= sanitize(commentaire.body) + - if file = commentaire.piece_justificative + .attachment-link + = link_to file.content_url, class: "button", target: "_blank", title: "Télécharger" do + %i.attachment + = file.original_filename = form_for(Commentaire.new, url: commentaire_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' }) do |f| = f.text_area :body, rows: 5, placeholder: 'Répondre ici', required: true diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 5d295de01..438f8de64 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -13,6 +13,7 @@ %i.edit %i.in-progress %i.bubble + %i.attachment %h1 Formulaires From 66549f93bbda816054f8d46b2e0cbf46346c516b Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 14 Sep 2017 10:57:40 +0200 Subject: [PATCH 164/222] [Fix #727] Engagement champ should behave like checkbox when displayed --- app/decorators/champ_decorator.rb | 2 +- spec/decorators/champ_decorator_spec.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/decorators/champ_decorator.rb b/app/decorators/champ_decorator.rb index 1e1995de7..4652d5d08 100644 --- a/app/decorators/champ_decorator.rb +++ b/app/decorators/champ_decorator.rb @@ -4,7 +4,7 @@ class ChampDecorator < Draper::Decorator def value if type_champ == "date" && object.value.present? Date.parse(object.value).strftime("%d/%m/%Y") - elsif type_champ == 'checkbox' + elsif type_champ.in? ["checkbox", "engagement"] object.value == 'on' ? 'Oui' : 'Non' elsif type_champ == 'yes_no' if object.value == 'true' diff --git a/spec/decorators/champ_decorator_spec.rb b/spec/decorators/champ_decorator_spec.rb index c0817e4b6..2dc572ec5 100644 --- a/spec/decorators/champ_decorator_spec.rb +++ b/spec/decorators/champ_decorator_spec.rb @@ -20,6 +20,19 @@ describe ChampDecorator do end end + describe 'for a engagement' do + let(:type_champ) { :engagement } + + context 'when value is on' do + before { champ.update value: 'on' } + it { is_expected.to eq 'Oui' } + end + + context 'when value is other' do + it { is_expected.to eq 'Non' } + end + end + describe 'for a multiple_drop_down_list' do let(:type_champ) { :multiple_drop_down_list } From fe7f772f9672dee9783b5ef3ad7feace1de977e7 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 14 Sep 2017 10:11:45 +0200 Subject: [PATCH 165/222] Improve procedure logo on procedure#show --- .../stylesheets/new_design/procedure-logo.scss | 17 +++++++++++++++++ .../new_gestionnaire/procedures/show.html.haml | 8 +++++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 app/assets/stylesheets/new_design/procedure-logo.scss diff --git a/app/assets/stylesheets/new_design/procedure-logo.scss b/app/assets/stylesheets/new_design/procedure-logo.scss new file mode 100644 index 000000000..e6de617d9 --- /dev/null +++ b/app/assets/stylesheets/new_design/procedure-logo.scss @@ -0,0 +1,17 @@ +@import "colors"; +@import "constants"; + +.procedure-logo { + display: flex; + background: #FFFFFF; + border: 1px solid $border-grey; + height: 84px; + width: 84px; + margin-right: 2 * $default-spacer; + + img { + margin: auto; + max-width: 80%; + max-height: 80%; + } +} diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index c3ecf838b..69df7ab10 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -1,10 +1,12 @@ #procedure-show .backoffice-header .container.flex - - if @procedure.logo.present? - = image_tag @procedure.logo, height: 40, class: 'procedure-logo' - .width-100 + .procedure-logo + - if @procedure.logo.present? + = image_tag @procedure.logo, alt: "Logo de la procédure" + + .procedure-header %h1= @procedure.libelle %ul.tabs %li{ class: (@statut == 'a-suivre') ? 'active' : nil }> From b477adf586e8ea6855f3d7d127e0458f07afcdb1 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 14 Sep 2017 10:13:48 +0200 Subject: [PATCH 166/222] Improve procedure logo on procedure#index --- .../new_design/procedure_list.scss | 7 +- .../procedures/index.html.haml | 84 ++++++++++--------- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/app/assets/stylesheets/new_design/procedure_list.scss b/app/assets/stylesheets/new_design/procedure_list.scss index 09db9808e..16579bd74 100644 --- a/app/assets/stylesheets/new_design/procedure_list.scss +++ b/app/assets/stylesheets/new_design/procedure_list.scss @@ -26,16 +26,15 @@ } .procedure-logo { - margin-right: 16px; - width: 40px; - border-bottom: 1px solid $border-grey; + height: 93px; + width: 93px; + margin-right: 3 * $default-spacer; } .procedure-title { min-height: 40px; font-size: 20px; margin-bottom: 16px; - padding-left: $default-spacer; } .procedure-status { diff --git a/app/views/new_gestionnaire/procedures/index.html.haml b/app/views/new_gestionnaire/procedures/index.html.haml index 8477051c3..ab074836d 100644 --- a/app/views/new_gestionnaire/procedures/index.html.haml +++ b/app/views/new_gestionnaire/procedures/index.html.haml @@ -5,46 +5,50 @@ - @procedures.each do |p| %li.procedure-item.flex.align-start = link_to(procedure_path(p)) do - .procedure-details - %p.procedure-title + .flex + + .procedure-logo - if p.logo.present? - = image_tag p.logo, class: "procedure-logo" - #{p.libelle} + = image_tag p.logo, alt: "Logo de la procédure" - %ul.procedure-stats.flex - %li - - a_suivre_count = @dossiers_a_suivre_count_per_procedure[p.id] || 0 - .stats-number - = a_suivre_count - .stats-legend - à suivre - %li - - if @notifications_count_per_procedure[p.id].present? - %span.notifications{ 'aria-label': "notifications" } - - followed_count = @followed_dossiers_count_per_procedure[p.id] || 0 - .stats-number - = followed_count - .stats-legend - = t('pluralize.followed', count: followed_count) - %li - - termines_count = @dossiers_termines_count_per_procedure[p.id] || 0 - .stats-number - = termines_count - .stats-legend - = t('pluralize.processed', count: termines_count) - %li - - dossier_count = @dossiers_count_per_procedure[p.id] || 0 - .stats-number - = dossier_count - .stats-legend - = t('pluralize.case', count: dossier_count) - %li - - archived_count = @dossiers_archived_count_per_procedure[p.id] || 0 - .stats-number - = archived_count - .stats-legend - = t('pluralize.archived', count: archived_count) + .procedure-details + %p.procedure-title + = p.libelle - - if p.archivee? - .procedure-status - %span.label Archivée + %ul.procedure-stats.flex + %li + - a_suivre_count = @dossiers_a_suivre_count_per_procedure[p.id] || 0 + .stats-number + = a_suivre_count + .stats-legend + à suivre + %li + - if @notifications_count_per_procedure[p.id].present? + %span.notifications{ 'aria-label': "notifications" } + - followed_count = @followed_dossiers_count_per_procedure[p.id] || 0 + .stats-number + = followed_count + .stats-legend + = t('pluralize.followed', count: followed_count) + %li + - termines_count = @dossiers_termines_count_per_procedure[p.id] || 0 + .stats-number + = termines_count + .stats-legend + = t('pluralize.processed', count: termines_count) + %li + - dossier_count = @dossiers_count_per_procedure[p.id] || 0 + .stats-number + = dossier_count + .stats-legend + = t('pluralize.case', count: dossier_count) + %li + - archived_count = @dossiers_archived_count_per_procedure[p.id] || 0 + .stats-number + = archived_count + .stats-legend + = t('pluralize.archived', count: archived_count) + + - if p.archivee? + .procedure-status + %span.label Archivée From 35d7bac49e27d7a8230f2dc712e77ece6a46e071 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 15 Sep 2017 10:56:14 +0200 Subject: [PATCH 167/222] Style success flash messages --- app/assets/stylesheets/new_design/_colors.scss | 3 +++ app/assets/stylesheets/new_design/new_alert.scss | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/app/assets/stylesheets/new_design/_colors.scss b/app/assets/stylesheets/new_design/_colors.scss index fe9ece182..c46c85b3d 100644 --- a/app/assets/stylesheets/new_design/_colors.scss +++ b/app/assets/stylesheets/new_design/_colors.scss @@ -8,4 +8,7 @@ $dark-red: #A94442; $light-red: #EBCCD1; $lighter-red: #F2DEDE; $green: #35D49E; +$lighter-green: lighten($green, 30%); +$light-green: lighten($green, 25%); +$dark-green: darken($green, 20%); $orange: #F59415; diff --git a/app/assets/stylesheets/new_design/new_alert.scss b/app/assets/stylesheets/new_design/new_alert.scss index c57594c31..d88c9d6f0 100644 --- a/app/assets/stylesheets/new_design/new_alert.scss +++ b/app/assets/stylesheets/new_design/new_alert.scss @@ -10,3 +10,9 @@ border-color: $light-red; color: $dark-red; } + +.alert-success { + background-color: $lighter-green; + border-color: $light-green; + color: $dark-green; +} From e33259a464042fb75a282061271e276d16149dea Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 15 Sep 2017 14:46:17 +0200 Subject: [PATCH 168/222] Add download dossiers button on procedure#show --- .../stylesheets/new_design/procedures_show.scss | 8 ++++++++ app/views/new_gestionnaire/procedures/show.html.haml | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index c69942023..84ea39756 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -23,4 +23,12 @@ text-align: center; margin: 60px 0; } + + .procedure-actions { + margin-left: auto; + + .dropdown-items li { + min-width: 150px; + } + } } diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 69df7ab10..28538c565 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -38,6 +38,18 @@ = t('pluralize.archived', count: @archived_dossiers.count) %span.badge= @archived_dossiers.count + .procedure-actions + %span.button.dropdown + Télécharger tous les dossiers + .dropdown-content.fade-in-down + %ul.dropdown-items + %li + = link_to "Au format .csv", backoffice_download_dossiers_tps_path(format: :csv, procedure_id: @procedure.id), target: "_blank" + %li + = link_to "Au format .xls", backoffice_download_dossiers_tps_path(format: :xls, procedure_id: @procedure.id), target: "_blank" + %li + = link_to "Au format .ods", backoffice_download_dossiers_tps_path(format: :ods, procedure_id: @procedure.id), target: "_blank" + .container - if @dossiers.present? %table.table.dossiers-table.hoverable From ca82fba170c704f93477ce2e156012e5bc997625 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 19 Sep 2017 15:31:31 +0200 Subject: [PATCH 169/222] [Fix #738] TPS link on header should navigate on same UI --- app/controllers/root_controller.rb | 4 ++++ app/views/layouts/_new_header.haml | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 981e53fed..0cd686880 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -2,6 +2,10 @@ class RootController < ApplicationController layout 'new_application' def index + if params[:new_ui] && gestionnaire_signed_in? # TODO delete new_ui when old UI is no longer used + return redirect_to procedures_path + end + if administrateur_signed_in? return redirect_to admin_procedures_path diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index 1b9d7c703..5fff9c479 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -2,7 +2,8 @@ .header-inner-content .flex.align-center - = link_to root_path, class: "header-logo" do + -# TODO delete new_ui when old UI is no longer used + = link_to root_path(new_ui: 1), class: "header-logo" do %img{ src: image_url("header/logo-tps.svg") } - if gestionnaire_signed_in? From d47033deb2edcaf59c978b8b1de1f062caaf0307 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 20 Sep 2017 10:18:48 +0200 Subject: [PATCH 170/222] When filling a champ ensure it is a text champ --- spec/features/users/dossier_edition_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/users/dossier_edition_spec.rb b/spec/features/users/dossier_edition_spec.rb index d2b5062f1..698cb0dd8 100644 --- a/spec/features/users/dossier_edition_spec.rb +++ b/spec/features/users/dossier_edition_spec.rb @@ -39,7 +39,7 @@ feature 'As a User I want to edit a dossier I own' do page.find_by_id('maj_infos').trigger('click') expect(page).to have_current_path(users_dossier_description_path(dossier.id.to_s), only_path: true) - champ_id = dossier.champs.order(:id).first.id + champ_id = dossier.champs.find { |t| t.type_champ == "text" }.id fill_in "champs_#{champ_id.to_s}", with: 'Contenu du champ 1' page.find_by_id('modification_terminee').click expect(page).to have_current_path(users_dossier_recapitulatif_path(dossier.id.to_s), only_path: true) From bce3efc5d435b2bbe63ce4f0f0d1f318e94c4e7c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 19 Sep 2017 16:43:19 +0200 Subject: [PATCH 171/222] [Fix #735] Change nouveau state to en construction --- app/views/new_gestionnaire/procedures/_status.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/procedures/_status.html.haml b/app/views/new_gestionnaire/procedures/_status.html.haml index 23297e4e4..b6fbd6df9 100644 --- a/app/views/new_gestionnaire/procedures/_status.html.haml +++ b/app/views/new_gestionnaire/procedures/_status.html.haml @@ -1,7 +1,7 @@ - if dossier.en_instruction? %span.label.instruction en instruction - elsif dossier.en_construction? - %span.label.construction nouveau + %span.label.construction en construction - elsif dossier.closed? %span.label.closed accepté - elsif dossier.refused? From 44b5c4b93b23ecd0250593a0d59cbd40d8e90b89 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 20 Sep 2017 10:52:41 +0200 Subject: [PATCH 172/222] Dossiers should be sorted by updated_at date --- .../new_gestionnaire/procedures_controller_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index ac228d79f..1a581eed9 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -190,10 +190,10 @@ describe NewGestionnaire::ProceduresController, type: :controller do end describe 'statut' do - let!(:a_suivre__dossier) { create(:dossier, procedure: procedure, state: 'received') } - let!(:new_followed_dossier) { create(:dossier, procedure: procedure, state: 'received') } - let!(:termine_dossier) { create(:dossier, procedure: procedure, state: 'closed') } - let!(:archived_dossier) { create(:dossier, procedure: procedure, state: 'received', archived: true) } + let!(:a_suivre__dossier) { Timecop.freeze(1.day.ago){ create(:dossier, procedure: procedure, state: 'received') } } + let!(:new_followed_dossier) { Timecop.freeze(2.day.ago){ create(:dossier, procedure: procedure, state: 'received') } } + let!(:termine_dossier) { Timecop.freeze(3.day.ago){ create(:dossier, procedure: procedure, state: 'closed') } } + let!(:archived_dossier) { Timecop.freeze(4.day.ago){ create(:dossier, procedure: procedure, state: 'received', archived: true) } } before do gestionnaire.followed_dossiers << new_followed_dossier get :show, params: { procedure_id: procedure.id, statut: statut } @@ -231,7 +231,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do let(:statut) { 'tous' } it { expect(assigns(:statut)).to eq('tous') } - it { expect(assigns(:dossiers)).to match([a_suivre__dossier, new_followed_dossier, termine_dossier]) } + it { expect(assigns(:dossiers)).to match([a_suivre__dossier, new_followed_dossier, termine_dossier].sort_by(&:updated_at)) } end context 'when statut is archives' do From 3cc09c98f9dbd1bfb39d884ea571788b46e98e5d Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 6 Sep 2017 11:21:29 +0200 Subject: [PATCH 173/222] Avis: index --- .../new_gestionnaire/avis_controller.rb | 22 ++++++++++++ .../new_gestionnaire/avis/index.html.haml | 35 +++++++++++++++++++ config/routes.rb | 1 + .../new_gestionnaire/avis_controller_spec.rb | 29 +++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 app/controllers/new_gestionnaire/avis_controller.rb create mode 100644 app/views/new_gestionnaire/avis/index.html.haml create mode 100644 spec/controllers/new_gestionnaire/avis_controller_spec.rb diff --git a/app/controllers/new_gestionnaire/avis_controller.rb b/app/controllers/new_gestionnaire/avis_controller.rb new file mode 100644 index 000000000..0c003c17a --- /dev/null +++ b/app/controllers/new_gestionnaire/avis_controller.rb @@ -0,0 +1,22 @@ +module NewGestionnaire + class AvisController < ApplicationController + layout 'new_application' + + A_DONNER_STATUS = 'a-donner' + DONNES_STATUS = 'donnes' + + def index + gestionnaire_avis = current_gestionnaire.avis.includes(dossier: [:procedure, :user]) + @avis_a_donner, @avis_donnes = gestionnaire_avis.partition { |avis| avis.answer.nil? } + + @statut = params[:statut].present? ? params[:statut] : A_DONNER_STATUS + + @avis = case @statut + when A_DONNER_STATUS + @avis_a_donner + when DONNES_STATUS + @avis_donnes + end + end + end +end diff --git a/app/views/new_gestionnaire/avis/index.html.haml b/app/views/new_gestionnaire/avis/index.html.haml new file mode 100644 index 000000000..ee71f4d09 --- /dev/null +++ b/app/views/new_gestionnaire/avis/index.html.haml @@ -0,0 +1,35 @@ +#avis-index + .backoffice-header + .container.flex + .width-100 + %h1 Avis + %ul.tabs + %li{ class: (@statut == NewGestionnaire::AvisController::A_DONNER_STATUS) ? 'active' : nil }> + = link_to(avis_index_path(statut: NewGestionnaire::AvisController::A_DONNER_STATUS)) do + avis à donner + %span.badge= @avis_a_donner.count + + %li{ class: (@statut == NewGestionnaire::AvisController::DONNES_STATUS) ? 'active' : nil }> + = link_to(avis_index_path(statut: NewGestionnaire::AvisController::DONNES_STATUS)) do + avis #{'donné'.pluralize(@avis_donnes.count)} + %span.badge= @avis_donnes.count + + .container + - if @avis.present? + %table.table.dossiers-table.hoverable + %thead + %tr + %th.number-col Nº dossier + %th Demandeur + %th Procédure + %tbody + - @avis.each do |avis| + %tr + %td.number-col + = link_to(avis_path(avis), class: 'cell-link') do + %i.folder + #{avis.dossier.id} + %td= link_to(avis.dossier.user.email, avis_path(avis), class: 'cell-link') + %td= link_to(avis.dossier.procedure.libelle, avis_path(avis), class: 'cell-link') + - else + %h2 Aucun avis diff --git a/config/routes.rb b/config/routes.rb index 83adc5228..54694cee2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -258,6 +258,7 @@ Rails.application.routes.draw do end end end + resources :avis, only: [:index] get "recherche" => "recherches#index" end diff --git a/spec/controllers/new_gestionnaire/avis_controller_spec.rb b/spec/controllers/new_gestionnaire/avis_controller_spec.rb new file mode 100644 index 000000000..13f4e4925 --- /dev/null +++ b/spec/controllers/new_gestionnaire/avis_controller_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe NewGestionnaire::AvisController, type: :controller do + render_views + + let(:claimant) { create(:gestionnaire) } + let(:gestionnaire) { create(:gestionnaire) } + let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } + let(:dossier) { create(:dossier, :replied, procedure: procedure) } + let!(:avis_without_answer) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire) } + let!(:avis_with_answer) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire, answer: 'yop') } + + before { sign_in(gestionnaire) } + + describe '#index' do + before { get :index } + + it { expect(response).to have_http_status(:success) } + it { expect(assigns(:avis_a_donner)).to match([avis_without_answer]) } + it { expect(assigns(:avis_donnes)).to match([avis_with_answer]) } + it { expect(assigns(:statut)).to eq('a-donner') } + + context 'with a statut equal to donnes' do + before { get :index, statut: 'donnes' } + + it { expect(assigns(:statut)).to eq('donnes') } + end + end +end From a1f9f7aa750bf9aecd29ec2d52f6427851e933ee Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 6 Sep 2017 11:26:32 +0200 Subject: [PATCH 174/222] Avis: show --- .../new_gestionnaire/avis_controller.rb | 11 +++++ .../new_gestionnaire/avis/_header.html.haml | 9 ++++ .../new_gestionnaire/avis/show.html.haml | 47 +++++++++++++++++++ config/routes.rb | 2 +- .../new_gestionnaire/avis_controller_spec.rb | 8 ++++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 app/views/new_gestionnaire/avis/_header.html.haml create mode 100644 app/views/new_gestionnaire/avis/show.html.haml diff --git a/app/controllers/new_gestionnaire/avis_controller.rb b/app/controllers/new_gestionnaire/avis_controller.rb index 0c003c17a..e97768f0c 100644 --- a/app/controllers/new_gestionnaire/avis_controller.rb +++ b/app/controllers/new_gestionnaire/avis_controller.rb @@ -18,5 +18,16 @@ module NewGestionnaire @avis_donnes end end + + def show + @avis = avis + @dossier = avis.dossier + end + + private + + def avis + current_gestionnaire.avis.includes(dossier: [:avis]).find(params[:id]) + end end end diff --git a/app/views/new_gestionnaire/avis/_header.html.haml b/app/views/new_gestionnaire/avis/_header.html.haml new file mode 100644 index 000000000..e38916596 --- /dev/null +++ b/app/views/new_gestionnaire/avis/_header.html.haml @@ -0,0 +1,9 @@ +.backoffice-header + .container + %ul.breadcrumbs + %li= link_to('Avis', avis_index_path) + %li= "#{dossier.procedure.libelle}, dossier nº #{dossier.id}" + + %ul.tabs + %li{ class: current_page?(avis_path(avis)) ? 'active' : nil } + = link_to 'Demande', avis_path(avis) diff --git a/app/views/new_gestionnaire/avis/show.html.haml b/app/views/new_gestionnaire/avis/show.html.haml new file mode 100644 index 000000000..e88d364f3 --- /dev/null +++ b/app/views/new_gestionnaire/avis/show.html.haml @@ -0,0 +1,47 @@ +#avis-show + = render partial: 'header', locals: { avis: @avis, dossier: @dossier } + + .container + .card + .card-title Identité du demandeur + - if @dossier.entreprise.present? + = render partial: 'new_gestionnaire/dossiers/identite_entreprise', locals: { entreprise: @dossier.entreprise } + + - if @dossier.individual.present? + = render partial: 'new_gestionnaire/dossiers/identite_individual', locals: { individual: @dossier.individual } + + .backoffice-title Formulaire + + - champs = @dossier.ordered_champs.decorate + - if champs.any? + .card.featured + = render partial: 'new_gestionnaire/dossiers/champs', locals: { champs: champs } + + - if @dossier.procedure.use_api_carto + = render partial: 'new_gestionnaire/dossiers/map', locals: { dossier: @dossier } + + - if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? + .card.featured + .card-title Pièces jointes + + %table.table.vertical + %tbody + - if @dossier.procedure.cerfa_flag? + %tr + %th Formulaire : + %td + - if @dossier.cerfa_available? + = link_to 'Télécharger', @dossier.cerfa.last.content_url, class: 'button', target: :blank + - else + Pièce non fournie + + - @dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| + %tr + %th= "#{type_de_piece_justificative.libelle} :" + %td + - pj = @dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id) + - if pj.present? + Pièce fournie - + = link_to "Consulter", pj.content_url, class: "link", target: :blank + - else + Pièce non fournie diff --git a/config/routes.rb b/config/routes.rb index 54694cee2..5026843f1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -258,7 +258,7 @@ Rails.application.routes.draw do end end end - resources :avis, only: [:index] + resources :avis, only: [:index, :show] get "recherche" => "recherches#index" end diff --git a/spec/controllers/new_gestionnaire/avis_controller_spec.rb b/spec/controllers/new_gestionnaire/avis_controller_spec.rb index 13f4e4925..b5874754a 100644 --- a/spec/controllers/new_gestionnaire/avis_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/avis_controller_spec.rb @@ -26,4 +26,12 @@ describe NewGestionnaire::AvisController, type: :controller do it { expect(assigns(:statut)).to eq('donnes') } end end + + describe '#show' do + before { get :show, { id: avis_without_answer.id } } + + it { expect(response).to have_http_status(:success) } + it { expect(assigns(:avis)).to eq(avis_without_answer) } + it { expect(assigns(:dossier)).to eq(dossier) } + end end From 88c27479ee5e6b7ac600a61b13bd92bc29207b81 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 6 Sep 2017 16:14:03 +0200 Subject: [PATCH 175/222] Avis: instruction --- app/assets/stylesheets/new_design/avis.scss | 14 ++++++ .../new_gestionnaire/avis_controller.rb | 15 ++++++ .../new_gestionnaire/avis/_header.html.haml | 2 + .../avis/instruction.html.haml | 47 +++++++++++++++++++ config/routes.rb | 6 ++- .../new_gestionnaire/avis_controller_spec.rb | 19 ++++++++ 6 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 app/views/new_gestionnaire/avis/instruction.html.haml diff --git a/app/assets/stylesheets/new_design/avis.scss b/app/assets/stylesheets/new_design/avis.scss index e2ebc5675..f765678f6 100644 --- a/app/assets/stylesheets/new_design/avis.scss +++ b/app/assets/stylesheets/new_design/avis.scss @@ -2,6 +2,20 @@ @import "common"; @import "constants"; +.give-avis { + h1 { + font-size: 18px; + font-weight: bold; + margin-bottom: $default-padding; + } + + .avis-notice { + font-size: 12px; + color: $grey; + margin-bottom: 2 * $default-padding; + } +} + .ask-avis { h1 { font-size: 18px; diff --git a/app/controllers/new_gestionnaire/avis_controller.rb b/app/controllers/new_gestionnaire/avis_controller.rb index e97768f0c..ce1337f41 100644 --- a/app/controllers/new_gestionnaire/avis_controller.rb +++ b/app/controllers/new_gestionnaire/avis_controller.rb @@ -24,10 +24,25 @@ module NewGestionnaire @dossier = avis.dossier end + def instruction + @avis = avis + @dossier = avis.dossier + end + + def update + avis.update_attributes(avis_params) + flash.notice = 'Votre réponse est enregistrée.' + redirect_to instruction_avis_path(avis) + end + private def avis current_gestionnaire.avis.includes(dossier: [:avis]).find(params[:id]) end + + def avis_params + params.require(:avis).permit(:answer) + end end end diff --git a/app/views/new_gestionnaire/avis/_header.html.haml b/app/views/new_gestionnaire/avis/_header.html.haml index e38916596..9a01c84af 100644 --- a/app/views/new_gestionnaire/avis/_header.html.haml +++ b/app/views/new_gestionnaire/avis/_header.html.haml @@ -7,3 +7,5 @@ %ul.tabs %li{ class: current_page?(avis_path(avis)) ? 'active' : nil } = link_to 'Demande', avis_path(avis) + %li{ class: current_page?(instruction_avis_path(avis)) ? 'active' : nil } + = link_to 'Instruction', instruction_avis_path(avis) diff --git a/app/views/new_gestionnaire/avis/instruction.html.haml b/app/views/new_gestionnaire/avis/instruction.html.haml new file mode 100644 index 000000000..afcf61bb9 --- /dev/null +++ b/app/views/new_gestionnaire/avis/instruction.html.haml @@ -0,0 +1,47 @@ +#avis-show + = render partial: 'header', locals: { avis: @avis, dossier: @dossier } + +.container + %section.give-avis + %h1 Donner votre avis + %p.avis-notice= "#{@avis.claimant.email}: #{@avis.introduction}" + + = form_for @avis, url: avis_path(@avis), html: { class: 'form' } do |f| + = f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true + .send-wrapper + = f.submit 'Envoyer votre avis', class: 'button send' + + %section.ask-avis + %h1 Inviter une personne à donner son avis + %p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier. + + = form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f| + = f.email_field :email, placeholder: 'Adresse email', required: true + = f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true + .send-wrapper + = f.submit 'Demander un avis', class: 'button send' + + - if @dossier.avis.present? + %section.list-avis + %h1.title + Avis des invités + %span.count= @dossier.avis.count + + %ul + - @dossier.avis.each do |avis| + %li.one-avis + %h2.claimant + = (avis.claimant.email == current_gestionnaire.email) ? 'Vous' : avis.claimant.email + %span.date Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y')} + %p= avis.introduction + + .answer.flex.align-start + %i.bubble.avis-icon + .width-100 + %h2.gestionnaire + = avis.gestionnaire.email + - if avis.answer.present? + %span.date Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y')} + - else + %span.waiting En attente de réponse + %p= avis.answer diff --git a/config/routes.rb b/config/routes.rb index 5026843f1..25e54394b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -258,7 +258,11 @@ Rails.application.routes.draw do end end end - resources :avis, only: [:index, :show] + resources :avis, only: [:index, :show, :update] do + member do + get 'instruction' + end + end get "recherche" => "recherches#index" end diff --git a/spec/controllers/new_gestionnaire/avis_controller_spec.rb b/spec/controllers/new_gestionnaire/avis_controller_spec.rb index b5874754a..624730a64 100644 --- a/spec/controllers/new_gestionnaire/avis_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/avis_controller_spec.rb @@ -34,4 +34,23 @@ describe NewGestionnaire::AvisController, type: :controller do it { expect(assigns(:avis)).to eq(avis_without_answer) } it { expect(assigns(:dossier)).to eq(dossier) } end + + describe '#instruction' do + before { get :instruction, { id: avis_without_answer.id } } + + it { expect(response).to have_http_status(:success) } + it { expect(assigns(:avis)).to eq(avis_without_answer) } + it { expect(assigns(:dossier)).to eq(dossier) } + end + + describe '#update' do + before do + patch :update, { id: avis_without_answer.id, avis: { answer: 'answer' } } + avis_without_answer.reload + end + + it { expect(response).to redirect_to(instruction_avis_path(avis_without_answer)) } + it { expect(avis_without_answer.answer).to eq('answer') } + it { expect(flash.notice).to eq('Votre réponse est enregistrée.') } + end end From d1540c4a68365043ea93b2dcfa476f0a9c6d9565 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 6 Sep 2017 11:13:59 +0200 Subject: [PATCH 176/222] Avis: add avis link in header --- app/views/layouts/_new_header.haml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index 5fff9c479..e9a4f19ea 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -7,9 +7,14 @@ %img{ src: image_url("header/logo-tps.svg") } - if gestionnaire_signed_in? + - current_url = request.path_info %ul.header-tabs - %li - = link_to "Procédures", procedures_path, class: "active" + - if current_gestionnaire.procedures.count > 0 + %li + = link_to "Procédures", procedures_path, class: (controller_name != 'avis') ? "active" : nil + - if current_gestionnaire.avis.count > 0 + %li + = link_to "Avis", avis_index_path, class: (controller_name == 'avis') ? "active" : nil %li = link_to "Ancienne interface", backoffice_dossiers_path From 3dfd77e9144ac299dd9ebe3e701aebdd354a809a Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 6 Sep 2017 17:06:03 +0200 Subject: [PATCH 177/222] Avis: add messagerie --- .../new_gestionnaire/avis_controller.rb | 16 +++++++++++++- .../new_gestionnaire/avis/_header.html.haml | 2 ++ .../avis/messagerie.html.haml | 21 +++++++++++++++++++ config/routes.rb | 2 ++ .../new_gestionnaire/avis_controller_spec.rb | 17 +++++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 app/views/new_gestionnaire/avis/messagerie.html.haml diff --git a/app/controllers/new_gestionnaire/avis_controller.rb b/app/controllers/new_gestionnaire/avis_controller.rb index ce1337f41..a10b87c50 100644 --- a/app/controllers/new_gestionnaire/avis_controller.rb +++ b/app/controllers/new_gestionnaire/avis_controller.rb @@ -35,14 +35,28 @@ module NewGestionnaire redirect_to instruction_avis_path(avis) end + def messagerie + @avis = avis + @dossier = avis.dossier + end + + def create_commentaire + Commentaire.create(commentaire_params.merge(email: current_gestionnaire.email, dossier: avis.dossier)) + redirect_to messagerie_avis_path(avis) + end + private def avis - current_gestionnaire.avis.includes(dossier: [:avis]).find(params[:id]) + current_gestionnaire.avis.includes(dossier: [:avis, :commentaires]).find(params[:id]) end def avis_params params.require(:avis).permit(:answer) end + + def commentaire_params + params.require(:commentaire).permit(:body) + end end end diff --git a/app/views/new_gestionnaire/avis/_header.html.haml b/app/views/new_gestionnaire/avis/_header.html.haml index 9a01c84af..1933d5a71 100644 --- a/app/views/new_gestionnaire/avis/_header.html.haml +++ b/app/views/new_gestionnaire/avis/_header.html.haml @@ -9,3 +9,5 @@ = link_to 'Demande', avis_path(avis) %li{ class: current_page?(instruction_avis_path(avis)) ? 'active' : nil } = link_to 'Instruction', instruction_avis_path(avis) + %li{ class: current_page?(messagerie_avis_path(avis)) ? 'active' : nil } + = link_to 'Messagerie', messagerie_avis_path(avis) diff --git a/app/views/new_gestionnaire/avis/messagerie.html.haml b/app/views/new_gestionnaire/avis/messagerie.html.haml new file mode 100644 index 000000000..4365459e8 --- /dev/null +++ b/app/views/new_gestionnaire/avis/messagerie.html.haml @@ -0,0 +1,21 @@ += render partial: 'header', locals: { avis: @avis, dossier: @dossier } + +.messagerie.container + %ul + - @dossier.commentaires.ordered.each do |commentaire| + %li + = render partial: 'new_gestionnaire/dossiers/commentaire_icon', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } + + .width-100 + %h2 + %span.mail + = render partial: 'new_gestionnaire/dossiers/commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } + - if ![current_gestionnaire.email, @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') + %p= sanitize(commentaire.body) + + = form_for(Commentaire.new, url: commentaire_avis_path(@avis), html: { class: 'form' }) do |f| + = f.text_area :body, rows: 5, placeholder: 'Répondre ici', required: true + .send-wrapper + = f.submit 'Envoyer', class: 'button send' diff --git a/config/routes.rb b/config/routes.rb index 25e54394b..0cef1b99b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -261,6 +261,8 @@ Rails.application.routes.draw do resources :avis, only: [:index, :show, :update] do member do get 'instruction' + get 'messagerie' + post 'commentaire' => 'avis#create_commentaire' end end get "recherche" => "recherches#index" diff --git a/spec/controllers/new_gestionnaire/avis_controller_spec.rb b/spec/controllers/new_gestionnaire/avis_controller_spec.rb index 624730a64..03691fd1d 100644 --- a/spec/controllers/new_gestionnaire/avis_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/avis_controller_spec.rb @@ -43,6 +43,14 @@ describe NewGestionnaire::AvisController, type: :controller do it { expect(assigns(:dossier)).to eq(dossier) } end + describe '#messagerie' do + before { get :messagerie, { id: avis_without_answer.id } } + + it { expect(response).to have_http_status(:success) } + it { expect(assigns(:avis)).to eq(avis_without_answer) } + it { expect(assigns(:dossier)).to eq(dossier) } + end + describe '#update' do before do patch :update, { id: avis_without_answer.id, avis: { answer: 'answer' } } @@ -53,4 +61,13 @@ describe NewGestionnaire::AvisController, type: :controller do it { expect(avis_without_answer.answer).to eq('answer') } it { expect(flash.notice).to eq('Votre réponse est enregistrée.') } end + + describe '#create_commentaire' do + before do + post :create_commentaire, { id: avis_without_answer.id, commentaire: { body: 'commentaire body' } } + end + + it { expect(response).to redirect_to(messagerie_avis_path(avis_without_answer)) } + it { expect(dossier.commentaires.map(&:body)).to match(['commentaire body']) } + end end From 112e3a57936f3b94761f21fae6918cbabe7ff9e9 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 7 Sep 2017 16:04:53 +0200 Subject: [PATCH 178/222] Procedures: redirect to avis if suitable --- .../new_gestionnaire/procedures_controller.rb | 7 ++++ .../procedures_controller_spec.rb | 41 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index 0dcd55db4..ab78a563b 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -1,6 +1,7 @@ module NewGestionnaire class ProceduresController < GestionnaireController before_action :ensure_ownership!, except: [:index] + before_action :redirect_to_avis_if_needed, only: [:index] def index @procedures = current_gestionnaire.procedures.order(archived_at: :desc, published_at: :desc) @@ -76,5 +77,11 @@ module NewGestionnaire redirect_to root_path end end + + def redirect_to_avis_if_needed + if current_gestionnaire.procedures.count == 0 && current_gestionnaire.avis.count > 0 + redirect_to avis_index_path + end + end end end diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index 1a581eed9..30f70803a 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -42,6 +42,47 @@ describe NewGestionnaire::ProceduresController, type: :controller do end end + describe "before_action: redirect_to_avis_if_needed" do + it "is present" do + before_actions = NewGestionnaire::ProceduresController + ._process_action_callbacks + .find_all{|process_action_callbacks| process_action_callbacks.kind == :before} + .map(&:filter) + + expect(before_actions).to include(:redirect_to_avis_if_needed) + end + end + + describe "redirect_to_avis_if_needed" do + let(:gestionnaire) { create(:gestionnaire) } + + before do + expect(@controller).to receive(:current_gestionnaire).at_least(:once).and_return(gestionnaire) + allow(@controller).to receive(:redirect_to) + end + + context "when a gestionnaire has some procedures" do + let!(:some_procedure) { create(:procedure, gestionnaires: [gestionnaire]) } + + before { @controller.send(:redirect_to_avis_if_needed) } + + it "does not redirects nor flash" do + expect(@controller).not_to have_received(:redirect_to) + end + end + + context "when a gestionnaire has no procedure and some avis" do + before do + Avis.create!(dossier: create(:dossier), claimant: create(:gestionnaire), gestionnaire: gestionnaire) + @controller.send(:redirect_to_avis_if_needed) + end + + it "redirects avis" do + expect(@controller).to have_received(:redirect_to).with(avis_index_path) + end + end + end + describe "#index" do let(:gestionnaire) { create(:gestionnaire) } subject { get :index } From f55c7a05128acfa6055af04a3a349e410faf89e6 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Fri, 8 Sep 2017 11:52:20 +0200 Subject: [PATCH 179/222] Avis: add confidentiel field --- .../20170908094900_add_confidentiel_field_to_avis.rb | 5 +++++ db/schema.rb | 9 +++++---- .../2017_09_19_set_confidentialite_to_old_avis.rake | 5 +++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20170908094900_add_confidentiel_field_to_avis.rb create mode 100644 lib/tasks/2017_09_19_set_confidentialite_to_old_avis.rake diff --git a/db/migrate/20170908094900_add_confidentiel_field_to_avis.rb b/db/migrate/20170908094900_add_confidentiel_field_to_avis.rb new file mode 100644 index 000000000..eed554510 --- /dev/null +++ b/db/migrate/20170908094900_add_confidentiel_field_to_avis.rb @@ -0,0 +1,5 @@ +class AddConfidentielFieldToAvis < ActiveRecord::Migration[5.0] + def change + add_column :avis, :confidentiel, :boolean, default: false, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 04ae79e32..ec4a5d01a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170801083632) do +ActiveRecord::Schema.define(version: 20170908101023) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -99,9 +99,10 @@ ActiveRecord::Schema.define(version: 20170801083632) do t.text "answer" t.integer "gestionnaire_id" t.integer "dossier_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "claimant_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "claimant_id", null: false + t.boolean "confidentiel", default: false, null: false t.index ["claimant_id"], name: "index_avis_on_claimant_id", using: :btree t.index ["dossier_id"], name: "index_avis_on_dossier_id", using: :btree t.index ["gestionnaire_id"], name: "index_avis_on_gestionnaire_id", using: :btree diff --git a/lib/tasks/2017_09_19_set_confidentialite_to_old_avis.rake b/lib/tasks/2017_09_19_set_confidentialite_to_old_avis.rake new file mode 100644 index 000000000..9579811da --- /dev/null +++ b/lib/tasks/2017_09_19_set_confidentialite_to_old_avis.rake @@ -0,0 +1,5 @@ +namespace :'2017_09_19_set_confidentialite_to_old_avis' do + task set: :environment do + Avis.unscoped.update_all(confidentiel: true) + end +end From fdbf34f04bacc3b0a248dd267cfc619a2e69c778 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Fri, 8 Sep 2017 11:52:20 +0200 Subject: [PATCH 180/222] Avis instruction: only authorized avis --- app/models/dossier.rb | 12 +++++ .../avis/instruction.html.haml | 4 +- spec/models/dossier_spec.rb | 50 +++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 0c30adc50..c214479b0 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -348,6 +348,18 @@ class Dossier < ActiveRecord::Base parts.join end + def avis_for(gestionnaire) + if gestionnaire.dossiers.include?(self) + avis.order(created_at: :asc) + else + avis + .where(confidentiel: false) + .or(avis.where(claimant: gestionnaire)) + .or(avis.where(gestionnaire: gestionnaire)) + .order(created_at: :asc) + end + end + private def build_attestation diff --git a/app/views/new_gestionnaire/avis/instruction.html.haml b/app/views/new_gestionnaire/avis/instruction.html.haml index afcf61bb9..2df4cf918 100644 --- a/app/views/new_gestionnaire/avis/instruction.html.haml +++ b/app/views/new_gestionnaire/avis/instruction.html.haml @@ -25,10 +25,10 @@ %section.list-avis %h1.title Avis des invités - %span.count= @dossier.avis.count + %span.count= @dossier.avis_for(current_gestionnaire).count %ul - - @dossier.avis.each do |avis| + - @dossier.avis_for(current_gestionnaire).each do |avis| %li.one-avis %h2.claimant = (avis.claimant.email == current_gestionnaire.email) ? 'Vous' : avis.claimant.email diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index acba3c1ad..a0edb21b7 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -695,6 +695,56 @@ describe Dossier do end end + describe '#avis_for' do + let!(:procedure) { create(:procedure, :published) } + let!(:dossier) { create(:dossier, procedure: procedure, state: :initiated) } + + let!(:gestionnaire) { create(:gestionnaire, procedures: [procedure]) } + let!(:expert_1) { create(:gestionnaire) } + let!(:expert_2) { create(:gestionnaire) } + + context 'when there is a public advice asked from the dossiers gestionnaire' do + let!(:avis) { Avis.create(dossier: dossier, claimant: gestionnaire, gestionnaire: expert_1, confidentiel: false) } + + it { expect(dossier.avis_for(gestionnaire)).to match([avis]) } + it { expect(dossier.avis_for(expert_1)).to match([avis]) } + it { expect(dossier.avis_for(expert_2)).to match([avis]) } + end + + context 'when there is a private advice asked from the dossiers gestionnaire' do + let!(:avis) { Avis.create(dossier: dossier, claimant: gestionnaire, gestionnaire: expert_1, confidentiel: true) } + + it { expect(dossier.avis_for(gestionnaire)).to match([avis]) } + it { expect(dossier.avis_for(expert_1)).to match([avis]) } + it { expect(dossier.avis_for(expert_2)).to match([]) } + end + + context 'when there is a public advice asked from one expert to another' do + let!(:avis) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false) } + + it { expect(dossier.avis_for(gestionnaire)).to match([avis]) } + it { expect(dossier.avis_for(expert_1)).to match([avis]) } + it { expect(dossier.avis_for(expert_2)).to match([avis]) } + end + + context 'when there is a private advice asked from one expert to another' do + let!(:avis) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: true) } + + it { expect(dossier.avis_for(gestionnaire)).to match([avis]) } + it { expect(dossier.avis_for(expert_1)).to match([avis]) } + it { expect(dossier.avis_for(expert_2)).to match([avis]) } + end + + context 'when they are a lot of advice' do + let!(:avis_1) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: DateTime.parse('10/01/2010')) } + let!(:avis_2) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: DateTime.parse('9/01/2010')) } + let!(:avis_3) { Avis.create(dossier: dossier, claimant: expert_1, gestionnaire: expert_2, confidentiel: false, created_at: DateTime.parse('11/01/2010')) } + + it { expect(dossier.avis_for(gestionnaire)).to match([avis_2, avis_1, avis_3]) } + it { expect(dossier.avis_for(expert_1)).to match([avis_2, avis_1, avis_3]) } + end + end + describe '#update_state_dates' do let(:state) { 'draft' } let(:dossier) { create(:dossier, state: state) } From f420cde53165c25d7dc789317f741dab5518fbdb Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 19 Sep 2017 17:43:07 +0200 Subject: [PATCH 181/222] Icons: add lock --- app/assets/images/icons/lock.svg | 1 + app/assets/stylesheets/new_design/icons.scss | 4 ++++ app/views/root/patron.html.haml | 1 + 3 files changed, 6 insertions(+) create mode 100644 app/assets/images/icons/lock.svg diff --git a/app/assets/images/icons/lock.svg b/app/assets/images/icons/lock.svg new file mode 100644 index 000000000..a2aa4f2ab --- /dev/null +++ b/app/assets/images/icons/lock.svg @@ -0,0 +1 @@ + diff --git a/app/assets/stylesheets/new_design/icons.scss b/app/assets/stylesheets/new_design/icons.scss index fe7d8add2..2e09bac25 100644 --- a/app/assets/stylesheets/new_design/icons.scss +++ b/app/assets/stylesheets/new_design/icons.scss @@ -52,4 +52,8 @@ i { &.attachment { background-image: image-url("icons/attachment.svg"); } + + &.lock { + background-image: image-url("icons/lock.svg"); + } } diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 438f8de64..c5cc0164e 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -14,6 +14,7 @@ %i.in-progress %i.bubble %i.attachment + %i.lock %h1 Formulaires From 4dd20c17d13fb89cab2805209fb184a74750d722 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 20 Sep 2017 10:41:09 +0200 Subject: [PATCH 182/222] Avis: extract of avis list and add confidential icon --- .../avis/_avis_list.html.haml | 30 +++++++++++++++++++ .../avis/instruction.html.haml | 25 +--------------- .../dossiers/instruction.html.haml | 25 +--------------- 3 files changed, 32 insertions(+), 48 deletions(-) create mode 100644 app/views/new_gestionnaire/avis/_avis_list.html.haml diff --git a/app/views/new_gestionnaire/avis/_avis_list.html.haml b/app/views/new_gestionnaire/avis/_avis_list.html.haml new file mode 100644 index 000000000..ffcdcadc2 --- /dev/null +++ b/app/views/new_gestionnaire/avis/_avis_list.html.haml @@ -0,0 +1,30 @@ +- if avis.present? + %section.list-avis + %h1.title + Avis des invités + %span.count= avis.count + + %ul + - avis.each do |avis| + %li.one-avis.flex.align-start + .width-100 + %h2.claimant + Demandeur : + %span.email= (avis.claimant.email == current_gestionnaire.email) ? 'Vous' : avis.claimant.email + - if avis.confidentiel? + %span.confidentiel + confidentiel + %i.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')} + %p= avis.introduction + + .answer.flex.align-start + %i.bubble.avis-icon + .width-100 + %h2.gestionnaire + = (avis.gestionnaire.email == current_gestionnaire.email) ? 'Vous' : avis.gestionnaire.email + - if avis.answer.present? + %span.date Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y')} + - 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 2df4cf918..dd11eada0 100644 --- a/app/views/new_gestionnaire/avis/instruction.html.haml +++ b/app/views/new_gestionnaire/avis/instruction.html.haml @@ -21,27 +21,4 @@ .send-wrapper = f.submit 'Demander un avis', class: 'button send' - - if @dossier.avis.present? - %section.list-avis - %h1.title - Avis des invités - %span.count= @dossier.avis_for(current_gestionnaire).count - - %ul - - @dossier.avis_for(current_gestionnaire).each do |avis| - %li.one-avis - %h2.claimant - = (avis.claimant.email == current_gestionnaire.email) ? 'Vous' : avis.claimant.email - %span.date Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y')} - %p= avis.introduction - - .answer.flex.align-start - %i.bubble.avis-icon - .width-100 - %h2.gestionnaire - = avis.gestionnaire.email - - if avis.answer.present? - %span.date Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y')} - - else - %span.waiting En attente de réponse - %p= avis.answer + = render partial: 'avis_list', locals: { avis: @dossier.avis_for(current_gestionnaire) } diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml index 016abc911..c07dcbe5c 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -11,30 +11,7 @@ .send-wrapper = f.submit 'Demander un avis', class: 'button send' - - if @dossier.avis.present? - %section.list-avis - %h1.title - Avis des invités - %span.count= @dossier.avis.count - - %ul - - @dossier.avis.each do |avis| - %li.one-avis - %h2.claimant - = (avis.claimant.email == current_gestionnaire.email) ? 'Vous' : avis.claimant.email - %span.date Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y')} - %p= avis.introduction - - .answer.flex.align-start - %i.bubble.avis-icon - .width-100 - %h2.gestionnaire - = avis.gestionnaire.email - - if avis.answer.present? - %span.date Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y')} - - else - %span.waiting En attente de réponse - %p= avis.answer + = render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis } - if @dossier.ordered_champs_private.present? %section From caaa3169e5847006536553973e86b244bf0cf36f Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 20 Sep 2017 10:52:48 +0200 Subject: [PATCH 183/222] Avis instruction: can ask for a confidentiel avis --- app/assets/stylesheets/new_design/avis.scss | 59 ++++++++++++++++++- app/assets/stylesheets/new_design/flex.scss | 4 ++ .../new_gestionnaire/avis_controller.rb | 10 ++++ .../avis/instruction.html.haml | 30 ++++++++-- config/routes.rb | 1 + .../new_gestionnaire/avis_controller_spec.rb | 42 +++++++++++++ 6 files changed, 137 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/new_design/avis.scss b/app/assets/stylesheets/new_design/avis.scss index f765678f6..94ff4b0ee 100644 --- a/app/assets/stylesheets/new_design/avis.scss +++ b/app/assets/stylesheets/new_design/avis.scss @@ -9,10 +9,30 @@ margin-bottom: $default-padding; } - .avis-notice { + .lock { + margin-right: $default-spacer; + } + + h2 { + font-weight: bold; + margin-bottom: $default-padding; + } + + .introduction { + margin-bottom: $default-padding; + } + + .confidentiel { + color: $grey; + font-weight: normal; + margin-bottom: 2 * $default-padding; + } + + .date { font-size: 12px; color: $grey; - margin-bottom: 2 * $default-padding; + float: right; + font-weight: normal; } } @@ -24,7 +44,7 @@ } .avis-notice { - font-size: 12px; + font-size: 14px; color: $grey; margin-bottom: 2 * $default-padding; } @@ -32,6 +52,23 @@ input[type=email] { max-width: 500px; } + + form > label { + display: inline-block; + } + + .confidentiel { + color: $grey; + font-weight: normal; + margin-bottom: 2 * $default-padding; + } + + .confidentiel-wrapper { + label, + select { + display: inline-block; + } + } } .list-avis { @@ -57,6 +94,10 @@ border-top: 1px solid $grey; padding: $default-padding 0; + .lock { + margin-right: $default-spacer; + } + h2 { font-weight: bold; margin-bottom: $default-spacer; @@ -73,6 +114,18 @@ .avis-icon { margin-right: $default-spacer; } + + .confidentiel { + color: $grey; + font-size: 12px; + + .lock { + width: 12px; + height: 12px; + background-size: 12px 12px; + vertical-align: sub; + } + } } .date, diff --git a/app/assets/stylesheets/new_design/flex.scss b/app/assets/stylesheets/new_design/flex.scss index b3910bc37..43416c333 100644 --- a/app/assets/stylesheets/new_design/flex.scss +++ b/app/assets/stylesheets/new_design/flex.scss @@ -9,6 +9,10 @@ align-items: flex-start; } + &.align-baseline { + align-items: baseline; + } + &.justify-between { justify-content: space-between; } diff --git a/app/controllers/new_gestionnaire/avis_controller.rb b/app/controllers/new_gestionnaire/avis_controller.rb index a10b87c50..94f05886e 100644 --- a/app/controllers/new_gestionnaire/avis_controller.rb +++ b/app/controllers/new_gestionnaire/avis_controller.rb @@ -45,6 +45,12 @@ module NewGestionnaire redirect_to messagerie_avis_path(avis) end + def create_avis + confidentiel = avis.confidentiel || params[:avis][:confidentiel] + Avis.create(create_avis_params.merge(claimant: current_gestionnaire, dossier: avis.dossier, confidentiel: confidentiel)) + redirect_to instruction_avis_path(avis) + end + private def avis @@ -58,5 +64,9 @@ module NewGestionnaire def commentaire_params params.require(:commentaire).permit(:body) end + + def create_avis_params + params.require(:avis).permit(:email, :introduction) + end end end diff --git a/app/views/new_gestionnaire/avis/instruction.html.haml b/app/views/new_gestionnaire/avis/instruction.html.haml index dd11eada0..82380bb29 100644 --- a/app/views/new_gestionnaire/avis/instruction.html.haml +++ b/app/views/new_gestionnaire/avis/instruction.html.haml @@ -4,21 +4,39 @@ .container %section.give-avis %h1 Donner votre avis - %p.avis-notice= "#{@avis.claimant.email}: #{@avis.introduction}" + %h2.claimant + = @avis.claimant.email + %span.date Demande d'avis envoyée le #{I18n.l(@avis.created_at.localtime, format: '%d/%m/%y')} + %p.introduction= @avis.introduction = form_for @avis, url: avis_path(@avis), html: { class: 'form' } do |f| = f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true - .send-wrapper - = f.submit 'Envoyer votre avis', class: 'button send' + .flex.justify-between.align-baseline + %p.confidentiel + %i.lock + Cet avis est confidentiel et n'est pas affiché aux autres experts consultés + .send-wrapper + = f.submit 'Envoyer votre avis', class: 'button send' %section.ask-avis %h1 Inviter une personne à donner son avis %p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier. - = form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f| + = form_for Avis.new, url: avis_avis_path(@avis), html: { class: 'form' } do |f| = f.email_field :email, placeholder: 'Adresse email', required: true = f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true - .send-wrapper - = f.submit 'Demander un avis', class: 'button send' + .flex.justify-between.align-baseline + - if @avis.confidentiel? + %p.confidentiel + %i.lock + Cet avis est confidentiel et n'est pas affiché aux autres experts consultés + .send-wrapper + = f.submit 'Demander un avis', class: 'button send' + - else + .confidentiel-wrapper + = f.label :confidentiel, 'Cet avis est' + = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]] + .send-wrapper + = f.submit 'Demander un avis', class: 'button send' = render partial: 'avis_list', locals: { avis: @dossier.avis_for(current_gestionnaire) } diff --git a/config/routes.rb b/config/routes.rb index 0cef1b99b..755d30ff2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -263,6 +263,7 @@ Rails.application.routes.draw do get 'instruction' get 'messagerie' post 'commentaire' => 'avis#create_commentaire' + post 'avis' => 'avis#create_avis' end end get "recherche" => "recherches#index" diff --git a/spec/controllers/new_gestionnaire/avis_controller_spec.rb b/spec/controllers/new_gestionnaire/avis_controller_spec.rb index 03691fd1d..5254c3344 100644 --- a/spec/controllers/new_gestionnaire/avis_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/avis_controller_spec.rb @@ -70,4 +70,46 @@ describe NewGestionnaire::AvisController, type: :controller do it { expect(response).to redirect_to(messagerie_avis_path(avis_without_answer)) } it { expect(dossier.commentaires.map(&:body)).to match(['commentaire body']) } end + + describe '#create_avis' do + let!(:previous_avis) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire, confidentiel: previous_avis_confidentiel) } + let(:email) { 'a@b.com' } + let(:intro) { 'introduction' } + let(:created_avis) { Avis.last } + + before do + post :create_avis, { id: previous_avis.id, avis: { email: email, introduction: intro, confidentiel: asked_confidentiel } } + end + + context 'when the previous avis is public' do + let(:previous_avis_confidentiel) { false } + + context 'when the user asked for a public avis' do + let(:asked_confidentiel) { false } + + it { expect(created_avis.confidentiel).to be(false) } + it { expect(created_avis.email).to eq(email) } + it { expect(created_avis.introduction).to eq(intro) } + it { expect(created_avis.dossier).to eq(previous_avis.dossier) } + it { expect(created_avis.claimant).to eq(gestionnaire) } + it { expect(response).to redirect_to(instruction_avis_path(previous_avis)) } + end + + context 'when the user asked for a confidentiel avis' do + let(:asked_confidentiel) { true } + + it { expect(created_avis.confidentiel).to be(true) } + end + end + + context 'when the preivous avis is confidentiel' do + let(:previous_avis_confidentiel) { true } + + context 'when the user asked for a public avis' do + let(:asked_confidentiel) { false } + + it { expect(created_avis.confidentiel).to be(true) } + end + end + end end From 3c3e303a59ebed1cc76a7e110e597b9c9cd3a2fd Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 20 Sep 2017 10:42:16 +0200 Subject: [PATCH 184/222] Dossier instruction: can ask for a confidentiel avis --- app/controllers/new_gestionnaire/dossiers_controller.rb | 2 +- app/views/new_gestionnaire/dossiers/instruction.html.haml | 8 ++++++-- .../new_gestionnaire/dossiers_controller_spec.rb | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 99ce6f033..69ea7ee99 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -87,7 +87,7 @@ module NewGestionnaire end def avis_params - params.require(:avis).permit(:email, :introduction) + params.require(:avis).permit(:email, :introduction, :confidentiel) end def champs_private_params diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml index c07dcbe5c..19955f412 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -8,8 +8,12 @@ = form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f| = f.email_field :email, placeholder: 'Adresse email', required: true = f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true - .send-wrapper - = f.submit 'Demander un avis', class: 'button send' + .flex.justify-between.align-baseline + .confidentiel-wrapper + = f.label :confidentiel, 'Cet avis est' + = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]] + .send-wrapper + = f.submit 'Demander un avis', class: 'button send' = render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis } diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 084a52ed2..988e8e05a 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe NewGestionnaire::DossiersController, type: :controller do + render_views + let(:gestionnaire) { create(:gestionnaire) } let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } let(:dossier) { create(:dossier, :replied, procedure: procedure) } @@ -122,12 +124,13 @@ describe NewGestionnaire::DossiersController, type: :controller do post :create_avis, params: { procedure_id: procedure.id, dossier_id: dossier.id, - avis: { email: 'email@a.com', introduction: 'intro' } + avis: { email: 'email@a.com', introduction: 'intro', confidentiel: true } } end it { expect(saved_avis.email).to eq('email@a.com') } it { expect(saved_avis.introduction).to eq('intro') } + it { expect(saved_avis.confidentiel).to eq(true) } it { expect(saved_avis.dossier).to eq(dossier) } it { expect(saved_avis.claimant).to eq(gestionnaire) } it { expect(response).to redirect_to(instruction_dossier_path(dossier.procedure, dossier)) } From bacff0a17898c337e8cf577442afa2bd916f4375 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 20 Sep 2017 10:51:06 +0200 Subject: [PATCH 185/222] Avis: wording --- app/assets/stylesheets/new_design/avis.scss | 11 ++++++----- app/views/new_gestionnaire/avis/instruction.html.haml | 3 ++- .../new_gestionnaire/dossiers/instruction.html.haml | 2 +- app/views/root/patron.html.haml | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/new_design/avis.scss b/app/assets/stylesheets/new_design/avis.scss index 94ff4b0ee..2686d8311 100644 --- a/app/assets/stylesheets/new_design/avis.scss +++ b/app/assets/stylesheets/new_design/avis.scss @@ -14,8 +14,11 @@ } h2 { - font-weight: bold; margin-bottom: $default-padding; + + .email { + font-weight: bold; + } } .introduction { @@ -32,7 +35,6 @@ font-size: 12px; color: $grey; float: right; - font-weight: normal; } } @@ -99,11 +101,10 @@ } h2 { - font-weight: bold; margin-bottom: $default-spacer; - span { - font-weight: normal; + .email { + font-weight: bold; } } diff --git a/app/views/new_gestionnaire/avis/instruction.html.haml b/app/views/new_gestionnaire/avis/instruction.html.haml index 82380bb29..53c4dd8e7 100644 --- a/app/views/new_gestionnaire/avis/instruction.html.haml +++ b/app/views/new_gestionnaire/avis/instruction.html.haml @@ -5,7 +5,8 @@ %section.give-avis %h1 Donner votre avis %h2.claimant - = @avis.claimant.email + Demandeur : + %span.email= @avis.claimant.email %span.date Demande d'avis envoyée le #{I18n.l(@avis.created_at.localtime, format: '%d/%m/%y')} %p.introduction= @avis.introduction diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml index 19955f412..ed597681f 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -3,7 +3,7 @@ #dossier-instruction.container %section.ask-avis %h1 Inviter une personne à donner son avis - %p.avis-notice Elle pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais elle ne pourra le modifier. + %p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier. = form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f| = f.email_field :email, placeholder: 'Adresse email', required: true diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index c5cc0164e..6c7abfb16 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -162,7 +162,7 @@ .container %section.ask-avis %h1 Inviter une personne à donner son avis - %p.avis-notice Elle pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais elle ne pourra le modifier. + %p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier. = form_for Avis.new, url: '/', html: { class: 'form' } do |f| = f.email_field :email, placeholder: 'Adresse email', required: true From 11e8feacce3faf0428ba081c62aa391826c4da49 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 20 Sep 2017 17:07:09 +0200 Subject: [PATCH 186/222] Style: extract class describing empty stuff --- app/assets/stylesheets/new_design/procedures_show.scss | 7 ------- app/assets/stylesheets/new_design/utils.scss | 7 +++++++ app/views/new_gestionnaire/avis/index.html.haml | 2 +- app/views/new_gestionnaire/procedures/show.html.haml | 2 +- app/views/root/patron.html.haml | 3 +++ 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index 84ea39756..5b9805c8a 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -17,13 +17,6 @@ margin: (3 * $default-spacer) auto; } - h2 { - font-size: 20px; - font-weight: bold; - text-align: center; - margin: 60px 0; - } - .procedure-actions { margin-left: auto; diff --git a/app/assets/stylesheets/new_design/utils.scss b/app/assets/stylesheets/new_design/utils.scss index 91e3fed99..599609dd5 100644 --- a/app/assets/stylesheets/new_design/utils.scss +++ b/app/assets/stylesheets/new_design/utils.scss @@ -25,3 +25,10 @@ .width-100 { width: 100%; } + +.empty-text { + font-size: 20px; + font-weight: bold; + text-align: center; + margin: 60px 0; +} diff --git a/app/views/new_gestionnaire/avis/index.html.haml b/app/views/new_gestionnaire/avis/index.html.haml index ee71f4d09..052a6e918 100644 --- a/app/views/new_gestionnaire/avis/index.html.haml +++ b/app/views/new_gestionnaire/avis/index.html.haml @@ -32,4 +32,4 @@ %td= link_to(avis.dossier.user.email, avis_path(avis), class: 'cell-link') %td= link_to(avis.dossier.procedure.libelle, avis_path(avis), class: 'cell-link') - else - %h2 Aucun avis + %h2.empty-text Aucun avis diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 28538c565..5bd179d12 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -74,4 +74,4 @@ = render partial: 'status', locals: { dossier: dossier } %td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) } - else - %h2 Aucun dossier + %h2.empty-text Aucun dossier diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 6c7abfb16..8777c35d9 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -189,3 +189,6 @@ gestionnnaire@tps.com %span.date Réponse donnée le 13/01/2012 %p Je donne un avis favorable + + .container + %h2.empty-text Aucun dossier From 5b955677c20c5bd8c575d5503aeff950fcf8bd8d Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 14 Sep 2017 16:41:58 +0200 Subject: [PATCH 187/222] [Fix #719] Unformat date and yes/no values in the form --- .../users/description/champs/_date.html.haml | 2 +- .../description/champs/_yes_no.html.haml | 4 +-- .../champs/_date.html.haml_spec.rb | 15 +++++++++++ .../champs/_yes_no.html.haml_spec.rb | 25 +++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 spec/views/users/description/champs/_date.html.haml_spec.rb create mode 100644 spec/views/users/description/champs/_yes_no.html.haml_spec.rb diff --git a/app/views/users/description/champs/_date.html.haml b/app/views/users/description/champs/_date.html.haml index f04b581a6..74088b67c 100644 --- a/app/views/users/description/champs/_date.html.haml +++ b/app/views/users/description/champs/_date.html.haml @@ -1,5 +1,5 @@ %input.form-control{ name: "champs['#{champ.id}']", placeholder: "JJ/MM/AAAA", id: "champs_#{champ.id}", - value: champ.value, + value: champ.value ? champ.object.value : champ.value, type: "date" } diff --git a/app/views/users/description/champs/_yes_no.html.haml b/app/views/users/description/champs/_yes_no.html.haml index e914d1bb3..83d4622dc 100644 --- a/app/views/users/description/champs/_yes_no.html.haml +++ b/app/views/users/description/champs/_yes_no.html.haml @@ -1,8 +1,8 @@ %div %label.radio-inline - = radio_button_tag "champs['#{champ.id}']", "true", champ.value == 'true' + = radio_button_tag "champs['#{champ.id}']", "true", champ.object.value == 'true' Oui %label.radio-inline - = radio_button_tag "champs['#{champ.id}']", "false", champ.value == 'false' + = radio_button_tag "champs['#{champ.id}']", "false", champ.object.value == 'false' Non diff --git a/spec/views/users/description/champs/_date.html.haml_spec.rb b/spec/views/users/description/champs/_date.html.haml_spec.rb new file mode 100644 index 000000000..5e0e797e7 --- /dev/null +++ b/spec/views/users/description/champs/_date.html.haml_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe 'users/description/champs/date.html.haml', type: :view do + let(:type_champ) { create(:type_de_champ_public, type_champ: :date) } + + before do + render 'users/description/champs/date.html.haml', champ: champ + end + + let!(:champ) { create(:champ, type_de_champ: type_champ, value: "2017-09-19").decorate } + + it 'should render an input for the dossier link' do + expect(rendered).to have_css("input[value='2017-09-19']") + end +end diff --git a/spec/views/users/description/champs/_yes_no.html.haml_spec.rb b/spec/views/users/description/champs/_yes_no.html.haml_spec.rb new file mode 100644 index 000000000..9d2af680c --- /dev/null +++ b/spec/views/users/description/champs/_yes_no.html.haml_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe 'users/description/champs/yes_no.html.haml', type: :view do + let(:type_champ) { create(:type_de_champ_public, type_champ: :yes_no) } + + before do + render 'users/description/champs/yes_no.html.haml', champ: champ + end + + context "when the value is Oui" do + let!(:champ) { create(:champ, type_de_champ: type_champ, value: "true").decorate } + + it 'should select the Oui radio button' do + expect(rendered).to have_selector("input[value='true'][checked]") + end + end + + context "when the value is Non" do + let!(:champ) { create(:champ, type_de_champ: type_champ, value: "false").decorate } + + it 'should select the Non radio button' do + expect(rendered).to have_selector("input[value='false'][checked]") + end + end +end From 8dace5217a840445efe255af91c442eb33302fef Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 20 Sep 2017 15:47:57 +0200 Subject: [PATCH 188/222] Share badges style in /patron --- app/assets/stylesheets/new_design/_tabs.scss | 10 ---------- app/assets/stylesheets/new_design/badges.scss | 18 ++++++++++++++++++ app/views/root/patron.html.haml | 5 +++++ 3 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 app/assets/stylesheets/new_design/badges.scss diff --git a/app/assets/stylesheets/new_design/_tabs.scss b/app/assets/stylesheets/new_design/_tabs.scss index 9583e917e..c6447a5ee 100644 --- a/app/assets/stylesheets/new_design/_tabs.scss +++ b/app/assets/stylesheets/new_design/_tabs.scss @@ -43,16 +43,6 @@ } } - .badge { - background-color: rgba(0, 0, 0, 0.08); - padding-left: 5px; - padding-right: 5px; - border-radius: 100px; - font-weight: bold; - color: rgba(0, 0, 0, 0.6); - font-size: 14px; - } - .notifications { top: 3px; right: 3px; diff --git a/app/assets/stylesheets/new_design/badges.scss b/app/assets/stylesheets/new_design/badges.scss new file mode 100644 index 000000000..6151b9d47 --- /dev/null +++ b/app/assets/stylesheets/new_design/badges.scss @@ -0,0 +1,18 @@ +@import "colors"; +@import "constants"; + +.badge { + padding: 0 5px; + font-size: 14px; + font-weight: bold; + text-align: center; + white-space: nowrap; + border-radius: 100px; + background-color: rgba(0, 0, 0, 0.08); + vertical-align: top; + + &.warning { + background-color: $orange; + color: #FFFFFF; + } +} diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 8777c35d9..cd02e6caf 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -68,6 +68,11 @@ %span.label.refused .label.refused %span.label.without-continuation .label.without-continuation + %h1 Badges + + %span.badge 1 + %span.badge.warning 1 + %h1 Cards .card From a927affae6570dcdcb80157aea858fd98dc870c4 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Wed, 20 Sep 2017 15:49:49 +0200 Subject: [PATCH 189/222] Display avis counter on header --- app/assets/stylesheets/new_design/new_header.scss | 1 + app/views/layouts/_new_header.haml | 6 +++++- app/views/new_gestionnaire/avis/index.html.haml | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss index 44f169298..959e7fa1d 100644 --- a/app/assets/stylesheets/new_design/new_header.scss +++ b/app/assets/stylesheets/new_design/new_header.scss @@ -31,6 +31,7 @@ } a { + display: inline-block; padding: 23px $default-padding; font-size: 18px; color: $black; diff --git a/app/views/layouts/_new_header.haml b/app/views/layouts/_new_header.haml index e9a4f19ea..27b381fa1 100644 --- a/app/views/layouts/_new_header.haml +++ b/app/views/layouts/_new_header.haml @@ -14,7 +14,11 @@ = link_to "Procédures", procedures_path, class: (controller_name != 'avis') ? "active" : nil - if current_gestionnaire.avis.count > 0 %li - = link_to "Avis", avis_index_path, class: (controller_name == 'avis') ? "active" : nil + = link_to avis_index_path, class: (controller_name == 'avis') ? "active" : nil do + Avis + - avis_counter = current_gestionnaire.avis.without_answer.count + - if avis_counter > 0 + %span.badge.warning= avis_counter %li = link_to "Ancienne interface", backoffice_dossiers_path diff --git a/app/views/new_gestionnaire/avis/index.html.haml b/app/views/new_gestionnaire/avis/index.html.haml index 052a6e918..3a0ea5fc4 100644 --- a/app/views/new_gestionnaire/avis/index.html.haml +++ b/app/views/new_gestionnaire/avis/index.html.haml @@ -8,6 +8,8 @@ = link_to(avis_index_path(statut: NewGestionnaire::AvisController::A_DONNER_STATUS)) do avis à donner %span.badge= @avis_a_donner.count + - if @avis_a_donner.any? + %span.notifications %li{ class: (@statut == NewGestionnaire::AvisController::DONNES_STATUS) ? 'active' : nil }> = link_to(avis_index_path(statut: NewGestionnaire::AvisController::DONNES_STATUS)) do From 1962037728a2b05f2794f4bc8a12c4c98c092d73 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 14 Sep 2017 10:36:01 +0200 Subject: [PATCH 190/222] New Design: add motivation and attestation --- .../stylesheets/new_design/buttons.scss | 31 +++++++++++++++++++ .../dossiers/_state_button.html.haml | 28 +++++++++++++---- app/views/root/patron.html.haml | 2 ++ 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index 0f991fb24..6c9874b33 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -44,6 +44,17 @@ } } + &.success { + color: #FFFFFF; + border-color: $green; + background-color: $green; + + &:hover { + color: $green; + background-color: #FFFFFF; + } + } + &.large { font-size: 18px; line-height: 26px; @@ -91,6 +102,26 @@ right: 0; top: 5 * $default-spacer; cursor: default; + z-index: 10; + + &.terminated { + width: 600px; + color: $black; + padding: $default-padding; + + h4 { + font-size: 24px; + } + + .dossier-motivation { + margin-top: 2 * $default-padding; + } + + .attestation { + margin: $default-padding 0; + color: $grey; + } + } } .dropdown-items { diff --git a/app/views/new_gestionnaire/dossiers/_state_button.html.haml b/app/views/new_gestionnaire/dossiers/_state_button.html.haml index 402766709..7584cd95d 100644 --- a/app/views/new_gestionnaire/dossiers/_state_button.html.haml +++ b/app/views/new_gestionnaire/dossiers/_state_button.html.haml @@ -59,9 +59,25 @@ %span.button{ onclick: "TPS.motivationCancel();" } Annuler = button_tag "Valider la décision", name: :process_action, value: "close", class: 'button primary', title: 'Accepter', data: { confirm: "Accepter ce dossier ?" } -- elsif dossier.closed? - %span.label.closed Accepté -- elsif dossier.refused? - %span.label.refused Refusé -- elsif dossier.without_continuation? - %span.label.without-continuation Sans suite +- else + %span.button.dropdown{ class: dossier.closed? ? 'success' : nil } + - if dossier.closed? + accepté + - elsif dossier.without_continuation? + classé sans suite + - elsif dossier.refused? + refusé + .dropdown-content.fade-in-down.terminated + %h4 + - if dossier.closed? + Dossier nº #{dossier.id} accepté + - elsif dossier.without_continuation? + Dossier nº #{dossier.id} classé sans suite + - elsif dossier.refused? + Dossier nº #{dossier.id} refusé + + %p.dossier-motivation= dossier.motivation.present? ? dossier.motivation : "aucune motivation n'a été fournie" + + - if dossier.attestation.present? + %p.attestation L'acceptation du dossier a envoyé automatiquement une attestation au demandeur + = link_to "Voir l'attestation", attestation_dossier_path(dossier.procedure, dossier), target: '_blank', class: 'button' diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index cd02e6caf..38c478083 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -39,6 +39,8 @@ = link_to ".button.secondary", "#", class: "button secondary" + = link_to ".button.success", "#", class: "button success" + = link_to ".button.large", "#", class: "button large" = link_to ".button.large.primary", "#", class: "button large primary" From 10b22b018ec2b8f2c0d13dbfb0dc4b12a86571b7 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 21 Sep 2017 11:02:01 +0200 Subject: [PATCH 191/222] Header menu should be above every dropdown content --- app/assets/stylesheets/new_design/new_header.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/new_design/new_header.scss b/app/assets/stylesheets/new_design/new_header.scss index 959e7fa1d..380f78ae0 100644 --- a/app/assets/stylesheets/new_design/new_header.scss +++ b/app/assets/stylesheets/new_design/new_header.scss @@ -108,7 +108,7 @@ border: 1px solid $border-grey; min-width: 270px; max-width: 340px; - z-index: 10; + z-index: 20; &.open { display: block; From fdb187368d2214c80b5da6775f6d6a2bb703c9a1 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 21 Sep 2017 15:19:10 +0200 Subject: [PATCH 192/222] When procedure libelle is too long, don't shrink logo or button --- app/assets/stylesheets/new_design/procedure_list.scss | 1 + app/assets/stylesheets/new_design/procedures_show.scss | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/assets/stylesheets/new_design/procedure_list.scss b/app/assets/stylesheets/new_design/procedure_list.scss index 16579bd74..210410596 100644 --- a/app/assets/stylesheets/new_design/procedure_list.scss +++ b/app/assets/stylesheets/new_design/procedure_list.scss @@ -29,6 +29,7 @@ height: 93px; width: 93px; margin-right: 3 * $default-spacer; + flex-shrink: 0; } .procedure-title { diff --git a/app/assets/stylesheets/new_design/procedures_show.scss b/app/assets/stylesheets/new_design/procedures_show.scss index 5b9805c8a..340d1068d 100644 --- a/app/assets/stylesheets/new_design/procedures_show.scss +++ b/app/assets/stylesheets/new_design/procedures_show.scss @@ -5,6 +5,7 @@ #procedure-show { .procedure-logo { margin-right: $default-padding; + flex-shrink: 0; } h1 { @@ -19,6 +20,7 @@ .procedure-actions { margin-left: auto; + flex-shrink: 0; .dropdown-items li { min-width: 150px; From 47db8f9c7d00582ac1b96c0538aa8dada0de663f Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 21 Sep 2017 16:47:06 +0200 Subject: [PATCH 193/222] Add Kaminari gem for pagination --- Gemfile | 1 + Gemfile.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 9b4d7a0bf..a254eeb39 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,7 @@ gem 'bootstrap-sass', '~> 3.3.5' # Pagination gem 'will_paginate-bootstrap' +gem 'kaminari' # Decorators gem 'draper', '~> 3.0.0.pre1' diff --git a/Gemfile.lock b/Gemfile.lock index fca30b5c4..fda9782df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -710,6 +710,7 @@ DEPENDENCIES haml-rails hashie jquery-rails + kaminari launchy leaflet-draw-rails leaflet-markercluster-rails (~> 0.7.0) From 2737a8d52997f691d0341f24d80ec6b231a9202a Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 21 Sep 2017 16:47:43 +0200 Subject: [PATCH 194/222] Add pagination on dossiers list --- app/controllers/new_gestionnaire/procedures_controller.rb | 2 ++ app/views/new_gestionnaire/procedures/show.html.haml | 1 + 2 files changed, 3 insertions(+) diff --git a/app/controllers/new_gestionnaire/procedures_controller.rb b/app/controllers/new_gestionnaire/procedures_controller.rb index ab78a563b..6aa514c45 100644 --- a/app/controllers/new_gestionnaire/procedures_controller.rb +++ b/app/controllers/new_gestionnaire/procedures_controller.rb @@ -63,6 +63,8 @@ module NewGestionnaire when 'archives' @archived_dossiers end + + @dossiers = @dossiers.page([params[:page].to_i, 1].max) end private diff --git a/app/views/new_gestionnaire/procedures/show.html.haml b/app/views/new_gestionnaire/procedures/show.html.haml index 5bd179d12..f2498d451 100644 --- a/app/views/new_gestionnaire/procedures/show.html.haml +++ b/app/views/new_gestionnaire/procedures/show.html.haml @@ -73,5 +73,6 @@ = link_to(dossier_path(@procedure, dossier), class: 'cell-link') do = render partial: 'status', locals: { dossier: dossier } %td.follow-col= render partial: 'dossier_actions', locals: { procedure: @procedure, dossier: dossier, dossier_is_followed: @followed_dossiers_id.include?(dossier.id) } + = paginate @dossiers - else %h2.empty-text Aucun dossier From 3b3f4efa18e8ccee99e773b1c9f6576ff64a9272 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 21 Sep 2017 17:07:38 +0200 Subject: [PATCH 195/222] Design kaminari pagination --- app/assets/stylesheets/new_design/pagination.scss | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/assets/stylesheets/new_design/pagination.scss diff --git a/app/assets/stylesheets/new_design/pagination.scss b/app/assets/stylesheets/new_design/pagination.scss new file mode 100644 index 000000000..464ed74ab --- /dev/null +++ b/app/assets/stylesheets/new_design/pagination.scss @@ -0,0 +1,10 @@ +@import "constants"; + +.pagination { + text-align: center; + margin-bottom: 3 * $default-spacer; + + > span { + margin: 0 $default-spacer; + } +} From 6a58873ba7861f9d1b137fcd3d58ccfbd397d0b5 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 21 Sep 2017 17:19:15 +0200 Subject: [PATCH 196/222] Add pagination on avis --- app/controllers/new_gestionnaire/avis_controller.rb | 5 ++++- app/views/new_gestionnaire/avis/index.html.haml | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/new_gestionnaire/avis_controller.rb b/app/controllers/new_gestionnaire/avis_controller.rb index 94f05886e..03dc94fec 100644 --- a/app/controllers/new_gestionnaire/avis_controller.rb +++ b/app/controllers/new_gestionnaire/avis_controller.rb @@ -7,7 +7,8 @@ module NewGestionnaire def index gestionnaire_avis = current_gestionnaire.avis.includes(dossier: [:procedure, :user]) - @avis_a_donner, @avis_donnes = gestionnaire_avis.partition { |avis| avis.answer.nil? } + @avis_a_donner = gestionnaire_avis.without_answer + @avis_donnes = gestionnaire_avis.with_answer @statut = params[:statut].present? ? params[:statut] : A_DONNER_STATUS @@ -17,6 +18,8 @@ module NewGestionnaire when DONNES_STATUS @avis_donnes end + + @avis = @avis.page([params[:page].to_i, 1].max) end def show diff --git a/app/views/new_gestionnaire/avis/index.html.haml b/app/views/new_gestionnaire/avis/index.html.haml index 3a0ea5fc4..984db4f24 100644 --- a/app/views/new_gestionnaire/avis/index.html.haml +++ b/app/views/new_gestionnaire/avis/index.html.haml @@ -33,5 +33,6 @@ #{avis.dossier.id} %td= link_to(avis.dossier.user.email, avis_path(avis), class: 'cell-link') %td= link_to(avis.dossier.procedure.libelle, avis_path(avis), class: 'cell-link') + = paginate(@avis) - else %h2.empty-text Aucun avis From 356c16b1bc8d63412f149e8877f898bbba8ae4e2 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Thu, 21 Sep 2017 11:39:02 +0200 Subject: [PATCH 197/222] Hide crisp default button, to avoid usagers to spam us --- app/views/layouts/_crisp.html.haml | 29 ++++++++++++++--------------- app/views/root/landing.html.haml | 4 ++-- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/views/layouts/_crisp.html.haml b/app/views/layouts/_crisp.html.haml index d16217cd0..4100bd050 100644 --- a/app/views/layouts/_crisp.html.haml +++ b/app/views/layouts/_crisp.html.haml @@ -1,15 +1,14 @@ -- if request.path == root_path - :javascript - window.$crisp=[]; - window.CRISP_WEBSITE_ID="779b5050-4cc1-4172-8dd0-bde55716a289"; - (function(){ - d=document; - s=d.createElement("script"); - s.src="https://client.crisp.im/l.js"; - s.async=1; - d.getElementsByTagName("head")[0].appendChild(s); - })(); - window.$crisp.push(["do", "chat:show"]); -- else - :javascript - window.$crisp && window.$crisp.push(["do", "chat:hide"]); +:javascript + window.$crisp=[]; + window.CRISP_WEBSITE_ID="779b5050-4cc1-4172-8dd0-bde55716a289"; + (function(){ + d=document; + s=d.createElement("script"); + s.src="https://client.crisp.im/l.js"; + s.async=1; + d.getElementsByTagName("head")[0].appendChild(s); + })(); + window.$crisp.push(["do", "chat:hide"]); + window.$crisp.push(["on", "chat:closed", function () { + window.$crisp.push(["do", "chat:hide"]); + }]); diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index b57f03c79..c85bf7b80 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -8,7 +8,7 @@ %br vos procédures administratives en quelques minutes - %a.hero-button{ target: "_blank", onclick: "javascript: ga('send', 'pageview', '/demander-une-demo'); $crisp.push(['do', 'chat:open'])" } Demander une démo + %a.hero-button{ target: "_blank", onclick: "javascript: ga('send', 'pageview', '/demander-une-demo'); $crisp.push(['do', 'chat:show']); $crisp.push(['do', 'chat:open']);" } Demander une démo %p.hero-phone-cta ou nous appeler au 09 72 62 57 12 @@ -128,6 +128,6 @@ %h1.cta-panel-title Commencez à dématerialiser vos procédures %p.cta-panel-explanation Nous vous accompagnons dans la prise en main de l’outil %div - %a.cta-panel-button{ target: "_blank", onclick: "javascript: ga('send', 'pageview', '/demander-une-demo'); $crisp.push(['do', 'chat:open'])" } Demander une démo + %a.cta-panel-button{ target: "_blank", onclick: "javascript: ga('send', 'pageview', '/demander-une-demo'); $crisp.push(['do', 'chat:show']); $crisp.push(['do', 'chat:open']);" } Demander une démo %p.cta-panel-phone-cta ou nous appeler au 09 72 62 57 12 From 64f4bcf257d46f72a279dd7b23efcc9cbc5b5555 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 22 Sep 2017 11:19:01 +0200 Subject: [PATCH 198/222] Fix if gestionnaire is nil (sentry issue : https://sentry.apientreprise.fr/apientreprise/tps_dev/issues/1865/) --- app/views/new_gestionnaire/avis/_avis_list.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/new_gestionnaire/avis/_avis_list.html.haml b/app/views/new_gestionnaire/avis/_avis_list.html.haml index ffcdcadc2..a389fd5e5 100644 --- a/app/views/new_gestionnaire/avis/_avis_list.html.haml +++ b/app/views/new_gestionnaire/avis/_avis_list.html.haml @@ -22,7 +22,7 @@ %i.bubble.avis-icon .width-100 %h2.gestionnaire - = (avis.gestionnaire.email == current_gestionnaire.email) ? 'Vous' : avis.gestionnaire.email + = (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')} - else From 45cf26e855be513da9561e221a50ad6827843ce5 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 22 Sep 2017 12:38:37 +0200 Subject: [PATCH 199/222] If type de champ has no dropdownlist do not crash, (sentry issue: https://sentry.apientreprise.fr/apientreprise/tps_dev/issues/1833/) --- .../dossiers/champs/_drop_down_list.html.haml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 c629a8cc8..ee46b4b26 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,6 +1,7 @@ = render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ } -= form.select :value, - champ.drop_down_list.options, - disabled: champ.drop_down_list.disabled_options, - required: champ.mandatory +- if champ.drop_down_list && champ.drop_down_list.options.any? + = form.select :value, + champ.drop_down_list.options, + disabled: champ.drop_down_list.disabled_options, + required: champ.mandatory From 53f0a16186c8cd99f5217abd4ea06e5c574779e5 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Fri, 22 Sep 2017 17:58:16 +0200 Subject: [PATCH 200/222] BackofficeAvisController: make new avis confidentiel by default --- app/controllers/backoffice/avis_controller.rb | 2 +- spec/controllers/backoffice/avis_controller_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/backoffice/avis_controller.rb b/app/controllers/backoffice/avis_controller.rb index ec76c663a..d2375e74f 100644 --- a/app/controllers/backoffice/avis_controller.rb +++ b/app/controllers/backoffice/avis_controller.rb @@ -4,7 +4,7 @@ class Backoffice::AvisController < ApplicationController before_action :check_avis_exists_and_email_belongs_to_avis, only: [:sign_up, :create_gestionnaire] def create - avis = Avis.new(create_params.merge(claimant: current_gestionnaire, dossier: dossier)) + avis = Avis.new(create_params.merge(claimant: current_gestionnaire, dossier: dossier, confidentiel: true)) if avis.save flash[:notice] = "Votre demande d'avis a bien été envoyée à #{avis.email_to_display}" diff --git a/spec/controllers/backoffice/avis_controller_spec.rb b/spec/controllers/backoffice/avis_controller_spec.rb index 950ad57b9..c059ba7b8 100644 --- a/spec/controllers/backoffice/avis_controller_spec.rb +++ b/spec/controllers/backoffice/avis_controller_spec.rb @@ -34,6 +34,7 @@ describe Backoffice::AvisController, type: :controller do it { expect(created_avis.dossier_id).to eq(dossier.id) } it { expect(created_avis.gestionnaire).to eq(gestionnaire) } it { expect(created_avis.claimant).to eq(claimant) } + it { expect(created_avis.confidentiel).to be(true) } end end From 460cd3e2375cf741918c9e3d997baed359ab9134 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 21 Sep 2017 15:24:16 +0200 Subject: [PATCH 201/222] [Fix #503] Dossier: Remove waiting for user scope --- app/facades/admin_procedures_show_facades.rb | 4 ---- app/models/dossier.rb | 3 --- app/views/admin/procedures/show.html.haml | 4 ---- spec/facades/admin_procedures_show_facades_spec.rb | 6 ------ 4 files changed, 17 deletions(-) diff --git a/app/facades/admin_procedures_show_facades.rb b/app/facades/admin_procedures_show_facades.rb index 297f74358..0bdc084d1 100644 --- a/app/facades/admin_procedures_show_facades.rb +++ b/app/facades/admin_procedures_show_facades.rb @@ -36,10 +36,6 @@ class AdminProceduresShowFacades dossiers.waiting_for_gestionnaire.size end - def dossiers_waiting_user_total - dossiers.waiting_for_user.size - end - def dossiers_termine_total dossiers.where(state: :termine).size end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index c214479b0..9049e7255 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -14,7 +14,6 @@ class Dossier < ActiveRecord::Base NOUVEAUX = %w(initiated) OUVERT = %w(updated replied) WAITING_FOR_GESTIONNAIRE = %w(updated) - WAITING_FOR_USER = %w(replied) EN_CONSTRUCTION = %w(initiated updated replied) EN_INSTRUCTION = %w(received) EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION @@ -52,7 +51,6 @@ class Dossier < ActiveRecord::Base scope :state_nouveaux, -> { where(state: NOUVEAUX) } scope :state_ouvert, -> { where(state: OUVERT) } scope :state_waiting_for_gestionnaire, -> { where(state: WAITING_FOR_GESTIONNAIRE) } - scope :state_waiting_for_user, -> { where(state: WAITING_FOR_USER) } scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) } scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) } scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) } @@ -68,7 +66,6 @@ class Dossier < ActiveRecord::Base scope :nouveaux, -> { not_archived.state_nouveaux.order_by_updated_at(:asc) } scope :ouvert, -> { not_archived.state_ouvert.order_by_updated_at(:asc) } scope :waiting_for_gestionnaire, -> { not_archived.state_waiting_for_gestionnaire.order_by_updated_at(:asc) } - scope :waiting_for_user, -> { not_archived.state_waiting_for_user.order_by_updated_at(:asc) } scope :a_instruire, -> { not_archived.state_a_instruire.order_by_updated_at(:asc) } scope :termine, -> { not_archived.state_termine.order_by_updated_at(:asc) } scope :downloadable, -> { state_not_brouillon.order_by_updated_at(:asc) } diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index 5827186b6..3ebdd8db0 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -102,10 +102,6 @@ %div = @facade.dossiers_waiting_gestionnaire_total - %h4.text-info Attente Usager - %div - = @facade.dossiers_waiting_user_total - %h4.text-success Terminé %div = @facade.dossiers_termine_total diff --git a/spec/facades/admin_procedures_show_facades_spec.rb b/spec/facades/admin_procedures_show_facades_spec.rb index 1ea3a1a1e..d37b1607c 100644 --- a/spec/facades/admin_procedures_show_facades_spec.rb +++ b/spec/facades/admin_procedures_show_facades_spec.rb @@ -56,12 +56,6 @@ describe AdminProceduresShowFacades do it { is_expected.to eq(1) } end - describe 'dossiers_waiting_user_total' do - subject { super().dossiers_waiting_user_total } - - it { is_expected.to eq(1) } - end - describe 'dossiers_termine_total' do subject { super().dossiers_termine_total } From 73357c5144848fcc553ba9f82e20c950e58b4293 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 21 Sep 2017 15:27:14 +0200 Subject: [PATCH 202/222] [Fix #503] Dossier: Remove waiting for gestionnaire scope --- app/facades/admin_procedures_show_facades.rb | 4 ---- app/models/dossier.rb | 3 --- app/views/admin/procedures/show.html.haml | 4 ---- spec/facades/admin_procedures_show_facades_spec.rb | 6 ------ 4 files changed, 17 deletions(-) diff --git a/app/facades/admin_procedures_show_facades.rb b/app/facades/admin_procedures_show_facades.rb index 0bdc084d1..b099f5c43 100644 --- a/app/facades/admin_procedures_show_facades.rb +++ b/app/facades/admin_procedures_show_facades.rb @@ -32,10 +32,6 @@ class AdminProceduresShowFacades dossiers.size end - def dossiers_waiting_gestionnaire_total - dossiers.waiting_for_gestionnaire.size - end - def dossiers_termine_total dossiers.where(state: :termine).size end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 9049e7255..6da2b984e 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -13,7 +13,6 @@ class Dossier < ActiveRecord::Base BROUILLON = %w(draft) NOUVEAUX = %w(initiated) OUVERT = %w(updated replied) - WAITING_FOR_GESTIONNAIRE = %w(updated) EN_CONSTRUCTION = %w(initiated updated replied) EN_INSTRUCTION = %w(received) EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION @@ -50,7 +49,6 @@ class Dossier < ActiveRecord::Base scope :state_not_brouillon, -> { where.not(state: BROUILLON) } scope :state_nouveaux, -> { where(state: NOUVEAUX) } scope :state_ouvert, -> { where(state: OUVERT) } - scope :state_waiting_for_gestionnaire, -> { where(state: WAITING_FOR_GESTIONNAIRE) } scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) } scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) } scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) } @@ -65,7 +63,6 @@ class Dossier < ActiveRecord::Base scope :all_state, -> { not_archived.state_not_brouillon.order_by_updated_at(:asc) } scope :nouveaux, -> { not_archived.state_nouveaux.order_by_updated_at(:asc) } scope :ouvert, -> { not_archived.state_ouvert.order_by_updated_at(:asc) } - scope :waiting_for_gestionnaire, -> { not_archived.state_waiting_for_gestionnaire.order_by_updated_at(:asc) } scope :a_instruire, -> { not_archived.state_a_instruire.order_by_updated_at(:asc) } scope :termine, -> { not_archived.state_termine.order_by_updated_at(:asc) } scope :downloadable, -> { state_not_brouillon.order_by_updated_at(:asc) } diff --git a/app/views/admin/procedures/show.html.haml b/app/views/admin/procedures/show.html.haml index 3ebdd8db0..8d564cb22 100644 --- a/app/views/admin/procedures/show.html.haml +++ b/app/views/admin/procedures/show.html.haml @@ -98,10 +98,6 @@ %div = @facade.dossiers_total - %h4.text-danger Attente Accompagnateur - %div - = @facade.dossiers_waiting_gestionnaire_total - %h4.text-success Terminé %div = @facade.dossiers_termine_total diff --git a/spec/facades/admin_procedures_show_facades_spec.rb b/spec/facades/admin_procedures_show_facades_spec.rb index d37b1607c..781fb9393 100644 --- a/spec/facades/admin_procedures_show_facades_spec.rb +++ b/spec/facades/admin_procedures_show_facades_spec.rb @@ -50,12 +50,6 @@ describe AdminProceduresShowFacades do it { is_expected.to eq(4) } end - describe 'dossiers_waiting_gestionnaire_total' do - subject { super().dossiers_waiting_gestionnaire_total } - - it { is_expected.to eq(1) } - end - describe 'dossiers_termine_total' do subject { super().dossiers_termine_total } From 2eca14a731e8db5257bd45733a6bf72a7893ede3 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 21 Sep 2017 16:18:20 +0200 Subject: [PATCH 203/222] DossierListGestionnaire: change a_traiter filter from ouvert to nouveau --- app/services/dossiers_list_gestionnaire_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/dossiers_list_gestionnaire_service.rb b/app/services/dossiers_list_gestionnaire_service.rb index 2a7058456..e7b49c286 100644 --- a/app/services/dossiers_list_gestionnaire_service.rb +++ b/app/services/dossiers_list_gestionnaire_service.rb @@ -8,7 +8,7 @@ class DossiersListGestionnaireService def dossiers_to_display @dossiers_to_display ||= {'nouveaux' => nouveaux, - 'a_traiter' => ouvert, + 'a_traiter' => nouveaux, 'a_instruire' => a_instruire, 'termine' => termine, 'archive' => archive, From 030a11d98c41ff02be8e32391e776106fad4fc5e Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 21 Sep 2017 16:19:52 +0200 Subject: [PATCH 204/222] [Fix #503] Dossier: remove unused ouvert state --- app/models/dossier.rb | 3 --- app/services/dossiers_list_gestionnaire_service.rb | 4 ---- 2 files changed, 7 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 6da2b984e..1f59bd56f 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -12,7 +12,6 @@ class Dossier < ActiveRecord::Base BROUILLON = %w(draft) NOUVEAUX = %w(initiated) - OUVERT = %w(updated replied) EN_CONSTRUCTION = %w(initiated updated replied) EN_INSTRUCTION = %w(received) EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION @@ -48,7 +47,6 @@ class Dossier < ActiveRecord::Base scope :state_brouillon, -> { where(state: BROUILLON) } scope :state_not_brouillon, -> { where.not(state: BROUILLON) } scope :state_nouveaux, -> { where(state: NOUVEAUX) } - scope :state_ouvert, -> { where(state: OUVERT) } scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) } scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) } scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) } @@ -62,7 +60,6 @@ class Dossier < ActiveRecord::Base scope :all_state, -> { not_archived.state_not_brouillon.order_by_updated_at(:asc) } scope :nouveaux, -> { not_archived.state_nouveaux.order_by_updated_at(:asc) } - scope :ouvert, -> { not_archived.state_ouvert.order_by_updated_at(:asc) } scope :a_instruire, -> { not_archived.state_a_instruire.order_by_updated_at(:asc) } scope :termine, -> { not_archived.state_termine.order_by_updated_at(:asc) } scope :downloadable, -> { state_not_brouillon.order_by_updated_at(:asc) } diff --git a/app/services/dossiers_list_gestionnaire_service.rb b/app/services/dossiers_list_gestionnaire_service.rb index e7b49c286..843185fee 100644 --- a/app/services/dossiers_list_gestionnaire_service.rb +++ b/app/services/dossiers_list_gestionnaire_service.rb @@ -31,10 +31,6 @@ class DossiersListGestionnaireService @nouveaux ||= filter_dossiers.nouveaux end - def ouvert - @ouvert ||= filter_dossiers.ouvert - end - def a_instruire @a_instruire ||= filter_dossiers.a_instruire end From 633b55aca0b30d2b89efb38caf29b446cd2827ce Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 21 Sep 2017 17:12:21 +0200 Subject: [PATCH 205/222] [Fix #503] Dossier: remove replied --- .../backoffice/dossiers_controller.rb | 2 +- app/controllers/users/carte_controller.rb | 2 +- .../users/description_controller.rb | 2 +- .../users/recapitulatif_controller.rb | 2 +- app/models/dossier.rb | 15 ++----- app/views/dossiers/_dossier_show.html.haml | 2 +- config/locales/models/dossier/fr.yml | 1 - .../commentaires_controller_spec.rb | 4 +- .../backoffice/dossiers_controller_spec.rb | 4 +- spec/controllers/invites_controller_spec.rb | 2 +- .../new_gestionnaire/avis_controller_spec.rb | 2 +- .../dossiers_controller_spec.rb | 8 ++-- .../procedures_controller_spec.rb | 2 +- .../recherches_controller_spec.rb | 6 +-- .../users/commentaires_controller_spec.rb | 18 -------- .../dossiers/commentaires_controller_spec.rb | 2 - spec/decorators/dossier_decorator_spec.rb | 5 --- .../admin_procedures_show_facades_spec.rb | 2 +- spec/factories/dossier.rb | 4 +- .../users/flux_de_commentaires_spec.rb | 2 +- spec/features/users/list_dossiers_spec.rb | 6 +-- spec/features/users/onglets_link_spec.rb | 3 +- spec/models/dossier_spec.rb | 42 +------------------ spec/models/procedure_spec.rb | 2 +- ...dossiers_list_gestionnaire_service_spec.rb | 3 -- .../user_routes_authorization_service_spec.rb | 25 ----------- .../dossiers/index_html.haml_spec.rb | 5 +-- ...backoffice_dossierscontroller_show_spec.rb | 12 ------ ...users_recapitulatifcontroller_show_spec.rb | 10 ----- .../dossiers/show.html.haml_spec.rb | 2 +- .../users/dossiers/index_html.haml_spec.rb | 7 +--- .../auto_archive_procedure_worker_spec.rb | 2 +- 32 files changed, 37 insertions(+), 169 deletions(-) diff --git a/app/controllers/backoffice/dossiers_controller.rb b/app/controllers/backoffice/dossiers_controller.rb index e25fc8275..4a9412636 100644 --- a/app/controllers/backoffice/dossiers_controller.rb +++ b/app/controllers/backoffice/dossiers_controller.rb @@ -179,7 +179,7 @@ class Backoffice::DossiersController < Backoffice::DossiersListController def reopen create_dossier_facade params[:dossier_id] - @facade.dossier.replied! + @facade.dossier.initiated! flash.notice = 'Dossier repassé en construction.' redirect_to_dossier(@facade.dossier) diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index 3c10c7df9..f561bad88 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -56,7 +56,7 @@ class Users::CarteController < UsersController def self.route_authorization { - states: [:draft, :initiated, :replied, :updated], + states: [:draft, :initiated, :updated], api_carto: true } end diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index 0771c13ea..d27627c53 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -93,7 +93,7 @@ class Users::DescriptionController < UsersController def self.route_authorization { - states: [:draft, :initiated, :replied, :updated] + states: [:draft, :initiated, :updated] } end diff --git a/app/controllers/users/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb index 88dd4d2f8..3405b899d 100644 --- a/app/controllers/users/recapitulatif_controller.rb +++ b/app/controllers/users/recapitulatif_controller.rb @@ -18,7 +18,7 @@ class Users::RecapitulatifController < UsersController def self.route_authorization { - states: [:initiated, :replied, :updated, :received, :without_continuation, :closed, :refused] + states: [:initiated, :updated, :received, :without_continuation, :closed, :refused] } end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 1f59bd56f..dc0e2c884 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -2,7 +2,6 @@ class Dossier < ActiveRecord::Base enum state: { draft: 'draft', initiated: 'initiated', - replied: 'replied', # action utilisateur demandé updated: 'updated', # etude par l'administration en cours received: 'received', closed: 'closed', @@ -12,7 +11,7 @@ class Dossier < ActiveRecord::Base BROUILLON = %w(draft) NOUVEAUX = %w(initiated) - EN_CONSTRUCTION = %w(initiated updated replied) + EN_CONSTRUCTION = %w(initiated updated) EN_INSTRUCTION = %w(received) EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION A_INSTRUIRE = %w(received) @@ -161,22 +160,14 @@ class Dossier < ActiveRecord::Base if draft? initiated! end - when 'update' - if replied? - updated! - end - when 'comment' - if replied? - updated! - end end when 'gestionnaire' case action when 'comment' if updated? - replied! + initiated! elsif initiated? - replied! + initiated! end when 'follow' if initiated? diff --git a/app/views/dossiers/_dossier_show.html.haml b/app/views/dossiers/_dossier_show.html.haml index afb5a5c77..7c733d9fb 100644 --- a/app/views/dossiers/_dossier_show.html.haml +++ b/app/views/dossiers/_dossier_show.html.haml @@ -13,7 +13,7 @@ .col-xs-8.title-no-expanse .carret-right INFORMATIONS DU DEMANDEUR - - if !@current_gestionnaire && ["draft", "updated", "replied", "initiated"].include?(@facade.dossier.state) + - if !@current_gestionnaire && ["draft", "updated", "initiated"].include?(@facade.dossier.state) %a#add_siret.action{ href: users_dossier_add_siret_path(dossier_id: @facade.dossier.id) } .col-lg-4.col-md-4.col-sm-4.col-xs-4.action Renseigner un SIRET diff --git a/config/locales/models/dossier/fr.yml b/config/locales/models/dossier/fr.yml index 562adc110..67ab08e55 100644 --- a/config/locales/models/dossier/fr.yml +++ b/config/locales/models/dossier/fr.yml @@ -10,7 +10,6 @@ fr: state: draft: "Brouillon" initiated: "En construction" - replied: "En construction" updated: "En construction" received: "En instruction" closed: "Accepté" diff --git a/spec/controllers/backoffice/commentaires_controller_spec.rb b/spec/controllers/backoffice/commentaires_controller_spec.rb index a491df621..c3c2ea20b 100644 --- a/spec/controllers/backoffice/commentaires_controller_spec.rb +++ b/spec/controllers/backoffice/commentaires_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Backoffice::CommentairesController, type: :controller do - let(:dossier) { create(:dossier, :replied) } + let(:dossier) { create(:dossier, :initiated) } let(:dossier_id) { dossier.id } let(:email_commentaire) { 'test@test.com' } let(:texte_commentaire) { 'Commentaire de test' } @@ -124,7 +124,7 @@ describe Backoffice::CommentairesController, type: :controller do subject { dossier.state } - it { is_expected.to eq('replied') } + it { is_expected.to eq('initiated') } it 'Notification email is send' do expect(NotificationMailer).to receive(:new_answer).and_return(NotificationMailer) diff --git a/spec/controllers/backoffice/dossiers_controller_spec.rb b/spec/controllers/backoffice/dossiers_controller_spec.rb index befeac817..d5837a5ae 100644 --- a/spec/controllers/backoffice/dossiers_controller_spec.rb +++ b/spec/controllers/backoffice/dossiers_controller_spec.rb @@ -360,11 +360,11 @@ describe Backoffice::DossiersController, type: :controller do subject { post :reopen, params: {dossier_id: dossier_id} } - it 'change state to replied' do + it 'change state to initiated' do subject dossier.reload - expect(dossier.state).to eq('replied') + expect(dossier.state).to eq('initiated') end it { is_expected.to redirect_to backoffice_dossier_path(id: dossier_id) } diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb index 952e10e42..c2c0441b9 100644 --- a/spec/controllers/invites_controller_spec.rb +++ b/spec/controllers/invites_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe InvitesController, type: :controller do - let(:dossier) { create(:dossier, :replied) } + let(:dossier) { create(:dossier, :initiated) } let(:email) { 'plop@octo.com' } describe '#POST create' do diff --git a/spec/controllers/new_gestionnaire/avis_controller_spec.rb b/spec/controllers/new_gestionnaire/avis_controller_spec.rb index 5254c3344..1a8b27a6a 100644 --- a/spec/controllers/new_gestionnaire/avis_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/avis_controller_spec.rb @@ -6,7 +6,7 @@ describe NewGestionnaire::AvisController, type: :controller do let(:claimant) { create(:gestionnaire) } let(:gestionnaire) { create(:gestionnaire) } let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } - let(:dossier) { create(:dossier, :replied, procedure: procedure) } + let(:dossier) { create(:dossier, :initiated, procedure: procedure) } let!(:avis_without_answer) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire) } let!(:avis_with_answer) { Avis.create(dossier: dossier, claimant: claimant, gestionnaire: gestionnaire, answer: 'yop') } diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 988e8e05a..0ddb3f10a 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -5,16 +5,16 @@ describe NewGestionnaire::DossiersController, type: :controller do let(:gestionnaire) { create(:gestionnaire) } let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } - let(:dossier) { create(:dossier, :replied, procedure: procedure) } + let(:dossier) { create(:dossier, :initiated, procedure: procedure) } before { sign_in(gestionnaire) } describe '#attestation' do context 'when a dossier has an attestation' do let(:fake_pdf) { double(read: 'pdf content') } - let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) } + let!(:dossier) { create(:dossier, :initiated, attestation: Attestation.new, procedure: procedure) } let!(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) } - let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) } + let!(:dossier) { create(:dossier, :initiated, attestation: Attestation.new, procedure: procedure) } it 'returns the attestation pdf' do allow_any_instance_of(Attestation).to receive(:pdf).and_return(fake_pdf) @@ -148,7 +148,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end let(:dossier) do - create(:dossier, :replied, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_datetime]) + create(:dossier, :initiated, procedure: procedure, champs_private: [champ_multiple_drop_down_list, champ_datetime]) end before do diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index 30f70803a..254260cf7 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -137,7 +137,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do let(:state) { "initiated" } before do - create(:dossier, procedure: procedure, state: "replied") + create(:dossier, procedure: procedure, state: "initiated") create(:dossier, procedure: procedure, state: "received") create(:dossier, procedure: procedure, state: "without_continuation", archived: true) diff --git a/spec/controllers/new_gestionnaire/recherches_controller_spec.rb b/spec/controllers/new_gestionnaire/recherches_controller_spec.rb index f7147c73d..06a3f557a 100644 --- a/spec/controllers/new_gestionnaire/recherches_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/recherches_controller_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe NewGestionnaire::RecherchesController, type: :controller do - let(:dossier) { create(:dossier, :replied) } - let(:dossier2) { create(:dossier, :replied, procedure: dossier.procedure) } + let(:dossier) { create(:dossier, :initiated) } + let(:dossier2) { create(:dossier, :initiated, procedure: dossier.procedure) } let(:gestionnaire) { create(:gestionnaire) } before { gestionnaire.procedures << dossier2.procedure } @@ -26,7 +26,7 @@ describe NewGestionnaire::RecherchesController, type: :controller do end context 'when gestionnaire do not own the dossier' do - let(:dossier3) { create(:dossier, :replied) } + let(:dossier3) { create(:dossier, :initiated) } let(:query) { dossier3.id } it { is_expected.to have_http_status(200) } diff --git a/spec/controllers/users/commentaires_controller_spec.rb b/spec/controllers/users/commentaires_controller_spec.rb index 1be0021cf..1b05ff5ac 100644 --- a/spec/controllers/users/commentaires_controller_spec.rb +++ b/spec/controllers/users/commentaires_controller_spec.rb @@ -102,23 +102,5 @@ describe Users::CommentairesController, type: :controller do end end end - - describe 'change dossier state after post a comment' do - context 'when user is connected' do - context 'when dossier is at state replied' do - before do - sign_in dossier.user - dossier.replied! - - post :create, params: { dossier_id: dossier_id, texte_commentaire: texte_commentaire } - dossier.reload - end - - subject { dossier.state } - - it { is_expected.to eq('updated') } - end - end - end end end diff --git a/spec/controllers/users/dossiers/commentaires_controller_spec.rb b/spec/controllers/users/dossiers/commentaires_controller_spec.rb index 1fd067919..18908f468 100644 --- a/spec/controllers/users/dossiers/commentaires_controller_spec.rb +++ b/spec/controllers/users/dossiers/commentaires_controller_spec.rb @@ -15,13 +15,11 @@ describe Users::Dossiers::CommentairesController, type: :controller do before do sign_in invite.user - dossier.replied! end it do subject is_expected.to redirect_to users_dossiers_invite_path(invite.id) - expect(dossier.state).to eq 'replied' end it 'should notify user' do diff --git a/spec/decorators/dossier_decorator_spec.rb b/spec/decorators/dossier_decorator_spec.rb index 9920a89b4..e68943382 100644 --- a/spec/decorators/dossier_decorator_spec.rb +++ b/spec/decorators/dossier_decorator_spec.rb @@ -27,11 +27,6 @@ describe DossierDecorator do expect(subject).to eq('En construction') end - it 'replied is repondu' do - dossier.replied! - expect(subject).to eq('En construction') - end - it 'updated is mis à jour' do dossier.updated! expect(subject).to eq('En construction') diff --git a/spec/facades/admin_procedures_show_facades_spec.rb b/spec/facades/admin_procedures_show_facades_spec.rb index 781fb9393..f9b4a8234 100644 --- a/spec/facades/admin_procedures_show_facades_spec.rb +++ b/spec/facades/admin_procedures_show_facades_spec.rb @@ -5,7 +5,7 @@ describe AdminProceduresShowFacades do let!(:dossier_0) { create(:dossier, procedure: procedure, state: 'draft') } let!(:dossier_1) { create(:dossier, procedure: procedure, state: 'initiated') } - let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'replied') } + let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') } let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'initiated') } let!(:dossier_7) { create(:dossier, procedure: procedure, state: 'updated') } diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index 62c6c6dc0..036d498ca 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -72,8 +72,8 @@ FactoryGirl.define do end end - trait :replied do - state 'replied' + trait :initiated do + state 'initiated' end end end diff --git a/spec/features/users/flux_de_commentaires_spec.rb b/spec/features/users/flux_de_commentaires_spec.rb index 4ce44cd3e..734db0d78 100644 --- a/spec/features/users/flux_de_commentaires_spec.rb +++ b/spec/features/users/flux_de_commentaires_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'users: flux de commentaires' do let(:user) { create(:user) } - let(:dossier) { create(:dossier, :with_entreprise, user: user, state: "replied") } + let(:dossier) { create(:dossier, :with_entreprise, user: user, state: "initiated") } let(:dossier_id) { dossier.id } let(:champ1) { dossier.champs.first } diff --git a/spec/features/users/list_dossiers_spec.rb b/spec/features/users/list_dossiers_spec.rb index 6acdbfb50..64a55d0b2 100644 --- a/spec/features/users/list_dossiers_spec.rb +++ b/spec/features/users/list_dossiers_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' describe 'user access to the list of his dossier' do let(:user) { create(:user) } - let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'replied')} - let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'replied') } + let!(:last_updated_dossier) { create(:dossier, :with_entreprise, user: user, state: 'initiated')} + let!(:dossier1) { create(:dossier, :with_entreprise, user: user, state: 'initiated') } let!(:dossier2) { create(:dossier, :with_entreprise) } - let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'replied') } + let!(:dossier_archived) { create(:dossier, :with_entreprise, user: user, state: 'initiated') } before do last_updated_dossier.update_column(:updated_at, "19/07/2052 15:35".to_time) diff --git a/spec/features/users/onglets_link_spec.rb b/spec/features/users/onglets_link_spec.rb index a3fef2dc3..a229087b8 100644 --- a/spec/features/users/onglets_link_spec.rb +++ b/spec/features/users/onglets_link_spec.rb @@ -7,7 +7,6 @@ feature 'on click on tabs button' do before do create(:dossier, :with_entreprise, user: user, state: 'initiated') - create(:dossier, :with_entreprise, user: user, state: 'replied') create(:dossier, :with_entreprise, user: user, state: 'updated') create(:dossier, :with_entreprise, user: user, state: 'received') create(:dossier, :with_entreprise, user: user, state: 'closed') @@ -23,7 +22,7 @@ feature 'on click on tabs button' do context 'when he click on tabs en construction' do before do visit users_dossiers_url(liste: :a_traiter) - page.click_on 'En construction 3' + page.click_on 'En construction 2' end scenario 'it redirect to users dossier termine' do diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index a0edb21b7..e8db47137 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -182,7 +182,7 @@ describe Dossier do context 'when is post a comment' do let(:action) { 'comment' } - it { is_expected.to eq('replied') } + it { is_expected.to eq('initiated') } end context 'when is follow' do @@ -193,44 +193,6 @@ describe Dossier do end end - context 'when dossier is at state replied' do - before do - dossier.replied! - end - - context 'when user is connect' do - let(:role) { 'user' } - - context 'when is post a comment' do - let(:action) { 'comment' } - - it { is_expected.to eq('updated') } - end - - context 'when is updated dossier informations' do - let(:action) { 'update' } - - it { is_expected.to eq('updated') } - end - end - - context 'when gestionnaire is connect' do - let(:role) { 'gestionnaire' } - - context 'when is post a comment' do - let(:action) { 'comment' } - - it { is_expected.to eq('replied') } - end - - context 'when is follow' do - let(:action) { 'follow' } - - it { is_expected.to eq 'replied' } - end - end - end - context 'when dossier is at state updated' do before do dossier.updated! @@ -258,7 +220,7 @@ describe Dossier do context 'when is post a comment' do let(:action) { 'comment' } - it { is_expected.to eq('replied') } + it { is_expected.to eq('initiated') } end end end diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 249b21931..4a0244e23 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -309,7 +309,7 @@ describe Procedure do before do create :dossier, procedure: procedure, state: :initiated create :dossier, procedure: procedure, state: :draft - create :dossier, procedure: procedure, state: :replied + create :dossier, procedure: procedure, state: :initiated end subject { procedure.total_dossier } diff --git a/spec/services/dossiers_list_gestionnaire_service_spec.rb b/spec/services/dossiers_list_gestionnaire_service_spec.rb index 3af0796b9..2e1e8d164 100644 --- a/spec/services/dossiers_list_gestionnaire_service_spec.rb +++ b/spec/services/dossiers_list_gestionnaire_service_spec.rb @@ -348,8 +348,6 @@ describe DossiersListGestionnaireService do let!(:dossier) { create(:dossier, procedure: procedure, state: 'draft') } let!(:dossier2) { create(:dossier, procedure: procedure, state: 'initiated') } #nouveaux let!(:dossier3) { create(:dossier, procedure: procedure, state: 'initiated') } #nouveaux - let!(:dossier4) { create(:dossier, procedure: procedure, state: 'replied') } #en_attente - let!(:dossier5) { create(:dossier, procedure: procedure, state: 'updated') } #a_traiter let!(:dossier6) { create(:dossier, procedure: procedure, state: 'received') } #a_instruire let!(:dossier7) { create(:dossier, procedure: procedure, state: 'received') } #a_instruire let!(:dossier8) { create(:dossier, procedure: procedure, state: 'closed') } #termine @@ -357,7 +355,6 @@ describe DossiersListGestionnaireService do let!(:dossier10) { create(:dossier, procedure: procedure, state: 'without_continuation') } #termine let!(:dossier11) { create(:dossier, procedure: procedure, state: 'closed') } #termine let!(:dossier12) { create(:dossier, procedure: procedure, state: 'initiated', archived: true) } #a_traiter #archived - let!(:dossier13) { create(:dossier, procedure: procedure, state: 'replied', archived: true) } #en_attente #archived let!(:dossier14) { create(:dossier, procedure: procedure, state: 'closed', archived: true) } #termine #archived describe '#termine' do diff --git a/spec/services/user_routes_authorization_service_spec.rb b/spec/services/user_routes_authorization_service_spec.rb index 4bbb7d825..699d16778 100644 --- a/spec/services/user_routes_authorization_service_spec.rb +++ b/spec/services/user_routes_authorization_service_spec.rb @@ -23,11 +23,6 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_falsey } end - describe 'replied' do - let(:state) { 'replied' } - it { is_expected.to be_falsey } - end - describe 'updated' do let(:state) { 'updated' } it { is_expected.to be_falsey } @@ -53,11 +48,6 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_falsey } end - describe 'replied' do - let(:state) { 'replied' } - it { is_expected.to be_falsey } - end - describe 'updated' do let(:state) { 'updated' } it { is_expected.to be_falsey } @@ -82,11 +72,6 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_truthy } end - describe 'replied' do - let(:state) { 'replied' } - it { is_expected.to be_truthy } - end - describe 'updated' do let(:state) { 'updated' } it { is_expected.to be_truthy } @@ -112,11 +97,6 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_truthy } end - describe 'replied' do - let(:state) { 'replied' } - it { is_expected.to be_truthy } - end - describe 'updated' do let(:state) { 'updated' } it { is_expected.to be_truthy } @@ -141,11 +121,6 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_truthy } end - describe 'replied' do - let(:state) { 'replied' } - it { is_expected.to be_truthy } - end - describe 'updated' do let(:state) { 'updated' } it { is_expected.to be_truthy } diff --git a/spec/views/backoffice/dossiers/index_html.haml_spec.rb b/spec/views/backoffice/dossiers/index_html.haml_spec.rb index 539e2c4f9..9781882b0 100644 --- a/spec/views/backoffice/dossiers/index_html.haml_spec.rb +++ b/spec/views/backoffice/dossiers/index_html.haml_spec.rb @@ -7,7 +7,6 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do let!(:procedure) { create(:procedure, :published, administrateur: administrateur) } let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated').decorate } - let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, procedure: procedure, state: 'replied').decorate } let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated').decorate } let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, procedure: procedure, state: 'received').decorate } let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, procedure: procedure, state: 'closed').decorate } @@ -21,7 +20,6 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do let(:all_state_dossiers_list) { dossiers_list_facade.service.all_state } before do - decorate_dossier_replied.entreprise.update_column(:raison_sociale, 'plap') decorate_dossier_updated.entreprise.update_column(:raison_sociale, 'plep') decorate_dossier_received.entreprise.update_column(:raison_sociale, 'plup') decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plyp') @@ -79,14 +77,13 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do 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 7 dossiers') } + it { is_expected.to have_content('Tous les dossiers 6 dossiers') } it { is_expected.to have_content('État') } it { is_expected.to have_content('Libellé procédure') } it { is_expected.to have_content('Raison sociale') } it { is_expected.to have_content('Mise à jour le') } - it { is_expected.to have_content('plap') } it { is_expected.to have_content('plep') } it { is_expected.to have_content('plup') } it { is_expected.to have_content('plyp') } 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 4682bb331..cf19e5c4a 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 @@ -40,18 +40,6 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm include_examples 'button Passer en instruction is present' end - context 'when dossier have state replied' do - let(:state) { 'replied' } - - before do - render - end - - it { expect(rendered).to have_content('En construction') } - - include_examples 'button Passer en instruction is present' - end - context 'when dossier have state update' do let(:state) { 'updated' } diff --git a/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb b/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb index f580715a9..54e4a0498 100644 --- a/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb +++ b/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb @@ -20,16 +20,6 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm it { expect(rendered).to have_content('En construction') } end - context 'when dossier state is replied' do - let(:state) { 'replied' } - - before do - render - end - - it { expect(rendered).to have_content('En construction') } - end - context 'when dossier state is updated' do let(:state) { 'updated' } 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 1e4f01b32..33a02b377 100644 --- a/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb +++ b/spec/views/new_gestionnaire/dossiers/show.html.haml_spec.rb @@ -1,7 +1,7 @@ describe 'new_gestionnaire/dossiers/show.html.haml', type: :view do let(:individual) { nil } let(:entreprise) { nil } - let(:dossier) { create(:dossier, :replied, entreprise: entreprise, individual: individual) } + let(:dossier) { create(:dossier, :initiated, entreprise: entreprise, individual: individual) } before do assign(:dossier, dossier) diff --git a/spec/views/users/dossiers/index_html.haml_spec.rb b/spec/views/users/dossiers/index_html.haml_spec.rb index dc6721b41..39aaed776 100644 --- a/spec/views/users/dossiers/index_html.haml_spec.rb +++ b/spec/views/users/dossiers/index_html.haml_spec.rb @@ -4,7 +4,6 @@ describe 'users/dossiers/index.html.haml', type: :view do let(:user) { create(:user) } let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, user: user, state: 'initiated').decorate } - let!(:decorate_dossier_replied) { create(:dossier, :with_entreprise, user: user, state: 'replied').decorate } let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, user: user, state: 'updated').decorate } let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, user: user, state: 'received').decorate } let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, user: user, state: 'closed').decorate } @@ -41,7 +40,7 @@ describe 'users/dossiers/index.html.haml', type: :view do end describe 'on tab en construction' do - let(:total_dossiers) { 3 } + let(:total_dossiers) { 2 } let(:active_class) { '.active .text-danger' } let(:dossiers_to_display) { user.dossiers.state_en_construction } let(:liste) { 'a_traiter' } @@ -50,10 +49,6 @@ describe 'users/dossiers/index.html.haml', type: :view do let(:decorate_dossier_at_check) { decorate_dossier_initiated } end - it_behaves_like 'check_tab_content' do - let(:decorate_dossier_at_check) { decorate_dossier_replied } - end - it_behaves_like 'check_tab_content' do let(:decorate_dossier_at_check) { decorate_dossier_updated } end diff --git a/spec/workers/auto_archive_procedure_worker_spec.rb b/spec/workers/auto_archive_procedure_worker_spec.rb index 9b4c57d81..c76e297d5 100644 --- a/spec/workers/auto_archive_procedure_worker_spec.rb +++ b/spec/workers/auto_archive_procedure_worker_spec.rb @@ -20,7 +20,7 @@ RSpec.describe AutoArchiveProcedureWorker, type: :worker do context "when procedures have auto_archive_on set on yesterday or today" do let!(:dossier1) { create(:dossier, procedure: procedure_hier, state: 'draft', archived: false)} let!(:dossier2) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)} - let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'replied', archived: false)} + let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)} let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'updated', archived: false)} let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'received', archived: false)} let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'closed', archived: false)} From 1cfeb10ce990c438a58b2ea97a0ac37fbcb7ec3e Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Fri, 22 Sep 2017 10:28:16 +0200 Subject: [PATCH 206/222] [Fix #503] Dossier: remove updated --- app/controllers/users/carte_controller.rb | 2 +- .../users/description_controller.rb | 2 +- .../users/recapitulatif_controller.rb | 2 +- app/models/dossier.rb | 13 +------ app/views/dossiers/_dossier_show.html.haml | 2 +- config/locales/models/dossier/fr.yml | 1 - doc/apipie_examples.json | 2 +- .../commentaires_controller_spec.rb | 8 ++--- .../procedures_controller_spec.rb | 2 +- spec/decorators/dossier_decorator_spec.rb | 7 +--- .../admin_procedures_show_facades_spec.rb | 7 ++-- .../backoffice/add_commentaire_spec.rb | 2 +- .../backoffice/flux_de_commentaires_spec.rb | 2 +- ..._page_pref_list_dossier_backoffice_spec.rb | 2 +- ...st_dossier_by_procedure_backoffice_spec.rb | 2 +- .../backoffice/navigate_to_dossier_spec.rb | 6 ++-- spec/features/users/onglets_link_spec.rb | 3 +- spec/models/dossier_spec.rb | 34 +------------------ .../user_routes_authorization_service_spec.rb | 25 -------------- .../dossiers/index_html.haml_spec.rb | 5 +-- ...backoffice_dossierscontroller_show_spec.rb | 12 ------- ...users_recapitulatifcontroller_show_spec.rb | 10 ------ .../users/dossiers/index_html.haml_spec.rb | 7 +--- .../auto_archive_procedure_worker_spec.rb | 2 +- 24 files changed, 25 insertions(+), 135 deletions(-) diff --git a/app/controllers/users/carte_controller.rb b/app/controllers/users/carte_controller.rb index f561bad88..09c8dd0ec 100644 --- a/app/controllers/users/carte_controller.rb +++ b/app/controllers/users/carte_controller.rb @@ -56,7 +56,7 @@ class Users::CarteController < UsersController def self.route_authorization { - states: [:draft, :initiated, :updated], + states: [:draft, :initiated], api_carto: true } end diff --git a/app/controllers/users/description_controller.rb b/app/controllers/users/description_controller.rb index d27627c53..ac5abf6ab 100644 --- a/app/controllers/users/description_controller.rb +++ b/app/controllers/users/description_controller.rb @@ -93,7 +93,7 @@ class Users::DescriptionController < UsersController def self.route_authorization { - states: [:draft, :initiated, :updated] + states: [:draft, :initiated] } end diff --git a/app/controllers/users/recapitulatif_controller.rb b/app/controllers/users/recapitulatif_controller.rb index 3405b899d..5066c9dc1 100644 --- a/app/controllers/users/recapitulatif_controller.rb +++ b/app/controllers/users/recapitulatif_controller.rb @@ -18,7 +18,7 @@ class Users::RecapitulatifController < UsersController def self.route_authorization { - states: [:initiated, :updated, :received, :without_continuation, :closed, :refused] + states: [:initiated, :received, :without_continuation, :closed, :refused] } end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index dc0e2c884..0b317b86d 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -2,7 +2,6 @@ class Dossier < ActiveRecord::Base enum state: { draft: 'draft', initiated: 'initiated', - updated: 'updated', # etude par l'administration en cours received: 'received', closed: 'closed', refused: 'refused', @@ -11,7 +10,7 @@ class Dossier < ActiveRecord::Base BROUILLON = %w(draft) NOUVEAUX = %w(initiated) - EN_CONSTRUCTION = %w(initiated updated) + EN_CONSTRUCTION = %w(initiated) EN_INSTRUCTION = %w(received) EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION A_INSTRUIRE = %w(received) @@ -163,16 +162,6 @@ class Dossier < ActiveRecord::Base end when 'gestionnaire' case action - when 'comment' - if updated? - initiated! - elsif initiated? - initiated! - end - when 'follow' - if initiated? - updated! - end when 'close' if received? self.attestation = build_attestation diff --git a/app/views/dossiers/_dossier_show.html.haml b/app/views/dossiers/_dossier_show.html.haml index 7c733d9fb..09f09cd99 100644 --- a/app/views/dossiers/_dossier_show.html.haml +++ b/app/views/dossiers/_dossier_show.html.haml @@ -13,7 +13,7 @@ .col-xs-8.title-no-expanse .carret-right INFORMATIONS DU DEMANDEUR - - if !@current_gestionnaire && ["draft", "updated", "initiated"].include?(@facade.dossier.state) + - if !@current_gestionnaire && ["draft", "initiated"].include?(@facade.dossier.state) %a#add_siret.action{ href: users_dossier_add_siret_path(dossier_id: @facade.dossier.id) } .col-lg-4.col-md-4.col-sm-4.col-xs-4.action Renseigner un SIRET diff --git a/config/locales/models/dossier/fr.yml b/config/locales/models/dossier/fr.yml index 67ab08e55..c24c200b1 100644 --- a/config/locales/models/dossier/fr.yml +++ b/config/locales/models/dossier/fr.yml @@ -10,7 +10,6 @@ fr: state: draft: "Brouillon" initiated: "En construction" - updated: "En construction" received: "En instruction" closed: "Accepté" refused: "Refusé" diff --git a/doc/apipie_examples.json b/doc/apipie_examples.json index 3b5809195..e88b2a84c 100644 --- a/doc/apipie_examples.json +++ b/doc/apipie_examples.json @@ -45,7 +45,7 @@ "updated_at": "2008-09-01T08:05:00.000Z", "archived": false, "mandataire_social": false, - "state": "updated", + "state": "initiated", "simplified_state": "En construction", "initiated_at": "2017-04-11T12:00:12.000Z", "received_at": null, diff --git a/spec/controllers/backoffice/commentaires_controller_spec.rb b/spec/controllers/backoffice/commentaires_controller_spec.rb index c3c2ea20b..27e3d5486 100644 --- a/spec/controllers/backoffice/commentaires_controller_spec.rb +++ b/spec/controllers/backoffice/commentaires_controller_spec.rb @@ -113,19 +113,15 @@ describe Backoffice::CommentairesController, type: :controller do describe 'change dossier state after post a comment' do context 'gestionnaire is connected' do - context 'when dossier is at state updated' do + context 'when dossier is at state initiated' do before do sign_in gestionnaire - dossier.updated! + dossier.initiated! post :create, params: {dossier_id: dossier_id, texte_commentaire: texte_commentaire} dossier.reload end - subject { dossier.state } - - it { is_expected.to eq('initiated') } - it 'Notification email is send' do expect(NotificationMailer).to receive(:new_answer).and_return(NotificationMailer) expect(NotificationMailer).to receive(:deliver_now!) diff --git a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb index 254260cf7..99ed9d86c 100644 --- a/spec/controllers/new_gestionnaire/procedures_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/procedures_controller_spec.rb @@ -142,7 +142,7 @@ describe NewGestionnaire::ProceduresController, type: :controller do create(:dossier, procedure: procedure, state: "without_continuation", archived: true) gestionnaire.procedures << procedure2 - create(:dossier, :followed, procedure: procedure2, state: "updated") + create(:dossier, :followed, procedure: procedure2, state: "initiated") create(:dossier, procedure: procedure2, state: "closed") gestionnaire.followed_dossiers << create(:dossier, procedure: procedure2, state: "received") diff --git a/spec/decorators/dossier_decorator_spec.rb b/spec/decorators/dossier_decorator_spec.rb index e68943382..058d72563 100644 --- a/spec/decorators/dossier_decorator_spec.rb +++ b/spec/decorators/dossier_decorator_spec.rb @@ -27,11 +27,6 @@ describe DossierDecorator do expect(subject).to eq('En construction') end - it 'updated is mis à jour' do - dossier.updated! - expect(subject).to eq('En construction') - end - it 'closed is traité' do dossier.closed! expect(subject).to eq('Accepté') @@ -74,7 +69,7 @@ describe DossierDecorator do context "when the dossier is not in brouillon state" do before do - dossier.state = 'updated' + dossier.state = 'initiated' dossier.save end diff --git a/spec/facades/admin_procedures_show_facades_spec.rb b/spec/facades/admin_procedures_show_facades_spec.rb index f9b4a8234..5e1641aca 100644 --- a/spec/facades/admin_procedures_show_facades_spec.rb +++ b/spec/facades/admin_procedures_show_facades_spec.rb @@ -7,7 +7,6 @@ describe AdminProceduresShowFacades do let!(:dossier_1) { create(:dossier, procedure: procedure, state: 'initiated') } let!(:dossier_2) { create(:dossier, procedure: procedure, state: 'initiated') } let!(:dossier_6) { create(:dossier, procedure: procedure, archived: true, state: 'initiated') } - let!(:dossier_7) { create(:dossier, procedure: procedure, state: 'updated') } subject { AdminProceduresShowFacades.new procedure } @@ -20,13 +19,13 @@ describe AdminProceduresShowFacades do describe '.dossiers' do subject { super().dossiers } - it { expect(subject.size).to eq(4) } + it { expect(subject.size).to eq(3) } end describe '.dossiers_for_pie_highchart' do subject { super().dossiers_for_pie_highchart } - it { expect(subject).to eq({ 'En construction' => 3 }) } + it { expect(subject).to eq({ 'En construction' => 2 }) } end describe '.dossiers_archived_by_state_total' do @@ -47,7 +46,7 @@ describe AdminProceduresShowFacades do describe 'dossiers_total' do subject { super().dossiers_total } - it { is_expected.to eq(4) } + it { is_expected.to eq(3) } end describe 'dossiers_termine_total' do diff --git a/spec/features/backoffice/add_commentaire_spec.rb b/spec/features/backoffice/add_commentaire_spec.rb index 007966589..7bc6d1769 100644 --- a/spec/features/backoffice/add_commentaire_spec.rb +++ b/spec/features/backoffice/add_commentaire_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'add commentaire on backoffice' do let(:procedure) { create(:procedure, :published) } - let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') } + let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } let(:dossier_id) { dossier.id } let!(:commentaire) { create(:commentaire, dossier: dossier, email: 'toto@toto.com') } let(:email_commentaire) { 'test@test.com' } diff --git a/spec/features/backoffice/flux_de_commentaires_spec.rb b/spec/features/backoffice/flux_de_commentaires_spec.rb index 87247e8ad..8ff622b4d 100644 --- a/spec/features/backoffice/flux_de_commentaires_spec.rb +++ b/spec/features/backoffice/flux_de_commentaires_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature 'backoffice: flux de commentaires' do let(:procedure) { create(:procedure, :published) } let(:gestionnaire) { create(:gestionnaire) } - let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') } + let(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } let(:dossier_id) { dossier.id } let(:champ1) { create(:champ, dossier: dossier, type_de_champ: create(:type_de_champ_public, libelle: "subtitle1")) } diff --git a/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb b/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb index 54168c166..7e7f57772 100644 --- a/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb +++ b/spec/features/backoffice/lateral_page_pref_list_dossier_backoffice_spec.rb @@ -6,7 +6,7 @@ feature 'usage of pref list dossier lateral panel', js: true do let(:procedure) { create(:procedure, :published, administrateur: administrateur) } before do - create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') + create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') create :assign_to, procedure: procedure, gestionnaire: gestionnaire login_as gestionnaire, scope: :gestionnaire diff --git a/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb b/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb index 9f4178f50..9b9dd4432 100644 --- a/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb +++ b/spec/features/backoffice/lateral_page_pref_list_dossier_by_procedure_backoffice_spec.rb @@ -6,7 +6,7 @@ feature 'usage of pref list dossier lateral panel by procedure', js: true do let(:procedure) { create(:procedure, :published, :with_type_de_champ, administrateur: administrateur) } before do - create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') + create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') create :assign_to, procedure: procedure, gestionnaire: gestionnaire login_as gestionnaire, scope: :gestionnaire diff --git a/spec/features/backoffice/navigate_to_dossier_spec.rb b/spec/features/backoffice/navigate_to_dossier_spec.rb index aa2750b6b..f2e80f9f2 100644 --- a/spec/features/backoffice/navigate_to_dossier_spec.rb +++ b/spec/features/backoffice/navigate_to_dossier_spec.rb @@ -6,8 +6,8 @@ feature 'on backoffice page', js: true do let(:procedure) { create(:procedure, :published, administrateur: administrateur) } let(:procedure_individual) { create :procedure, :published, libelle: 'procedure individual', administrateur: administrateur, for_individual: true } - let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated') } - let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'updated' } + let!(:dossier) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated') } + let!(:dossier_individual) { create :dossier, procedure: procedure_individual, state: 'initiated' } before do create :assign_to, gestionnaire: gestionnaire, procedure: procedure @@ -34,7 +34,7 @@ feature 'on backoffice page', js: true do end context "and goes to the page of a dossier he hasn't access to" do - let!(:unauthorized_dossier) { create(:dossier, :with_entreprise, state: 'updated') } + let!(:unauthorized_dossier) { create(:dossier, :with_entreprise, state: 'initiated') } before do visit backoffice_dossier_path(unauthorized_dossier) diff --git a/spec/features/users/onglets_link_spec.rb b/spec/features/users/onglets_link_spec.rb index a229087b8..5c9232c86 100644 --- a/spec/features/users/onglets_link_spec.rb +++ b/spec/features/users/onglets_link_spec.rb @@ -7,7 +7,6 @@ feature 'on click on tabs button' do before do create(:dossier, :with_entreprise, user: user, state: 'initiated') - create(:dossier, :with_entreprise, user: user, state: 'updated') create(:dossier, :with_entreprise, user: user, state: 'received') create(:dossier, :with_entreprise, user: user, state: 'closed') create(:dossier, :with_entreprise, user: user, state: 'refused') @@ -22,7 +21,7 @@ feature 'on click on tabs button' do context 'when he click on tabs en construction' do before do visit users_dossiers_url(liste: :a_traiter) - page.click_on 'En construction 2' + page.click_on 'En construction 1' end scenario 'it redirect to users dossier termine' do diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index e8db47137..60418ad84 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -188,39 +188,7 @@ describe Dossier do context 'when is follow' do let(:action) { 'follow' } - it { is_expected.to eq 'updated' } - end - end - end - - context 'when dossier is at state updated' do - before do - dossier.updated! - end - - context 'when user is connect' do - let(:role) { 'user' } - - context 'when is post a comment' do - let(:action) { 'comment' } - - it { is_expected.to eq('updated') } - end - - context 'when is updated dossier informations' do - let(:action) { 'update' } - - it { is_expected.to eq('updated') } - end - end - - context 'when gestionnaire is connect' do - let(:role) { 'gestionnaire' } - - context 'when is post a comment' do - let(:action) { 'comment' } - - it { is_expected.to eq('initiated') } + it { is_expected.to eq 'initiated' } end end end diff --git a/spec/services/user_routes_authorization_service_spec.rb b/spec/services/user_routes_authorization_service_spec.rb index 699d16778..03a5b805b 100644 --- a/spec/services/user_routes_authorization_service_spec.rb +++ b/spec/services/user_routes_authorization_service_spec.rb @@ -23,11 +23,6 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_falsey } end - describe 'updated' do - let(:state) { 'updated' } - it { is_expected.to be_falsey } - end - describe 'closed' do let(:state) { 'closed' } it { is_expected.to be_falsey } @@ -48,11 +43,6 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_falsey } end - describe 'updated' do - let(:state) { 'updated' } - it { is_expected.to be_falsey } - end - describe 'closed' do let(:state) { 'closed' } it { is_expected.to be_falsey } @@ -72,11 +62,6 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_truthy } end - describe 'updated' do - let(:state) { 'updated' } - it { is_expected.to be_truthy } - end - describe 'closed' do let(:state) { 'closed' } it { is_expected.to be_falsey } @@ -97,11 +82,6 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_truthy } end - describe 'updated' do - let(:state) { 'updated' } - it { is_expected.to be_truthy } - end - describe 'closed' do let(:state) { 'closed' } it { is_expected.to be_falsey } @@ -121,11 +101,6 @@ describe UserRoutesAuthorizationService do it { is_expected.to be_truthy } end - describe 'updated' do - let(:state) { 'updated' } - it { is_expected.to be_truthy } - end - describe 'closed' do let(:state) { 'closed' } it { is_expected.to be_truthy } diff --git a/spec/views/backoffice/dossiers/index_html.haml_spec.rb b/spec/views/backoffice/dossiers/index_html.haml_spec.rb index 9781882b0..bfade3965 100644 --- a/spec/views/backoffice/dossiers/index_html.haml_spec.rb +++ b/spec/views/backoffice/dossiers/index_html.haml_spec.rb @@ -7,7 +7,6 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do let!(:procedure) { create(:procedure, :published, administrateur: administrateur) } let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated').decorate } - let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, procedure: procedure, state: 'updated').decorate } let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, procedure: procedure, state: 'received').decorate } let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, procedure: procedure, state: 'closed').decorate } let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, procedure: procedure, state: 'refused').decorate } @@ -20,7 +19,6 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do let(:all_state_dossiers_list) { dossiers_list_facade.service.all_state } before do - decorate_dossier_updated.entreprise.update_column(:raison_sociale, 'plep') decorate_dossier_received.entreprise.update_column(:raison_sociale, 'plup') decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plyp') decorate_dossier_refused.entreprise.update_column(:raison_sociale, 'plzp') @@ -77,14 +75,13 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do 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 6 dossiers') } + it { is_expected.to have_content('Tous les dossiers 5 dossiers') } it { is_expected.to have_content('État') } it { is_expected.to have_content('Libellé procédure') } it { is_expected.to have_content('Raison sociale') } it { is_expected.to have_content('Mise à jour le') } - it { is_expected.to have_content('plep') } it { is_expected.to have_content('plup') } it { is_expected.to have_content('plyp') } end 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 cf19e5c4a..17009aa9c 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 @@ -40,18 +40,6 @@ describe 'layouts/left_panels/_left_panel_backoffice_dossierscontroller_show.htm include_examples 'button Passer en instruction is present' end - context 'when dossier have state update' do - let(:state) { 'updated' } - - before do - render - end - - it { expect(rendered).to have_content('En construction') } - - include_examples 'button Passer en instruction is present' - end - context 'when dossier have state received' do let(:state) { 'received' } diff --git a/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb b/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb index 54e4a0498..831f61295 100644 --- a/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb +++ b/spec/views/layouts/left_panels/_left_panel_users_recapitulatifcontroller_show_spec.rb @@ -20,16 +20,6 @@ describe 'layouts/left_panels/_left_panel_users_recapitulatifcontroller_show.htm it { expect(rendered).to have_content('En construction') } end - context 'when dossier state is updated' do - let(:state) { 'updated' } - - before do - render - end - - it { expect(rendered).to have_content('En construction') } - end - context 'when dossier state is closed' do let(:state) { 'closed' } diff --git a/spec/views/users/dossiers/index_html.haml_spec.rb b/spec/views/users/dossiers/index_html.haml_spec.rb index 39aaed776..a8c6e9e11 100644 --- a/spec/views/users/dossiers/index_html.haml_spec.rb +++ b/spec/views/users/dossiers/index_html.haml_spec.rb @@ -4,7 +4,6 @@ describe 'users/dossiers/index.html.haml', type: :view do let(:user) { create(:user) } let!(:decorate_dossier_initiated) { create(:dossier, :with_entreprise, user: user, state: 'initiated').decorate } - let!(:decorate_dossier_updated) { create(:dossier, :with_entreprise, user: user, state: 'updated').decorate } let!(:decorate_dossier_received) { create(:dossier, :with_entreprise, user: user, state: 'received').decorate } let!(:decorate_dossier_closed) { create(:dossier, :with_entreprise, user: user, state: 'closed').decorate } let!(:decorate_dossier_refused) { create(:dossier, :with_entreprise, user: user, state: 'refused').decorate } @@ -40,7 +39,7 @@ describe 'users/dossiers/index.html.haml', type: :view do end describe 'on tab en construction' do - let(:total_dossiers) { 2 } + let(:total_dossiers) { 1 } let(:active_class) { '.active .text-danger' } let(:dossiers_to_display) { user.dossiers.state_en_construction } let(:liste) { 'a_traiter' } @@ -48,10 +47,6 @@ describe 'users/dossiers/index.html.haml', type: :view do it_behaves_like 'check_tab_content' do let(:decorate_dossier_at_check) { decorate_dossier_initiated } end - - it_behaves_like 'check_tab_content' do - let(:decorate_dossier_at_check) { decorate_dossier_updated } - end end describe 'on tab etude en examen' do diff --git a/spec/workers/auto_archive_procedure_worker_spec.rb b/spec/workers/auto_archive_procedure_worker_spec.rb index c76e297d5..ae47d6f42 100644 --- a/spec/workers/auto_archive_procedure_worker_spec.rb +++ b/spec/workers/auto_archive_procedure_worker_spec.rb @@ -21,7 +21,7 @@ RSpec.describe AutoArchiveProcedureWorker, type: :worker do let!(:dossier1) { create(:dossier, procedure: procedure_hier, state: 'draft', archived: false)} let!(:dossier2) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)} let!(:dossier3) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)} - let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'updated', archived: false)} + let!(:dossier4) { create(:dossier, procedure: procedure_hier, state: 'initiated', archived: false)} let!(:dossier5) { create(:dossier, procedure: procedure_hier, state: 'received', archived: false)} let!(:dossier6) { create(:dossier, procedure: procedure_hier, state: 'closed', archived: false)} let!(:dossier7) { create(:dossier, procedure: procedure_hier, state: 'refused', archived: false)} From 27013c7908d20fe01035e1073d64c292ccff5566 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Fri, 22 Sep 2017 11:11:04 +0200 Subject: [PATCH 207/222] [Fix #503] Lib task: move updated, replied state to initiated --- .../2017_09_22_set_dossier_updated_replied_to_initiated.rake | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 lib/tasks/2017_09_22_set_dossier_updated_replied_to_initiated.rake diff --git a/lib/tasks/2017_09_22_set_dossier_updated_replied_to_initiated.rake b/lib/tasks/2017_09_22_set_dossier_updated_replied_to_initiated.rake new file mode 100644 index 000000000..001672458 --- /dev/null +++ b/lib/tasks/2017_09_22_set_dossier_updated_replied_to_initiated.rake @@ -0,0 +1,5 @@ +namespace :'2017_09_22_set_dossier_updated_replied_to_initiated' do + task set: :environment do + Dossier.unscoped.where(state: [:updated, :replied]).update_all(state: :initiated) + end +end From fb5472d3f64f3c768f58fcb7ec572099c1b6138b Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Fri, 22 Sep 2017 18:27:05 +0200 Subject: [PATCH 208/222] Dossier: remove a_instruire scope As it s a duplication of en_instruction --- app/models/dossier.rb | 4 +--- app/services/dossiers_list_gestionnaire_service.rb | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 0b317b86d..45f0c0a0f 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -13,7 +13,6 @@ class Dossier < ActiveRecord::Base EN_CONSTRUCTION = %w(initiated) EN_INSTRUCTION = %w(received) EN_CONSTRUCTION_OU_INSTRUCTION = EN_CONSTRUCTION + EN_INSTRUCTION - A_INSTRUIRE = %w(received) TERMINE = %w(closed refused without_continuation) has_one :etablissement, dependent: :destroy @@ -48,7 +47,6 @@ class Dossier < ActiveRecord::Base scope :state_en_construction, -> { where(state: EN_CONSTRUCTION) } scope :state_en_instruction, -> { where(state: EN_INSTRUCTION) } scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) } - scope :state_a_instruire, -> { where(state: A_INSTRUIRE) } scope :state_termine, -> { where(state: TERMINE) } scope :archived, -> { where(archived: true) } @@ -58,7 +56,7 @@ class Dossier < ActiveRecord::Base scope :all_state, -> { not_archived.state_not_brouillon.order_by_updated_at(:asc) } scope :nouveaux, -> { not_archived.state_nouveaux.order_by_updated_at(:asc) } - scope :a_instruire, -> { not_archived.state_a_instruire.order_by_updated_at(:asc) } + scope :en_instruction, -> { not_archived.state_en_instruction.order_by_updated_at(:asc) } scope :termine, -> { not_archived.state_termine.order_by_updated_at(:asc) } scope :downloadable, -> { state_not_brouillon.order_by_updated_at(:asc) } scope :en_cours, -> { not_archived.state_en_construction_ou_instruction.order_by_updated_at(:asc) } diff --git a/app/services/dossiers_list_gestionnaire_service.rb b/app/services/dossiers_list_gestionnaire_service.rb index 843185fee..3f5135164 100644 --- a/app/services/dossiers_list_gestionnaire_service.rb +++ b/app/services/dossiers_list_gestionnaire_service.rb @@ -32,7 +32,7 @@ class DossiersListGestionnaireService end def a_instruire - @a_instruire ||= filter_dossiers.a_instruire + @a_instruire ||= filter_dossiers.en_instruction end def archive From a421f0257e6b96802ba883d76523361b64d7f959 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Tue, 26 Sep 2017 14:38:16 +0200 Subject: [PATCH 209/222] [Fix #762] split annotations and avis --- .../new_gestionnaire/dossiers_controller.rb | 7 ++++++- .../dossiers/_header.html.haml | 4 +++- .../new_gestionnaire/dossiers/avis.html.haml | 18 ++++++++++++++++++ .../dossiers/instruction.html.haml | 19 +++---------------- config/routes.rb | 1 + .../dossiers_controller_spec.rb | 2 +- 6 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 app/views/new_gestionnaire/dossiers/avis.html.haml diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 69ea7ee99..c93d42fb7 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -19,6 +19,11 @@ module NewGestionnaire dossier.notifications.instruction.mark_as_read end + def avis + @dossier = dossier + dossier.notifications.instruction.mark_as_read + end + def follow current_gestionnaire.follow(dossier) dossier.next_step!('gestionnaire', 'follow') @@ -67,7 +72,7 @@ module NewGestionnaire def create_avis Avis.create(avis_params.merge(claimant: current_gestionnaire, dossier: dossier)) - redirect_to instruction_dossier_path(dossier.procedure, dossier) + redirect_to avis_dossier_path(dossier.procedure, dossier) end def update_annotations diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index d464b6a14..6fd791c69 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -16,9 +16,11 @@ %span.notifications{ 'aria-label': 'notifications' } = link_to "Demande", dossier_path(dossier.procedure, dossier) %li{ class: current_page?(instruction_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } + = link_to "Annotations Privées", instruction_dossier_path(dossier.procedure, dossier) + %li{ class: current_page?(avis_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } - if notifications_summary[:instruction] %span.notifications{ 'aria-label': 'notifications' } - = link_to "Instruction", instruction_dossier_path(dossier.procedure, dossier) + = link_to "Avis Externes", avis_dossier_path(dossier.procedure, dossier) %li{ class: current_page?(messagerie_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } - if notifications_summary[:messagerie] %span.notifications{ 'aria-label': 'notifications' } diff --git a/app/views/new_gestionnaire/dossiers/avis.html.haml b/app/views/new_gestionnaire/dossiers/avis.html.haml new file mode 100644 index 000000000..5484a0b29 --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/avis.html.haml @@ -0,0 +1,18 @@ += render partial: "header", locals: { dossier: @dossier } + +.container + %section.ask-avis + %h1 Inviter une personne à donner son avis + %p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier. + + = form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f| + = f.email_field :email, placeholder: 'Adresse email', required: true + = f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true + .flex.justify-between.align-baseline + .confidentiel-wrapper + = f.label :confidentiel, 'Cet avis est' + = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]] + .send-wrapper + = f.submit 'Demander un avis', class: 'button send' + + = render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis } diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml index ed597681f..ccc8752e0 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -1,22 +1,6 @@ = render partial: "header", locals: { dossier: @dossier } #dossier-instruction.container - %section.ask-avis - %h1 Inviter une personne à donner son avis - %p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier. - - = form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f| - = f.email_field :email, placeholder: 'Adresse email', required: true - = f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true - .flex.justify-between.align-baseline - .confidentiel-wrapper - = f.label :confidentiel, 'Cet avis est' - = f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]] - .send-wrapper - = f.submit 'Demander un avis', class: 'button send' - - = render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis } - - if @dossier.ordered_champs_private.present? %section %h1.private-annotations Annotations privées @@ -29,3 +13,6 @@ .send-wrapper = f.submit 'Sauvegarder', class: 'button send' + + - else + %h2.empty-text Aucune annotation privée diff --git a/config/routes.rb b/config/routes.rb index 755d30ff2..c7064cb16 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -244,6 +244,7 @@ Rails.application.routes.draw do get 'attestation' get 'messagerie' get 'instruction' + get 'avis' patch 'follow' patch 'unfollow' patch 'archive' diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 0ddb3f10a..083dffa4a 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -133,7 +133,7 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(saved_avis.confidentiel).to eq(true) } it { expect(saved_avis.dossier).to eq(dossier) } it { expect(saved_avis.claimant).to eq(gestionnaire) } - it { expect(response).to redirect_to(instruction_dossier_path(dossier.procedure, dossier)) } + it { expect(response).to redirect_to(avis_dossier_path(dossier.procedure, dossier)) } end describe "#update_annotations" do From f5a227fa92d903c68532684e5be36906f56d0acf Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 27 Sep 2017 12:08:47 +0200 Subject: [PATCH 210/222] [Fix #762] move dossier instruction -> dossier annotations_privees --- ...ier_instruction.scss => dossier_annotations_privees.scss} | 2 +- app/controllers/new_gestionnaire/dossiers_controller.rb | 5 ++--- app/views/new_gestionnaire/dossiers/_header.html.haml | 4 ++-- .../{instruction.html.haml => annotations_privees.html.haml} | 2 +- config/routes.rb | 2 +- .../controllers/new_gestionnaire/dossiers_controller_spec.rb | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) rename app/assets/stylesheets/new_design/{dossier_instruction.scss => dossier_annotations_privees.scss} (83%) rename app/views/new_gestionnaire/dossiers/{instruction.html.haml => annotations_privees.html.haml} (94%) diff --git a/app/assets/stylesheets/new_design/dossier_instruction.scss b/app/assets/stylesheets/new_design/dossier_annotations_privees.scss similarity index 83% rename from app/assets/stylesheets/new_design/dossier_instruction.scss rename to app/assets/stylesheets/new_design/dossier_annotations_privees.scss index 9a0747fb8..f92b704a0 100644 --- a/app/assets/stylesheets/new_design/dossier_instruction.scss +++ b/app/assets/stylesheets/new_design/dossier_annotations_privees.scss @@ -2,7 +2,7 @@ @import "common"; @import "constants"; -#dossier-instruction { +#dossier-annotations-privees { h1 { font-size: 18px; font-weight: bold; diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index c93d42fb7..85f753a1a 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -14,9 +14,8 @@ module NewGestionnaire dossier.notifications.messagerie.mark_as_read end - def instruction + def annotations_privees @dossier = dossier - dossier.notifications.instruction.mark_as_read end def avis @@ -78,7 +77,7 @@ module NewGestionnaire def update_annotations dossier = current_gestionnaire.dossiers.includes(champs_private: :type_de_champ).find(params[:dossier_id]) dossier.update_attributes(champs_private_params) - redirect_to instruction_dossier_path(dossier.procedure, dossier) + redirect_to annotations_privees_dossier_path(dossier.procedure, dossier) end private diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 6fd791c69..631ac63a4 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -15,8 +15,8 @@ - if notifications_summary[:demande] %span.notifications{ 'aria-label': 'notifications' } = link_to "Demande", dossier_path(dossier.procedure, dossier) - %li{ class: current_page?(instruction_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } - = link_to "Annotations Privées", instruction_dossier_path(dossier.procedure, dossier) + %li{ class: current_page?(annotations_privees_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } + = link_to "Annotations Privées", annotations_privees_dossier_path(dossier.procedure, dossier) %li{ class: current_page?(avis_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } - if notifications_summary[:instruction] %span.notifications{ 'aria-label': 'notifications' } diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/annotations_privees.html.haml similarity index 94% rename from app/views/new_gestionnaire/dossiers/instruction.html.haml rename to app/views/new_gestionnaire/dossiers/annotations_privees.html.haml index ccc8752e0..6aaece0df 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/annotations_privees.html.haml @@ -1,6 +1,6 @@ = render partial: "header", locals: { dossier: @dossier } -#dossier-instruction.container +#dossier-annotations-privees.container - if @dossier.ordered_champs_private.present? %section %h1.private-annotations Annotations privées diff --git a/config/routes.rb b/config/routes.rb index c7064cb16..c0272c9ef 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -243,7 +243,7 @@ Rails.application.routes.draw do member do get 'attestation' get 'messagerie' - get 'instruction' + get 'annotations-privees' => 'dossiers#annotations_privees' get 'avis' patch 'follow' patch 'unfollow' diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 083dffa4a..16343dcf8 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -88,7 +88,7 @@ describe NewGestionnaire::DossiersController, type: :controller do end context '#instruction' do - let(:method) { :instruction } + let(:method) { :annotations_privees } it { expect(dossier.notifications.map(&:already_read)).to match([false, true, false]) } it { expect(response).to have_http_status(:success) } end @@ -179,6 +179,6 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(champ_multiple_drop_down_list.value).to eq('["un", "deux"]') } it { expect(champ_datetime.value).to eq('21/12/2019 13:17') } - it { expect(response).to redirect_to(instruction_dossier_path(dossier.procedure, dossier)) } + it { expect(response).to redirect_to(annotations_privees_dossier_path(dossier.procedure, dossier)) } end end From 04d1e0f0e863c18406d1af0964477eb8c7e01212 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 27 Sep 2017 11:55:56 +0200 Subject: [PATCH 211/222] Notification: instruction -> avis --- app/controllers/new_gestionnaire/dossiers_controller.rb | 2 +- app/models/dossier.rb | 2 +- app/models/notification.rb | 8 ++++---- app/views/new_gestionnaire/dossiers/_header.html.haml | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 85f753a1a..d4f6d172b 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -20,7 +20,7 @@ module NewGestionnaire def avis @dossier = dossier - dossier.notifications.instruction.mark_as_read + dossier.notifications.avis.mark_as_read end def follow diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 45f0c0a0f..50cc36722 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -96,7 +96,7 @@ class Dossier < ActiveRecord::Base { demande: unread_notifications.select(&:demande?).present?, - instruction: unread_notifications.select(&:instruction?).present?, + avis: unread_notifications.select(&:avis?).present?, messagerie: unread_notifications.select(&:messagerie?).present? } end diff --git a/app/models/notification.rb b/app/models/notification.rb index b2cd552fe..d630ad494 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -9,14 +9,14 @@ class Notification < ActiveRecord::Base } DEMANDE = %w(cerfa piece_justificative champs submitted) - INSTRUCTION = %w(avis) + AVIS = %w(avis) MESSAGERIE = %w(commentaire) belongs_to :dossier scope :unread, -> { where(already_read: false) } scope :demande, -> { where(type_notif: DEMANDE) } - scope :instruction, -> { where(type_notif: INSTRUCTION) } + scope :avis, -> { where(type_notif: AVIS) } scope :messagerie, -> { where(type_notif: MESSAGERIE) } scope :mark_as_read, -> { update_all(already_read: true) } @@ -24,8 +24,8 @@ class Notification < ActiveRecord::Base Notification::DEMANDE.include?(type_notif) end - def instruction? - Notification::INSTRUCTION.include?(type_notif) + def avis? + Notification::AVIS.include?(type_notif) end def messagerie? diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 631ac63a4..8d8f3ebb0 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -18,7 +18,7 @@ %li{ class: current_page?(annotations_privees_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } = link_to "Annotations Privées", annotations_privees_dossier_path(dossier.procedure, dossier) %li{ class: current_page?(avis_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } - - if notifications_summary[:instruction] + - if notifications_summary[:avis] %span.notifications{ 'aria-label': 'notifications' } = link_to "Avis Externes", avis_dossier_path(dossier.procedure, dossier) %li{ class: current_page?(messagerie_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } From f2e1480c73eb82021f11703229dfafe2577ae7fe Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 27 Sep 2017 12:14:41 +0200 Subject: [PATCH 212/222] Notifications: add annotations_privees --- app/models/notification.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index d630ad494..38347c88f 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -5,7 +5,8 @@ class Notification < ActiveRecord::Base piece_justificative: 'piece_justificative', champs: 'champs', submitted: 'submitted', - avis: 'avis' + avis: 'avis', + annotations_privees: 'annotations_privees' } DEMANDE = %w(cerfa piece_justificative champs submitted) @@ -14,11 +15,12 @@ class Notification < ActiveRecord::Base belongs_to :dossier - scope :unread, -> { where(already_read: false) } - scope :demande, -> { where(type_notif: DEMANDE) } - scope :avis, -> { where(type_notif: AVIS) } - scope :messagerie, -> { where(type_notif: MESSAGERIE) } - scope :mark_as_read, -> { update_all(already_read: true) } + scope :unread, -> { where(already_read: false) } + scope :demande, -> { where(type_notif: DEMANDE) } + scope :avis, -> { where(type_notif: AVIS) } + scope :messagerie, -> { where(type_notif: MESSAGERIE) } + scope :annotations_privees, -> { where(type_notif: annotations_privees) } + scope :mark_as_read, -> { update_all(already_read: true) } def demande? Notification::DEMANDE.include?(type_notif) From 2b760c85c4074e7da71b2ce6ef9e6498341e9ae4 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Wed, 27 Sep 2017 15:08:34 +0200 Subject: [PATCH 213/222] [Fix #763] Add annotations_privees to buggy annotation system --- .../new_gestionnaire/dossiers_controller.rb | 1 + app/models/champ.rb | 8 ++++++-- app/models/dossier.rb | 3 ++- app/models/notification.rb | 7 ++++++- .../dossiers/_header.html.haml | 2 ++ .../dossiers_controller_spec.rb | 18 ++++++++++++------ 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index d4f6d172b..8bd5cac96 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -16,6 +16,7 @@ module NewGestionnaire def annotations_privees @dossier = dossier + dossier.notifications.annotations_privees.mark_as_read end def avis diff --git a/app/models/champ.rb b/app/models/champ.rb index 03882a670..950a6b70b 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -83,8 +83,12 @@ class Champ < ActiveRecord::Base end def internal_notification - unless dossier.state == 'draft' - NotificationService.new('champs', self.dossier.id, self.libelle).notify + if dossier.state != 'draft' + if type == 'ChampPublic' + NotificationService.new('champs', self.dossier.id, self.libelle).notify + else + NotificationService.new('annotations_privees', self.dossier.id, self.libelle).notify + end end end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 50cc36722..94cf0aa5c 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -97,7 +97,8 @@ class Dossier < ActiveRecord::Base { demande: unread_notifications.select(&:demande?).present?, avis: unread_notifications.select(&:avis?).present?, - messagerie: unread_notifications.select(&:messagerie?).present? + messagerie: unread_notifications.select(&:messagerie?).present?, + annotations_privees: unread_notifications.select(&:annotations_privees?).present? } end diff --git a/app/models/notification.rb b/app/models/notification.rb index 38347c88f..a9fb5b7dc 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -12,6 +12,7 @@ class Notification < ActiveRecord::Base DEMANDE = %w(cerfa piece_justificative champs submitted) AVIS = %w(avis) MESSAGERIE = %w(commentaire) + ANNOTATIONS_PRIVEES = %w(annotations_privees) belongs_to :dossier @@ -19,7 +20,7 @@ class Notification < ActiveRecord::Base scope :demande, -> { where(type_notif: DEMANDE) } scope :avis, -> { where(type_notif: AVIS) } scope :messagerie, -> { where(type_notif: MESSAGERIE) } - scope :annotations_privees, -> { where(type_notif: annotations_privees) } + scope :annotations_privees, -> { where(type_notif: ANNOTATIONS_PRIVEES) } scope :mark_as_read, -> { update_all(already_read: true) } def demande? @@ -33,4 +34,8 @@ class Notification < ActiveRecord::Base def messagerie? Notification::MESSAGERIE.include?(type_notif) end + + def annotations_privees? + Notification::ANNOTATIONS_PRIVEES.include?(type_notif) + end end diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 8d8f3ebb0..2321f44aa 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -16,6 +16,8 @@ %span.notifications{ 'aria-label': 'notifications' } = link_to "Demande", dossier_path(dossier.procedure, dossier) %li{ class: current_page?(annotations_privees_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } + - if notifications_summary[:annotations_privees] + %span.notifications{ 'aria-label': 'notifications' } = link_to "Annotations Privées", annotations_privees_dossier_path(dossier.procedure, dossier) %li{ class: current_page?(avis_dossier_path(dossier.procedure, dossier)) ? 'active' : nil } - if notifications_summary[:avis] diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 16343dcf8..6610ae4c9 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -74,28 +74,34 @@ describe NewGestionnaire::DossiersController, type: :controller do it { expect(response).to redirect_to(procedures_url) } end - describe '#show #messagerie #instruction' do + describe '#show #messagerie #annotations_privees #avis' do before do - dossier.notifications = %w(champs avis commentaire).map{ |type| Notification.create!(type_notif: type) } + dossier.notifications = %w(champs annotations_privees avis commentaire).map{ |type| Notification.create!(type_notif: type) } get method, params: { procedure_id: procedure.id, dossier_id: dossier.id } dossier.notifications.each(&:reload) end context '#show' do let(:method) { :show } - it { expect(dossier.notifications.map(&:already_read)).to match([true, false, false]) } + it { expect(dossier.notifications.map(&:already_read)).to match([true, false, false, false]) } it { expect(response).to have_http_status(:success) } end - context '#instruction' do + context '#annotations_privees' do let(:method) { :annotations_privees } - it { expect(dossier.notifications.map(&:already_read)).to match([false, true, false]) } + it { expect(dossier.notifications.map(&:already_read)).to match([false, true, false, false]) } + it { expect(response).to have_http_status(:success) } + end + + context '#avis' do + let(:method) { :avis } + it { expect(dossier.notifications.map(&:already_read)).to match([false, false, true, false]) } it { expect(response).to have_http_status(:success) } end context '#messagerie' do let(:method) { :messagerie } - it { expect(dossier.notifications.map(&:already_read)).to match([false, false, true]) } + it { expect(dossier.notifications.map(&:already_read)).to match([false, false, false, true]) } it { expect(response).to have_http_status(:success) } end end From 608419701e0394413e55e693e4beb64101bc95a5 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 26 Sep 2017 10:43:50 +0200 Subject: [PATCH 214/222] Add and install delayed_job gem --- Gemfile | 3 +++ Gemfile.lock | 6 +++++ bin/delayed_job | 5 +++++ .../20170926083816_create_delayed_jobs.rb | 22 +++++++++++++++++++ db/schema.rb | 17 +++++++++++++- 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100755 bin/delayed_job create mode 100644 db/migrate/20170926083816_create_delayed_jobs.rb diff --git a/Gemfile b/Gemfile index a254eeb39..c1b53f322 100644 --- a/Gemfile +++ b/Gemfile @@ -101,6 +101,9 @@ gem 'sidekiq' gem 'sidekiq-cron', '~> 0.4.4' gem 'sinatra', git: 'https://github.com/sinatra/sinatra.git', require: false +# Cron jobs +gem 'delayed_job_active_record' + gem 'select2-rails' # PDF Generation diff --git a/Gemfile.lock b/Gemfile.lock index fda9782df..8861e6c2b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -130,6 +130,11 @@ GEM debug_inspector (0.0.2) deep_cloneable (2.2.2) activerecord (>= 3.1.0, < 5.2.0) + delayed_job (4.1.3) + activesupport (>= 3.0, < 5.2) + delayed_job_active_record (4.1.2) + activerecord (>= 3.0, < 5.2) + delayed_job (>= 3.0, < 5) devise (4.2.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -696,6 +701,7 @@ DEPENDENCIES copy_carrierwave_file database_cleaner deep_cloneable (~> 2.2.1) + delayed_job_active_record devise dotenv-rails draper (~> 3.0.0.pre1) diff --git a/bin/delayed_job b/bin/delayed_job new file mode 100755 index 000000000..edf195985 --- /dev/null +++ b/bin/delayed_job @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby + +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) +require 'delayed/command' +Delayed::Command.new(ARGV).daemonize diff --git a/db/migrate/20170926083816_create_delayed_jobs.rb b/db/migrate/20170926083816_create_delayed_jobs.rb new file mode 100644 index 000000000..130a8d570 --- /dev/null +++ b/db/migrate/20170926083816_create_delayed_jobs.rb @@ -0,0 +1,22 @@ +class CreateDelayedJobs < ActiveRecord::Migration[5.0] + def self.up + create_table :delayed_jobs, force: true do |table| + table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue + table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually. + table.text :handler, null: false # YAML-encoded string of the object that will do work + table.text :last_error # reason for last failure (See Note below) + table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. + table.datetime :locked_at # Set when a client is working on this object + table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) + table.string :locked_by # Who is working on this object (if locked) + table.string :queue # The name of the queue this job is in + table.timestamps null: true + end + + add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority" + end + + def self.down + drop_table :delayed_jobs + end +end diff --git a/db/schema.rb b/db/schema.rb index ec4a5d01a..56e5f14e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170908101023) do +ActiveRecord::Schema.define(version: 20170926083816) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -162,6 +162,21 @@ ActiveRecord::Schema.define(version: 20170908101023) do t.index ["dossier_id"], name: "index_commentaires_on_dossier_id", using: :btree end + create_table "delayed_jobs", force: :cascade do |t| + t.integer "priority", default: 0, null: false + t.integer "attempts", default: 0, null: false + t.text "handler", null: false + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + t.index ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree + end + create_table "dossiers", force: :cascade do |t| t.boolean "autorisation_donnees" t.integer "procedure_id" From 8965c668d9144aee5fe0c182a0db2ecae6313b83 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 26 Sep 2017 11:32:34 +0200 Subject: [PATCH 215/222] Add and install delayed_cron_job gem --- Gemfile | 1 + Gemfile.lock | 3 +++ db/migrate/20170926092716_add_cron_to_delayed_jobs.rb | 9 +++++++++ db/schema.rb | 3 ++- 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170926092716_add_cron_to_delayed_jobs.rb diff --git a/Gemfile b/Gemfile index c1b53f322..20d3d3890 100644 --- a/Gemfile +++ b/Gemfile @@ -103,6 +103,7 @@ gem 'sinatra', git: 'https://github.com/sinatra/sinatra.git', require: false # Cron jobs gem 'delayed_job_active_record' +gem 'delayed_cron_job' gem 'select2-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 8861e6c2b..4e96db14e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -130,6 +130,8 @@ GEM debug_inspector (0.0.2) deep_cloneable (2.2.2) activerecord (>= 3.1.0, < 5.2.0) + delayed_cron_job (0.7.2) + delayed_job (>= 4.1) delayed_job (4.1.3) activesupport (>= 3.0, < 5.2) delayed_job_active_record (4.1.2) @@ -701,6 +703,7 @@ DEPENDENCIES copy_carrierwave_file database_cleaner deep_cloneable (~> 2.2.1) + delayed_cron_job delayed_job_active_record devise dotenv-rails diff --git a/db/migrate/20170926092716_add_cron_to_delayed_jobs.rb b/db/migrate/20170926092716_add_cron_to_delayed_jobs.rb new file mode 100644 index 000000000..33e89d190 --- /dev/null +++ b/db/migrate/20170926092716_add_cron_to_delayed_jobs.rb @@ -0,0 +1,9 @@ +class AddCronToDelayedJobs < ActiveRecord::Migration[5.0] + def self.up + add_column :delayed_jobs, :cron, :string + end + + def self.down + remove_column :delayed_jobs, :cron + end +end diff --git a/db/schema.rb b/db/schema.rb index 56e5f14e9..e2bd74e20 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170926083816) do +ActiveRecord::Schema.define(version: 20170926092716) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -174,6 +174,7 @@ ActiveRecord::Schema.define(version: 20170926083816) do t.string "queue" t.datetime "created_at" t.datetime "updated_at" + t.string "cron" t.index ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree end From 68506fe2c74b144aae8fbb8e106f6ece45210c42 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 26 Sep 2017 12:06:32 +0200 Subject: [PATCH 216/222] Add and install daemons gem --- Gemfile | 1 + Gemfile.lock | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index 20d3d3890..c5257b517 100644 --- a/Gemfile +++ b/Gemfile @@ -103,6 +103,7 @@ gem 'sinatra', git: 'https://github.com/sinatra/sinatra.git', require: false # Cron jobs gem 'delayed_job_active_record' +gem "daemons" gem 'delayed_cron_job' gem 'select2-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 4e96db14e..17ba3ad98 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -126,6 +126,7 @@ GEM carrierwave (>= 0.9) crack (0.4.3) safe_yaml (~> 1.0.0) + daemons (1.2.4) database_cleaner (1.5.3) debug_inspector (0.0.2) deep_cloneable (2.2.2) @@ -701,6 +702,7 @@ DEPENDENCIES chunky_png clamav-client copy_carrierwave_file + daemons database_cleaner deep_cloneable (~> 2.2.1) delayed_cron_job From b9869d861f413b91a27b08322f48af8d4fc940db Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 26 Sep 2017 12:04:05 +0200 Subject: [PATCH 217/222] Add and install delayed_job_web gem --- Gemfile | 1 + Gemfile.lock | 5 +++++ config/routes.rb | 1 + 3 files changed, 7 insertions(+) diff --git a/Gemfile b/Gemfile index c5257b517..be12e52ef 100644 --- a/Gemfile +++ b/Gemfile @@ -105,6 +105,7 @@ gem 'sinatra', git: 'https://github.com/sinatra/sinatra.git', require: false gem 'delayed_job_active_record' gem "daemons" gem 'delayed_cron_job' +gem "delayed_job_web" gem 'select2-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 17ba3ad98..950868119 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -138,6 +138,10 @@ GEM delayed_job_active_record (4.1.2) activerecord (>= 3.0, < 5.2) delayed_job (>= 3.0, < 5) + delayed_job_web (1.4) + activerecord (> 3.0.0) + delayed_job (> 2.0.3) + sinatra (>= 1.4.4) devise (4.2.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -707,6 +711,7 @@ DEPENDENCIES deep_cloneable (~> 2.2.1) delayed_cron_job delayed_job_active_record + delayed_job_web devise dotenv-rails draper (~> 3.0.0.pre1) diff --git a/config/routes.rb b/config/routes.rb index c0272c9ef..aac7387bf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -50,6 +50,7 @@ Rails.application.routes.draw do require 'sidekiq/web' require 'sidekiq/cron/web' mount Sidekiq::Web => '/sidekiq' + match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post] end end From fbad15bc84d0b49686802e9ca9f29523d9fc9cba Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 26 Sep 2017 14:12:55 +0200 Subject: [PATCH 218/222] Change AutoArchiveProcedureWorker for delayed_job --- app/workers/auto_archive_procedure_worker.rb | 10 ++++++++-- spec/workers/auto_archive_procedure_worker_spec.rb | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/workers/auto_archive_procedure_worker.rb b/app/workers/auto_archive_procedure_worker.rb index d9715b843..d8c6df0a1 100644 --- a/app/workers/auto_archive_procedure_worker.rb +++ b/app/workers/auto_archive_procedure_worker.rb @@ -1,7 +1,6 @@ class AutoArchiveProcedureWorker - include Sidekiq::Worker - def perform(*args) + Rails.logger.info("AutoArchiveProcedureWorker started at #{Time.now}") Procedure.publiees.where("auto_archive_on <= ?", Date.today).each do |procedure| procedure.dossiers.state_en_construction.each do |dossier| dossier.received! @@ -9,5 +8,12 @@ class AutoArchiveProcedureWorker procedure.archive end + Rails.logger.info("AutoArchiveProcedureWorker ended at #{Time.now}") end + + def queue_name + "cron" + end + + handle_asynchronously :perform end diff --git a/spec/workers/auto_archive_procedure_worker_spec.rb b/spec/workers/auto_archive_procedure_worker_spec.rb index ae47d6f42..af3fe73fe 100644 --- a/spec/workers/auto_archive_procedure_worker_spec.rb +++ b/spec/workers/auto_archive_procedure_worker_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe AutoArchiveProcedureWorker, type: :worker do + before { Delayed::Worker.delay_jobs = false } + after { Delayed::Worker.delay_jobs = true } + let!(:procedure) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: nil )} let!(:procedure_hier) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: 1.day.ago )} let!(:procedure_aujourdhui) { create(:procedure, published_at: Time.now, archived_at: nil, auto_archive_on: Date.today )} From f46330be1a9fa2ca9816972ced579fc99e0b1590 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 26 Sep 2017 14:58:51 +0200 Subject: [PATCH 219/222] Update README for delayed_job --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d395433ee..e2ea0ad8d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ Téléprocédures Simplifiées, ou TPS pour les intimes, est une plateforme 100 ### Tous environnements - postgresql -- redis ### Développement @@ -61,11 +60,13 @@ Afin de générer la BDD de l'application, il est nécessaire d'éxécuter les c ## Lancement de l'application - redis-server - sidekiq + bin/delayed_job run mailcatcher -f rails s +## Lancement des workers + + Delayed::Job.enqueue(AutoArchiveProcedureWorker.new, cron: "* * * * *") ## Exécution des tests (RSpec) From e753c67ad6af05ab5078f1a277f86514cfe3f3f8 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 26 Sep 2017 15:32:03 +0200 Subject: [PATCH 220/222] Change WeeklyOverviewWorker for delayed_job --- README.md | 1 + app/workers/weekly_overview_worker.rb | 10 ++++++++-- spec/workers/weekly_overview_worker_spec.rb | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e2ea0ad8d..23c936df1 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Afin de générer la BDD de l'application, il est nécessaire d'éxécuter les c ## Lancement des workers Delayed::Job.enqueue(AutoArchiveProcedureWorker.new, cron: "* * * * *") + Delayed::Job.enqueue(WeeklyOverviewWorker.new, cron: "0 8 * * 0") ## Exécution des tests (RSpec) diff --git a/app/workers/weekly_overview_worker.rb b/app/workers/weekly_overview_worker.rb index 8f15194a7..2d3cf9260 100644 --- a/app/workers/weekly_overview_worker.rb +++ b/app/workers/weekly_overview_worker.rb @@ -1,7 +1,6 @@ class WeeklyOverviewWorker - include Sidekiq::Worker - def perform(*args) + Rails.logger.info("WeeklyOverviewWorker started at #{Time.now}") # Feature flipped to avoid mails in staging due to unprocessed dossier if Features.weekly_overview Gestionnaire.all @@ -9,5 +8,12 @@ class WeeklyOverviewWorker .reject { |_, overview| overview.nil? } .each { |gestionnaire, overview| GestionnaireMailer.last_week_overview(gestionnaire, overview).deliver_now } end + Rails.logger.info("WeeklyOverviewWorker ended at #{Time.now}") end + + def queue_name + "cron" + end + + handle_asynchronously :perform end diff --git a/spec/workers/weekly_overview_worker_spec.rb b/spec/workers/weekly_overview_worker_spec.rb index e2bff3e80..9568e1509 100644 --- a/spec/workers/weekly_overview_worker_spec.rb +++ b/spec/workers/weekly_overview_worker_spec.rb @@ -1,6 +1,9 @@ require 'rails_helper' RSpec.describe WeeklyOverviewWorker, type: :worker do + before { Delayed::Worker.delay_jobs = false } + after { Delayed::Worker.delay_jobs = true } + describe 'perform' do let!(:gestionnaire) { create(:gestionnaire) } let(:overview) { double('overview') } From 7b20395b638d43925ac52e02a2ec8db154219f96 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 26 Sep 2017 15:50:39 +0200 Subject: [PATCH 221/222] Remove sidekiq traces --- Gemfile | 5 ----- Gemfile.lock | 38 +++++++--------------------------- config/deploy.rb | 5 ++--- config/initializers/sidekiq.rb | 6 ------ config/routes.rb | 3 --- config/sidekiq.yml | 7 ------- 6 files changed, 10 insertions(+), 54 deletions(-) delete mode 100644 config/initializers/sidekiq.rb delete mode 100644 config/sidekiq.yml diff --git a/Gemfile b/Gemfile index be12e52ef..a68d6e3f1 100644 --- a/Gemfile +++ b/Gemfile @@ -96,11 +96,6 @@ gem 'newrelic_rpm' gem 'scenic' -# Sidekiq -gem 'sidekiq' -gem 'sidekiq-cron', '~> 0.4.4' -gem 'sinatra', git: 'https://github.com/sinatra/sinatra.git', require: false - # Cron jobs gem 'delayed_job_active_record' gem "daemons" diff --git a/Gemfile.lock b/Gemfile.lock index 950868119..6ce018ead 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,18 +7,6 @@ GIT open4 (~> 1.3.4) rake -GIT - remote: https://github.com/sinatra/sinatra.git - revision: d0c4053fd459be9f2c207cfeec5c0606461c014b - specs: - rack-protection (2.0.0.rc1) - rack - sinatra (2.0.0.rc1) - mustermann (= 1.0.0) - rack (~> 2.0) - rack-protection (= 2.0.0.rc1) - tilt (~> 2.0) - GEM remote: https://rubygems.org/ specs: @@ -121,7 +109,6 @@ GEM execjs coffee-script-source (1.12.2) concurrent-ruby (1.0.5) - connection_pool (2.2.1) copy_carrierwave_file (1.3.0) carrierwave (>= 0.9) crack (0.4.3) @@ -408,7 +395,7 @@ GEM minitest (5.10.1) multi_json (1.12.1) multipart-post (2.0.0) - mustermann (1.0.0) + mustermann (1.0.1) nenv (0.3.0) netrc (0.11.0) newrelic_rpm (3.18.1.330) @@ -468,6 +455,8 @@ GEM httpclient (>= 2.4) multi_json (>= 1.3.6) rack (>= 1.1) + rack-protection (2.0.0) + rack rack-test (0.6.3) rack (>= 1.0) rails (5.0.0.1) @@ -511,8 +500,6 @@ GEM trollop (~> 2.1) rdoc (4.3.0) redis (3.3.3) - redis-namespace (1.5.3) - redis (~> 3.0, >= 3.0.4) ref (2.0.0) request_store (1.3.1) responders (2.3.0) @@ -561,8 +548,6 @@ GEM ruby_parser (3.8.3) sexp_processor (~> 4.1) rubyzip (1.0.0) - rufus-scheduler (3.3.4) - tzinfo safe_yaml (1.0.4) sass (3.4.22) sass-rails (5.0.6) @@ -589,18 +574,14 @@ GEM shellany (0.0.1) shoulda-matchers (3.1.1) activesupport (>= 4.0.0) - sidekiq (4.2.9) - concurrent-ruby (~> 1.0) - connection_pool (~> 2.2, >= 2.2.0) - rack-protection (>= 1.5.0) - redis (~> 3.2, >= 3.2.1) - sidekiq-cron (0.4.5) - redis-namespace (>= 1.5.2) - rufus-scheduler (>= 2.0.24) - sidekiq (>= 4.2.1) simple_form (3.4.0) actionpack (> 4, < 5.1) activemodel (> 4, < 5.1) + sinatra (2.0.0) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.0) + tilt (~> 2.0) slop (3.6.0) smart_listing (1.2.0) coffee-rails @@ -759,10 +740,7 @@ DEPENDENCIES select2-rails sentry-raven shoulda-matchers - sidekiq - sidekiq-cron (~> 0.4.4) simple_form - sinatra! smart_listing spreadsheet_architect spring diff --git a/config/deploy.rb b/config/deploy.rb index c6c264d9c..0a48ab1a3 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -58,7 +58,6 @@ set :shared_paths, [ "config/fog_credentials.yml", 'config/initializers/secret_token.rb', 'config/initializers/features.yml', - 'config/initializers/sidekiq.rb', "config/environments/#{rails_env}.rb", "config/initializers/token.rb", "config/initializers/urls.rb", @@ -131,7 +130,7 @@ desc "Deploys the current version to the server." task :deploy => :environment do queue 'export PATH=$PATH:/usr/local/rbenv/bin:/usr/local/rbenv/shims' deploy do - queue %[sudo stop sidekiq_#{user!} || true] + queue %[sudo stop delayed_job_#{user!} || true] # Put things that will set up an empty directory into a fully set-up # instance of your project. invoke :'git:clone' @@ -142,7 +141,7 @@ task :deploy => :environment do to :launch do queue "/etc/init.d/#{user} upgrade " - queue! %[sudo start sidekiq_#{user!}] + queue! %[sudo start delayed_job_#{user!}] queue "cd #{deploy_to}/#{current_path}/" queue "bundle exec rake db:seed RAILS_ENV=#{rails_env}" diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb deleted file mode 100644 index a61ed5e57..000000000 --- a/config/initializers/sidekiq.rb +++ /dev/null @@ -1,6 +0,0 @@ -Sidekiq.configure_server do |config| - Sidekiq::Logging.logger = Rails.logger - - schedule_file = "config/schedule.yml" - Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file) -end diff --git a/config/routes.rb b/config/routes.rb index aac7387bf..dbaa51e86 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -47,9 +47,6 @@ Rails.application.routes.draw do authenticate :administration do resources :administrations, only: [:index, :create] namespace :administrations do - require 'sidekiq/web' - require 'sidekiq/cron/web' - mount Sidekiq::Web => '/sidekiq' match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post] end end diff --git a/config/sidekiq.yml b/config/sidekiq.yml deleted file mode 100644 index 0fe0c4360..000000000 --- a/config/sidekiq.yml +++ /dev/null @@ -1,7 +0,0 @@ -:concurrency: 5 -staging: - :concurrency: 2 -production: - :concurrency: 2 -:queues: - - default From 1e03f0b4be81d105afb0581a8c5cd8cef0427ce0 Mon Sep 17 00:00:00 2001 From: Simon Lehericey Date: Thu, 28 Sep 2017 10:48:48 +0200 Subject: [PATCH 222/222] Fix mina and delayed_job --- config/deploy.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index 0a48ab1a3..9f7cbbdec 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -130,7 +130,7 @@ desc "Deploys the current version to the server." task :deploy => :environment do queue 'export PATH=$PATH:/usr/local/rbenv/bin:/usr/local/rbenv/shims' deploy do - queue %[sudo stop delayed_job_#{user!} || true] + queue %[sudo service delayed_job_#{user!} stop || true] # Put things that will set up an empty directory into a fully set-up # instance of your project. invoke :'git:clone' @@ -141,7 +141,7 @@ task :deploy => :environment do to :launch do queue "/etc/init.d/#{user} upgrade " - queue! %[sudo start delayed_job_#{user!}] + queue! %[sudo service delayed_job_#{user!} start] queue "cd #{deploy_to}/#{current_path}/" queue "bundle exec rake db:seed RAILS_ENV=#{rails_env}"