Merge pull request #7162 from tchak/feat-i18n-procedure-presentation
i18n(procedure_presentation): translate fields
This commit is contained in:
commit
c789484880
5 changed files with 121 additions and 52 deletions
|
@ -37,43 +37,43 @@ class ProcedurePresentation < ApplicationRecord
|
|||
|
||||
def fields
|
||||
fields = [
|
||||
field_hash('Créé le', 'self', 'created_at'),
|
||||
field_hash('En construction le', 'self', 'en_construction_at'),
|
||||
field_hash('Déposé le', 'self', 'depose_at'),
|
||||
field_hash('Mis à jour le', 'self', 'updated_at'),
|
||||
field_hash('Demandeur', 'user', 'email'),
|
||||
field_hash('Email instructeur', 'followers_instructeurs', 'email'),
|
||||
field_hash('Groupe instructeur', 'groupe_instructeur', 'label')
|
||||
field_hash('self', 'created_at'),
|
||||
field_hash('self', 'en_construction_at'),
|
||||
field_hash('self', 'depose_at'),
|
||||
field_hash('self', 'updated_at'),
|
||||
field_hash('user', 'email'),
|
||||
field_hash('followers_instructeurs', 'email'),
|
||||
field_hash('groupe_instructeur', 'label')
|
||||
]
|
||||
|
||||
if procedure.for_individual
|
||||
fields.push(
|
||||
field_hash("Prénom", "individual", "prenom"),
|
||||
field_hash("Nom", "individual", "nom"),
|
||||
field_hash("Civilité", "individual", "gender")
|
||||
field_hash("individual", "prenom"),
|
||||
field_hash("individual", "nom"),
|
||||
field_hash("individual", "gender")
|
||||
)
|
||||
end
|
||||
|
||||
if !procedure.for_individual
|
||||
fields.push(
|
||||
field_hash('SIREN', 'etablissement', 'entreprise_siren'),
|
||||
field_hash('Forme juridique', 'etablissement', 'entreprise_forme_juridique'),
|
||||
field_hash('Nom commercial', 'etablissement', 'entreprise_nom_commercial'),
|
||||
field_hash('Raison sociale', 'etablissement', 'entreprise_raison_sociale'),
|
||||
field_hash('SIRET siège social', 'etablissement', 'entreprise_siret_siege_social'),
|
||||
field_hash('Date de création', 'etablissement', 'entreprise_date_creation')
|
||||
field_hash('etablissement', 'entreprise_siren'),
|
||||
field_hash('etablissement', 'entreprise_forme_juridique'),
|
||||
field_hash('etablissement', 'entreprise_nom_commercial'),
|
||||
field_hash('etablissement', 'entreprise_raison_sociale'),
|
||||
field_hash('etablissement', 'entreprise_siret_siege_social'),
|
||||
field_hash('etablissement', 'entreprise_date_creation')
|
||||
)
|
||||
|
||||
fields.push(
|
||||
field_hash('SIRET', 'etablissement', 'siret'),
|
||||
field_hash('Libellé NAF', 'etablissement', 'libelle_naf'),
|
||||
field_hash('Code postal', 'etablissement', 'code_postal')
|
||||
field_hash('etablissement', 'siret'),
|
||||
field_hash('etablissement', 'libelle_naf'),
|
||||
field_hash('etablissement', 'code_postal')
|
||||
)
|
||||
end
|
||||
|
||||
fields.concat procedure.types_de_champ_for_procedure_presentation
|
||||
.pluck(:libelle, :private, :stable_id)
|
||||
.map { |(libelle, is_private, stable_id)| field_hash(libelle, is_private ? TYPE_DE_CHAMP_PRIVATE : TYPE_DE_CHAMP, stable_id.to_s) }
|
||||
.map { |(libelle, is_private, stable_id)| field_hash(is_private ? TYPE_DE_CHAMP_PRIVATE : TYPE_DE_CHAMP, stable_id.to_s, label: libelle) }
|
||||
|
||||
fields
|
||||
end
|
||||
|
@ -85,6 +85,14 @@ class ProcedurePresentation < ApplicationRecord
|
|||
]
|
||||
end
|
||||
|
||||
def displayed_fields_for_headers
|
||||
[
|
||||
*displayed_fields,
|
||||
field_hash('self', 'id', classname: 'number-col'),
|
||||
field_hash('self', 'state', classname: 'state-col')
|
||||
]
|
||||
end
|
||||
|
||||
def sorted_ids(dossiers, count)
|
||||
table, column, order = sort.values_at(TABLE, COLUMN, 'order')
|
||||
|
||||
|
@ -323,11 +331,12 @@ class ProcedurePresentation < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def field_hash(label, table, column)
|
||||
def field_hash(table, column, label: nil, classname: '')
|
||||
{
|
||||
'label' => label,
|
||||
'label' => label || I18n.t(column, scope: [:activerecord, :attributes, :procedure_presentation, :fields, table]),
|
||||
TABLE => table,
|
||||
COLUMN => column
|
||||
COLUMN => column,
|
||||
'classname' => classname
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -75,12 +75,8 @@
|
|||
- else
|
||||
%th.notification-col
|
||||
|
||||
= render partial: "header_field", locals: { field: { "label" => "Nº dossier", "table" => "self", "column" => "id" }, classname: "number-col" }
|
||||
|
||||
- @procedure_presentation.displayed_fields.each do |field|
|
||||
= render partial: "header_field", locals: { field: field, classname: "" }
|
||||
|
||||
= render partial: "header_field", locals: { field: { "label" => "Statut", "table" => "self", "column" => "state" }, classname: "status-col" }
|
||||
- @procedure_presentation.displayed_fields_for_headers.each do |field|
|
||||
= render partial: "header_field", locals: { field: field, classname: field['classname'] }
|
||||
|
||||
%th.action-col.follow-col
|
||||
%span.dropdown
|
||||
|
|
32
config/locales/models/procedure_presentation/en.yml
Normal file
32
config/locales/models/procedure_presentation/en.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
fr:
|
||||
activerecord:
|
||||
attributes:
|
||||
procedure_presentation:
|
||||
fields:
|
||||
self:
|
||||
id: File Nº
|
||||
state: State
|
||||
created_at: Created on
|
||||
en_construction_at: En construction le
|
||||
depose_at: Submitted on
|
||||
updated_at: Updated on
|
||||
user:
|
||||
email: Requester
|
||||
followers_instructeurs:
|
||||
email: Email instructeur
|
||||
groupe_instructeur:
|
||||
label: Team
|
||||
individual:
|
||||
prenom: First name
|
||||
nom: Last name
|
||||
gender: Title
|
||||
etablissement:
|
||||
entreprise_siren: SIREN
|
||||
entreprise_forme_juridique: Forme juridique
|
||||
entreprise_nom_commercial: Commercial name
|
||||
entreprise_raison_sociale: Raison sociale
|
||||
entreprise_siret_siege_social: SIRET siège social
|
||||
entreprise_date_creation: Creation date
|
||||
siret: SIRET
|
||||
libelle_naf: Libellé NAF
|
||||
code_postal: Postal code
|
32
config/locales/models/procedure_presentation/fr.yml
Normal file
32
config/locales/models/procedure_presentation/fr.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
fr:
|
||||
activerecord:
|
||||
attributes:
|
||||
procedure_presentation:
|
||||
fields:
|
||||
self:
|
||||
id: Nº dossier
|
||||
state: Statut
|
||||
created_at: Créé le
|
||||
en_construction_at: En construction le
|
||||
depose_at: Déposé le
|
||||
updated_at: Mis à jour le
|
||||
user:
|
||||
email: Demandeur
|
||||
followers_instructeurs:
|
||||
email: Email instructeur
|
||||
groupe_instructeur:
|
||||
label: Groupe instructeur
|
||||
individual:
|
||||
prenom: Prénom
|
||||
nom: Nom
|
||||
gender: Civilité
|
||||
etablissement:
|
||||
entreprise_siren: SIREN
|
||||
entreprise_forme_juridique: Forme juridique
|
||||
entreprise_nom_commercial: Nom commercial
|
||||
entreprise_raison_sociale: Raison sociale
|
||||
entreprise_siret_siege_social: SIRET siège social
|
||||
entreprise_date_creation: Date de création
|
||||
siret: SIRET
|
||||
libelle_naf: Libellé NAF
|
||||
code_postal: Code postal
|
|
@ -58,26 +58,26 @@ describe ProcedurePresentation do
|
|||
let(:tdc_private_2) { procedure.types_de_champ_private[1] }
|
||||
let(:expected) {
|
||||
[
|
||||
{ "label" => 'Créé le', "table" => 'self', "column" => 'created_at' },
|
||||
{ "label" => 'En construction le', "table" => 'self', "column" => 'en_construction_at' },
|
||||
{ "label" => 'Déposé le', "table" => 'self', "column" => 'depose_at' },
|
||||
{ "label" => 'Mis à jour le', "table" => 'self', "column" => 'updated_at' },
|
||||
{ "label" => 'Demandeur', "table" => 'user', "column" => 'email' },
|
||||
{ "label" => 'Email instructeur', "table" => 'followers_instructeurs', "column" => 'email' },
|
||||
{ "label" => 'Groupe instructeur', "table" => 'groupe_instructeur', "column" => 'label' },
|
||||
{ "label" => 'SIREN', "table" => 'etablissement', "column" => 'entreprise_siren' },
|
||||
{ "label" => 'Forme juridique', "table" => 'etablissement', "column" => 'entreprise_forme_juridique' },
|
||||
{ "label" => 'Nom commercial', "table" => 'etablissement', "column" => 'entreprise_nom_commercial' },
|
||||
{ "label" => 'Raison sociale', "table" => 'etablissement', "column" => 'entreprise_raison_sociale' },
|
||||
{ "label" => 'SIRET siège social', "table" => 'etablissement', "column" => 'entreprise_siret_siege_social' },
|
||||
{ "label" => 'Date de création', "table" => 'etablissement', "column" => 'entreprise_date_creation' },
|
||||
{ "label" => 'SIRET', "table" => 'etablissement', "column" => 'siret' },
|
||||
{ "label" => 'Libellé NAF', "table" => 'etablissement', "column" => 'libelle_naf' },
|
||||
{ "label" => 'Code postal', "table" => 'etablissement', "column" => 'code_postal' },
|
||||
{ "label" => tdc_1.libelle, "table" => 'type_de_champ', "column" => tdc_1.stable_id.to_s },
|
||||
{ "label" => tdc_2.libelle, "table" => 'type_de_champ', "column" => tdc_2.stable_id.to_s },
|
||||
{ "label" => tdc_private_1.libelle, "table" => 'type_de_champ_private', "column" => tdc_private_1.stable_id.to_s },
|
||||
{ "label" => tdc_private_2.libelle, "table" => 'type_de_champ_private', "column" => tdc_private_2.stable_id.to_s }
|
||||
{ "label" => 'Créé le', "table" => 'self', "column" => 'created_at', 'classname' => '' },
|
||||
{ "label" => 'En construction le', "table" => 'self', "column" => 'en_construction_at', 'classname' => '' },
|
||||
{ "label" => 'Déposé le', "table" => 'self', "column" => 'depose_at', 'classname' => '' },
|
||||
{ "label" => 'Mis à jour le', "table" => 'self', "column" => 'updated_at', 'classname' => '' },
|
||||
{ "label" => 'Demandeur', "table" => 'user', "column" => 'email', 'classname' => '' },
|
||||
{ "label" => 'Email instructeur', "table" => 'followers_instructeurs', "column" => 'email', 'classname' => '' },
|
||||
{ "label" => 'Groupe instructeur', "table" => 'groupe_instructeur', "column" => 'label', 'classname' => '' },
|
||||
{ "label" => 'SIREN', "table" => 'etablissement', "column" => 'entreprise_siren', 'classname' => '' },
|
||||
{ "label" => 'Forme juridique', "table" => 'etablissement', "column" => 'entreprise_forme_juridique', 'classname' => '' },
|
||||
{ "label" => 'Nom commercial', "table" => 'etablissement', "column" => 'entreprise_nom_commercial', 'classname' => '' },
|
||||
{ "label" => 'Raison sociale', "table" => 'etablissement', "column" => 'entreprise_raison_sociale', 'classname' => '' },
|
||||
{ "label" => 'SIRET siège social', "table" => 'etablissement', "column" => 'entreprise_siret_siege_social', 'classname' => '' },
|
||||
{ "label" => 'Date de création', "table" => 'etablissement', "column" => 'entreprise_date_creation', 'classname' => '' },
|
||||
{ "label" => 'SIRET', "table" => 'etablissement', "column" => 'siret', 'classname' => '' },
|
||||
{ "label" => 'Libellé NAF', "table" => 'etablissement', "column" => 'libelle_naf', 'classname' => '' },
|
||||
{ "label" => 'Code postal', "table" => 'etablissement', "column" => 'code_postal', 'classname' => '' },
|
||||
{ "label" => tdc_1.libelle, "table" => 'type_de_champ', "column" => tdc_1.stable_id.to_s, 'classname' => '' },
|
||||
{ "label" => tdc_2.libelle, "table" => 'type_de_champ', "column" => tdc_2.stable_id.to_s, 'classname' => '' },
|
||||
{ "label" => tdc_private_1.libelle, "table" => 'type_de_champ_private', "column" => tdc_private_1.stable_id.to_s, 'classname' => '' },
|
||||
{ "label" => tdc_private_2.libelle, "table" => 'type_de_champ_private', "column" => tdc_private_2.stable_id.to_s, 'classname' => '' }
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -94,9 +94,9 @@ describe ProcedurePresentation do
|
|||
end
|
||||
|
||||
context 'when the procedure is for individuals' do
|
||||
let(:name_field) { { "label" => "Prénom", "table" => "individual", "column" => "prenom" } }
|
||||
let(:surname_field) { { "label" => "Nom", "table" => "individual", "column" => "nom" } }
|
||||
let(:gender_field) { { "label" => "Civilité", "table" => "individual", "column" => "gender" } }
|
||||
let(:name_field) { { "label" => "Prénom", "table" => "individual", "column" => "prenom", 'classname' => '' } }
|
||||
let(:surname_field) { { "label" => "Nom", "table" => "individual", "column" => "nom", 'classname' => '' } }
|
||||
let(:gender_field) { { "label" => "Civilité", "table" => "individual", "column" => "gender", 'classname' => '' } }
|
||||
let(:procedure) { create(:procedure, :for_individual) }
|
||||
let(:procedure_presentation) { create(:procedure_presentation, assign_to: assign_to) }
|
||||
|
||||
|
|
Loading…
Reference in a new issue