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