beta-glozic-workflow 1.24.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +59 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -74,11 +74,68 @@ class Designer extends _react.Component {
|
|
|
74
74
|
data.definition.actions = props.Nodes;
|
|
75
75
|
this.importedJsonFile(data);
|
|
76
76
|
} else if (props.options.updatedNodeId && props.options.properties) {
|
|
77
|
-
|
|
78
|
-
console.log(props.options);
|
|
77
|
+
//Update Properties
|
|
79
78
|
if (this.nodes[props.options.updatedNodeId]) {
|
|
80
79
|
this.nodes[props.options.updatedNodeId].configuration["properties"] = props.options.properties;
|
|
81
80
|
}
|
|
81
|
+
|
|
82
|
+
// Update Branch
|
|
83
|
+
function updateBranchesByActionID(data, targetActionID, newBranches) {
|
|
84
|
+
try {
|
|
85
|
+
// Recursive function to traverse the structure
|
|
86
|
+
function traverse(actions) {
|
|
87
|
+
for (let action of actions) {
|
|
88
|
+
if (action.configuration && action.configuration.actionID === targetActionID) {
|
|
89
|
+
// Update branches array when actionID matches
|
|
90
|
+
var tempBranch = action.branches;
|
|
91
|
+
if (tempBranch.length > newBranches.length) {
|
|
92
|
+
tempBranch = tempBranch.slice(0, newBranches.length);
|
|
93
|
+
} else {
|
|
94
|
+
newBranches.forEach((ele, index) => {
|
|
95
|
+
if (!tempBranch[index]) {
|
|
96
|
+
tempBranch.push({
|
|
97
|
+
name: "branch".concat(index),
|
|
98
|
+
actions: []
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
action.branches = tempBranch;
|
|
104
|
+
return true; // Exit once the update is done
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Check nested branches if exist
|
|
108
|
+
if (action.branches) {
|
|
109
|
+
for (let branch of action.branches) {
|
|
110
|
+
if (traverse(branch.actions)) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return false; // If no match found at this level
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Start traversing from the root actions
|
|
120
|
+
const isUpdated = traverse(data);
|
|
121
|
+
|
|
122
|
+
// Return status or data based on the update result
|
|
123
|
+
return isUpdated ? data : null;
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.error("An error occurred while updating branches:", error);
|
|
126
|
+
return null; // Return null if there's an error
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (this.nodes[props.options.updatedNodeId].nodeType == "BRANCH" && this.nodes[props.options.updatedNodeId].configuration) {
|
|
130
|
+
const newBranches = this.nodes[props.options.updatedNodeId].configuration.properties.branches;
|
|
131
|
+
const updatedData = updateBranchesByActionID(props.Nodes, props.options.updatedNodeId, newBranches);
|
|
132
|
+
let data = JSON.parse(JSON.stringify(layout));
|
|
133
|
+
data.definition.actions = updatedData;
|
|
134
|
+
this.importedJsonFile(data);
|
|
135
|
+
}
|
|
136
|
+
window.setTimeout(() => {
|
|
137
|
+
self.props.onChange(self.flowchartToJson());
|
|
138
|
+
}, 400);
|
|
82
139
|
}
|
|
83
140
|
}
|
|
84
141
|
});
|