Merge pull request #637 from sgmap/search_on_new_design
Search on new design
This commit is contained in:
commit
3d3a7ce3e2
16 changed files with 216 additions and 99 deletions
33
app/assets/stylesheets/new_design/dossiers_table.scss
Normal file
33
app/assets/stylesheets/new_design/dossiers_table.scss
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
module NewGestionnaire
|
||||
class GestionnaireController < ApplicationController
|
||||
layout "new_application"
|
||||
|
||||
before_action :authenticate_gestionnaire!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
module NewGestionnaire
|
||||
class ProceduresController < GestionnaireController
|
||||
layout "new_application"
|
||||
|
||||
before_action :ensure_ownership!, except: [:index]
|
||||
|
||||
def index
|
||||
|
|
23
app/controllers/new_gestionnaire/recherches_controller.rb
Normal file
23
app/controllers/new_gestionnaire/recherches_controller.rb
Normal file
|
@ -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
|
|
@ -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"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
%table.table
|
||||
%table.table.vertical
|
||||
%tbody
|
||||
- champs.each do |c|
|
||||
%tr
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
- etablissement = entreprise.etablissement
|
||||
%h4= entreprise.raison_sociale_or_name
|
||||
|
||||
%table.table
|
||||
%table.table.vertical
|
||||
%tbody
|
||||
%tr
|
||||
%th SIRET :
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
%table.table
|
||||
%table.table.vertical
|
||||
%tbody
|
||||
%tr
|
||||
%th Civilité :
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
.card.featured
|
||||
.card-title Pièces jointes
|
||||
|
||||
%table.table
|
||||
%table.table.vertical
|
||||
%tbody
|
||||
- if @dossier.procedure.cerfa_flag?
|
||||
%tr
|
||||
|
|
|
@ -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
|
||||
|
|
27
app/views/new_gestionnaire/recherches/index.html.haml
Normal file
27
app/views/new_gestionnaire/recherches/index.html.haml
Normal file
|
@ -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é
|
|
@ -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
|
||||
|
|
|
@ -258,6 +258,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
end
|
||||
get "recherche" => "recherches#index"
|
||||
end
|
||||
|
||||
apipie
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue