Kit manager menu oncesi
This commit is contained in:
@@ -99,27 +99,24 @@ class MetaMoveCommand:
|
||||
|
||||
|
||||
class AddComponentCommand:
|
||||
"""Placing a component, plus the <kit> entry that placing it may have required."""
|
||||
"""Placing a component.
|
||||
|
||||
def __init__(self, parent, index, element, schema_parent=None, kit_element=None, label="add"):
|
||||
Nothing here touches <schema>. The kit a placement needs is declared when the file is
|
||||
saved, from the component types actually in the DOM, so undoing a placement takes its
|
||||
kit out of that reckoning without this command having to unwind anything.
|
||||
"""
|
||||
|
||||
def __init__(self, parent, index, element, label="add"):
|
||||
self.parent = parent
|
||||
self.index = index
|
||||
self.element = element
|
||||
self.schema_parent = schema_parent
|
||||
self.kit_element = kit_element
|
||||
self.label = label
|
||||
|
||||
def undo(self):
|
||||
if self.element in list(self.parent):
|
||||
self.parent.remove(self.element)
|
||||
if self.kit_element is not None and self.schema_parent is not None:
|
||||
if self.kit_element in list(self.schema_parent):
|
||||
self.schema_parent.remove(self.kit_element)
|
||||
|
||||
def redo(self):
|
||||
if self.kit_element is not None and self.schema_parent is not None:
|
||||
if self.kit_element not in list(self.schema_parent):
|
||||
self.schema_parent.append(self.kit_element)
|
||||
if self.element not in list(self.parent):
|
||||
self.parent.insert(self.index, self.element)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user