Add lateral panel to configure dossier list in back office
This commit is contained in:
parent
2d9fd187d9
commit
a37320bae9
29 changed files with 794 additions and 27 deletions
33
app/assets/javascripts/pref_list_dossier.js
Normal file
33
app/assets/javascripts/pref_list_dossier.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
$(document).on('page:load', pref_list_dossier_actions);
|
||||
$(document).ready(pref_list_dossier_actions);
|
||||
|
||||
function pref_list_dossier_actions() {
|
||||
pref_list_dossier_open_action();
|
||||
pref_list_dossier_close_action();
|
||||
}
|
||||
|
||||
function pref_list_dossier_open_action() {
|
||||
$("#pref_list_dossier_open_action").on('click', function () {
|
||||
$("#pref_list_menu").css('display', 'block');
|
||||
$("#pref_list_menu").css('visibility', 'visible');
|
||||
|
||||
$("#pref_list_menu").animate({
|
||||
right: 0
|
||||
}, 250);
|
||||
});
|
||||
}
|
||||
|
||||
function pref_list_dossier_close_action() {
|
||||
$("#pref_list_dossier_close_action").on('click', function () {
|
||||
$("#pref_list_menu").animate({
|
||||
right: parseInt($("#pref_list_menu").css('width'), 10)*(-1)+'px'
|
||||
},{
|
||||
duration: 250,
|
||||
complete: function () {
|
||||
$("#pref_list_menu").css('display', 'none');
|
||||
$("#pref_list_menu").css('visibility', 'hidden');
|
||||
}
|
||||
}
|
||||
)
|
||||
});
|
||||
}
|
|
@ -6,6 +6,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
#backoffice_index, #backoffice_search {
|
||||
margin-left: -7rem;
|
||||
margin-right: -7rem;
|
||||
}
|
||||
|
||||
#pref_list{
|
||||
.dropdown-menu {
|
||||
padding: 10px;
|
||||
width: 500px;
|
||||
}
|
||||
}
|
||||
|
||||
#onglets {
|
||||
ul {
|
||||
li, li.active {
|
||||
|
|
20
app/assets/stylesheets/pref_list_menu.scss
Normal file
20
app/assets/stylesheets/pref_list_menu.scss
Normal file
|
@ -0,0 +1,20 @@
|
|||
#pref_list_menu{
|
||||
z-index: 100;
|
||||
display: none;
|
||||
position: fixed;
|
||||
visibility: hidden;
|
||||
top: 10px;
|
||||
right: -470px;
|
||||
background-color: rgba(255, 255, 255, 0.95);
|
||||
border-left: solid 1px lightgrey;
|
||||
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
|
||||
width: 470px;
|
||||
height: calc(100% - 25px);
|
||||
padding: 15px;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
.open_pref_list {
|
||||
right: 0 !important;
|
||||
display: block !important;
|
||||
}
|
|
@ -7,10 +7,7 @@ class Backoffice::DossiersController < ApplicationController
|
|||
def index
|
||||
@liste = params[:liste] || 'a_traiter'
|
||||
|
||||
@dossiers = smart_listing_create :dossiers,
|
||||
dossiers_to_display,
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true
|
||||
smartlisting_dossier
|
||||
|
||||
total_dossiers_per_state
|
||||
end
|
||||
|
@ -61,8 +58,26 @@ class Backoffice::DossiersController < ApplicationController
|
|||
redirect_to request.referer
|
||||
end
|
||||
|
||||
def reload_smartlisting
|
||||
begin
|
||||
@liste = URI(request.referer).query.split('=').second
|
||||
rescue NoMethodError
|
||||
@liste = 'a_traiter'
|
||||
end
|
||||
smartlisting_dossier
|
||||
|
||||
render 'backoffice/dossiers/index', formats: :js
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def smartlisting_dossier
|
||||
@dossiers = smart_listing_create :dossiers,
|
||||
dossiers_to_display,
|
||||
partial: "backoffice/dossiers/list",
|
||||
array: true
|
||||
end
|
||||
|
||||
def dossiers_to_display
|
||||
{'a_traiter' => waiting_for_gestionnaire,
|
||||
'en_attente' => waiting_for_user,
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
class Backoffice::PreferenceListDossierController < ApplicationController
|
||||
include SmartListing::Helper::ControllerExtensions
|
||||
helper SmartListing::Helper
|
||||
|
||||
before_action :authenticate_gestionnaire!
|
||||
|
||||
def add
|
||||
PreferenceListDossier.create(
|
||||
libelle: params[:libelle],
|
||||
table: params[:table],
|
||||
attr: params[:attr],
|
||||
attr_decorate: params[:attr_decorate],
|
||||
bootstrap_lg: params[:bootstrap_lg],
|
||||
order: nil,
|
||||
filter: nil,
|
||||
gestionnaire: current_gestionnaire
|
||||
)
|
||||
|
||||
render partial: 'backoffice/dossiers/pref_list', formats: :js
|
||||
end
|
||||
|
||||
def reload_pref_list
|
||||
render partial: 'backoffice/dossiers/pref_list'
|
||||
end
|
||||
|
||||
def delete
|
||||
PreferenceListDossier.delete(params[:pref_id])
|
||||
|
||||
render partial: 'backoffice/dossiers/pref_list', formats: :js
|
||||
end
|
||||
end
|
|
@ -8,6 +8,10 @@ class DossierDecorator < Draper::Decorator
|
|||
'dd/mm/YYYY'
|
||||
end
|
||||
|
||||
def first_creation
|
||||
created_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||
end
|
||||
|
||||
def last_update
|
||||
updated_at.localtime.strftime('%d/%m/%Y %H:%M')
|
||||
end
|
||||
|
|
4
app/decorators/etablissement_decorator.rb
Normal file
4
app/decorators/etablissement_decorator.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class EtablissementDecorator < Draper::Decorator
|
||||
delegate_all
|
||||
|
||||
end
|
4
app/decorators/france_connect_information_decorator.rb
Normal file
4
app/decorators/france_connect_information_decorator.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class FranceConnectInformationDecorator < Draper::Decorator
|
||||
delegate_all
|
||||
|
||||
end
|
|
@ -4,7 +4,7 @@ class NewAdminMailer < ApplicationMailer
|
|||
@admin = admin
|
||||
@password = password
|
||||
|
||||
mail(from: "tech@apientreprise.fr", to: 'tech@apientreprise.fr',
|
||||
mail(from: "tps@apientreprise.fr", to: 'tech@apientreprise.fr',
|
||||
subject: "Création d'un compte Admin TPS")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,6 +27,7 @@ class Dossier < ActiveRecord::Base
|
|||
delegate :siret, to: :etablissement, allow_nil: true
|
||||
delegate :types_de_piece_justificative, to: :procedure
|
||||
delegate :types_de_champ, to: :procedure
|
||||
delegate :france_connect_information, to: :user
|
||||
|
||||
after_save :build_default_champs, if: Proc.new { procedure_id_changed? }
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ class Gestionnaire < ActiveRecord::Base
|
|||
has_many :procedures, through: :assign_to
|
||||
has_many :dossiers, through: :procedures
|
||||
has_many :follows
|
||||
has_many :preference_list_dossiers
|
||||
|
||||
def dossiers_filter
|
||||
dossiers.where(procedure_id: procedure_filter_list)
|
||||
|
|
94
app/models/preference_list_dossier.rb
Normal file
94
app/models/preference_list_dossier.rb
Normal file
|
@ -0,0 +1,94 @@
|
|||
class PreferenceListDossier < ActiveRecord::Base
|
||||
belongs_to :gestionnaire
|
||||
|
||||
def table_attr
|
||||
return self.attr if table.empty?
|
||||
table + '.' + attr
|
||||
end
|
||||
|
||||
def self.available_columns
|
||||
{
|
||||
dossier: columns_dossier,
|
||||
procedure: columns_procedure,
|
||||
entreprise: columns_entreprise,
|
||||
etablissement: columns_etablissement,
|
||||
user: columns_user
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.columns_dossier
|
||||
table = nil
|
||||
|
||||
{
|
||||
dossier_id: create_column('ID', table, 'id', 'id', 1),
|
||||
created_at: create_column('Créé le', table, 'created_at', 'first_creation', 2),
|
||||
updated_at: create_column('Mise à jour le', table, 'updated_at', 'last_update', 2),
|
||||
state: create_column('Statut', table, 'state', 'display_state', 1)
|
||||
}
|
||||
end
|
||||
|
||||
def self.columns_procedure
|
||||
table = 'procedure'
|
||||
|
||||
{
|
||||
libelle: create_column('Libellé procédure', table, 'libelle', 'libelle', 4),
|
||||
organisation: create_column('Organisation', table, 'organisation', 'organisation', 3),
|
||||
direction: create_column('Direction', table, 'direction', 'direction', 3)
|
||||
}
|
||||
end
|
||||
|
||||
def self.columns_entreprise
|
||||
table = 'entreprise'
|
||||
|
||||
{
|
||||
siren: create_column('SIREN', table, 'siren', 'siren', 2),
|
||||
forme_juridique: create_column('Forme juridique', table, 'forme_juridique', 'forme_juridique', 3),
|
||||
nom_commercial: create_column('Nom commercial', table, 'nom_commercial', 'nom_commercial', 3),
|
||||
raison_sociale: create_column('Raison sociale', table, 'raison_sociale', 'raison_sociale', 3),
|
||||
siret_siege_social: create_column('SIRET siège social', table, 'siret_siege_social', 'siret_siege_social', 2),
|
||||
date_creation: create_column('Date de création', table, 'date_creation', 'date_creation', 2),
|
||||
}
|
||||
end
|
||||
|
||||
def self.columns_etablissement
|
||||
table = 'etablissement'
|
||||
|
||||
{
|
||||
siret: create_column('SIRET', table, 'siret', 'siret', 2),
|
||||
libelle: create_column('Nom établissement', table, 'libelle_naf', 'libelle_naf', 3),
|
||||
code_postal: create_column('Code postal', table, 'code_postal', 'code_postal', 1)
|
||||
}
|
||||
end
|
||||
|
||||
def self.columns_user
|
||||
table = 'user'
|
||||
|
||||
{
|
||||
email: create_column('Email', table, 'email', 'email', 2)
|
||||
}
|
||||
end
|
||||
|
||||
def self.columns_france_connect
|
||||
table = 'france_connect_information'
|
||||
|
||||
{
|
||||
gender: create_column('Civilité', table, 'gender', 'gender', 1),
|
||||
given_name: create_column('Prénom', table, 'given_name', 'given_name', 2),
|
||||
family_name: create_column('Nom', table, 'family_name', 'family_name', 2)
|
||||
}
|
||||
end
|
||||
|
||||
def self.create_column libelle, table, attr, attr_decorate, bootstrap_lg
|
||||
{
|
||||
libelle: libelle,
|
||||
table: table,
|
||||
attr: attr,
|
||||
attr_decorate: attr_decorate,
|
||||
bootstrap_lg: bootstrap_lg,
|
||||
order: nil,
|
||||
filter: nil
|
||||
}
|
||||
end
|
||||
end
|
|
@ -1,21 +1,25 @@
|
|||
- unless smart_listing.empty?
|
||||
%table.table
|
||||
%thead
|
||||
%th= smart_listing.sortable 'Procédure', 'procedure.libelle'
|
||||
%th= smart_listing.sortable 'Raison sociale', 'entreprise.raison_sociale'
|
||||
%th= smart_listing.sortable 'État', 'state'
|
||||
%th= smart_listing.sortable 'Date de mise à jour', 'updated_at'
|
||||
%th.center Actions
|
||||
%th.center Abonnés
|
||||
- current_gestionnaire.preference_list_dossiers.order(:id).each do |preference|
|
||||
%th{class: "col-md-#{preference.bootstrap_lg} col-lg-#{preference.bootstrap_lg}"}= smart_listing.sortable preference.libelle, preference.table_attr
|
||||
%th.col-md-1.col-lg-1.center Actions
|
||||
%th.col-md-1.col-lg-1.center Abonnés
|
||||
|
||||
- @dossiers.each do |dossier|
|
||||
- dossier = dossier.decorate
|
||||
%tr
|
||||
%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= dossier.display_state
|
||||
%td= dossier.last_update
|
||||
- current_gestionnaire.preference_list_dossiers.order(:id).each_with_index do |preference, index|
|
||||
%td
|
||||
- if preference.table.empty?
|
||||
- value = dossier.decorate.public_send(preference.attr_decorate)
|
||||
- else
|
||||
- value = dossier.public_send(preference.table).decorate.public_send(preference.attr_decorate)
|
||||
|
||||
- if index == 0
|
||||
= link_to value, backoffice_dossier_path(id: dossier.id)
|
||||
- else
|
||||
= value
|
||||
|
||||
%td.center
|
||||
- if current_gestionnaire.follow?(dossier.id)
|
||||
= link_to('Quitter'.html_safe, backoffice_dossier_follow_path(dossier_id: dossier.id), 'data-method' => :put, class: 'btn-sm btn-danger', id: "suivre_dossier_#{dossier.id}")
|
||||
|
@ -26,6 +30,7 @@
|
|||
|
||||
= smart_listing.paginate
|
||||
= smart_listing.pagination_per_page_links
|
||||
|
||||
- else
|
||||
%h4.center
|
||||
Aucun dossier
|
||||
Aucun dossier
|
|
@ -31,12 +31,20 @@
|
|||
.badge.progress-bar-success
|
||||
=@dossiers_termine_total
|
||||
|
||||
%li#search{class: "#{'active' unless @dossiers_search.nil?}", style:'float:right'}
|
||||
%a
|
||||
= form_tag(backoffice_dossiers_search_url, method: :get) do
|
||||
.input-group{style:'width: 300px'}
|
||||
= text_field_tag('q', "#{@search_terms unless @search_terms.nil? }", id: 'q', placeholder: "Rechercher un dossier ...", class:'form-control')
|
||||
%span.input-group-btn
|
||||
%button.btn.btn-default{ id:'search_button' }
|
||||
%i.fa.fa-search
|
||||
%ul.nav.nav-tabs.navbar-right{style:'border-bottom: none;'}
|
||||
%li#search{class: "#{'active' unless @dossiers_search.nil?}"}
|
||||
%a
|
||||
= form_tag(backoffice_dossiers_search_url, method: :get) do
|
||||
.input-group{style:'width: 300px'}
|
||||
= text_field_tag('q', "#{@search_terms unless @search_terms.nil? }", id: 'q', placeholder: "Rechercher un dossier ...", class:'form-control')
|
||||
%span.input-group-btn
|
||||
%button.btn.btn-default{ id:'search_button' }
|
||||
%i.fa.fa-search
|
||||
|
||||
- if @dossiers_search.nil?
|
||||
%li#pref_list
|
||||
%a.btn#pref_list_dossier_open_action{href: '#'}
|
||||
%i.fa.fa-columns
|
||||
|
||||
|
||||
%br
|
43
app/views/backoffice/dossiers/_pref_list.html.haml
Normal file
43
app/views/backoffice/dossiers/_pref_list.html.haml
Normal file
|
@ -0,0 +1,43 @@
|
|||
%button#pref_list_dossier_close_action.btn.btn-danger.btn-xs{style:'float:right'}
|
||||
%i.fa.fa-close
|
||||
%h3 Gestion de colonnes affichées
|
||||
|
||||
%p{style:'margin-top: 15px; margin-bottom: 20px'}
|
||||
Ce menu vous permet de choisir les différentes colonnes que vous souhaitez voir apparaitrent dans votre interface de suivi des dossiers.
|
||||
|
||||
%h4.text-primary
|
||||
Actuelles
|
||||
|
||||
%ul
|
||||
- current_gestionnaire.preference_list_dossiers.order(:id).each_with_index do |preference, index|
|
||||
%li
|
||||
= form_tag backoffice_preference_list_dossier_delete_path, method: :delete, remote: true do
|
||||
= hidden_field_tag :pref_id, preference.id
|
||||
= preference.libelle
|
||||
%button.btn.btn-default.btn-xs{type: :submit, id: "delete_pref_list_#{preference[:table]}_#{preference[:attr]}"}
|
||||
%i.fa.fa-minus
|
||||
|
||||
%h4.text-success{style:'margin-top: 15px'}
|
||||
Disponibles
|
||||
|
||||
%table
|
||||
- PreferenceListDossier.available_columns.each_with_index do |tables, index|
|
||||
- if index%2 == 0
|
||||
%tr
|
||||
|
||||
%td.col-sm-5.col-md-5.col-lg-5{style: 'vertical-align: top'}
|
||||
%h5= tables.first.to_s.gsub('_', ' ').capitalize
|
||||
%ul
|
||||
- tables.second.each do |columns|
|
||||
%li
|
||||
= form_tag backoffice_preference_list_dossier_add_path, method: :post, remote: true do
|
||||
= hidden_field_tag :libelle, columns.second[:libelle]
|
||||
= hidden_field_tag :table, columns.second[:table]
|
||||
= hidden_field_tag :attr, columns.second[:attr]
|
||||
= hidden_field_tag :attr_decorate, columns.second[:attr_decorate]
|
||||
= hidden_field_tag :bootstrap_lg, columns.second[:bootstrap_lg]
|
||||
|
||||
= columns.second[:libelle]
|
||||
%button.btn.btn-default.btn-xs{type: :submit, id: "add_pref_list_#{columns.second[:table]}_#{columns.second[:attr]}"}
|
||||
%i.fa.fa-plus
|
||||
|
14
app/views/backoffice/dossiers/_pref_list.js.erb
Normal file
14
app/views/backoffice/dossiers/_pref_list.js.erb
Normal file
|
@ -0,0 +1,14 @@
|
|||
$.ajax({
|
||||
method: 'get',
|
||||
url: '/backoffice/preference_list_dossier/reload_smartlisting',
|
||||
async: true
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
methd: 'get',
|
||||
url: '/backoffice/preference_list_dossier/reload_pref_list',
|
||||
async: true
|
||||
}).done(function (data) {
|
||||
$("#pref_list_menu").html(data);
|
||||
pref_list_dossier_actions();
|
||||
});
|
|
@ -1,4 +1,6 @@
|
|||
#backoffice_index
|
||||
#pref_list_menu
|
||||
= render partial: 'pref_list'
|
||||
= render partial: 'onglets'
|
||||
|
||||
= smart_listing_render :dossiers
|
||||
|
|
|
@ -7,9 +7,15 @@
|
|||
|
||||
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
||||
= stylesheet_link_tag 'application_split2', media: 'all', 'data-turbolinks-track' => true
|
||||
|
||||
|
||||
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
||||
= csrf_meta_tags
|
||||
%body
|
||||
- if Rails.env == 'test'
|
||||
%script{type: 'text/javascript'}
|
||||
(typeof jQuery !== 'undefined') && (jQuery.fx.off = true);
|
||||
|
||||
%div#wrap
|
||||
%div#header.navbar
|
||||
=render partial: "layouts/navbar"
|
||||
|
|
|
@ -139,6 +139,14 @@ Rails.application.routes.draw do
|
|||
patch 'filtres/update' => 'procedure_filter#update'
|
||||
|
||||
|
||||
namespace :preference_list_dossier do
|
||||
post 'add'
|
||||
delete 'delete'
|
||||
|
||||
get 'reload_smartlisting' => '/backoffice/dossiers#reload_smartlisting'
|
||||
get 'reload_pref_list'
|
||||
end
|
||||
|
||||
resources :dossiers do
|
||||
post 'valid' => 'dossiers#valid'
|
||||
post 'close' => 'dossiers#close'
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class AddPreferenceListDossierTable < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :preference_list_dossiers do |t|
|
||||
t.string :libelle
|
||||
t.string :table
|
||||
t.string :attr
|
||||
t.string :attr_decorate
|
||||
t.string :bootstrap_lg
|
||||
t.string :order
|
||||
t.string :filter
|
||||
end
|
||||
|
||||
add_belongs_to :preference_list_dossiers, :gestionnaire
|
||||
end
|
||||
end
|
13
db/schema.rb
13
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160718124741) do
|
||||
ActiveRecord::Schema.define(version: 20160722135927) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -234,6 +234,17 @@ ActiveRecord::Schema.define(version: 20160718124741) do
|
|||
|
||||
add_index "pieces_justificatives", ["type_de_piece_justificative_id"], name: "index_pieces_justificatives_on_type_de_piece_justificative_id", using: :btree
|
||||
|
||||
create_table "preference_list_dossiers", force: :cascade do |t|
|
||||
t.string "libelle"
|
||||
t.string "table"
|
||||
t.string "attr"
|
||||
t.string "attr_decorate"
|
||||
t.string "bootstrap_lg"
|
||||
t.string "order"
|
||||
t.string "filter"
|
||||
t.integer "gestionnaire_id"
|
||||
end
|
||||
|
||||
create_table "procedure_paths", force: :cascade do |t|
|
||||
t.string "path", limit: 30
|
||||
t.integer "procedure_id"
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Backoffice::PreferenceListDossierController, type: :controller do
|
||||
let(:gestionnaire) { create :gestionnaire }
|
||||
let(:libelle) { 'Plop' }
|
||||
let(:table) { 'plip' }
|
||||
let(:attr) { 'plap' }
|
||||
let(:attr_decorate) { 'plup' }
|
||||
let(:bootstrap_lg) { 'plyp' }
|
||||
|
||||
before do
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
||||
describe '#POST add' do
|
||||
subject { post :add, libelle: libelle,
|
||||
table: table,
|
||||
attr: attr,
|
||||
attr_decorate: attr_decorate,
|
||||
bootstrap_lg: bootstrap_lg }
|
||||
|
||||
it { expect(subject.status).to eq 200 }
|
||||
it { expect { subject }.to change(PreferenceListDossier, :count).by(1) }
|
||||
|
||||
describe 'attributs' do
|
||||
let(:last) { PreferenceListDossier.last }
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(last.libelle).to eq libelle }
|
||||
it { expect(last.table).to eq table }
|
||||
it { expect(last.attr).to eq attr }
|
||||
it { expect(last.attr_decorate).to eq attr_decorate }
|
||||
it { expect(last.bootstrap_lg).to eq bootstrap_lg }
|
||||
it { expect(last.order).to be_nil }
|
||||
it { expect(last.filter).to be_nil }
|
||||
it { expect(last.gestionnaire).to eq gestionnaire }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#DELETE delete' do
|
||||
let!(:pref) { create :preference_list_dossier }
|
||||
|
||||
subject { delete :delete, pref_id: pref.id }
|
||||
|
||||
it { expect(subject.status).to eq 200 }
|
||||
it { expect { subject }.to change(PreferenceListDossier, :count).by(-1) }
|
||||
end
|
||||
end
|
11
spec/factories/preference_list_dossier.rb
Normal file
11
spec/factories/preference_list_dossier.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
FactoryGirl.define do
|
||||
factory :preference_list_dossier do
|
||||
libelle 'Procedure'
|
||||
table 'procedure'
|
||||
attr 'libelle'
|
||||
attr_decorate 'libelle'
|
||||
order nil
|
||||
filter nil
|
||||
bootstrap_lg 1
|
||||
end
|
||||
end
|
|
@ -0,0 +1,86 @@
|
|||
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) }
|
||||
|
||||
before do
|
||||
create(:dossier, :with_entreprise, procedure: procedure, state: 'initiated')
|
||||
create :assign_to, procedure: procedure, gestionnaire: gestionnaire
|
||||
visit backoffice_path
|
||||
end
|
||||
|
||||
scenario 'he is redirected to /gestionnaires/sign_id' do
|
||||
expect(page).to have_css('#gestionnaire_login')
|
||||
end
|
||||
|
||||
context 'when user enter good credentials' do
|
||||
before do
|
||||
page.find_by_id(:gestionnaire_email).set gestionnaire.email
|
||||
page.find_by_id(:gestionnaire_password).set gestionnaire.password
|
||||
page.click_on 'Se connecter'
|
||||
end
|
||||
|
||||
scenario 'he is redirected to /backoffice' do
|
||||
expect(page).to have_css('#backoffice_index')
|
||||
end
|
||||
|
||||
scenario 'lateral panel is masked' do
|
||||
expect(page).to have_css('#pref_list_menu', visible: false)
|
||||
end
|
||||
|
||||
context 'when on click on pref list button' do
|
||||
before do
|
||||
page.click_on 'pref_list_dossier_open_action'
|
||||
end
|
||||
|
||||
scenario 'lateral panel is appeared' do
|
||||
expect(page).to have_css('#pref_list_menu')
|
||||
end
|
||||
|
||||
context 'when on click on add attribut button' do
|
||||
before do
|
||||
page.click_on 'add_pref_list_entreprise_siren'
|
||||
end
|
||||
|
||||
scenario 'preference list panel is brought up to date' do
|
||||
wait_for_ajax
|
||||
expect(page).to have_css('#delete_pref_list_entreprise_siren')
|
||||
end
|
||||
|
||||
scenario 'dossier is brought up to date' do
|
||||
wait_for_ajax
|
||||
expect(page).to have_selector("a.sortable[data-attr='entreprise.siren']")
|
||||
end
|
||||
|
||||
context 'when on click on delete attribut button' do
|
||||
before do
|
||||
page.click_on 'delete_pref_list_entreprise_siren'
|
||||
end
|
||||
|
||||
scenario 'preference list panel is brought up to date' do
|
||||
wait_for_ajax
|
||||
expect(page).not_to have_css('#delete_pref_list_entreprise_siren')
|
||||
end
|
||||
|
||||
scenario 'dossier is brought up to date' do
|
||||
wait_for_ajax
|
||||
expect(page).not_to have_selector("a.sortable[data-attr='entreprise.siren']")
|
||||
end
|
||||
|
||||
context 'when on click on close pref list button' do
|
||||
before do
|
||||
page.click_on 'pref_list_dossier_close_action'
|
||||
end
|
||||
|
||||
scenario 'lateral panel is masked' do
|
||||
expect(page).to have_css('#pref_list_menu', visible: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -9,6 +9,13 @@ feature 'on backoffice page' do
|
|||
|
||||
before do
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: 'entreprise',
|
||||
attr: 'raison_sociale',
|
||||
attr_decorate: 'raison_sociale'
|
||||
|
||||
visit backoffice_path
|
||||
end
|
||||
|
||||
|
@ -17,6 +24,8 @@ feature 'on backoffice page' do
|
|||
page.find_by_id(:gestionnaire_email).set gestionnaire.email
|
||||
page.find_by_id(:gestionnaire_password).set gestionnaire.password
|
||||
page.click_on 'Se connecter'
|
||||
|
||||
|
||||
end
|
||||
context 'when he click on first dossier' do
|
||||
before do
|
||||
|
|
|
@ -33,6 +33,7 @@ describe Dossier do
|
|||
it { is_expected.to delegate_method(:siret).to(:etablissement) }
|
||||
it { is_expected.to delegate_method(:types_de_piece_justificative).to(:procedure) }
|
||||
it { is_expected.to delegate_method(:types_de_champ).to(:procedure) }
|
||||
it { is_expected.to delegate_method(:france_connect_information).to(:user) }
|
||||
end
|
||||
|
||||
describe 'methods' do
|
||||
|
|
|
@ -32,6 +32,7 @@ describe Gestionnaire, type: :model do
|
|||
it { is_expected.to have_many(:procedures) }
|
||||
it { is_expected.to have_many(:dossiers) }
|
||||
it { is_expected.to have_many(:follows) }
|
||||
it { is_expected.to have_many(:preference_list_dossiers) }
|
||||
end
|
||||
|
||||
describe '#dossiers_filter' do
|
||||
|
|
253
spec/models/preference_list_dossier_spec.rb
Normal file
253
spec/models/preference_list_dossier_spec.rb
Normal file
|
@ -0,0 +1,253 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe PreferenceListDossier do
|
||||
it { is_expected.to have_db_column(:libelle) }
|
||||
it { is_expected.to have_db_column(:table) }
|
||||
it { is_expected.to have_db_column(:attr) }
|
||||
it { is_expected.to have_db_column(:attr_decorate) }
|
||||
it { is_expected.to have_db_column(:bootstrap_lg) }
|
||||
it { is_expected.to have_db_column(:order) }
|
||||
it { is_expected.to have_db_column(:filter) }
|
||||
it { is_expected.to have_db_column(:gestionnaire_id) }
|
||||
|
||||
it { is_expected.to belong_to(:gestionnaire) }
|
||||
|
||||
describe '.available_columns' do
|
||||
subject { PreferenceListDossier.available_columns }
|
||||
|
||||
describe 'dossier' do
|
||||
subject { super()[:dossier] }
|
||||
|
||||
it { expect(subject.size).to eq 4 }
|
||||
|
||||
describe 'dossier_id' do
|
||||
subject { super()[:dossier_id] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'ID' }
|
||||
it { expect(subject[:table]).to be_nil }
|
||||
it { expect(subject[:attr]).to eq 'id' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'id' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 1 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'created_at' do
|
||||
subject { super()[:created_at] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Créé le' }
|
||||
it { expect(subject[:table]).to be_nil }
|
||||
it { expect(subject[:attr]).to eq 'created_at' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'first_creation' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'updated_at' do
|
||||
subject { super()[:updated_at] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Mise à jour le' }
|
||||
it { expect(subject[:table]).to be_nil }
|
||||
it { expect(subject[:attr]).to eq 'updated_at' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'last_update' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'state' do
|
||||
subject { super()[:state] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Statut' }
|
||||
it { expect(subject[:table]).to be_nil }
|
||||
it { expect(subject[:attr]).to eq 'state' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'display_state' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 1 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'procedure' do
|
||||
subject { super()[:procedure] }
|
||||
|
||||
it { expect(subject.size).to eq 3 }
|
||||
|
||||
describe 'libelle' do
|
||||
subject { super()[:libelle] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Libellé procédure' }
|
||||
it { expect(subject[:table]).to eq 'procedure' }
|
||||
it { expect(subject[:attr]).to eq 'libelle' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'libelle' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 4 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'organisation' do
|
||||
subject { super()[:organisation] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Organisation' }
|
||||
it { expect(subject[:table]).to eq 'procedure' }
|
||||
it { expect(subject[:attr]).to eq 'organisation' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'organisation' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'direction' do
|
||||
subject { super()[:direction] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Direction' }
|
||||
it { expect(subject[:table]).to eq 'procedure' }
|
||||
it { expect(subject[:attr]).to eq 'direction' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'direction' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'entreprise' do
|
||||
subject { super()[:entreprise] }
|
||||
|
||||
it { expect(subject.size).to eq 6 }
|
||||
|
||||
describe 'siren' do
|
||||
subject { super()[:siren] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'SIREN' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'siren' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'siren' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'forme_juridique' do
|
||||
subject { super()[:forme_juridique] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Forme juridique' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'forme_juridique' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'forme_juridique' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'nom_commercial' do
|
||||
subject { super()[:nom_commercial] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Nom commercial' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'nom_commercial' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'nom_commercial' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'raison_sociale' do
|
||||
subject { super()[:raison_sociale] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Raison sociale' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'raison_sociale' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'raison_sociale' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'siret_siege_social' do
|
||||
subject { super()[:siret_siege_social] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'SIRET siège social' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'siret_siege_social' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'siret_siege_social' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'date_creation' do
|
||||
subject { super()[:date_creation] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Date de création' }
|
||||
it { expect(subject[:table]).to eq 'entreprise' }
|
||||
it { expect(subject[:attr]).to eq 'date_creation' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'date_creation' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'etablissement' do
|
||||
subject { super()[:etablissement] }
|
||||
|
||||
it { expect(subject.size).to eq 3 }
|
||||
|
||||
describe 'siret' do
|
||||
subject { super()[:siret] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'SIRET' }
|
||||
it { expect(subject[:table]).to eq 'etablissement' }
|
||||
it { expect(subject[:attr]).to eq 'siret' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'siret' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'libelle' do
|
||||
subject { super()[:libelle] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Nom établissement' }
|
||||
it { expect(subject[:table]).to eq 'etablissement' }
|
||||
it { expect(subject[:attr]).to eq 'libelle_naf' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'libelle_naf' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 3 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
|
||||
describe 'code_postal' do
|
||||
subject { super()[:code_postal] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Code postal' }
|
||||
it { expect(subject[:table]).to eq 'etablissement' }
|
||||
it { expect(subject[:attr]).to eq 'code_postal' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'code_postal' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 1 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'user' do
|
||||
subject { super()[:user] }
|
||||
|
||||
it { expect(subject.size).to eq 1 }
|
||||
|
||||
describe 'email' do
|
||||
subject { super()[:email] }
|
||||
|
||||
it { expect(subject[:libelle]).to eq 'Email' }
|
||||
it { expect(subject[:table]).to eq 'user' }
|
||||
it { expect(subject[:attr]).to eq 'email' }
|
||||
it { expect(subject[:attr_decorate]).to eq 'email' }
|
||||
it { expect(subject[:bootstrap_lg]).to eq 2 }
|
||||
it { expect(subject[:order]).to be_nil }
|
||||
it { expect(subject[:filter]).to be_nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -15,6 +15,30 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
|
|||
decorate_dossier_closed.entreprise.update_column(:raison_sociale, 'plip')
|
||||
decorate_dossier_replied.entreprise.update_column(:raison_sociale, 'plop')
|
||||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: '',
|
||||
attr: 'state',
|
||||
attr_decorate: 'display_state'
|
||||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: 'procedure',
|
||||
attr: 'libelle',
|
||||
attr_decorate: 'libelle'
|
||||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: 'entreprise',
|
||||
attr: 'raison_sociale',
|
||||
attr_decorate: 'raison_sociale'
|
||||
|
||||
create :preference_list_dossier,
|
||||
gestionnaire: gestionnaire,
|
||||
table: '',
|
||||
attr: 'last_update',
|
||||
attr_decorate: 'last_update'
|
||||
|
||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
||||
sign_in gestionnaire
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue