@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.
- package/bundles/esfaenza-es-diagrams.umd.js +99 -5
- package/bundles/esfaenza-es-diagrams.umd.js.map +1 -1
- package/esfaenza-es-diagrams.metadata.json +1 -1
- package/esm2015/lib/components/es-diagram.component.js +97 -4
- package/esm2015/lib/services/es-diagram.loc.js +3 -2
- package/esm2015/lib/services/es-diagram.service.js +2 -2
- package/fesm2015/esfaenza-es-diagrams.js +99 -5
- package/fesm2015/esfaenza-es-diagrams.js.map +1 -1
- package/lib/components/es-diagram.component.d.ts +45 -0
- package/lib/services/es-diagram.loc.d.ts +4 -0
- package/package.json +1 -1
|
@@ -543,7 +543,8 @@ const Loc = {
|
|
|
543
543
|
"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)" },
|
|
544
544
|
"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}" },
|
|
545
545
|
"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" },
|
|
546
|
-
"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" }
|
|
546
|
+
"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" },
|
|
547
|
+
"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" }
|
|
547
548
|
};
|
|
548
549
|
|
|
549
550
|
/** @ignore */ const cytoscape$1 = cy_;
|
|
@@ -581,7 +582,7 @@ class EsDiagramService {
|
|
|
581
582
|
switch (moduleId) {
|
|
582
583
|
case "cytoscape-cxtmenu": return import('cytoscape-cxtmenu').then((module) => this.modulesCache[moduleId] = module.default).catch(err => this.handleError(moduleId, err));
|
|
583
584
|
case "cytoscape-expand-collapse": return import('cytoscape-expand-collapse').then((module) => this.modulesCache[moduleId] = module.default).catch(err => this.handleError(moduleId, err));
|
|
584
|
-
case "cytoscape-html-node": return import('cytoscape-html-node').then((module) => this.modulesCache[moduleId] = module.register).catch(err => this.handleError(moduleId, err));
|
|
585
|
+
case "cytoscape-html-node": return import('@esfaenza/cytoscape-html-node').then((module) => this.modulesCache[moduleId] = module.register).catch(err => this.handleError(moduleId, err));
|
|
585
586
|
case "cytoscape-dagre":
|
|
586
587
|
yield import('dagre').catch(err => this.handleError("dagre", err));
|
|
587
588
|
return import('cytoscape-dagre').then((module) => this.modulesCache[moduleId] = module.default).catch(err => this.handleError(moduleId, err));
|
|
@@ -880,6 +881,27 @@ class EsDiagramComponent {
|
|
|
880
881
|
* Funziona solamente se il **Layout** corrente del diagramma supporta le animazioni
|
|
881
882
|
*/
|
|
882
883
|
this.AnimateLayoutChanges = true;
|
|
884
|
+
/**
|
|
885
|
+
* Attiva una modalità di selezione "smart"... o perlomeno "smarter" del default di Cytoscape.
|
|
886
|
+
*
|
|
887
|
+
* - Il click di un elemento non selezionato lo seleziona
|
|
888
|
+
* - Il click di un elemento selezionato lo deseleziona
|
|
889
|
+
* - Lo stato di selezione viene persistito sull'oggetto originale invece di rimanere in un internal
|
|
890
|
+
* - All'assegnazione di oggetti selezionati, questi vengono marcati correttamente con l'overlay di selezione
|
|
891
|
+
*
|
|
892
|
+
* N.B: la chiamata all'evento **onNodeClick** avviene **DOPO** la gestione della selezione
|
|
893
|
+
*/
|
|
894
|
+
this.SmartSelection = false;
|
|
895
|
+
/**
|
|
896
|
+
* 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,
|
|
897
|
+
* di colore **overlay-color** e con un opacità **overlay-opacity**
|
|
898
|
+
*
|
|
899
|
+
* Assegnando "{}" a questo input, la Smart selection viene gestita ma la gestione grafica è affidata all'utente,
|
|
900
|
+
* ad esempio usando dei **NodeHTMLTemplates** che definiscano selettori su nodi ":selected"
|
|
901
|
+
*
|
|
902
|
+
* @default {'overlay-color':'blue','overlay-opacity':0.5,'overlay-padding':7}
|
|
903
|
+
*/
|
|
904
|
+
this.SmartSelectionStyles = null;
|
|
883
905
|
/**
|
|
884
906
|
* Periodo di throttle da quando viene effettuato un resize a quando ricalcolare le dimensioni del diagramma.
|
|
885
907
|
*
|
|
@@ -926,6 +948,10 @@ class EsDiagramComponent {
|
|
|
926
948
|
* Evento lanciato al click di un nodo, contiene l'oggetto **data** del nodo in questione
|
|
927
949
|
*/
|
|
928
950
|
this.onNodeClick = new EventEmitter();
|
|
951
|
+
/**
|
|
952
|
+
* Evento lanciato alla selezione o deselezione di un nodo, contiene l'oggetto **data** del nodo in questione e informazioni sul suo stato di selezione
|
|
953
|
+
*/
|
|
954
|
+
this.onNodeSelection = new EventEmitter();
|
|
929
955
|
/**
|
|
930
956
|
* Evento lanciato al termine del caricamento del diagramma
|
|
931
957
|
*/
|
|
@@ -938,6 +964,10 @@ class EsDiagramComponent {
|
|
|
938
964
|
* Api dell'estensione expand-collapse per permettere di effettuare operazioni dall'esterno del diagramma. Vengono valorizzate se **UseExpandCollapse** è **true**
|
|
939
965
|
*/
|
|
940
966
|
this.ExpandCollapseApi = null;
|
|
967
|
+
/**
|
|
968
|
+
* Api dell'estensione html-node per permettere di effettuare operazioni dall'esterno del diagramma. Vengono valorizzate se sono impostati dei **NodeHTMLTemplates**
|
|
969
|
+
*/
|
|
970
|
+
this.HtmlNodeApi = null;
|
|
941
971
|
}
|
|
942
972
|
/**
|
|
943
973
|
* @ignore
|
|
@@ -991,6 +1021,8 @@ class EsDiagramComponent {
|
|
|
991
1021
|
if (elements && elements.length && elements.length > 0) {
|
|
992
1022
|
this.reviewCytoscapeElements(elements, previous_elements);
|
|
993
1023
|
this.cy.add(elements);
|
|
1024
|
+
if (this.SmartSelection)
|
|
1025
|
+
this.setupElementsSelectionIfNeeded();
|
|
994
1026
|
// Se solo gli elementi cambiano, riapplico il Layout precedente
|
|
995
1027
|
if (!layoutChanges && this.LastLayout) {
|
|
996
1028
|
// Se devo animare le modifche al layout forzo il parametro relativo
|
|
@@ -1029,9 +1061,39 @@ class EsDiagramComponent {
|
|
|
1029
1061
|
// Se devo aggiornare in automatico in base alla dimensione del contenitore collego il ResizeObserver
|
|
1030
1062
|
if (this.AutoupdateSize)
|
|
1031
1063
|
this.listenOnChanges();
|
|
1064
|
+
if (this.SmartSelection) {
|
|
1065
|
+
this.setupSelectionStyles();
|
|
1066
|
+
this.setupElementsSelectionIfNeeded();
|
|
1067
|
+
}
|
|
1032
1068
|
this.onLoaded.emit();
|
|
1033
1069
|
});
|
|
1034
1070
|
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Prende tutti gli elementi appena assegnati, e se qualcuno era selezionato la situazione viene persistita su cytoscape
|
|
1073
|
+
*/
|
|
1074
|
+
setupElementsSelectionIfNeeded() {
|
|
1075
|
+
for (let i = 0; i < this.Elements.length; i++) {
|
|
1076
|
+
let eldata = this.Elements[i].data;
|
|
1077
|
+
if (eldata.__selected) {
|
|
1078
|
+
let el = this.cy.$id(eldata.id);
|
|
1079
|
+
el.select();
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Carica gli stili per mostrare carina la selezione dei nodi
|
|
1085
|
+
*/
|
|
1086
|
+
setupSelectionStyles() {
|
|
1087
|
+
let cssItem = this.SmartSelectionStyles || {
|
|
1088
|
+
'overlay-color': 'blue',
|
|
1089
|
+
'overlay-opacity': 0.5,
|
|
1090
|
+
'overlay-padding': 7
|
|
1091
|
+
};
|
|
1092
|
+
// Backdoor per poter assegnare "{}" a SmartSelectionStyles in modo di utilizzare la smart selection ma senza che nessuno stile venga applicato
|
|
1093
|
+
// ad esempio qualora si volesse utilizzare l'htmlnode per gestire la grafica degli elementi selezionati
|
|
1094
|
+
if (cssItem['overlay-color'] && cssItem['overlay-opacity'] && cssItem['overlay-padding'])
|
|
1095
|
+
this.cy.style().selector('node:selected').css(cssItem);
|
|
1096
|
+
}
|
|
1035
1097
|
/**
|
|
1036
1098
|
* Registra l'ascolto al contenitore del grafico e in caso di modifiche alla dimensione, al massimo una volta ogni 500 millisecondi, lo ridisegna
|
|
1037
1099
|
*/
|
|
@@ -1053,7 +1115,29 @@ class EsDiagramComponent {
|
|
|
1053
1115
|
*/
|
|
1054
1116
|
bindCytoscapeEvents() {
|
|
1055
1117
|
this.cy.bind('click', 'node', (event) => {
|
|
1056
|
-
|
|
1118
|
+
let targetData = event.target.data();
|
|
1119
|
+
if (this.SmartSelection) {
|
|
1120
|
+
let id = targetData.id;
|
|
1121
|
+
let el = this.cy.$id(id);
|
|
1122
|
+
let selected = el.selected();
|
|
1123
|
+
el.selectify();
|
|
1124
|
+
if (selected)
|
|
1125
|
+
el.unselect();
|
|
1126
|
+
else
|
|
1127
|
+
el.select();
|
|
1128
|
+
el.unselectify();
|
|
1129
|
+
// Questo va anche nella lista degli elementi originali (this.Elements) dato che cytoscape li prende per riferimento (bbbbbravo cyto-chan)
|
|
1130
|
+
el.data("__selected", !selected);
|
|
1131
|
+
}
|
|
1132
|
+
this.onNodeClick.emit({ data: targetData });
|
|
1133
|
+
});
|
|
1134
|
+
this.cy.bind('select', 'node', (event) => {
|
|
1135
|
+
let targetData = event.target.data();
|
|
1136
|
+
this.onNodeSelection.emit({ data: targetData, selected: true });
|
|
1137
|
+
});
|
|
1138
|
+
this.cy.bind('unselect', 'node', (event) => {
|
|
1139
|
+
let targetData = event.target.data();
|
|
1140
|
+
this.onNodeSelection.emit({ data: targetData, selected: false });
|
|
1057
1141
|
});
|
|
1058
1142
|
// Altri eventi...
|
|
1059
1143
|
}
|
|
@@ -1098,8 +1182,8 @@ class EsDiagramComponent {
|
|
|
1098
1182
|
}
|
|
1099
1183
|
// Utilizzo dell'HTML node
|
|
1100
1184
|
if (this.NodeHTMLTemplates && this.NodeHTMLTemplates.length > 0) {
|
|
1101
|
-
|
|
1102
|
-
|
|
1185
|
+
this.HtmlNodeApi = anyCy.htmlnode();
|
|
1186
|
+
this.HtmlNodeApi.createHtmlNode(cytoscape, this.cy, this.NodeHTMLTemplates);
|
|
1103
1187
|
}
|
|
1104
1188
|
// Utilizzo del Context Menu
|
|
1105
1189
|
if (this.UseContextMenu)
|
|
@@ -1111,6 +1195,13 @@ class EsDiagramComponent {
|
|
|
1111
1195
|
if (this.ExtensionModulesApplyer)
|
|
1112
1196
|
this.ExtensionModulesApplyer(this.cy);
|
|
1113
1197
|
}
|
|
1198
|
+
updateCardData() {
|
|
1199
|
+
if (!this.HtmlNodeApi) {
|
|
1200
|
+
this.service.log("E", "Cannot update NodeHTMLTemplates as they don't seem to be used");
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
this.HtmlNodeApi.update();
|
|
1204
|
+
}
|
|
1114
1205
|
/**
|
|
1115
1206
|
* Metodo interno per il caricamento dei moduli di estensione
|
|
1116
1207
|
*
|
|
@@ -1218,12 +1309,15 @@ EsDiagramComponent.propDecorators = {
|
|
|
1218
1309
|
AutoupdateSize: [{ type: Input }],
|
|
1219
1310
|
PreserveElementsPosition: [{ type: Input }],
|
|
1220
1311
|
AnimateLayoutChanges: [{ type: Input }],
|
|
1312
|
+
SmartSelection: [{ type: Input }],
|
|
1313
|
+
SmartSelectionStyles: [{ type: Input }],
|
|
1221
1314
|
ResizeThrottleTime: [{ type: Input }],
|
|
1222
1315
|
Layout: [{ type: Input }],
|
|
1223
1316
|
NodeHTMLTemplates: [{ type: Input }],
|
|
1224
1317
|
ExtensionModulesImporter: [{ type: Input }],
|
|
1225
1318
|
ExtensionModulesApplyer: [{ type: Input }],
|
|
1226
1319
|
onNodeClick: [{ type: Output }],
|
|
1320
|
+
onNodeSelection: [{ type: Output }],
|
|
1227
1321
|
onLoaded: [{ type: Output }]
|
|
1228
1322
|
};
|
|
1229
1323
|
|