@esfaenza/es-table 11.2.110 → 11.2.112

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.
@@ -1054,9 +1054,9 @@
1054
1054
  var columnsOrderings = this.est.arrayMode ? this.est.arrayColumnOrdering : castedView.column_ordering;
1055
1055
  var columnOrders = this.est.arrayMode ? [] : castedView.orders;
1056
1056
  var toStore = {
1057
- columns: JSON.parse(JSON.stringify(columns)),
1058
- column_ordering: JSON.parse(JSON.stringify(columnsOrderings)),
1059
- orders: JSON.parse(JSON.stringify(columnOrders))
1057
+ columns: this.utiExts.deepClone(columns),
1058
+ column_ordering: this.utiExts.deepClone(columnsOrderings),
1059
+ orders: this.utiExts.deepClone(columnOrders)
1060
1060
  };
1061
1061
  this.prefService.setItem(this.est.ngControl.name, toStore, 'preference').subscribe();
1062
1062
  };
@@ -4278,9 +4278,9 @@
4278
4278
  /** @ignore */
4279
4279
  EsTableComponent.prototype.writeValue = function (obj, throttle) {
4280
4280
  if (throttle === void 0) { throttle = true; }
4281
- var _a;
4281
+ var _a, _b;
4282
4282
  return __awaiter(this, void 0, void 0, function () {
4283
- var firstItemGroupOrNoGrouping, prefs, cols, updatedPrefs, repository, source, i, prefs, cols, updatedPrefs, repository, source, i;
4283
+ var firstItemGroupOrNoGrouping, prefs, cols, updatedPrefs, repository, source, i, arr, thsCache, i, th, i, prefs, cols, updatedPrefs, repository, source, i;
4284
4284
  var _this = this;
4285
4285
  return __generator(this, function (_t) {
4286
4286
  switch (_t.label) {
@@ -4347,13 +4347,29 @@
4347
4347
  }
4348
4348
  // In modalità report devo controllare che tutte le colonne salvate facciano parte della vista
4349
4349
  // In modalità normale invece se le preferenze fanno riferimento a delle colonne che io non ho nella View attuale significa che
4350
- // sto facendo riferimento a una versione vecchia dell'es-table, quindi non foccio operazioni
4350
+ // sto facendo riferimento a una versione vecchia dell'es-table, quindi non faccio operazioni
4351
4351
  for (i = 0; i < source.length; i++) {
4352
4352
  if (repository.indexOf(source[i]) == -1) {
4353
4353
  updatedPrefs = false;
4354
4354
  break;
4355
4355
  }
4356
4356
  }
4357
+ // Se mi baso su direttive ma nelle preference è presente anche solo una colonna non presente nelle direttive
4358
+ // vuol dire che l'es-table è cambiata quindi non imposto preference
4359
+ if (((_b = this.EsThsDirective) === null || _b === void 0 ? void 0 : _b.length) > 0) {
4360
+ arr = this.EsThsDirective.toArray();
4361
+ thsCache = {};
4362
+ for (i = 0; i < arr.length; i++) {
4363
+ th = arr[i];
4364
+ thsCache[th.th] = th;
4365
+ }
4366
+ for (i = 0; i < repository.length; i++) {
4367
+ if (!thsCache[repository[i]]) {
4368
+ updatedPrefs = false;
4369
+ break;
4370
+ }
4371
+ }
4372
+ }
4357
4373
  if (updatedPrefs) {
4358
4374
  this.View.columns = (prefs === null || prefs === void 0 ? void 0 : prefs.columns) || [];
4359
4375
  this.View.column_ordering = (prefs === null || prefs === void 0 ? void 0 : prefs.column_ordering) || [];