@pxp-nd/flow 1.0.45 → 1.0.47
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/controllers/Flow.js +29 -19
- package/package.json +1 -1
package/dist/controllers/Flow.js
CHANGED
|
@@ -182,45 +182,57 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
async saveFlow(params, manager) {
|
|
185
|
-
console.log(params);
|
|
186
185
|
let nodeRefIds = params.board.columns['2-column-nodes-configured'].taskIds;
|
|
187
|
-
console.log("nodesRef:", nodeRefIds);
|
|
188
186
|
let nodes = params.board.tasks ? params.board.tasks : [];
|
|
189
|
-
console.log("nod:", nodes);
|
|
190
187
|
let masterId = null;
|
|
191
188
|
let id = null;
|
|
189
|
+
let newId = null;
|
|
192
190
|
let flowId = null;
|
|
193
191
|
let taskIds = [];
|
|
194
192
|
if (nodeRefIds.length === 0) {
|
|
195
|
-
|
|
193
|
+
let nodeDelIdd = parseInt(params.board.deleteId.split("-")[1]);
|
|
194
|
+
const lastNoded = await Node_1.default.findOne({
|
|
195
|
+
where: {
|
|
196
|
+
nodeId: nodeDelIdd
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
flowId = lastNoded.flowId;
|
|
196
200
|
}
|
|
197
201
|
else {
|
|
202
|
+
flowId = params.board.flowId;
|
|
198
203
|
for (const nodeId of nodeRefIds) {
|
|
199
|
-
// console.log ('node:',nodes[`${nodeId}`]);
|
|
200
204
|
if (nodeId != 'new') {
|
|
201
|
-
id = parseInt(nodeId.split("-")[1]);
|
|
205
|
+
id = parseInt(nodeId.split("node-")[1]);
|
|
206
|
+
if (!id) {
|
|
207
|
+
const lastNode = await Node_1.default.findOne({
|
|
208
|
+
where: {
|
|
209
|
+
flowId: flowId,
|
|
210
|
+
},
|
|
211
|
+
order: {
|
|
212
|
+
nodeId: 'DESC', // Ordena por ID en orden descendente para obtener el último registro
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
id = lastNode.nodeId;
|
|
216
|
+
}
|
|
202
217
|
taskIds.push(id);
|
|
203
218
|
const connectionsToDel = await manager.find(NodeConnection_1.default, {
|
|
204
219
|
where: { nodeIdChild: id }
|
|
205
220
|
});
|
|
206
221
|
if (connectionsToDel) {
|
|
207
|
-
//console.log("hay para eliminar---->", connectionsToDel);
|
|
208
222
|
const originalNodeCIds = connectionsToDel.map((node) => node.nodeConnectionId);
|
|
209
|
-
//console.log("eliminando: ", originalNodeCIds);
|
|
210
223
|
let flowNodeC = await (0, typeorm_1.getManager)().query(`DELETE
|
|
211
224
|
from twf_node_connection
|
|
212
225
|
WHERE node_connection_id = ${originalNodeCIds}`);
|
|
213
226
|
}
|
|
214
227
|
}
|
|
228
|
+
else {
|
|
229
|
+
taskIds.push('new');
|
|
230
|
+
}
|
|
215
231
|
//}
|
|
216
232
|
}
|
|
217
233
|
}
|
|
218
|
-
//if (nodes[`${nodeId}`]) {
|
|
219
|
-
//flowId = nodes[`${nodeId}`].flowId;
|
|
220
234
|
if (params.board.origin == 'deleteTask') {
|
|
221
|
-
console.log("aqui elimina", params.board.deleteID);
|
|
222
235
|
let nodeDelId = parseInt(params.board.deleteId.split("-")[1]);
|
|
223
|
-
console.log(nodeDelId);
|
|
224
236
|
if (nodeDelId) {
|
|
225
237
|
//If there are some nodes in node_connections after delete all records sent, to inactive node
|
|
226
238
|
let connectNoDel = await (0, typeorm_1.getManager)().query(`SELECT n.node_id
|
|
@@ -242,13 +254,10 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
242
254
|
}
|
|
243
255
|
}
|
|
244
256
|
}
|
|
245
|
-
console.log("aqui tiene q entrar a volver a insertar");
|
|
246
|
-
//armamos las relaciones
|
|
247
257
|
if (nodeRefIds.length === 0) {
|
|
248
258
|
}
|
|
249
259
|
else {
|
|
250
|
-
for (const nodeId of
|
|
251
|
-
// if (nodes[`${nodeId}`]) {
|
|
260
|
+
for (const nodeId of taskIds) {
|
|
252
261
|
if (nodeId === 'new') {
|
|
253
262
|
//get information about Action
|
|
254
263
|
const newAction = await Action_1.default.findOne({ code: nodes[`${nodeId}`].action.code });
|
|
@@ -260,9 +269,10 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
260
269
|
});
|
|
261
270
|
const saveNode = await manager.save(newNode);
|
|
262
271
|
id = saveNode.nodeId;
|
|
272
|
+
newId = saveNode.nodeId;
|
|
263
273
|
}
|
|
264
274
|
else {
|
|
265
|
-
id =
|
|
275
|
+
id = nodeId;
|
|
266
276
|
}
|
|
267
277
|
//save in node and node_connection
|
|
268
278
|
const newConnection = manager.create(NodeConnection_1.default, {
|
|
@@ -276,8 +286,7 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
276
286
|
}
|
|
277
287
|
//}
|
|
278
288
|
}
|
|
279
|
-
|
|
280
|
-
return { success: true };
|
|
289
|
+
return { success: true, nodeId: newId };
|
|
281
290
|
}
|
|
282
291
|
async getFlowRender(params) {
|
|
283
292
|
let actions = await (0, typeorm_1.getManager)()
|
|
@@ -318,6 +327,7 @@ let Flow = class Flow extends core_1.Controller {
|
|
|
318
327
|
item.actionId = `action-${item.actionId}`;
|
|
319
328
|
});
|
|
320
329
|
sortedNodes.forEach((item) => {
|
|
330
|
+
item.node = { nodeId: item.nodeId };
|
|
321
331
|
item.nodeId = `node-${item.nodeId}`;
|
|
322
332
|
});
|
|
323
333
|
const actionIds = actions.map((item) => item.actionId);
|