Added undo for edges and fixed more for undo nodes
This commit is contained in:
@@ -2931,7 +2931,12 @@ const AngularWorkflow = (props) => {
|
|||||||
|
|
||||||
const onEdgeRemoved = (event) => {
|
const onEdgeRemoved = (event) => {
|
||||||
setLastSaved(false);
|
setLastSaved(false);
|
||||||
|
|
||||||
|
|
||||||
const edge = event.target;
|
const edge = event.target;
|
||||||
|
if (edge.data("decorator") === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
workflow.branches = workflow.branches.filter(
|
workflow.branches = workflow.branches.filter(
|
||||||
(a) => a.id !== edge.data().id
|
(a) => a.id !== edge.data().id
|
||||||
@@ -2951,8 +2956,9 @@ const AngularWorkflow = (props) => {
|
|||||||
history.push({
|
history.push({
|
||||||
type: "edge",
|
type: "edge",
|
||||||
action: "removed",
|
action: "removed",
|
||||||
data: edge.data().source,
|
data: edge.data(),
|
||||||
});
|
});
|
||||||
|
|
||||||
setHistory(history);
|
setHistory(history);
|
||||||
setHistoryIndex(history.length);
|
setHistoryIndex(history.length);
|
||||||
}
|
}
|
||||||
@@ -9590,6 +9596,12 @@ const AngularWorkflow = (props) => {
|
|||||||
// Re-add the node
|
// Re-add the node
|
||||||
console.log("Item: ", item.data)
|
console.log("Item: ", item.data)
|
||||||
|
|
||||||
|
const edge = cy.getElementById(item.data.id).json()
|
||||||
|
if (edge !== null && edge !== undefined) {
|
||||||
|
console.log("Couldn't add node as it exists")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cy.add({
|
cy.add({
|
||||||
group: "nodes",
|
group: "nodes",
|
||||||
data: item.data,
|
data: item.data,
|
||||||
@@ -9603,10 +9615,23 @@ const AngularWorkflow = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (item.type === "edge" && item.action === "removed") {
|
} else if (item.type === "edge" && item.action === "removed") {
|
||||||
cy.add({
|
const sourcenode = cy.getElementById(item.data.source)
|
||||||
group: "edges",
|
const targetnode = cy.getElementById(item.data.target)
|
||||||
data: item.data,
|
if (sourcenode === undefined || sourcenode === null || targetnode === undefined || targetnode === null) {
|
||||||
});
|
console.log("Can't readd bad edge!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const edge = cy.getElementById(item.data.id).json()
|
||||||
|
if (edge !== null && edge !== undefined) {
|
||||||
|
console.log("Couldn't add edge as it exists")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cy.add({
|
||||||
|
group: "edges",
|
||||||
|
data: item.data,
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("UNHANDLED: ", item)
|
console.log("UNHANDLED: ", item)
|
||||||
|
|||||||
Reference in New Issue
Block a user