@pxp-nd/flow 1.0.40 → 1.0.41

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.
@@ -138,35 +138,42 @@ let Flow = class Flow extends core_1.Controller {
138
138
  }
139
139
  async duplicateFlow(params, manager) {
140
140
  const flowData = await manager.findOne(Flow_1.default, params.flowId);
141
- const flowToClone = {
142
- ...flowData,
143
- flowId: undefined,
144
- nodes: [],
145
- createdAt: undefined
146
- };
147
- const flowDataClone = await manager.save(Flow_1.default, { ...flowToClone, name: `${flowData.name} Copy` });
148
- const nodesToDuplicate = await manager.find(Node_1.default, { flowId: flowData === null || flowData === void 0 ? void 0 : flowData.flowId });
149
- const originalNodeIds = nodesToDuplicate.map((node) => node.nodeId);
150
- const duplicatedNodes = nodesToDuplicate.map((node) => {
151
- const duplicatedNode = manager.create(Node_1.default, { ...node, nodeId: undefined });
152
- duplicatedNode.flowId = flowDataClone.flowId;
153
- return duplicatedNode;
154
- });
155
- const savedNodes = await manager.save(duplicatedNodes);
156
- const newNodeIds = savedNodes.map((node) => node.nodeId);
157
- const connectionsToDuplicate = await manager.find(NodeConnection_1.default, {
158
- where: { nodeIdChild: typeorm_1.In(originalNodeIds) }
159
- });
160
- const duplicatedConnections = newNodeIds.map((nodeId, index) => {
161
- const duplicatedConnection = manager.create(NodeConnection_1.default, {
162
- nodeConnectionId: undefined,
163
- nodeIdMaster: index === 0 ? null : newNodeIds[index - 1],
164
- nodeIdChild: nodeId,
165
- });
166
- return duplicatedConnection;
167
- });
168
- await manager.save(duplicatedConnections);
169
- return { success: true };
141
+ if (flowData) {
142
+ const flowToClone = {
143
+ ...flowData,
144
+ flowId: undefined,
145
+ nodes: [],
146
+ createdAt: undefined
147
+ };
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 });
150
+ if (nodesToDuplicate) {
151
+ const originalNodeIds = nodesToDuplicate.map((node) => node.nodeId);
152
+ const duplicatedNodes = nodesToDuplicate.map((node) => {
153
+ const duplicatedNode = manager.create(Node_1.default, { ...node, nodeId: undefined });
154
+ duplicatedNode.flowId = flowDataClone.flowId;
155
+ return duplicatedNode;
156
+ });
157
+ const savedNodes = await manager.save(duplicatedNodes);
158
+ const newNodeIds = savedNodes.map((node) => node.nodeId);
159
+ const connectionsToDuplicate = await manager.find(NodeConnection_1.default, {
160
+ where: { nodeIdChild: typeorm_1.In(originalNodeIds) }
161
+ });
162
+ const duplicatedConnections = newNodeIds.map((nodeId, index) => {
163
+ const duplicatedConnection = manager.create(NodeConnection_1.default, {
164
+ nodeConnectionId: undefined,
165
+ nodeIdMaster: index === 0 ? null : newNodeIds[index - 1],
166
+ nodeIdChild: nodeId,
167
+ });
168
+ return duplicatedConnection;
169
+ });
170
+ await manager.save(duplicatedConnections);
171
+ }
172
+ return { success: true };
173
+ }
174
+ else {
175
+ return { success: false, "respuesta": "No Flow" };
176
+ }
170
177
  }
171
178
  async getFlowRender(params) {
172
179
  let actions = await typeorm_1.getManager()
@@ -277,28 +284,23 @@ let Flow = class Flow extends core_1.Controller {
277
284
  let id = null;
278
285
  let flowId = null;
279
286
  let taskIds = [];
280
- if (nodeRefIds.length === 0) {
281
- flowId = params.board.columns['2-column-nodes-configured'].flowId;
282
- }
283
- else {
284
- for (const nodeId of nodeRefIds) {
285
- // console.log ('node:',nodes[`${nodeId}`]);
286
- if (nodes[`${nodeId}`]) {
287
- flowId = nodes[`${nodeId}`].flowId;
288
- if (nodeId != 'new') {
289
- id = parseInt(nodeId.split("-")[1]);
290
- taskIds.push(id);
291
- const connectionsToDel = await manager.find(NodeConnection_1.default, {
292
- where: { nodeIdChild: id }
293
- });
294
- if (connectionsToDel) {
295
- //console.log("hay para eliminar---->", connectionsToDel);
296
- const originalNodeCIds = connectionsToDel.map((node) => node.nodeConnectionId);
297
- //console.log("eliminando: ", originalNodeCIds);
298
- let flowNodeC = await typeorm_1.getManager().query(`DELETE
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
299
302
  from twf_node_connection
300
303
  WHERE node_connection_id = ${originalNodeCIds}`);
301
- }
302
304
  }
303
305
  }
304
306
  }
@@ -320,36 +322,32 @@ let Flow = class Flow extends core_1.Controller {
320
322
  await manager.query(dNode);
321
323
  }
322
324
  }
323
- if (nodeRefIds.length === 0) {
324
- }
325
- else {
326
- for (const nodeId of nodeRefIds) {
327
- if (nodes[`${nodeId}`]) {
328
- if (nodeId === 'new') {
329
- //get information about Action
330
- const newAction = await Action_1.default.findOne({ code: nodes[`${nodeId}`].action.code });
331
- const newNode = manager.create(Node_1.default, {
332
- nodeId: undefined,
333
- flowId: nodes[`${nodeId}`].flowId,
334
- isInit: 'N',
335
- actionId: newAction.actionId
336
- });
337
- const saveNode = await manager.save(newNode);
338
- id = saveNode.nodeId;
339
- }
340
- else {
341
- id = parseInt(nodeId.split("-")[1]);
342
- }
343
- //save in node and node_connection
344
- const newConnection = manager.create(NodeConnection_1.default, {
345
- nodeConnectionId: undefined,
346
- nodeIdMaster: masterId,
347
- nodeIdChild: id,
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
348
335
  });
349
- masterId = id;
350
- const savedNodes = await manager.save(newConnection);
351
- // }
336
+ const saveNode = await manager.save(newNode);
337
+ id = saveNode.nodeId;
338
+ }
339
+ else {
340
+ id = parseInt(nodeId.split("-")[1]);
352
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
+ // }
353
351
  }
354
352
  }
355
353
  return { success: true };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxp-nd/flow",
3
- "version": "1.0.40",
3
+ "version": "1.0.41",
4
4
  "description": "Workflow module for pxp-nd framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,8 +32,8 @@
32
32
  "@types/lodash": "^4.14.172",
33
33
  "@types/node": "^16.4.13",
34
34
  "rimraf": "^3.0.2",
35
- "tsc-watch": "^4.2.9",
36
- "typescript": "^4.2.4"
35
+ "tsc-watch": "^4.6.2",
36
+ "typescript": "^4.9.5"
37
37
  },
38
38
  "dependencies": {
39
39
  "@pxp-nd/common": "^1.1.4",