add component preview
This commit is contained in:
parent
bf0f43f0ec
commit
d9c3dfa916
1 changed files with 50 additions and 0 deletions
|
@ -0,0 +1,50 @@
|
|||
class TypesDeChamp::ConditionsComponentPreview < ViewComponent::Preview
|
||||
include Logic
|
||||
|
||||
def with_empty_condition
|
||||
tdc = TypeDeChamp.create(type_champ: :text, condition: empty_operator(empty, empty), libelle: 't')
|
||||
upper_tdcs = []
|
||||
|
||||
render TypesDeChamp::ConditionsComponent.new(
|
||||
tdc: tdc, upper_tdcs: upper_tdcs, procedure_id: '1'
|
||||
)
|
||||
end
|
||||
|
||||
def with_conditions
|
||||
surface = TypeDeChamp.create(type_champ: :integer_number, libelle: 'surface')
|
||||
appartement = TypeDeChamp.create(type_champ: :yes_no, libelle: 'appartement')
|
||||
type_appartement = TypeDeChamp.create(type_champ: :drop_down_list, libelle: 'type', drop_down_list_value: "T1\r\nT2\r\nT3")
|
||||
upper_tdcs = [surface, appartement, type_appartement]
|
||||
|
||||
condition = ds_and([
|
||||
greater_than_eq(champ_value(surface.stable_id), constant(50)),
|
||||
ds_eq(champ_value(appartement.stable_id), constant(true)),
|
||||
ds_eq(champ_value(type_appartement.stable_id), constant('T2'))
|
||||
])
|
||||
tdc = TypeDeChamp.create(type_champ: :integer_number, condition: condition, libelle: 'nb de piece')
|
||||
|
||||
render TypesDeChamp::ConditionsComponent.new(
|
||||
tdc: tdc, upper_tdcs: upper_tdcs, procedure_id: '1'
|
||||
)
|
||||
end
|
||||
|
||||
def with_errors
|
||||
surface = TypeDeChamp.create(type_champ: :integer_number, libelle: 'surface')
|
||||
address = TypeDeChamp.create(type_champ: :address, libelle: 'adresse')
|
||||
yes_non = TypeDeChamp.create(type_champ: :yes_no, libelle: 'oui/non')
|
||||
|
||||
upper_tdcs = [address, yes_non]
|
||||
|
||||
condition = ds_and([
|
||||
ds_eq(champ_value(address.stable_id), empty),
|
||||
greater_than_eq(champ_value(surface.stable_id), constant(50)),
|
||||
ds_eq(champ_value(yes_non.stable_id), constant(5))
|
||||
])
|
||||
|
||||
tdc = TypeDeChamp.create(type_champ: :integer_number, condition: condition, libelle: 'nb de piece')
|
||||
|
||||
render TypesDeChamp::ConditionsComponent.new(
|
||||
tdc: tdc, upper_tdcs: upper_tdcs, procedure_id: '1'
|
||||
)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue