Skip to content

Commit e8a7c6f

Browse files
authored
Merge pull request #870 from MiraGeoscience/GEOPY-2739-Mat
GEOPY-2739: corrections
2 parents 9bb3206 + ab125cd commit e8a7c6f

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

geoh5py/ui_json/annotations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def deprecate(value, info):
9898
]
9999

100100
OptionalUUID = Annotated[
101-
UUID | None,
101+
list[UUID] | UUID | None,
102102
BeforeValidator(optional_uuid_mapper),
103103
PlainSerializer(stringify, when_used="json"),
104104
]

geoh5py/ui_json/forms.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ def set_value(self, value: Any):
157157
"""
158158
self.value = value
159159

160-
if "optional" in self.model_fields_set:
160+
if (
161+
"optional" in self.model_fields_set
162+
or "group_optional" in self.model_fields_set
163+
):
161164
self.enabled = self.value is not None
162165

163166

@@ -568,7 +571,7 @@ def property_if_not_is_value(self):
568571
def flatten(self) -> UUID | float | int | None:
569572
"""Returns the data for the form."""
570573
if "is_value" in self.model_fields_set and not self.is_value:
571-
return self.property
574+
return self.property # type: ignore
572575
return self.value
573576

574577
def set_value(self, value: Any):

geoh5py/ui_json/validation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ def parent_validation(name: str, data: dict[str, Any], ui_json: UIJson):
431431

432432
parent = data[parent_name]
433433

434-
if not isinstance(parent, ObjectBase) or (child not in parent.children):
434+
child = child if isinstance(child, list) else [child]
435+
missing_children = len(list(set(child) - set(parent.children))) > 0
436+
if not isinstance(parent, ObjectBase) or missing_children:
435437
raise UIJsonError(f"{name} data is not a child of {parent_name}.")
436438

437439

0 commit comments

Comments
 (0)