fixed deletion of edges connected to ghost nodes
This commit is contained in:
parent
77a3c9edea
commit
398f5f18ed
14
editor.ts
14
editor.ts
@ -668,7 +668,7 @@ export function ghostEdgeFrom() {
|
|||||||
|
|
||||||
export function removeSelection() {
|
export function removeSelection() {
|
||||||
if (selection) {
|
if (selection) {
|
||||||
if (selection.hasOwnProperty('actionData')) removeAction(<WF.WFEdge>selection);
|
if (selection instanceof WF.WFEdge) removeAction(selection);
|
||||||
else removeState(<WF.WFNode>selection);
|
else removeState(<WF.WFNode>selection);
|
||||||
deselect();
|
deselect();
|
||||||
edgeTarget = rightSelection = null;
|
edgeTarget = rightSelection = null;
|
||||||
@ -678,7 +678,7 @@ export function removeSelection() {
|
|||||||
|
|
||||||
export function removeRightSelection() {
|
export function removeRightSelection() {
|
||||||
if (rightSelection) {
|
if (rightSelection) {
|
||||||
if (rightSelection.hasOwnProperty('actionData')) removeAction(<WF.WFEdge>rightSelection);
|
if (rightSelection instanceof WF.WFEdge) removeAction(rightSelection);
|
||||||
else removeState(<WF.WFNode>rightSelection);
|
else removeState(<WF.WFNode>rightSelection);
|
||||||
if (selection === rightSelection) deselect();
|
if (selection === rightSelection) deselect();
|
||||||
edgeTarget = rightSelection = null;
|
edgeTarget = rightSelection = null;
|
||||||
@ -728,6 +728,10 @@ function generatePanelContent(selection: WF.WFNode | WF.WFEdge) {
|
|||||||
* @param action The action to remove.
|
* @param action The action to remove.
|
||||||
*/
|
*/
|
||||||
function removeAction(action: WF.WFEdge) {
|
function removeAction(action: WF.WFEdge) {
|
||||||
|
if (action.source instanceof WF.WFGhostNode)
|
||||||
|
removeState(action.source);
|
||||||
|
if (action.target instanceof WF.WFGhostNode)
|
||||||
|
removeState(action.target);
|
||||||
workflow.actions.splice(workflow.actions.indexOf(action), 1);
|
workflow.actions.splice(workflow.actions.indexOf(action), 1);
|
||||||
actionIndex.remove(action.id);
|
actionIndex.remove(action.id);
|
||||||
}
|
}
|
||||||
@ -738,11 +742,11 @@ function removeAction(action: WF.WFEdge) {
|
|||||||
* @param {*} state The state to remove.
|
* @param {*} state The state to remove.
|
||||||
*/
|
*/
|
||||||
function removeState(state: WF.WFNode | WF.WFGhostNode) {
|
function removeState(state: WF.WFNode | WF.WFGhostNode) {
|
||||||
workflow.actions
|
|
||||||
.filter(edge => edge.source === state || edge.target === state)
|
|
||||||
.forEach(edge => removeAction(edge));
|
|
||||||
workflow.states.splice(workflow.states.indexOf(state), 1);
|
workflow.states.splice(workflow.states.indexOf(state), 1);
|
||||||
if (state instanceof WF.WFNode) {
|
if (state instanceof WF.WFNode) {
|
||||||
|
workflow.actions
|
||||||
|
.filter(edge => edge.source === state || edge.target === state)
|
||||||
|
.forEach(edge => removeAction(edge));
|
||||||
stateAbbreviations.splice(stateAbbreviations.indexOf(state.stateData.abbreviation), 1);
|
stateAbbreviations.splice(stateAbbreviations.indexOf(state.stateData.abbreviation), 1);
|
||||||
nodeIndex.remove(state.id);
|
nodeIndex.remove(state.id);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user