@esfaenza/es-table 11.2.74 → 11.2.75

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.
@@ -967,6 +967,12 @@
967
967
  this.est.arrayOrders = [new AppOrdering(id, order)];
968
968
  }
969
969
  }
970
+ //Salvo le preferences di questa view
971
+ //Di default registro ordinamento e visibilità delle colonne nella vista. Solo le cose di UI
972
+ if (this.est.SavePreferences) {
973
+ var castedView = this.est.viewMode ? (this.est.MainGroupView || this.est.View) : null;
974
+ this.registerViewPreferences(castedView);
975
+ }
970
976
  this.est.onOrderChanged.emit({ id: id, order: order });
971
977
  if (this.est.viewMode) {
972
978
  if (this.est.groupSearchRequestsCache.length > 0)
@@ -977,6 +983,25 @@
977
983
  else if (this.est.arrayMode)
978
984
  this.est.internalWriteValue();
979
985
  };
986
+ /**
987
+ * Registra le preference relative alla view passata come parametro
988
+ *
989
+ * @param {any} castedView View di cui salvare colonne e ordinamento colonne
990
+ */
991
+ ColumnMetadataHandler.prototype.registerViewPreferences = function (castedView) {
992
+ if (!this.est.ngControl.name) {
993
+ console.error("Non posso utilizzare le preference senza avere un 'name' per la tabella");
994
+ return false;
995
+ }
996
+ if (!this.prefService) {
997
+ console.error("Non posso utilizzare le preference senza che il pacchetto @esfaenza/preferences sia installato");
998
+ return false;
999
+ }
1000
+ var columns = this.est.arrayMode ? this.est.arrayColumns : castedView.columns;
1001
+ var columnsOrderings = this.est.arrayMode ? this.est.arrayColumnOrdering : castedView.column_ordering;
1002
+ var toStore = { columns: JSON.parse(JSON.stringify(columns)), column_ordering: JSON.parse(JSON.stringify(columnsOrderings)) };
1003
+ this.prefService.setItem(this.est.ngControl.name, toStore, 'preference').subscribe();
1004
+ };
980
1005
  /**
981
1006
  * Partendo dagli **EsThs** estrappolo la lista di **EsTableColumn** che questa tabella dovrà eventualmente gestire per Visibilità e Ordine
982
1007
  *
@@ -1650,20 +1675,8 @@
1650
1675
  this.refreshColumnsVisibility(null, null, castedView);
1651
1676
  //Salvo le preferences di questa view
1652
1677
  //Di default registro ordinamento e visibilità delle colonne nella vista. Solo le cose di UI
1653
- if (this.est.SavePreferences) {
1654
- if (!this.est.ngControl.name) {
1655
- console.error("Non posso utilizzare le preference senza avere un 'name' per la tabella");
1656
- return false;
1657
- }
1658
- if (!this.prefService) {
1659
- console.error("Non posso utilizzare le preference senza che il pacchetto @esfaenza/preferences sia installato");
1660
- return false;
1661
- }
1662
- var columns = this.est.arrayMode ? this.est.arrayColumns : castedView.columns;
1663
- var columnsOrderings = this.est.arrayMode ? this.est.arrayColumnOrdering : castedView.column_ordering;
1664
- var toStore = { columns: JSON.parse(JSON.stringify(columns)), column_ordering: JSON.parse(JSON.stringify(columnsOrderings)) };
1665
- this.prefService.setItem(this.est.ngControl.name, toStore, 'preference').subscribe();
1666
- }
1678
+ if (this.est.SavePreferences)
1679
+ this.registerViewPreferences(castedView);
1667
1680
  // Rieseguo l'ultima ricerca bindata alla tabella
1668
1681
  // Mi assicuro di farlo dopo l'espansione del changed o rischio che la ricerca mi ridia colonne che in realtà non esistono
1669
1682
  if (this.est.viewMode)