Skip to content

Commit

Permalink
added some more placed where we flag graph as modified and undo steps
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Wicenec committed Oct 31, 2024
1 parent d116ab4 commit d8195dc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Eagle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2901,6 +2901,7 @@ export class Eagle {
this.addEdge(srcNode, srcPort, destNode, destPort, edge.isLoopAware(), edge.isClosesLoop(), () => {
this.checkGraph();
this.undo().pushSnapshot(this, "Add edge");
this.logicalGraph().fileInfo().modified = true;
// trigger the diagram to re-draw with the modified edge
this.logicalGraph.valueHasMutated();
});
Expand Down Expand Up @@ -2947,6 +2948,7 @@ export class Eagle {
this.addEdge(srcNode, srcPort, destNode, destPort, edge.isLoopAware(), edge.isClosesLoop(), () => {
this.checkGraph();
this.undo().pushSnapshot(this, "Edit edge");
this.logicalGraph().fileInfo().modified = true;
// trigger the diagram to re-draw with the modified edge
this.logicalGraph.valueHasMutated();
});
Expand Down Expand Up @@ -3530,6 +3532,7 @@ export class Eagle {
this.addEdge(realSourceNode, realSourcePort, realDestNode, realDestPort, false, false, (edge: Edge) => {
this.checkGraph();
this.undo().pushSnapshot(this, "Add edge " + edge.getId());
this.logicalGraph().fileInfo().modified = true;
this.logicalGraph.valueHasMutated();
});

Expand All @@ -3543,6 +3546,7 @@ export class Eagle {
this.addEdge(realDestNode, realDestPort, realSourceNode, realSourcePort, false, false, (edge: Edge) => {
this.checkGraph();
this.undo().pushSnapshot(this, "Add edge " + edge.getId());
this.logicalGraph().fileInfo().modified = true;
this.logicalGraph.valueHasMutated();
});

Expand Down Expand Up @@ -4000,6 +4004,7 @@ export class Eagle {
// refresh the display
this.checkGraph();
this.undo().pushSnapshot(this, "Change Node Parent");
this.logicalGraph().fileInfo().modified = true;
this.selectedObjects.valueHasMutated();
this.logicalGraph.valueHasMutated();
});
Expand Down Expand Up @@ -4048,6 +4053,7 @@ export class Eagle {
// refresh the display
this.checkGraph();
this.undo().pushSnapshot(this, "Change Node Subject");
this.logicalGraph().fileInfo().modified = true;
this.selectedObjects.valueHasMutated();
this.logicalGraph.valueHasMutated();
});
Expand Down Expand Up @@ -4246,6 +4252,7 @@ export class Eagle {
}

this.checkGraph();
this.logicalGraph().fileInfo().modified = true;
this.undo().pushSnapshot(this, "Add field");
});

Expand Down Expand Up @@ -4724,6 +4731,7 @@ export class Eagle {
this.flagActiveFileModified();
this.checkGraph();
this.undo().pushSnapshot(this, "Edit Node Category");
this.logicalGraph().fileInfo().modified = true;
this.logicalGraph.valueHasMutated();
}

Expand Down
3 changes: 3 additions & 0 deletions src/GraphRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1144,11 +1144,13 @@ export class GraphRenderer {
if (parent !== null && outerMostNode.getParentId() !== parent.getId() && outerMostNode.getId() !== parent.getId() && !ancestorOfParent && !outerMostNode.isEmbedded()){
GraphRenderer.updateNodeParent(outerMostNode, parent.getId(), allowGraphEditing);
GraphRenderer.NodeParentRadiusPreDrag = eagle.logicalGraph().findNodeByIdQuiet(parent.getId()).getRadius()
eagle.logicalGraph().fileInfo().modified = true;
}

// if no parent found, update
if (parent === null && outerMostNode.getParentId() !== null && !outerMostNode.isEmbedded()){
GraphRenderer.updateNodeParent(outerMostNode, null, allowGraphEditing);
eagle.logicalGraph().fileInfo().modified = true;
}

if (oldParent !== null){
Expand Down Expand Up @@ -2211,6 +2213,7 @@ export class GraphRenderer {
eagle.addEdge(srcNode, srcPort, destNode, destPort, loopAware, closesLoop, (edge : Edge) : void => {
eagle.checkGraph();
eagle.undo().pushSnapshot(eagle, "Added edge from " + srcNode.getName() + " to " + destNode.getName());
eagle.logicalGraph().fileInfo().modified = true;
eagle.logicalGraph.valueHasMutated();
GraphRenderer.clearEdgeVars();
});
Expand Down
3 changes: 3 additions & 0 deletions src/LogicalGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ export class LogicalGraph {

addGraphConfig = (config: GraphConfig): void => {
this.graphConfigs.push(config);
Eagle.getInstance().undo().pushSnapshot(Eagle.getInstance(), "Added a new graph config");
}

duplicateGraphConfig = (config: GraphConfig): void => {
Expand All @@ -367,6 +368,8 @@ export class LogicalGraph {
setTimeout(() => {
$('#graphConfigurationsTableWrapper .activeConfig .column-name input').focus().select()
}, 100);

Eagle.getInstance().undo().pushSnapshot(Eagle.getInstance(), "Duplicated a graph config" + clone.getName());
}

removeGraphConfig = (config: GraphConfig): void => {
Expand Down

0 comments on commit d8195dc

Please sign in to comment.