@ejfdelgado/ejflab-common 1.10.3 → 1.10.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-common",
3
3
  "type": "commonjs",
4
- "version": "1.10.3",
4
+ "version": "1.10.5",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ejfdelgado/ejflab-common.git"
package/src/MyTemplate.js CHANGED
@@ -213,6 +213,18 @@ class MyTemplate extends CsvWithFilters {
213
213
  }
214
214
  replaceBareValues(template, data, open = "\\{", close = "\\}", closeNoScape = "}", useStringify = false, skipUndefined = false) {
215
215
  const myPattern = new RegExp("\\$\\s*" + open + "([^" + closeNoScape + "]+)\\s*" + close, "g");
216
+ // Segond level replace
217
+ const myPattern2d = new RegExp("(\\$\\s*" + open + "[^$" + closeNoScape + "]+)\\$" + open + "([^" + closeNoScape + "]+)" + close + "([^" + closeNoScape + "]*" + close + ")", "g");
218
+ template = template.replace(myPattern2d, (match, g1, g2, g3) => {
219
+ const response = this.getColumnDescription(g2)[0];
220
+ const valor = SimpleObj.getValue(data, response.id);
221
+ const temp = this.filterValue(valor, response, undefined, response.id);
222
+ if (temp === undefined) {
223
+ return match;
224
+ } else {
225
+ return g1 + temp + g3;
226
+ }
227
+ });
216
228
  template = template.replace(myPattern, (match, g1) => {
217
229
  const response = this.getColumnDescription(g1)[0];
218
230
  const valor = SimpleObj.getValue(data, response.id);
@@ -76,6 +76,18 @@ function myTest() {
76
76
  exp: "my name is undefined Delgado and I like undefined undefined",
77
77
  skipUndefined: false,
78
78
  },
79
+ {
80
+ txt: "My ${index} lastname is ${lastname.${index}}",
81
+ data: { lastname: ["delgado", "leyton"], index: 0 },
82
+ exp: "My 0 lastname is delgado",
83
+ skipUndefined: false,
84
+ },
85
+ {
86
+ txt: "My ${index} lastname is ${lastname.${index}.detail}",
87
+ data: { lastname: [{ detail: "delgado" }, { detail: "leyton" }], index: 0 },
88
+ exp: "My 0 lastname is delgado",
89
+ skipUndefined: false,
90
+ },
79
91
  ];
80
92
 
81
93
  renderer.registerFunction("json", CsvFormatterFilters.json);
@@ -283,6 +283,26 @@ class FlowChartExec {
283
283
  return response;
284
284
  }
285
285
 
286
+ removeIndexPathNodes(prefix) {
287
+ let count = 0;
288
+ const noPrefix = (node) => {
289
+ // Erase node ids...
290
+ delete this.nodesById[node.id];
291
+ let pased = node.prefix != prefix;
292
+ if (!pased) {
293
+ count++;
294
+ }
295
+ return pased;
296
+ };
297
+ this.flowchart.shapes = this.flowchart.shapes.filter(noPrefix);
298
+ this.flowchart.arrows = this.flowchart.arrows.filter(noPrefix);
299
+ console.log(`Removed ${count} nodes from flowchart with prefix ${prefix}`);
300
+ const foudPrefix = this.flowchart.prefixes.indexOf(prefix);
301
+ if (foudPrefix >= 0) {
302
+ this.flowchart.prefixes.splice(foudPrefix, 1);
303
+ }
304
+ }
305
+
286
306
  loadFlowChart(paths) {
287
307
  return this.loadFlowChartInternal(paths, true);
288
308
  }
@@ -318,6 +338,9 @@ class FlowChartExec {
318
338
  const xmlFlowText = fs.readFileSync(path, 'utf8');
319
339
  const parser = new XMLParser(options);
320
340
  const xmlFlow = parser.parse(xmlFlowText);
341
+ // Previous clear old prefix
342
+ this.removeIndexPathNodes(prefix);
343
+ // Loads new nodes for prefix
321
344
  const localFlowChart = this.processFlowChart(xmlFlow, prefix);
322
345
  this.interpretColor(localFlowChart.shapes);
323
346
  //
@@ -337,11 +360,15 @@ class FlowChartExec {
337
360
  localFlowChart.arrows.forEach(placeMetadata);
338
361
  const startingPoints = this.getNodesWithText("start", undefined, localFlowChart);
339
362
  if (this.actualNodes instanceof Array && startingPoints instanceof Array) {
363
+ console.log(`Adding NEW #${startingPoints.length} starting points to flowchart`);
340
364
  this.actualNodes.push(...startingPoints);
341
365
  }
342
366
  }
343
367
  this.flowchart.shapes.push(...localFlowChart.shapes);
368
+ console.log(`Added ${localFlowChart.shapes.length} shapes with prefix ${prefix}`);
344
369
  this.flowchart.arrows.push(...localFlowChart.arrows);
370
+ console.log(`Added ${localFlowChart.arrows.length} arrows with prefix ${prefix}`);
371
+ console.log(`Added ${localFlowChart.arrows.length + localFlowChart.shapes.length} nodes with prefix ${prefix}`);
345
372
  this.flowchart.prefixes.push(prefix);
346
373
  if (check.flux) {
347
374
  for (let key in check.flux) {