add multiple disable_if_in support

This commit is contained in:
2021-01-30 15:19:18 +01:00
parent e618b3b42c
commit 1dcdbd474d
15 changed files with 159 additions and 25 deletions

View File

@ -220,22 +220,19 @@ class ConditionAnnotator:
listvar.default = self.force_service_value[target.name]
continue
value = condition.name != 'disabled_if_in'
if len(condition.param) != 1:
xmlfiles = self.objectspace.display_xmlfiles(condition.xmlfiles)
msg = _(f'a condition with "{listname}" can only have '
f'only have only on param')
raise DictConsistencyError(msg, 35) from err
if listvar.path in fills:
fill = fills[listvar.path]
fill.index += 1
or_needed = True
for param in fill.param:
if hasattr(param, 'name') and param.name == 'condition_operator':
or_needed = False
break
else:
fill = self.objectspace.fill(target.xmlfiles)
fill.target = listvar.path
fill.name = 'calc_value'
fill.namespace = 'services'
fill.index = 0
if not hasattr(self.objectspace.space, 'constraints'):
self.objectspace.space.constraints = self.objectspace.constraints(elt.xmlfiles)
fill.index = -1
if not hasattr(self.objectspace.space.constraints, 'fill'):
self.objectspace.space.constraints.fill = []
self.objectspace.space.constraints.fill.append(fill)
@ -248,15 +245,23 @@ class ConditionAnnotator:
param2.text = not value
param2.type = 'boolean'
fill.param = [param1, param2]
param3 = self.objectspace.param(target.xmlfiles)
param3.name = f'condition_{fill.index}'
param3.type = 'variable'
param3.text = condition.source
fill.param.append(param3)
param4 = self.objectspace.param(target.xmlfiles)
param4.name = f'expected_{fill.index}'
param4.text = getattr(condition.param[0], 'text', None)
fill.param.append(param4)
or_needed = len(condition.param) != 1
for param in condition.param:
fill.index += 1
param3 = self.objectspace.param(target.xmlfiles)
param3.name = f'condition_{fill.index}'
param3.type = 'variable'
param3.text = condition.source
fill.param.append(param3)
param4 = self.objectspace.param(target.xmlfiles)
param4.name = f'expected_{fill.index}'
param4.text = getattr(param, 'text', None)
fill.param.append(param4)
if or_needed:
param5 = self.objectspace.param(target.xmlfiles)
param5.name = 'condition_operator'
param5.text = 'OR'
fill.param.append(param5)
remove_targets.append(target_idx)
remove_targets.sort(reverse=True)
for target_idx in remove_targets: