@pxp-nd/flow 1.0.41 → 1.0.42

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.
@@ -146,7 +146,7 @@ let Flow = class Flow extends core_1.Controller {
146
146
  createdAt: undefined
147
147
  };
148
148
  const flowDataClone = await manager.save(Flow_1.default, { ...flowToClone, name: `${flowData.name} Copy` });
149
- const nodesToDuplicate = await manager.find(Node_1.default, { flowId: flowData === null || flowData === void 0 ? void 0 : flowData.flowId });
149
+ const nodesToDuplicate = await manager.find(Node_1.default, { flowId: flowData === null || flowData === void 0 ? void 0 : flowData.flowId, isActive: true });
150
150
  if (nodesToDuplicate) {
151
151
  const originalNodeIds = nodesToDuplicate.map((node) => node.nodeId);
152
152
  const duplicatedNodes = nodesToDuplicate.map((node) => {
@@ -284,23 +284,28 @@ let Flow = class Flow extends core_1.Controller {
284
284
  let id = null;
285
285
  let flowId = null;
286
286
  let taskIds = [];
287
- for (const nodeId of nodeRefIds) {
288
- // console.log ('node:',nodes[`${nodeId}`]);
289
- if (nodes[`${nodeId}`]) {
290
- flowId = nodes[`${nodeId}`].flowId;
291
- if (nodeId != 'new') {
292
- id = parseInt(nodeId.split("-")[1]);
293
- taskIds.push(id);
294
- const connectionsToDel = await manager.find(NodeConnection_1.default, {
295
- where: { nodeIdChild: id }
296
- });
297
- if (connectionsToDel) {
298
- //console.log("hay para eliminar---->", connectionsToDel);
299
- const originalNodeCIds = connectionsToDel.map((node) => node.nodeConnectionId);
300
- //console.log("eliminando: ", originalNodeCIds);
301
- let flowNodeC = await typeorm_1.getManager().query(`DELETE
287
+ if (nodeRefIds.length === 0) {
288
+ flowId = params.board.columns['2-column-nodes-configured'].flowId;
289
+ }
290
+ else {
291
+ for (const nodeId of nodeRefIds) {
292
+ // console.log ('node:',nodes[`${nodeId}`]);
293
+ if (nodes[`${nodeId}`]) {
294
+ flowId = nodes[`${nodeId}`].flowId;
295
+ if (nodeId != 'new') {
296
+ id = parseInt(nodeId.split("-")[1]);
297
+ taskIds.push(id);
298
+ const connectionsToDel = await manager.find(NodeConnection_1.default, {
299
+ where: { nodeIdChild: id }
300
+ });
301
+ if (connectionsToDel) {
302
+ //console.log("hay para eliminar---->", connectionsToDel);
303
+ const originalNodeCIds = connectionsToDel.map((node) => node.nodeConnectionId);
304
+ //console.log("eliminando: ", originalNodeCIds);
305
+ let flowNodeC = await typeorm_1.getManager().query(`DELETE
302
306
  from twf_node_connection
303
307
  WHERE node_connection_id = ${originalNodeCIds}`);
308
+ }
304
309
  }
305
310
  }
306
311
  }
@@ -322,32 +327,36 @@ let Flow = class Flow extends core_1.Controller {
322
327
  await manager.query(dNode);
323
328
  }
324
329
  }
325
- for (const nodeId of nodeRefIds) {
326
- if (nodes[`${nodeId}`]) {
327
- if (nodeId === 'new') {
328
- //get information about Action
329
- const newAction = await Action_1.default.findOne({ code: nodes[`${nodeId}`].action.code });
330
- const newNode = manager.create(Node_1.default, {
331
- nodeId: undefined,
332
- flowId: nodes[`${nodeId}`].flowId,
333
- isInit: 'N',
334
- actionId: newAction.actionId
330
+ if (nodeRefIds.length === 0) {
331
+ }
332
+ else {
333
+ for (const nodeId of nodeRefIds) {
334
+ if (nodes[`${nodeId}`]) {
335
+ if (nodeId === 'new') {
336
+ //get information about Action
337
+ const newAction = await Action_1.default.findOne({ code: nodes[`${nodeId}`].action.code });
338
+ const newNode = manager.create(Node_1.default, {
339
+ nodeId: undefined,
340
+ flowId: nodes[`${nodeId}`].flowId,
341
+ isInit: 'N',
342
+ actionId: newAction.actionId
343
+ });
344
+ const saveNode = await manager.save(newNode);
345
+ id = saveNode.nodeId;
346
+ }
347
+ else {
348
+ id = parseInt(nodeId.split("-")[1]);
349
+ }
350
+ //save in node and node_connection
351
+ const newConnection = manager.create(NodeConnection_1.default, {
352
+ nodeConnectionId: undefined,
353
+ nodeIdMaster: masterId,
354
+ nodeIdChild: id,
335
355
  });
336
- const saveNode = await manager.save(newNode);
337
- id = saveNode.nodeId;
356
+ masterId = id;
357
+ const savedNodes = await manager.save(newConnection);
358
+ // }
338
359
  }
339
- else {
340
- id = parseInt(nodeId.split("-")[1]);
341
- }
342
- //save in node and node_connection
343
- const newConnection = manager.create(NodeConnection_1.default, {
344
- nodeConnectionId: undefined,
345
- nodeIdMaster: masterId,
346
- nodeIdChild: id,
347
- });
348
- masterId = id;
349
- const savedNodes = await manager.save(newConnection);
350
- // }
351
360
  }
352
361
  }
353
362
  return { success: true };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxp-nd/flow",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "description": "Workflow module for pxp-nd framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",