index or null must be a string for json support
This commit is contained in:
parent
5f28acd59f
commit
44e17aa4c6
|
@ -114,7 +114,7 @@ class TiramisuOptionOption:
|
|||
def properties(self) -> List[str]:
|
||||
model = self.config.model.get(self._path, {})
|
||||
if self.isfollower():
|
||||
model = model.get(None, {})
|
||||
model = model.get('null', {})
|
||||
return self.config.get_properties(model, self._path, None)
|
||||
#
|
||||
# def requires(self) -> None:
|
||||
|
@ -145,7 +145,8 @@ class TiramisuOptionProperty:
|
|||
|
||||
def get(self, only_raises=False):
|
||||
if not only_raises:
|
||||
props = self.config.get_properties(self.config.model.get(self.path, {}), self.path, self.index, only_raises)
|
||||
model = self.config.model.get(self.path, {})
|
||||
props = self.config.get_properties(model, self.path, self.index, only_raises)
|
||||
else:
|
||||
props = []
|
||||
if self.config.is_hidden(self.path,
|
||||
|
@ -352,12 +353,16 @@ class TiramisuOptionValue(_Value):
|
|||
def default(self):
|
||||
if self.schema.get('isMulti'):
|
||||
if self.config.isfollower(self.path):
|
||||
if 'defaultmulti' in self.schema:
|
||||
defaultmulti = self.schema['defaultmulti']
|
||||
else:
|
||||
defaultmulti = None
|
||||
if self.index is not None:
|
||||
value = self.schema['defaultmulti']
|
||||
value = defaultmulti
|
||||
else:
|
||||
leader = next(iter(self.config.option(self.path.rsplit('.', 1)[0]).schema['properties']))
|
||||
len_value = len(self.config.get_value(leader))
|
||||
value = [self.schema['defaultmulti']] * len_value
|
||||
value = [defaultmulti] * len_value
|
||||
else:
|
||||
value = self.schema.get('value', [])
|
||||
else:
|
||||
|
@ -503,7 +508,7 @@ class TiramisuContextProperty:
|
|||
self.config = config
|
||||
|
||||
def get(self):
|
||||
return self.config.global_model.get('properties')
|
||||
return self.config.global_model.get('properties', [])
|
||||
|
||||
|
||||
class ContextOption(_Option):
|
||||
|
@ -579,7 +584,7 @@ class ContextValue(_Value):
|
|||
def mandatory(self):
|
||||
for key, value in self.dict().items():
|
||||
if self.config.isfollower(key):
|
||||
if self.config.model.get(key, {}).get(None, {}).get('required'):
|
||||
if self.config.model.get(key, {}).get('null', {}).get('required'):
|
||||
# FIXME test with index
|
||||
if self.config.get_schema(key).get('isSubMulti'):
|
||||
for val in value:
|
||||
|
@ -674,14 +679,6 @@ class Config:
|
|||
value: Any,
|
||||
remote: bool,
|
||||
leader_old_value: Any) -> None:
|
||||
if not remote:
|
||||
self.updates_value('modify',
|
||||
path,
|
||||
index,
|
||||
value,
|
||||
remote,
|
||||
False,
|
||||
leader_old_value)
|
||||
schema = self.get_schema(path)
|
||||
if value and isinstance(value, list) and undefined in value:
|
||||
new_value = schema.get('defaultmulti')
|
||||
|
@ -699,11 +696,26 @@ class Config:
|
|||
value[undefined_index] = schema_value[undefined_index]
|
||||
else:
|
||||
value[undefined_index] = new_value
|
||||
self.updates_value('modify',
|
||||
path,
|
||||
index,
|
||||
value,
|
||||
remote,
|
||||
False,
|
||||
leader_old_value)
|
||||
self.manage_updates('modify',
|
||||
path,
|
||||
index,
|
||||
value)
|
||||
else:
|
||||
if not remote:
|
||||
self.updates_value('modify',
|
||||
path,
|
||||
index,
|
||||
value,
|
||||
remote,
|
||||
False,
|
||||
leader_old_value)
|
||||
self.manage_updates('modify',
|
||||
path,
|
||||
index,
|
||||
|
@ -1249,7 +1261,7 @@ class Config:
|
|||
self.model[path_] = {}
|
||||
model = self.model[path_]
|
||||
if index is not None:
|
||||
if index not in model:
|
||||
if str(index) not in model:
|
||||
model[str(index)] = {}
|
||||
model = model[str(index)]
|
||||
if warnings_only:
|
||||
|
|
Loading…
Reference in New Issue