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; + } +} 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/assets/stylesheets/new_design/table.scss b/app/assets/stylesheets/new_design/table.scss index 625dcc5b0..43b37eb77 100644 --- a/app/assets/stylesheets/new_design/table.scss +++ b/app/assets/stylesheets/new_design/table.scss @@ -2,27 +2,51 @@ @import "constants"; @import "mixins"; -.table { +.table { // TODO : tester de remplacer par l'élément table uniquement width: 100%; - font-size: 14px; - line-height: 22px; - 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; + } - &.header-section { - color: $blue; - font-weight: bold; - font-size: 20px; + &.hoverable { + tbody tr:hover { + background: $light-grey; } } - td { - font-weight: bold; + &.vertical { + font-size: 14px; + line-height: 22px; + + tr { + border-top: none; + } + + th { + @include vertical-padding($default-spacer); + font-weight: normal; + + &.header-section { + color: $blue; + font-weight: bold; + font-size: 20px; + } + } + + td { + font-weight: bold; + } } } 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 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/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/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 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/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 03912e26f..91a8bb3d0 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -75,6 +75,36 @@ %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 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 %tbody %tr %th Header 1 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