options
This commit is contained in:
parent
12b6a0d6d6
commit
cd2b08e39b
5 changed files with 8 additions and 8 deletions
|
@ -156,7 +156,7 @@ class TypesDeChampEditor::ConditionsComponent < ApplicationComponent
|
|||
id: input_id_for('value', row_index)
|
||||
)
|
||||
when :enum, :enums
|
||||
enums_for_select = left.options
|
||||
enums_for_select = left.options(@upper_tdcs)
|
||||
|
||||
if right_invalid
|
||||
enums_for_select = empty_target_for_select + enums_for_select
|
||||
|
|
|
@ -38,7 +38,7 @@ module Logic
|
|||
when :empty
|
||||
Empty.new
|
||||
when :enum, :enums
|
||||
Constant.new(left.options.first.second)
|
||||
Constant.new(left.options(type_de_champs).first.second)
|
||||
when :number
|
||||
Constant.new(0)
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class Logic::Eq < Logic::BinaryOperator
|
|||
operator_name: self.class.name
|
||||
}
|
||||
elsif @left.type(type_de_champs) == :enum &&
|
||||
!left.options.map(&:second).include?(right.value)
|
||||
!left.options(type_de_champs).map(&:second).include?(right.value)
|
||||
errors << {
|
||||
type: :not_included,
|
||||
stable_id: @left.stable_id,
|
||||
|
|
|
@ -6,7 +6,7 @@ class Logic::IncludeOperator < Logic::BinaryOperator
|
|||
|
||||
if left_not_a_list?(type_de_champs)
|
||||
result << { type: :required_list }
|
||||
elsif right_value_not_in_list?
|
||||
elsif right_value_not_in_list?(type_de_champs)
|
||||
result << {
|
||||
type: :not_included,
|
||||
stable_id: @left.stable_id,
|
||||
|
@ -23,7 +23,7 @@ class Logic::IncludeOperator < Logic::BinaryOperator
|
|||
@left.type(type_de_champs) != :enums
|
||||
end
|
||||
|
||||
def right_value_not_in_list?
|
||||
!@left.options.map(&:second).include?(@right.value)
|
||||
def right_value_not_in_list?(type_de_champs)
|
||||
!@left.options(type_de_champs).map(&:second).include?(@right.value)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,13 +53,13 @@ describe Logic::ChampValue do
|
|||
|
||||
it { expect(champ_value(champ.stable_id).type([champ.type_de_champ])).to eq(:enum) }
|
||||
it { is_expected.to eq('val1') }
|
||||
it { expect(champ_value(champ.stable_id).options).to match_array([["val1", "val1"], ["val2", "val2"], ["val3", "val3"]]) }
|
||||
it { expect(champ_value(champ.stable_id).options([champ.type_de_champ])).to match_array([["val1", "val1"], ["val2", "val2"], ["val3", "val3"]]) }
|
||||
|
||||
context 'with other enabled' do
|
||||
let(:champ) { create(:champ_drop_down_list, value: 'val1', other: true) }
|
||||
|
||||
it { is_expected.to eq('val1') }
|
||||
it { expect(champ_value(champ.stable_id).options).to match_array([["val1", "val1"], ["val2", "val2"], ["val3", "val3"], ["Autre", "__other__"]]) }
|
||||
it { expect(champ_value(champ.stable_id).options([champ.type_de_champ])).to match_array([["val1", "val1"], ["val2", "val2"], ["val3", "val3"], ["Autre", "__other__"]]) }
|
||||
end
|
||||
|
||||
context 'with other filled' do
|
||||
|
|
Loading…
Reference in a new issue