Merge branch 'develop' into staging
This commit is contained in:
commit
a5aecd82ab
9 changed files with 37 additions and 81 deletions
|
@ -27,18 +27,12 @@ class Backoffice::DossiersController < Backoffice::DossiersListController
|
||||||
|
|
||||||
def search
|
def search
|
||||||
@search_terms = params[:q]
|
@search_terms = params[:q]
|
||||||
@dossiers_search, @dossier = Dossier.search(current_gestionnaire, @search_terms)
|
@dossier = Dossier.search(current_gestionnaire, @search_terms)
|
||||||
|
|
||||||
dossiers_list_facade
|
smartlisting_dossier @dossier, 'search'
|
||||||
|
|
||||||
unless @dossiers_search.empty?
|
|
||||||
@dossiers_search = @dossiers_search.paginate(:page => params[:page]).decorate
|
|
||||||
end
|
|
||||||
|
|
||||||
@dossier = @dossier.decorate unless @dossier.nil?
|
|
||||||
|
|
||||||
rescue RuntimeError
|
rescue RuntimeError
|
||||||
@dossiers_search = []
|
smartlisting_dossier [], 'search'
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid
|
def valid
|
||||||
|
|
|
@ -22,9 +22,12 @@ class Backoffice::DossiersListController < ApplicationController
|
||||||
@dossiers_list_facade ||= DossiersListFacades.new current_gestionnaire, liste, retrieve_procedure
|
@dossiers_list_facade ||= DossiersListFacades.new current_gestionnaire, liste, retrieve_procedure
|
||||||
end
|
end
|
||||||
|
|
||||||
def smartlisting_dossier
|
def smartlisting_dossier dossiers_list=nil, liste='a_traiter'
|
||||||
|
dossiers_list_facade liste
|
||||||
|
dossiers_list = dossiers_list_facade.dossiers_to_display if dossiers_list.nil?
|
||||||
|
|
||||||
@dossiers = smart_listing_create :dossiers,
|
@dossiers = smart_listing_create :dossiers,
|
||||||
dossiers_list_facade.dossiers_to_display,
|
dossiers_list,
|
||||||
partial: "backoffice/dossiers/list",
|
partial: "backoffice/dossiers/list",
|
||||||
array: true,
|
array: true,
|
||||||
default_sort: dossiers_list_facade.service.default_sort
|
default_sort: dossiers_list_facade.service.default_sort
|
||||||
|
|
|
@ -79,6 +79,10 @@ class DossiersListFacades
|
||||||
(@liste == 'invite' ? 'active' : '')
|
(@liste == 'invite' ? 'active' : '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def search_class
|
||||||
|
(@liste == 'search' ? 'active' : '')
|
||||||
|
end
|
||||||
|
|
||||||
def brouillon_total
|
def brouillon_total
|
||||||
service.brouillon.count
|
service.brouillon.count
|
||||||
end
|
end
|
||||||
|
|
|
@ -246,7 +246,7 @@ class Dossier < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.search current_gestionnaire, terms
|
def self.search current_gestionnaire, terms
|
||||||
return [], nil if terms.blank?
|
return [] if terms.blank?
|
||||||
|
|
||||||
dossiers = Dossier.arel_table
|
dossiers = Dossier.arel_table
|
||||||
users = User.arel_table
|
users = User.arel_table
|
||||||
|
@ -264,24 +264,16 @@ class Dossier < ActiveRecord::Base
|
||||||
composed_scope = composed_scope.where(
|
composed_scope = composed_scope.where(
|
||||||
users[:email].matches(query_string).or\
|
users[:email].matches(query_string).or\
|
||||||
etablissements[:siret].matches(query_string_start_with).or\
|
etablissements[:siret].matches(query_string_start_with).or\
|
||||||
entreprises[:raison_sociale].matches(query_string))
|
entreprises[:raison_sociale].matches(query_string).or\
|
||||||
|
dossiers[:id].eq(word_is_an_integer word))
|
||||||
end
|
end
|
||||||
|
|
||||||
#TODO refactor
|
|
||||||
composed_scope = composed_scope.where(
|
composed_scope = composed_scope.where(
|
||||||
dossiers[:id].eq_any(current_gestionnaire.dossiers.ids).and\
|
dossiers[:id].eq_any(current_gestionnaire.dossiers.ids).and\
|
||||||
dossiers[:state].does_not_match('draft').and\
|
dossiers[:state].does_not_match('draft').and\
|
||||||
dossiers[:archived].eq(false))
|
dossiers[:archived].eq(false))
|
||||||
|
|
||||||
begin
|
composed_scope
|
||||||
if Float(terms) && terms.to_i <= 2147483647 && current_gestionnaire.dossiers.ids.include?(terms.to_i)
|
|
||||||
dossier = Dossier.where("state != 'draft'").find(terms.to_i)
|
|
||||||
end
|
|
||||||
rescue ArgumentError, ActiveRecord::RecordNotFound
|
|
||||||
dossier = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
return composed_scope, dossier
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cerfa_available?
|
def cerfa_available?
|
||||||
|
@ -328,4 +320,12 @@ class Dossier < ActiveRecord::Base
|
||||||
def invite_by_user? email
|
def invite_by_user? email
|
||||||
(invites_user.pluck :email).include? email
|
(invites_user.pluck :email).include? email
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.word_is_an_integer word
|
||||||
|
return 0 if Float(word) > 2147483647
|
||||||
|
|
||||||
|
Float(word)
|
||||||
|
rescue ArgumentError
|
||||||
|
0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
=@dossiers_list_facade.termine_total
|
=@dossiers_list_facade.termine_total
|
||||||
|
|
||||||
%ul.nav.nav-tabs.navbar-right{style:'border-bottom: none;'}
|
%ul.nav.nav-tabs.navbar-right{style:'border-bottom: none;'}
|
||||||
%li#search{class: "#{'active' unless @dossiers_search.nil?}"}
|
%li#search{ class: (@dossiers_list_facade.search_class) }
|
||||||
%a
|
%a
|
||||||
= form_tag(backoffice_dossiers_search_url, method: :get) do
|
= form_tag(backoffice_dossiers_search_url, method: :get) do
|
||||||
.input-group{style:'width: 300px'}
|
.input-group{style:'width: 300px'}
|
||||||
|
|
|
@ -1,45 +1,4 @@
|
||||||
#backoffice_search
|
#backoffice_search
|
||||||
= render partial: 'onglets'
|
= render partial: 'onglets'
|
||||||
|
|
||||||
- unless @dossier.nil?
|
= smart_listing_render :dossiers
|
||||||
%table.table{style:'background-color: rgba(248, 248, 255, 0.8)'}
|
|
||||||
%tr
|
|
||||||
%th{colspan:2}
|
|
||||||
%h4
|
|
||||||
= "Dossier N°#{@dossier.id}"
|
|
||||||
%tr
|
|
||||||
%td.col-md-1.col-lg-1
|
|
||||||
= @dossier.id
|
|
||||||
%td.col-md-4.col-lg-4
|
|
||||||
= @dossier.procedure.libelle
|
|
||||||
%td.col-md-4.col-lg-4
|
|
||||||
= link_to(@dossier.entreprise.raison_sociale, "/backoffice/dossiers/#{@dossier.id}")
|
|
||||||
%td.col-md-2.col-lg-2
|
|
||||||
= @dossier.user.email
|
|
||||||
%td.col-md-1.col-lg-1{class: @dossier.state_color_class}
|
|
||||||
= @dossier.display_state
|
|
||||||
%br
|
|
||||||
|
|
||||||
- if @dossiers_search.empty? && @dossier.nil?
|
|
||||||
%div{style: 'text-align:center'}
|
|
||||||
%h4 Aucun dossier trouvé
|
|
||||||
|
|
||||||
- elsif !@dossiers_search.empty?
|
|
||||||
%table.table
|
|
||||||
%tr
|
|
||||||
%th.col-md-1.col-lg-1 ID dossier
|
|
||||||
%th.col-md-4.col-lg-4 Procédure
|
|
||||||
%th.col-md-4.col-lg-4 Raison Sociale
|
|
||||||
%th.col-md-2.col-lg-2 Email contact
|
|
||||||
%th.col-md-1.col-lg-1 État
|
|
||||||
|
|
||||||
- @dossiers_search.each do |dossier|
|
|
||||||
%tr
|
|
||||||
%td= dossier.id
|
|
||||||
%td= dossier.procedure.libelle
|
|
||||||
%td= link_to(dossier.entreprise.raison_sociale, "/backoffice/dossiers/#{dossier.id}")
|
|
||||||
%td= dossier.user.email
|
|
||||||
%td{class: dossier.state_color_class}= dossier.display_state
|
|
||||||
|
|
||||||
.pagination
|
|
||||||
= will_paginate @dossiers_search, renderer: BootstrapPagination::Rails
|
|
|
@ -24,7 +24,7 @@ feature 'search file on gestionnaire backoffice' do
|
||||||
it { expect(page).to have_css('#backoffice_search') }
|
it { expect(page).to have_css('#backoffice_search') }
|
||||||
|
|
||||||
context 'when terms input is empty' do
|
context 'when terms input is empty' do
|
||||||
it { expect(page).to have_content('Aucun dossier trouvé') }
|
it { expect(page).to have_content('Aucun dossier') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when terms input is informed' do
|
context 'when terms input is informed' do
|
||||||
|
@ -35,7 +35,7 @@ feature 'search file on gestionnaire backoffice' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when terms input does not return result' do
|
context 'when terms input does not return result' do
|
||||||
it { expect(page).to have_content('Aucun dossier trouvé') }
|
it { expect(page).to have_content('Aucun dossier') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when terms input does return result' do
|
context 'when terms input does return result' do
|
||||||
|
@ -45,12 +45,6 @@ feature 'search file on gestionnaire backoffice' do
|
||||||
let(:terms) { dossier.entreprise.raison_sociale }
|
let(:terms) { dossier.entreprise.raison_sociale }
|
||||||
|
|
||||||
it { expect(page).to have_content(dossier.entreprise.raison_sociale) }
|
it { expect(page).to have_content(dossier.entreprise.raison_sociale) }
|
||||||
|
|
||||||
context "when terms is a file's id" do
|
|
||||||
let(:terms) { dossier.id }
|
|
||||||
|
|
||||||
it { expect(page).to have_content("Dossier N°#{dossier.id}") }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -559,8 +559,8 @@ describe Dossier do
|
||||||
describe '.search' do
|
describe '.search' do
|
||||||
subject { liste_dossiers }
|
subject { liste_dossiers }
|
||||||
|
|
||||||
let(:liste_dossiers) { described_class.search(gestionnaire_1, terms)[0] }
|
let(:liste_dossiers) { described_class.search(gestionnaire_1, terms) }
|
||||||
let(:dossier) { described_class.search(gestionnaire_1, terms)[1] }
|
# let(:dossier) { described_class.search(gestionnaire_1, terms)[1] }
|
||||||
|
|
||||||
let(:administrateur_1) { create(:administrateur) }
|
let(:administrateur_1) { create(:administrateur) }
|
||||||
let(:administrateur_2) { create(:administrateur) }
|
let(:administrateur_2) { create(:administrateur) }
|
||||||
|
@ -596,6 +596,7 @@ describe Dossier do
|
||||||
let(:terms) { 'brouillon' }
|
let(:terms) { 'brouillon' }
|
||||||
|
|
||||||
it { expect(subject.size).to eq(0) }
|
it { expect(subject.size).to eq(0) }
|
||||||
|
it { expect(subject.class).to eq Dossier::ActiveRecord_Relation }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'search on contact email' do
|
describe 'search on contact email' do
|
||||||
|
@ -607,7 +608,7 @@ describe Dossier do
|
||||||
describe 'search on ID dossier' do
|
describe 'search on ID dossier' do
|
||||||
let(:terms) { "#{dossier_2.id}" }
|
let(:terms) { "#{dossier_2.id}" }
|
||||||
|
|
||||||
it { expect(dossier.id).to eq(dossier_2.id) }
|
it { expect(subject.size).to eq(1) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'search on SIRET' do
|
describe 'search on SIRET' do
|
||||||
|
|
|
@ -60,6 +60,7 @@ end
|
||||||
DatabaseCleaner.strategy = :truncation
|
DatabaseCleaner.strategy = :truncation
|
||||||
|
|
||||||
SIADETOKEN = :valid_token unless defined? SIADETOKEN
|
SIADETOKEN = :valid_token unless defined? SIADETOKEN
|
||||||
|
BROWSER.value = Browser.new('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)')
|
||||||
|
|
||||||
include Warden::Test::Helpers
|
include Warden::Test::Helpers
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue