novo-elements 7.4.1-next.2 → 7.5.0-next.1

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.
@@ -37285,6 +37285,8 @@ class DataTableState {
37285
37285
  this.isForceRefresh = false;
37286
37286
  this.updates = new EventEmitter();
37287
37287
  this.retainSelected = false;
37288
+ this.savedSearchName = undefined;
37289
+ this.displayedColumns = undefined;
37288
37290
  }
37289
37291
  get userFiltered() {
37290
37292
  return !!(this.filter || this.sort || this.globalSearch || this.outsideFilter || this.where);
@@ -37296,27 +37298,7 @@ class DataTableState {
37296
37298
  return Array.from(this.selectedRows.values());
37297
37299
  }
37298
37300
  reset(fireUpdate = true, persistUserFilters) {
37299
- if (!persistUserFilters) {
37300
- this.sort = undefined;
37301
- this.globalSearch = undefined;
37302
- this.filter = undefined;
37303
- this.where = undefined;
37304
- }
37305
- this.page = 0;
37306
- if (!this.retainSelected) {
37307
- this.selectedRows.clear();
37308
- this.resetSource.next();
37309
- }
37310
- this.onSortFilterChange();
37311
- this.retainSelected = false;
37312
- if (fireUpdate) {
37313
- this.updates.emit({
37314
- sort: this.sort,
37315
- filter: this.filter,
37316
- globalSearch: this.globalSearch,
37317
- where: this.where,
37318
- });
37319
- }
37301
+ this.setState({}, fireUpdate, persistUserFilters);
37320
37302
  }
37321
37303
  clearSort(fireUpdate = true) {
37322
37304
  this.sort = undefined;
@@ -37398,6 +37380,7 @@ class DataTableState {
37398
37380
  filter: this.filter,
37399
37381
  globalSearch: this.globalSearch,
37400
37382
  where: this.where,
37383
+ savedSearchName: this.savedSearchName,
37401
37384
  });
37402
37385
  }
37403
37386
  setInitialSortFilter(preferences) {
@@ -37409,24 +37392,60 @@ class DataTableState {
37409
37392
  this.sort = preferences.sort;
37410
37393
  }
37411
37394
  if (preferences.filter) {
37412
- const filters = Helpers.convertToArray(preferences.filter);
37413
- filters.forEach((filter) => {
37414
- filter.value =
37415
- filter.selectedOption && filter.type
37416
- ? NovoDataTableFilterUtils.constructFilter(filter.selectedOption, filter.type)
37417
- : filter.value;
37418
- });
37419
- this.filter = filters;
37395
+ this.filter = this.transformFilters(preferences.filter);
37420
37396
  }
37421
37397
  if (preferences.globalSearch) {
37422
37398
  this.globalSearch = preferences.globalSearch;
37423
37399
  }
37400
+ if (preferences.savedSearchName) {
37401
+ this.savedSearchName = preferences.savedSearchName;
37402
+ }
37403
+ }
37404
+ }
37405
+ setState(preferences, fireUpdate = true, persistUserFilters = false) {
37406
+ var _a;
37407
+ if (!persistUserFilters) {
37408
+ this.where = preferences.where;
37409
+ this.sort = preferences.sort;
37410
+ this.filter = preferences.filter ? this.transformFilters(preferences.filter) : undefined;
37411
+ this.globalSearch = preferences.globalSearch;
37412
+ this.savedSearchName = preferences.savedSearchName;
37413
+ if ((_a = preferences.displayedColumns) === null || _a === void 0 ? void 0 : _a.length) {
37414
+ this.displayedColumns = preferences.displayedColumns;
37415
+ }
37416
+ }
37417
+ this.page = 0;
37418
+ if (!this.retainSelected) {
37419
+ this.selectedRows.clear();
37420
+ this.resetSource.next();
37421
+ }
37422
+ this.onSortFilterChange();
37423
+ this.retainSelected = false;
37424
+ if (fireUpdate) {
37425
+ this.updates.emit({
37426
+ sort: this.sort,
37427
+ filter: this.filter,
37428
+ globalSearch: this.globalSearch,
37429
+ where: this.where,
37430
+ savedSearchName: this.savedSearchName,
37431
+ displayedColumns: this.displayedColumns,
37432
+ });
37424
37433
  }
37425
37434
  }
37426
37435
  checkRetainment(caller, allMatchingSelected = false) {
37427
37436
  var _a;
37428
37437
  this.retainSelected = ((_a = this.selectionOptions) === null || _a === void 0 ? void 0 : _a.some((option) => option.label === caller)) || this.retainSelected || allMatchingSelected;
37429
37438
  }
37439
+ transformFilters(filters) {
37440
+ const filterArray = Helpers.convertToArray(filters);
37441
+ filterArray.forEach((filter) => {
37442
+ filter.value =
37443
+ filter.selectedOption && filter.type
37444
+ ? NovoDataTableFilterUtils.constructFilter(filter.selectedOption, filter.type)
37445
+ : filter.value;
37446
+ });
37447
+ return filterArray;
37448
+ }
37430
37449
  }
37431
37450
  DataTableState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DataTableState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
37432
37451
  DataTableState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: DataTableState });
@@ -40868,6 +40887,7 @@ class NovoDataTable {
40868
40887
  filter: event.filter,
40869
40888
  globalSearch: event.globalSearch,
40870
40889
  where: event.where,
40890
+ savedSearchName: event.savedSearchName,
40871
40891
  });
40872
40892
  this.performInteractions('change');
40873
40893
  }
@@ -41000,17 +41020,19 @@ class NovoDataTable {
41000
41020
  }
41001
41021
  modifyCellHeaderMultiSelectFilterOptions(column, newOptions) {
41002
41022
  const header = this.cellHeaders.find((cellHeader) => cellHeader.id === column);
41003
- if (header && header.config && header.config.filterConfig && header.config.filterConfig.options) {
41004
- const filterOptions = header.config.filterConfig.options;
41005
- const optionsToKeep = filterOptions.filter((opt) => header.isSelected(opt, header.multiSelectedOptions) &&
41006
- !newOptions.find((newOpt) => opt.value && newOpt.value && newOpt.value === opt.value));
41007
- header.config.filterConfig.options = [...optionsToKeep, ...newOptions];
41008
- }
41009
- else {
41010
- header.config.filterConfig.options = newOptions;
41023
+ if (header) {
41024
+ if (header.config && header.config.filterConfig && header.config.filterConfig.options) {
41025
+ const filterOptions = header.config.filterConfig.options;
41026
+ const optionsToKeep = filterOptions.filter((opt) => header.isSelected(opt, header.multiSelectedOptions) &&
41027
+ !newOptions.find((newOpt) => opt.value && newOpt.value && newOpt.value === opt.value));
41028
+ header.config.filterConfig.options = [...optionsToKeep, ...newOptions];
41029
+ }
41030
+ else {
41031
+ header.config.filterConfig.options = newOptions;
41032
+ }
41033
+ header.setupFilterOptions();
41034
+ header.changeDetectorRef.markForCheck();
41011
41035
  }
41012
- header.setupFilterOptions();
41013
- header.changeDetectorRef.markForCheck();
41014
41036
  }
41015
41037
  ngOnDestroy() {
41016
41038
  var _a, _b, _c, _d, _e;