feat(conditional): can condition on epci champ value

This commit is contained in:
Eric Leroy-Terquem 2023-10-17 11:23:56 +02:00
parent 90524cb541
commit 422a22e14b
2 changed files with 19 additions and 3 deletions

View file

@ -6,6 +6,7 @@ class Logic::ChampValue < Logic::Term
:decimal_number, :decimal_number,
:drop_down_list, :drop_down_list,
:multiple_drop_down_list, :multiple_drop_down_list,
:epci,
:departements, :departements,
:regions :regions
) )
@ -62,7 +63,10 @@ class Logic::ChampValue < Logic::Term
CHAMP_VALUE_TYPE.fetch(:boolean) CHAMP_VALUE_TYPE.fetch(:boolean)
when MANAGED_TYPE_DE_CHAMP.fetch(:integer_number), MANAGED_TYPE_DE_CHAMP.fetch(:decimal_number) when MANAGED_TYPE_DE_CHAMP.fetch(:integer_number), MANAGED_TYPE_DE_CHAMP.fetch(:decimal_number)
CHAMP_VALUE_TYPE.fetch(:number) CHAMP_VALUE_TYPE.fetch(:number)
when MANAGED_TYPE_DE_CHAMP.fetch(:drop_down_list),MANAGED_TYPE_DE_CHAMP.fetch(:departements), MANAGED_TYPE_DE_CHAMP.fetch(:regions) when MANAGED_TYPE_DE_CHAMP.fetch(:drop_down_list),
MANAGED_TYPE_DE_CHAMP.fetch(:departements),
MANAGED_TYPE_DE_CHAMP.fetch(:regions),
MANAGED_TYPE_DE_CHAMP.fetch(:epci)
CHAMP_VALUE_TYPE.fetch(:enum) CHAMP_VALUE_TYPE.fetch(:enum)
when MANAGED_TYPE_DE_CHAMP.fetch(:multiple_drop_down_list) when MANAGED_TYPE_DE_CHAMP.fetch(:multiple_drop_down_list)
CHAMP_VALUE_TYPE.fetch(:enums) CHAMP_VALUE_TYPE.fetch(:enums)
@ -98,7 +102,7 @@ class Logic::ChampValue < Logic::Term
tdc = type_de_champ(type_de_champs) tdc = type_de_champ(type_de_champs)
case tdc.type_champ case tdc.type_champ
when MANAGED_TYPE_DE_CHAMP.fetch(:departements) when MANAGED_TYPE_DE_CHAMP.fetch(:departements), MANAGED_TYPE_DE_CHAMP.fetch(:epci)
APIGeoService.departements.map { ["#{_1[:code]} #{_1[:name]}", _1[:code]] } APIGeoService.departements.map { ["#{_1[:code]} #{_1[:name]}", _1[:code]] }
when MANAGED_TYPE_DE_CHAMP.fetch(:regions) when MANAGED_TYPE_DE_CHAMP.fetch(:regions)
APIGeoService.regions.map { ["#{_1[:code]} #{_1[:name]}", _1[:code]] } APIGeoService.regions.map { ["#{_1[:code]} #{_1[:name]}", _1[:code]] }

View file

@ -81,6 +81,18 @@ describe TypesDeChampEditor::ConditionsComponent, type: :component do
end end
end end
context 'epcis' do
let(:epcis) { create(:type_de_champ_epci) }
let(:upper_tdcs) { [epcis] }
let(:condition) { empty_operator(champ_value(epcis.stable_id), constant(true)) }
let(:departement_options) { APIGeoService.departements.map { "#{_1[:code]} #{_1[:name]}" } }
it do
expect(page).to have_select('type_de_champ[condition_form][rows][][operator_name]', with_options: ['Est'])
expect(page).to have_select('type_de_champ[condition_form][rows][][value]', options: (['Sélectionner'] + departement_options))
end
end
context 'departements' do context 'departements' do
let(:departements) { create(:type_de_champ_departements) } let(:departements) { create(:type_de_champ_departements) }
let(:upper_tdcs) { [departements] } let(:upper_tdcs) { [departements] }