Skip to content

Commit

Permalink
Disable creating nodes while the flowchart is running
Browse files Browse the repository at this point in the history
  • Loading branch information
FeniXb3 committed Aug 2, 2023
1 parent ff51e01 commit 6df690c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
14 changes: 9 additions & 5 deletions public/Alakazam.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ export class Alakazam {

document.addEventListener('keyup', event => {
if (event.key == "Enter" && event.getModifierState('Control')) {
this.flowchart.alakazam();
this.alakazam();
}
else if (event.key == "Escape") {
this.isDeciding = false;
Expand All @@ -593,7 +593,7 @@ export class Alakazam {
this.nodeTypeMenu.hide();
this.hideAlert();
}
else if (!modal.isVisible) {
else if (!modal.isVisible && !this.flowchart.isMagicHappening) {
if (event.key == "ArrowDown") {
this.targetConnectionDescription = '';
this.flowchart.selectNextNode();
Expand Down Expand Up @@ -738,9 +738,7 @@ export class Alakazam {
});

this.runButton.addEventListener('click', e => {
clearInterval(this.moveButtonDownInterval)
document.querySelector('#theGraph').setAttribute('viewBox', this.startingViewBoxData);
this.flowchart.alakazam();
this.alakazam();
});
}

Expand Down Expand Up @@ -832,6 +830,12 @@ export class Alakazam {
this.startingViewBoxData = document.querySelector('#theGraph').getAttribute('viewBox');
}

alakazam() {
clearInterval(this.moveButtonDownInterval);
document.querySelector('#theGraph').setAttribute('viewBox', this.startingViewBoxData);
this.flowchart.alakazam();
}

handleAddingDecisionNode() {
const titleText = 'Provide condition to be checked';
const data = { 'data-node-type': 'decision' };
Expand Down
4 changes: 4 additions & 0 deletions public/Flowchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export class Flowchart {


alakazam() {
this.isMagicHappening = true;
Node.onPerformFinish = () => {
this.isMagicHappening = false;
};
const usedElements = document.querySelectorAll('.used-node');
console.log(usedElements);
usedElements.forEach(nodeElement => {
Expand Down
28 changes: 17 additions & 11 deletions public/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,25 @@ export class Node {
console.log(state);
setTimeout(() => {
this.markAsUsed();
this.connections.forEach(c => {
if (!nextConnection || c.description == nextConnection) {
if (this.tweenActiveElement) {
this.init(this, c.target, state, nextConnection, (state, nextConnection) => {
if (this.connections.length == 0) {
Node.onPerformFinish();
}
else {

this.connections.forEach(c => {
if (!nextConnection || c.description == nextConnection) {
if (this.tweenActiveElement) {
this.init(this, c.target, state, nextConnection, (state, nextConnection) => {
c.target.perform(state);
});
this.animate();
}
else {
c.target.perform(state);
});
this.animate();
}
else {
c.target.perform(state);
}
}
}
});
});
}
}, 500);
// this.init(state, nextConnection);
// this.animate();
Expand Down

0 comments on commit 6df690c

Please sign in to comment.