Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion geoh5py/ui_json/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def deprecate(value, info):
]

OptionalUUID = Annotated[
UUID | None,
list[UUID] | UUID | None,
BeforeValidator(optional_uuid_mapper),
PlainSerializer(stringify, when_used="json"),
]
Expand Down
7 changes: 5 additions & 2 deletions geoh5py/ui_json/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ def set_value(self, value: Any):
"""
self.value = value

if "optional" in self.model_fields_set:
if (
"optional" in self.model_fields_set
or "group_optional" in self.model_fields_set
):
self.enabled = self.value is not None


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

def set_value(self, value: Any):
Expand Down
4 changes: 3 additions & 1 deletion geoh5py/ui_json/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@ def parent_validation(name: str, data: dict[str, Any], ui_json: UIJson):

parent = data[parent_name]

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


Expand Down