Another implementation of undo/redo
This commit is contained in:
@@ -1,23 +1,6 @@
|
||||
from components.BaseCommandManager import BaseCommandManager
|
||||
from components.undo_redo.components.UndoRedo import CommandHistory
|
||||
from components.workflows.constants import Routes, ROUTE_ROOT
|
||||
|
||||
class AddConnectorCommand(CommandHistory):
|
||||
|
||||
def __init__(self, owner, connector):
|
||||
super().__init__("Add connector", "Add connector", owner)
|
||||
self.connector = connector
|
||||
|
||||
def undo(self):
|
||||
del self.owner.get_state().components[self.connector.id]
|
||||
self.owner.get_db().save_state(self.owner.get_key(), self.owner.get_state()) # update db
|
||||
return self.owner.refresh_designer(True)
|
||||
|
||||
def redo(self, oob=True):
|
||||
self.owner.get_state().components[self.connector.id] = self.connector
|
||||
self.owner.get_db().save_state(self.owner.get_key(), self.owner.get_state()) # update db
|
||||
return self.owner.refresh_designer(oob)
|
||||
|
||||
|
||||
class WorkflowsCommandManager(BaseCommandManager):
|
||||
def __init__(self, owner):
|
||||
@@ -108,6 +91,13 @@ class WorkflowDesignerCommandManager(BaseCommandManager):
|
||||
"hx-swap": "outerHTML",
|
||||
"hx-vals": f'js:{{"_id": "{self._id}"}}',
|
||||
}
|
||||
|
||||
def refresh(self):
|
||||
return {
|
||||
"hx_post": f"{ROUTE_ROOT}{Routes.Refresh}",
|
||||
"hx-swap": "none",
|
||||
"hx-vals": f'js:{{"_id": "{self._id}"}}',
|
||||
}
|
||||
|
||||
|
||||
class WorkflowPlayerCommandManager(BaseCommandManager):
|
||||
|
||||
Reference in New Issue
Block a user