2016-08-01 18:10:32 +02:00
|
|
|
class PreferenceListDossier < ActiveRecord::Base
|
|
|
|
belongs_to :gestionnaire
|
2016-09-08 16:21:54 +02:00
|
|
|
belongs_to :procedure
|
2016-08-01 18:10:32 +02:00
|
|
|
|
|
|
|
def table_attr
|
2016-08-02 14:49:41 +02:00
|
|
|
return self.attr if table.nil? || table.empty?
|
2016-08-01 18:10:32 +02:00
|
|
|
table + '.' + attr
|
|
|
|
end
|
|
|
|
|
2016-10-04 19:19:03 +02:00
|
|
|
def table_with_s_attr
|
2016-10-10 14:56:23 +02:00
|
|
|
return 'dossiers.'+self.attr if table.nil? || table.empty?
|
2016-10-04 19:19:03 +02:00
|
|
|
table + 's' + '.' + attr
|
|
|
|
end
|
|
|
|
|
2016-09-09 15:05:46 +02:00
|
|
|
def self.available_columns_for procedure_id = nil
|
|
|
|
columns = {
|
2016-08-01 18:10:32 +02:00
|
|
|
dossier: columns_dossier,
|
|
|
|
procedure: columns_procedure,
|
|
|
|
entreprise: columns_entreprise,
|
|
|
|
etablissement: columns_etablissement,
|
2016-09-09 15:05:46 +02:00
|
|
|
user: columns_user,
|
|
|
|
france_connect: columns_france_connect
|
2016-08-01 18:10:32 +02:00
|
|
|
}
|
2016-09-09 15:05:46 +02:00
|
|
|
|
|
|
|
columns = columns.merge({
|
|
|
|
champs: columns_champs_procedure(procedure_id)
|
|
|
|
}) unless procedure_id.nil?
|
|
|
|
|
|
|
|
columns
|
2016-08-01 18:10:32 +02:00
|
|
|
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'
|
|
|
|
|
|
|
|
{
|
2016-09-09 15:05:46 +02:00
|
|
|
gender: create_column('Civilité (FC)', table, 'gender', 'gender_fr', 1),
|
|
|
|
given_name: create_column('Prénom (FC)', table, 'given_name', 'given_name', 2),
|
|
|
|
family_name: create_column('Nom (FC)', table, 'family_name', 'family_name', 2)
|
2016-08-01 18:10:32 +02:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2016-09-09 15:05:46 +02:00
|
|
|
def self.columns_champs_procedure procedure_id
|
|
|
|
table = 'champs'
|
|
|
|
|
|
|
|
Procedure.find(procedure_id).types_de_champ.inject({}) do |acc, type_de_champ|
|
|
|
|
acc = acc.merge({
|
|
|
|
"type_de_champ_#{type_de_champ.id}" => create_column(type_de_champ.libelle, table, type_de_champ.id, 'value', 2)
|
|
|
|
}) if type_de_champ.field_for_list?
|
|
|
|
acc
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-01 18:10:32 +02:00
|
|
|
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
|