@esfaenza/es-diagrams 12.2.8 → 12.2.9

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.
@@ -938,7 +938,8 @@
938
938
  "is loaded and managed directly by this library. You don't need to import it or use it directly, just be sure to set the relative options": { "en-US": "is loaded and managed directly by this library. You don't need to import it or use it directly, just be sure to set the relative options", "it-IT": "viene caricato e gestito nativamente dalla libreria. Non c'è bisogno di reimportarlo, né di configurarlo (usare le opzioni specifiche)" },
939
939
  "If you don't specify a source and a target for an edge you have to write its id in the format {source}-{target}": { "en-US": "If you don't specify a source and a target for an edge you have to write its id in the format {source}-{target}", "it-IT": "Se non è specificata una sorgente e una destinazione per il collegamento è opportuno scriverne l'id nel formato {sorgente}-{destinazione}" },
940
940
  "Elements have been changed after diagram initialization": { "en-US": "Elements have been changed after diagram initialization", "it-IT": "Rilevato un cambio di Elementi dopo l'inizializzazione del Diagramma" },
941
- "Layout have been changed after diagram initialization": { "en-US": "Layout have been changed after diagram initialization", "it-IT": "Rilevato un cambio di Layout dopo l'inizializzazione del Diagramma" }
941
+ "Layout have been changed after diagram initialization": { "en-US": "Layout have been changed after diagram initialization", "it-IT": "Rilevato un cambio di Layout dopo l'inizializzazione del Diagramma" },
942
+ "Cannot update NodeHTMLTemplates as they don't seem to be used": { "en-US": "Cannot update NodeHTMLTemplates as they don't seem to be used", "it-IT": "Impossibile aggiornare i NodeHTMLTemplates dato che non sembra siano utilizzati" }
942
943
  };
943
944
 
944
945
  /** @ignore */ var cytoscape$1 = cy___namespace;
@@ -986,7 +987,7 @@
986
987
  return [3 /*break*/, 6];
987
988
  case 1: return [2 /*return*/, import('cytoscape-cxtmenu').then(function (module) { return _this.modulesCache[moduleId] = module.default; }).catch(function (err) { return _this.handleError(moduleId, err); })];
988
989
  case 2: return [2 /*return*/, import('cytoscape-expand-collapse').then(function (module) { return _this.modulesCache[moduleId] = module.default; }).catch(function (err) { return _this.handleError(moduleId, err); })];
989
- case 3: return [2 /*return*/, import('cytoscape-html-node').then(function (module) { return _this.modulesCache[moduleId] = module.register; }).catch(function (err) { return _this.handleError(moduleId, err); })];
990
+ case 3: return [2 /*return*/, import('@esfaenza/cytoscape-html-node').then(function (module) { return _this.modulesCache[moduleId] = module.register; }).catch(function (err) { return _this.handleError(moduleId, err); })];
990
991
  case 4: return [4 /*yield*/, import('dagre').catch(function (err) { return _this.handleError("dagre", err); })];
991
992
  case 5:
992
993
  _b.sent();
@@ -1296,6 +1297,27 @@
1296
1297
  * Funziona solamente se il **Layout** corrente del diagramma supporta le animazioni
1297
1298
  */
1298
1299
  this.AnimateLayoutChanges = true;
1300
+ /**
1301
+ * Attiva una modalità di selezione "smart"... o perlomeno "smarter" del default di Cytoscape.
1302
+ *
1303
+ * - Il click di un elemento non selezionato lo seleziona
1304
+ * - Il click di un elemento selezionato lo deseleziona
1305
+ * - Lo stato di selezione viene persistito sull'oggetto originale invece di rimanere in un internal
1306
+ * - All'assegnazione di oggetti selezionati, questi vengono marcati correttamente con l'overlay di selezione
1307
+ *
1308
+ * N.B: la chiamata all'evento **onNodeClick** avviene **DOPO** la gestione della selezione
1309
+ */
1310
+ this.SmartSelection = false;
1311
+ /**
1312
+ * CSS per la graficazione della selezione dei nodi. Quando un nodo verrà selezionato avrà sopra di se un overlay che 'sborda' di **overlay-padding** pixel,
1313
+ * di colore **overlay-color** e con un opacità **overlay-opacity**
1314
+ *
1315
+ * Assegnando "{}" a questo input, la Smart selection viene gestita ma la gestione grafica è affidata all'utente,
1316
+ * ad esempio usando dei **NodeHTMLTemplates** che definiscano selettori su nodi ":selected"
1317
+ *
1318
+ * @default {'overlay-color':'blue','overlay-opacity':0.5,'overlay-padding':7}
1319
+ */
1320
+ this.SmartSelectionStyles = null;
1299
1321
  /**
1300
1322
  * Periodo di throttle da quando viene effettuato un resize a quando ricalcolare le dimensioni del diagramma.
1301
1323
  *
@@ -1342,6 +1364,10 @@
1342
1364
  * Evento lanciato al click di un nodo, contiene l'oggetto **data** del nodo in questione
1343
1365
  */
1344
1366
  this.onNodeClick = new i0.EventEmitter();
1367
+ /**
1368
+ * Evento lanciato alla selezione o deselezione di un nodo, contiene l'oggetto **data** del nodo in questione e informazioni sul suo stato di selezione
1369
+ */
1370
+ this.onNodeSelection = new i0.EventEmitter();
1345
1371
  /**
1346
1372
  * Evento lanciato al termine del caricamento del diagramma
1347
1373
  */
@@ -1354,6 +1380,10 @@
1354
1380
  * Api dell'estensione expand-collapse per permettere di effettuare operazioni dall'esterno del diagramma. Vengono valorizzate se **UseExpandCollapse** è **true**
1355
1381
  */
1356
1382
  this.ExpandCollapseApi = null;
1383
+ /**
1384
+ * Api dell'estensione html-node per permettere di effettuare operazioni dall'esterno del diagramma. Vengono valorizzate se sono impostati dei **NodeHTMLTemplates**
1385
+ */
1386
+ this.HtmlNodeApi = null;
1357
1387
  }
1358
1388
  /**
1359
1389
  * @ignore
@@ -1408,6 +1438,8 @@
1408
1438
  if (elements && elements.length && elements.length > 0) {
1409
1439
  this.reviewCytoscapeElements(elements, previous_elements);
1410
1440
  this.cy.add(elements);
1441
+ if (this.SmartSelection)
1442
+ this.setupElementsSelectionIfNeeded();
1411
1443
  // Se solo gli elementi cambiano, riapplico il Layout precedente
1412
1444
  if (!layoutChanges && this.LastLayout) {
1413
1445
  // Se devo animare le modifche al layout forzo il parametro relativo
@@ -1452,12 +1484,42 @@
1452
1484
  // Se devo aggiornare in automatico in base alla dimensione del contenitore collego il ResizeObserver
1453
1485
  if (this.AutoupdateSize)
1454
1486
  this.listenOnChanges();
1487
+ if (this.SmartSelection) {
1488
+ this.setupSelectionStyles();
1489
+ this.setupElementsSelectionIfNeeded();
1490
+ }
1455
1491
  this.onLoaded.emit();
1456
1492
  return [2 /*return*/];
1457
1493
  }
1458
1494
  });
1459
1495
  });
1460
1496
  };
1497
+ /**
1498
+ * Prende tutti gli elementi appena assegnati, e se qualcuno era selezionato la situazione viene persistita su cytoscape
1499
+ */
1500
+ EsDiagramComponent.prototype.setupElementsSelectionIfNeeded = function () {
1501
+ for (var i = 0; i < this.Elements.length; i++) {
1502
+ var eldata = this.Elements[i].data;
1503
+ if (eldata.__selected) {
1504
+ var el = this.cy.$id(eldata.id);
1505
+ el.select();
1506
+ }
1507
+ }
1508
+ };
1509
+ /**
1510
+ * Carica gli stili per mostrare carina la selezione dei nodi
1511
+ */
1512
+ EsDiagramComponent.prototype.setupSelectionStyles = function () {
1513
+ var cssItem = this.SmartSelectionStyles || {
1514
+ 'overlay-color': 'blue',
1515
+ 'overlay-opacity': 0.5,
1516
+ 'overlay-padding': 7
1517
+ };
1518
+ // Backdoor per poter assegnare "{}" a SmartSelectionStyles in modo di utilizzare la smart selection ma senza che nessuno stile venga applicato
1519
+ // ad esempio qualora si volesse utilizzare l'htmlnode per gestire la grafica degli elementi selezionati
1520
+ if (cssItem['overlay-color'] && cssItem['overlay-opacity'] && cssItem['overlay-padding'])
1521
+ this.cy.style().selector('node:selected').css(cssItem);
1522
+ };
1461
1523
  /**
1462
1524
  * Registra l'ascolto al contenitore del grafico e in caso di modifiche alla dimensione, al massimo una volta ogni 500 millisecondi, lo ridisegna
1463
1525
  */
@@ -1481,7 +1543,29 @@
1481
1543
  EsDiagramComponent.prototype.bindCytoscapeEvents = function () {
1482
1544
  var _this = this;
1483
1545
  this.cy.bind('click', 'node', function (event) {
1484
- _this.onNodeClick.emit({ data: event.target.data() });
1546
+ var targetData = event.target.data();
1547
+ if (_this.SmartSelection) {
1548
+ var id = targetData.id;
1549
+ var el = _this.cy.$id(id);
1550
+ var selected = el.selected();
1551
+ el.selectify();
1552
+ if (selected)
1553
+ el.unselect();
1554
+ else
1555
+ el.select();
1556
+ el.unselectify();
1557
+ // Questo va anche nella lista degli elementi originali (this.Elements) dato che cytoscape li prende per riferimento (bbbbbravo cyto-chan)
1558
+ el.data("__selected", !selected);
1559
+ }
1560
+ _this.onNodeClick.emit({ data: targetData });
1561
+ });
1562
+ this.cy.bind('select', 'node', function (event) {
1563
+ var targetData = event.target.data();
1564
+ _this.onNodeSelection.emit({ data: targetData, selected: true });
1565
+ });
1566
+ this.cy.bind('unselect', 'node', function (event) {
1567
+ var targetData = event.target.data();
1568
+ _this.onNodeSelection.emit({ data: targetData, selected: false });
1485
1569
  });
1486
1570
  // Altri eventi...
1487
1571
  };
@@ -1551,8 +1635,8 @@
1551
1635
  }
1552
1636
  // Utilizzo dell'HTML node
1553
1637
  if (this.NodeHTMLTemplates && this.NodeHTMLTemplates.length > 0) {
1554
- var htmlnode = anyCy.htmlnode();
1555
- htmlnode.createHtmlNode(cytoscape, this.cy, this.NodeHTMLTemplates);
1638
+ this.HtmlNodeApi = anyCy.htmlnode();
1639
+ this.HtmlNodeApi.createHtmlNode(cytoscape, this.cy, this.NodeHTMLTemplates);
1556
1640
  }
1557
1641
  // Utilizzo del Context Menu
1558
1642
  if (this.UseContextMenu)
@@ -1564,6 +1648,13 @@
1564
1648
  if (this.ExtensionModulesApplyer)
1565
1649
  this.ExtensionModulesApplyer(this.cy);
1566
1650
  };
1651
+ EsDiagramComponent.prototype.updateCardData = function () {
1652
+ if (!this.HtmlNodeApi) {
1653
+ this.service.log("E", "Cannot update NodeHTMLTemplates as they don't seem to be used");
1654
+ return;
1655
+ }
1656
+ this.HtmlNodeApi.update();
1657
+ };
1567
1658
  /**
1568
1659
  * Metodo interno per il caricamento dei moduli di estensione
1569
1660
  *
@@ -1680,12 +1771,15 @@
1680
1771
  AutoupdateSize: [{ type: i0.Input }],
1681
1772
  PreserveElementsPosition: [{ type: i0.Input }],
1682
1773
  AnimateLayoutChanges: [{ type: i0.Input }],
1774
+ SmartSelection: [{ type: i0.Input }],
1775
+ SmartSelectionStyles: [{ type: i0.Input }],
1683
1776
  ResizeThrottleTime: [{ type: i0.Input }],
1684
1777
  Layout: [{ type: i0.Input }],
1685
1778
  NodeHTMLTemplates: [{ type: i0.Input }],
1686
1779
  ExtensionModulesImporter: [{ type: i0.Input }],
1687
1780
  ExtensionModulesApplyer: [{ type: i0.Input }],
1688
1781
  onNodeClick: [{ type: i0.Output }],
1782
+ onNodeSelection: [{ type: i0.Output }],
1689
1783
  onLoaded: [{ type: i0.Output }]
1690
1784
  };
1691
1785