Skip to content

Commit

Permalink
add warning upon encountering conflicting class names
Browse files Browse the repository at this point in the history
  • Loading branch information
vorozhkog committed Oct 29, 2024
1 parent 2265d7c commit 0dd7daa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/ui/dtl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def get_classes_mapping_value(
default_allowed: bool = False,
):
mapping = classes_mapping_widget.get_mapping()
existing_classes = classes_mapping_widget.get_classes()
if hasattr(existing_classes, "keys"):
existing_classes = existing_classes.keys()

if default_allowed:
default = [cls_name for cls_name, cls_values in mapping.items() if cls_values["default"]]
classes = classes_mapping_widget.get_classes()
Expand All @@ -138,6 +142,11 @@ def get_classes_mapping_value(
other_allowed=other_allowed,
)

if any([object_class in existing_classes for object_class in result_mapping.values()]):
classes_mapping_widget.conflict_notification.show()
else:
classes_mapping_widget.conflict_notification.hide()

return result_mapping


Expand Down
7 changes: 7 additions & 0 deletions src/ui/widgets/classes_mapping/classes_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ def __init__(
title="No classes",
description="Connect node and ensure that source node produces classes of type needed for this node.",
)
self.conflict_notification = NotificationBox(
title="Conflicting names",
description="Some class names are conflicting. Please, resolve the conflicts before saving.",
box_type="warning",
)
self.conflict_notification.hide()
self.empty_notification = empty_notification

self._classes = classes

self._select_all_btn = Button()
Expand Down
3 changes: 3 additions & 0 deletions src/ui/widgets/classes_mapping/template.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<div v-show="data.{{{widget.widget_id}}}.classes.length == 0">
{{{widget.empty_notification}}}
</div>
<div>
{{{widget.conflict_notification}}}
</div>
<div v-show="data.{{{widget.widget_id}}}.classes.length != 0">
<link
rel="stylesheet"
Expand Down

0 comments on commit 0dd7daa

Please sign in to comment.