@firestitch/filter 12.1.2 → 12.2.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.
@@ -5,8 +5,6 @@ import { RouterModule } from '@angular/router';
5
5
  import { BehaviorSubject, Subject, isObservable, forkJoin, of, fromEvent, merge, timer, combineLatest } from 'rxjs';
6
6
  import { tap, finalize, take, takeUntil, debounceTime, filter as filter$1, distinctUntilChanged, switchMap, delay, skip, mapTo, startWith, map } from 'rxjs/operators';
7
7
  import { isFunction, clone, isObject, isString, toString, pickBy } from 'lodash-es';
8
- import { __decorate, __metadata } from 'tslib';
9
- import { Model, Alias } from 'tsmodels';
10
8
  import { filter, isEmpty, getNormalizedPath, list, remove, FsCommonModule } from '@firestitch/common';
11
9
  import { simpleFormat, format } from '@firestitch/date';
12
10
  import { parseISO, isValid, isDate, isEqual } from 'date-fns';
@@ -421,9 +419,8 @@ class SimpleSelectItem extends BaseSelectItem {
421
419
 
422
420
  const SORT_BY_FIELD = 'sortName';
423
421
  const SORT_DIRECTION_FIELD = 'sortDirection';
424
- class FsFilterConfig extends Model {
422
+ class FsFilterConfig {
425
423
  constructor(data = {}) {
426
- super();
427
424
  this.load = true;
428
425
  this.persist = false;
429
426
  this.inline = false;
@@ -431,13 +428,40 @@ class FsFilterConfig extends Model {
431
428
  this.chips = false;
432
429
  this.sortValues = null;
433
430
  this.sort = null;
434
- this.sortDirection = null;
431
+ // public sortDirection = null;
435
432
  this.queryParam = false;
436
433
  this.case = 'camel';
437
- this._fromJSON(data);
438
- this._init();
439
- }
440
- _init() {
434
+ this._init(data);
435
+ }
436
+ _init(data = {}) {
437
+ var _a, _b, _c, _d, _e, _f, _g;
438
+ this.load = (_a = data.load) !== null && _a !== void 0 ? _a : true;
439
+ this.persist = data.persist;
440
+ this.savedFilters = data.savedFilters;
441
+ this.inline = (_b = data.inline) !== null && _b !== void 0 ? _b : false;
442
+ this.autofocus = (_c = data.autofocus) !== null && _c !== void 0 ? _c : false;
443
+ this.chips = (_d = data.chips) !== null && _d !== void 0 ? _d : false;
444
+ this.sortValues = data.sorts;
445
+ this.sort = data.sort;
446
+ this.queryParam = (_e = data.queryParam) !== null && _e !== void 0 ? _e : false;
447
+ this.init = data.init;
448
+ this.change = data.change;
449
+ this.reload = data.reload;
450
+ this.clear = data.clear;
451
+ this.sortChange = data.sortChange;
452
+ this.case = (_f = data.case) !== null && _f !== void 0 ? _f : 'camel';
453
+ this.reloadWhenConfigChanged = data.reloadWhenConfigChanged;
454
+ this.button = data.button;
455
+ this.items = data.items;
456
+ this.actions = data.actions;
457
+ this.case = (_g = data.case) !== null && _g !== void 0 ? _g : 'camel';
458
+ if (this.persist) {
459
+ if (typeof this.persist === 'object') {
460
+ if (this.persist.name) {
461
+ this.namespace = this.persist.name;
462
+ }
463
+ }
464
+ }
441
465
  if (!this.button) {
442
466
  this.button = {};
443
467
  }
@@ -457,99 +481,7 @@ class FsFilterConfig extends Model {
457
481
  this.clear = () => { };
458
482
  }
459
483
  }
460
- _fromJSON(value) {
461
- var _a;
462
- super._fromJSON(value);
463
- this.case = (_a = value.case) !== null && _a !== void 0 ? _a : 'camel';
464
- if (this.persist) {
465
- if (typeof this.persist === 'object') {
466
- if (this.persist.name) {
467
- this.namespace = this.persist.name;
468
- }
469
- }
470
- }
471
- }
472
484
  }
473
- __decorate([
474
- Alias(),
475
- __metadata("design:type", Object)
476
- ], FsFilterConfig.prototype, "load", void 0);
477
- __decorate([
478
- Alias(),
479
- __metadata("design:type", Object)
480
- ], FsFilterConfig.prototype, "persist", void 0);
481
- __decorate([
482
- Alias(),
483
- __metadata("design:type", Object)
484
- ], FsFilterConfig.prototype, "savedFilters", void 0);
485
- __decorate([
486
- Alias(),
487
- __metadata("design:type", Object)
488
- ], FsFilterConfig.prototype, "inline", void 0);
489
- __decorate([
490
- Alias(),
491
- __metadata("design:type", Object)
492
- ], FsFilterConfig.prototype, "autofocus", void 0);
493
- __decorate([
494
- Alias(),
495
- __metadata("design:type", Object)
496
- ], FsFilterConfig.prototype, "chips", void 0);
497
- __decorate([
498
- Alias('sorts'),
499
- __metadata("design:type", Array)
500
- ], FsFilterConfig.prototype, "sortValues", void 0);
501
- __decorate([
502
- Alias(),
503
- __metadata("design:type", Object)
504
- ], FsFilterConfig.prototype, "sort", void 0);
505
- __decorate([
506
- Alias(),
507
- __metadata("design:type", Object)
508
- ], FsFilterConfig.prototype, "sortDirection", void 0);
509
- __decorate([
510
- Alias(),
511
- __metadata("design:type", Object)
512
- ], FsFilterConfig.prototype, "queryParam", void 0);
513
- __decorate([
514
- Alias(),
515
- __metadata("design:type", Function)
516
- ], FsFilterConfig.prototype, "init", void 0);
517
- __decorate([
518
- Alias(),
519
- __metadata("design:type", Function)
520
- ], FsFilterConfig.prototype, "change", void 0);
521
- __decorate([
522
- Alias(),
523
- __metadata("design:type", Function)
524
- ], FsFilterConfig.prototype, "reload", void 0);
525
- __decorate([
526
- Alias(),
527
- __metadata("design:type", Function)
528
- ], FsFilterConfig.prototype, "clear", void 0);
529
- __decorate([
530
- Alias(),
531
- __metadata("design:type", Function)
532
- ], FsFilterConfig.prototype, "sortChange", void 0);
533
- __decorate([
534
- Alias(),
535
- __metadata("design:type", String)
536
- ], FsFilterConfig.prototype, "case", void 0);
537
- __decorate([
538
- Alias(),
539
- __metadata("design:type", Boolean)
540
- ], FsFilterConfig.prototype, "reloadWhenConfigChanged", void 0);
541
- __decorate([
542
- Alias(),
543
- __metadata("design:type", Object)
544
- ], FsFilterConfig.prototype, "button", void 0);
545
- __decorate([
546
- Alias(),
547
- __metadata("design:type", Array)
548
- ], FsFilterConfig.prototype, "items", void 0);
549
- __decorate([
550
- Alias(),
551
- __metadata("design:type", Array)
552
- ], FsFilterConfig.prototype, "actions", void 0);
553
485
 
554
486
  class MultipleSelectItem extends BaseSelectItem {
555
487
  constructor(itemConfig, _persistedValues) {
@@ -1804,12 +1736,13 @@ class PersistanceParamsController extends FsPersistanceStore {
1804
1736
  }
1805
1737
  restore() {
1806
1738
  super.restore();
1739
+ const items = [
1740
+ ...this._itemsStore.items,
1741
+ this._itemsStore.sortByItem,
1742
+ this._itemsStore.sortDirectionItem,
1743
+ ].filter((item) => !!item);
1807
1744
  if (this._value) {
1808
- this._value.data = restoreItems(this._value.data, [
1809
- ...this._itemsStore.items,
1810
- this._itemsStore.sortByItem,
1811
- this._itemsStore.sortDirectionItem,
1812
- ], this._paramsCase);
1745
+ this._value.data = restoreItems(this._value.data, items, this._paramsCase);
1813
1746
  }
1814
1747
  }
1815
1748
  }
@@ -1859,11 +1792,12 @@ class QueryParamsController {
1859
1792
  * Parse query and update filter values
1860
1793
  */
1861
1794
  fetchFromQueryParams() {
1862
- this._fetchedParams = restoreItems(this._route.snapshot.queryParams, [
1795
+ const items = [
1863
1796
  ...this._itemsStore.items,
1864
1797
  this._itemsStore.sortByItem,
1865
1798
  this._itemsStore.sortDirectionItem,
1866
- ], this._paramsCase);
1799
+ ].filter((item) => !!item);
1800
+ this._fetchedParams = restoreItems(this._route.snapshot.queryParams, items, this._paramsCase);
1867
1801
  }
1868
1802
  }
1869
1803
  QueryParamsController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: QueryParamsController, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }, { token: FsFilterItemsStore }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -3987,7 +3921,9 @@ class FilterComponent {
3987
3921
  init() {
3988
3922
  const data = this._filterItems.valuesAsQuery();
3989
3923
  this._sort = this._filterItems.getSort();
3990
- this.config.init(data, this._sort);
3924
+ if (this.config.init) {
3925
+ this.config.init(data, this._sort);
3926
+ }
3991
3927
  this._updateChipsVisibility();
3992
3928
  }
3993
3929
  clear(event = null) {
@@ -4202,9 +4138,7 @@ class FilterComponent {
4202
4138
  ])
4203
4139
  .pipe(filter$1(([pendingParams, itemsReady]) => !pendingParams && itemsReady), takeUntil(this._destroy$))
4204
4140
  .subscribe(() => {
4205
- if (this.config.init) {
4206
- this.init();
4207
- }
4141
+ this.init();
4208
4142
  this._syncSearchInputWithKeyword();
4209
4143
  this.ready.emit();
4210
4144
  });