@firestitch/filter 12.1.1 → 12.2.0
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/app/interfaces/config.interface.d.ts +2 -2
- package/app/models/filter-config.d.ts +1 -4
- package/bundles/firestitch-filter.umd.js +59 -120
- package/bundles/firestitch-filter.umd.js.map +1 -1
- package/esm2015/app/components/filter/filter.component.js +5 -5
- package/esm2015/app/interfaces/config.interface.js +1 -1
- package/esm2015/app/models/filter-config.js +33 -101
- package/esm2015/app/services/external-params/persistance-params-controller.service.js +6 -2
- package/esm2015/app/services/external-params/query-params-controller.service.js +6 -2
- package/fesm2015/firestitch-filter.js +47 -107
- package/fesm2015/firestitch-filter.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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
|
-
|
|
431
|
+
// public sortDirection = null;
|
|
435
432
|
this.queryParam = false;
|
|
436
433
|
this.case = 'camel';
|
|
437
|
-
this.
|
|
438
|
-
|
|
439
|
-
}
|
|
440
|
-
|
|
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) {
|
|
@@ -1805,7 +1737,11 @@ class PersistanceParamsController extends FsPersistanceStore {
|
|
|
1805
1737
|
restore() {
|
|
1806
1738
|
super.restore();
|
|
1807
1739
|
if (this._value) {
|
|
1808
|
-
this._value.data = restoreItems(this._value.data, [
|
|
1740
|
+
this._value.data = restoreItems(this._value.data, [
|
|
1741
|
+
...this._itemsStore.items,
|
|
1742
|
+
this._itemsStore.sortByItem,
|
|
1743
|
+
this._itemsStore.sortDirectionItem,
|
|
1744
|
+
], this._paramsCase);
|
|
1809
1745
|
}
|
|
1810
1746
|
}
|
|
1811
1747
|
}
|
|
@@ -1855,7 +1791,11 @@ class QueryParamsController {
|
|
|
1855
1791
|
* Parse query and update filter values
|
|
1856
1792
|
*/
|
|
1857
1793
|
fetchFromQueryParams() {
|
|
1858
|
-
this._fetchedParams = restoreItems(this._route.snapshot.queryParams, [
|
|
1794
|
+
this._fetchedParams = restoreItems(this._route.snapshot.queryParams, [
|
|
1795
|
+
...this._itemsStore.items,
|
|
1796
|
+
this._itemsStore.sortByItem,
|
|
1797
|
+
this._itemsStore.sortDirectionItem,
|
|
1798
|
+
], this._paramsCase);
|
|
1859
1799
|
}
|
|
1860
1800
|
}
|
|
1861
1801
|
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 });
|
|
@@ -3979,7 +3919,9 @@ class FilterComponent {
|
|
|
3979
3919
|
init() {
|
|
3980
3920
|
const data = this._filterItems.valuesAsQuery();
|
|
3981
3921
|
this._sort = this._filterItems.getSort();
|
|
3982
|
-
this.config.init
|
|
3922
|
+
if (this.config.init) {
|
|
3923
|
+
this.config.init(data, this._sort);
|
|
3924
|
+
}
|
|
3983
3925
|
this._updateChipsVisibility();
|
|
3984
3926
|
}
|
|
3985
3927
|
clear(event = null) {
|
|
@@ -4194,9 +4136,7 @@ class FilterComponent {
|
|
|
4194
4136
|
])
|
|
4195
4137
|
.pipe(filter$1(([pendingParams, itemsReady]) => !pendingParams && itemsReady), takeUntil(this._destroy$))
|
|
4196
4138
|
.subscribe(() => {
|
|
4197
|
-
|
|
4198
|
-
this.init();
|
|
4199
|
-
}
|
|
4139
|
+
this.init();
|
|
4200
4140
|
this._syncSearchInputWithKeyword();
|
|
4201
4141
|
this.ready.emit();
|
|
4202
4142
|
});
|