Translate type de champ values
This commit is contained in:
parent
b16c5d7bea
commit
39df032c8c
4 changed files with 29 additions and 4 deletions
|
@ -26,4 +26,8 @@ class TypeDeChamp < ActiveRecord::Base
|
||||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||||
validates :type_champ, presence: true, allow_blank: false, allow_nil: false
|
validates :type_champ, presence: true, allow_blank: false, allow_nil: false
|
||||||
# validates :order_place, presence: true, allow_blank: false, allow_nil: false
|
# validates :order_place, presence: true, allow_blank: false, allow_nil: false
|
||||||
|
|
||||||
|
def self.type_de_champs_list_fr
|
||||||
|
type_champs.map { |champ| [ I18n.t("activerecord.attributes.type_de_champ.type_champs.#{champ.last}"), champ.first ] }
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
.form-group.type
|
.form-group.type
|
||||||
%h4 Type
|
%h4 Type
|
||||||
= ff.select :type_champ, TypeDeChamp.type_champs, {}, {class: 'form-control type_champ'}
|
= ff.select :type_champ, TypeDeChamp.type_de_champs_list_fr, {}, {class: 'form-control type_champ'}
|
||||||
|
|
||||||
.form-group.description
|
.form-group.description
|
||||||
%h4 Description
|
%h4 Description
|
||||||
|
|
20
config/locales/models/type_de_champ/fr.yml
Normal file
20
config/locales/models/type_de_champ/fr.yml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
fr:
|
||||||
|
activerecord:
|
||||||
|
models:
|
||||||
|
type_de_champ: 'Type de champ'
|
||||||
|
attributes:
|
||||||
|
type_de_champ:
|
||||||
|
type_champs:
|
||||||
|
text: 'Texte'
|
||||||
|
textarea: 'Zone de texte'
|
||||||
|
date: 'Date'
|
||||||
|
datetime: 'Date et Heure'
|
||||||
|
number: 'Nombre'
|
||||||
|
checkbox: 'checkbox'
|
||||||
|
civilite: 'Civilité'
|
||||||
|
email: 'Email'
|
||||||
|
phone: 'Téléphone'
|
||||||
|
address: 'Adresse'
|
||||||
|
yes_no: 'Oui/Non'
|
||||||
|
drop_down_list: 'Menu déroulant'
|
||||||
|
header_section: 'Titre de section'
|
|
@ -40,11 +40,12 @@ feature 'add a new type de champs', js: true do
|
||||||
|
|
||||||
context 'user fill another one' do
|
context 'user fill another one' do
|
||||||
let(:libelle) { 'coucou' }
|
let(:libelle) { 'coucou' }
|
||||||
let(:type_champ) { 'textarea' }
|
let(:type_champ_value) { 'textarea' }
|
||||||
|
let(:type_champ_label) { 'Zone de texte' }
|
||||||
let(:description) { 'to be or not to be' }
|
let(:description) { 'to be or not to be' }
|
||||||
before do
|
before do
|
||||||
page.find_by_id('procedure_types_de_champ_attributes_1_libelle').set libelle
|
page.find_by_id('procedure_types_de_champ_attributes_1_libelle').set libelle
|
||||||
select(type_champ, from: 'procedure_types_de_champ_attributes_1_type_champ')
|
select(type_champ_label, from: 'procedure_types_de_champ_attributes_1_type_champ')
|
||||||
page.find_by_id('procedure_types_de_champ_attributes_1_description').set description
|
page.find_by_id('procedure_types_de_champ_attributes_1_description').set description
|
||||||
click_button 'Ajouter le champ'
|
click_button 'Ajouter le champ'
|
||||||
wait_for_ajax
|
wait_for_ajax
|
||||||
|
@ -54,7 +55,7 @@ feature 'add a new type de champs', js: true do
|
||||||
scenario 'creates another types_de_champ' do
|
scenario 'creates another types_de_champ' do
|
||||||
expect(page).to have_css('#procedure_types_de_champ_attributes_2_libelle')
|
expect(page).to have_css('#procedure_types_de_champ_attributes_2_libelle')
|
||||||
expect(subject.libelle).to eq(libelle)
|
expect(subject.libelle).to eq(libelle)
|
||||||
expect(subject.type_champ).to eq(type_champ)
|
expect(subject.type_champ).to eq(type_champ_value)
|
||||||
expect(subject.description).to eq(description)
|
expect(subject.description).to eq(description)
|
||||||
expect(subject.order_place).to eq(1)
|
expect(subject.order_place).to eq(1)
|
||||||
expect(procedure.types_de_champ.count).to eq(2)
|
expect(procedure.types_de_champ.count).to eq(2)
|
||||||
|
|
Loading…
Reference in a new issue