Skip to content

Commit

Permalink
More commenting.
Browse files Browse the repository at this point in the history
  • Loading branch information
mchilvers committed Apr 2, 2024
1 parent 5e2ad34 commit 3a2e8ca
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/tools/builder/src/python/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ def _on_drop_component(self, event, component):
event.preventDefault()
event.stopPropagation()

# Moving a component that is already on the page...
# Are we...
#
# a) Moving a component that is already on the page.
move_data = event.dataTransfer.getData("move")
if move_data:
# You can't drop a component onto itself :)
Expand All @@ -514,23 +516,24 @@ def _on_drop_component(self, event, component):

component_to_move = Component.get_component_by_id(move_data)

# You also can't drop a container onto one of its children!
# You also can't drop a container onto one of its own children!
# TODO: Is one level enough, should this check recursively...
if isinstance(component_to_move, Container):
for item in component_to_move.content:
if item.id == component.id:
return

# We "move" by deleting and re-inserting!
# DO the "move" by deleting and re-inserting!
self.delete_component(component_to_move.id)
new_component = component_to_move.clone()

# ...adding a new component to the page.
# Or...
#
# b) Adding a new component to the page.
else:
widget_data = event.dataTransfer.getData("widget")
if widget_data:
component_blueprint = json.loads(widget_data)
new_component = create_component(component_blueprint["name"])
component_blueprint = json.loads(widget_data)
new_component = create_component(component_blueprint["name"])

# Dropping onto a Widget or a Container? #######################################
#
Expand Down

0 comments on commit 3a2e8ca

Please sign in to comment.