@firestitch/filter 12.1.0 → 12.1.3
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/models/filter-config.d.ts +2 -2
- package/app/services/items-store.service.d.ts +1 -0
- package/bundles/firestitch-filter.umd.js +23 -12
- package/bundles/firestitch-filter.umd.js.map +1 -1
- package/esm2015/app/components/filter/filter.component.js +5 -5
- package/esm2015/app/models/filter-config.js +3 -3
- 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/esm2015/app/services/items-store.service.js +10 -5
- package/fesm2015/firestitch-filter.js +25 -12
- package/fesm2015/firestitch-filter.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@ import { FilterButton, FilterConfig, FsFilterPersistance, IFilterConfigItem } fr
|
|
|
3
3
|
import { ChangeFn, Sort } from '../interfaces/config.interface';
|
|
4
4
|
import { IFilterSavedFiltersConfig } from '../interfaces/saved-filters.interface';
|
|
5
5
|
import { FsFilterAction } from '../interfaces/action.interface';
|
|
6
|
-
export declare const SORT_BY_FIELD = "
|
|
7
|
-
export declare const SORT_DIRECTION_FIELD = "
|
|
6
|
+
export declare const SORT_BY_FIELD = "sortName";
|
|
7
|
+
export declare const SORT_DIRECTION_FIELD = "sortDirection";
|
|
8
8
|
export declare class FsFilterConfig extends Model {
|
|
9
9
|
load: boolean;
|
|
10
10
|
persist: FsFilterPersistance;
|
|
@@ -57,6 +57,7 @@ export declare class FsFilterItemsStore implements OnDestroy {
|
|
|
57
57
|
private _createItems;
|
|
58
58
|
private _subscribeToItemsChanges;
|
|
59
59
|
private _lazyInit;
|
|
60
|
+
private _initSortingItems;
|
|
60
61
|
private _createSortingItems;
|
|
61
62
|
private _setKeywordItem;
|
|
62
63
|
static ɵfac: i0.ɵɵFactoryDeclaration<FsFilterItemsStore, never>;
|
|
@@ -976,8 +976,8 @@
|
|
|
976
976
|
return SimpleSelectItem;
|
|
977
977
|
}(BaseSelectItem));
|
|
978
978
|
|
|
979
|
-
var SORT_BY_FIELD = '
|
|
980
|
-
var SORT_DIRECTION_FIELD = '
|
|
979
|
+
var SORT_BY_FIELD = 'sortName';
|
|
980
|
+
var SORT_DIRECTION_FIELD = 'sortDirection';
|
|
981
981
|
var FsFilterConfig = /** @class */ (function (_super) {
|
|
982
982
|
__extends(FsFilterConfig, _super);
|
|
983
983
|
function FsFilterConfig(data) {
|
|
@@ -2244,7 +2244,7 @@
|
|
|
2244
2244
|
.forEach(function (item) {
|
|
2245
2245
|
item.initValues(p[item.name]);
|
|
2246
2246
|
});
|
|
2247
|
-
this.
|
|
2247
|
+
this._initSortingItems(p);
|
|
2248
2248
|
this.loadAsyncDefaults();
|
|
2249
2249
|
this._subscribeToItemsChanges();
|
|
2250
2250
|
};
|
|
@@ -2317,6 +2317,7 @@
|
|
|
2317
2317
|
_this._itemsByName.set(item.name, filterItem);
|
|
2318
2318
|
return filterItem;
|
|
2319
2319
|
});
|
|
2320
|
+
this._createSortingItems();
|
|
2320
2321
|
};
|
|
2321
2322
|
FsFilterItemsStore.prototype._subscribeToItemsChanges = function () {
|
|
2322
2323
|
var _this = this;
|
|
@@ -2351,7 +2352,13 @@
|
|
|
2351
2352
|
_this._setKeywordItem();
|
|
2352
2353
|
});
|
|
2353
2354
|
};
|
|
2354
|
-
FsFilterItemsStore.prototype.
|
|
2355
|
+
FsFilterItemsStore.prototype._initSortingItems = function (p) {
|
|
2356
|
+
if (this.sortByItem && this.sortDirectionItem) {
|
|
2357
|
+
this.sortByItem.initValues(p[this.sortByItem.name]);
|
|
2358
|
+
this.sortDirectionItem.initValues(p[this.sortDirectionItem.name]);
|
|
2359
|
+
}
|
|
2360
|
+
};
|
|
2361
|
+
FsFilterItemsStore.prototype._createSortingItems = function () {
|
|
2355
2362
|
var _a;
|
|
2356
2363
|
if (((_a = this._config.sortValues) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
2357
2364
|
var sortByItem = {
|
|
@@ -2364,7 +2371,6 @@
|
|
|
2364
2371
|
sortByItem.default = this._config.sort.value;
|
|
2365
2372
|
}
|
|
2366
2373
|
this.sortByItem = new SimpleSelectItem(sortByItem, null);
|
|
2367
|
-
this.sortByItem.initValues(p[this.sortByItem.name]);
|
|
2368
2374
|
var sortDirectionItem = {
|
|
2369
2375
|
name: SORT_DIRECTION_FIELD,
|
|
2370
2376
|
type: exports.ItemType.Select,
|
|
@@ -2378,7 +2384,6 @@
|
|
|
2378
2384
|
sortDirectionItem.default = this._config.sort.direction;
|
|
2379
2385
|
}
|
|
2380
2386
|
this.sortDirectionItem = new SimpleSelectItem(sortDirectionItem, null);
|
|
2381
|
-
this.sortDirectionItem.initValues(p[this.sortDirectionItem.name]);
|
|
2382
2387
|
}
|
|
2383
2388
|
};
|
|
2384
2389
|
FsFilterItemsStore.prototype._setKeywordItem = function () {
|
|
@@ -2549,7 +2554,10 @@
|
|
|
2549
2554
|
PersistanceParamsController.prototype.restore = function () {
|
|
2550
2555
|
_super.prototype.restore.call(this);
|
|
2551
2556
|
if (this._value) {
|
|
2552
|
-
this._value.data = restoreItems(this._value.data, this._itemsStore.items,
|
|
2557
|
+
this._value.data = restoreItems(this._value.data, __spreadArray(__spreadArray([], __read(this._itemsStore.items)), [
|
|
2558
|
+
this._itemsStore.sortByItem,
|
|
2559
|
+
this._itemsStore.sortDirectionItem,
|
|
2560
|
+
]), this._paramsCase);
|
|
2553
2561
|
}
|
|
2554
2562
|
};
|
|
2555
2563
|
return PersistanceParamsController;
|
|
@@ -2610,7 +2618,10 @@
|
|
|
2610
2618
|
* Parse query and update filter values
|
|
2611
2619
|
*/
|
|
2612
2620
|
QueryParamsController.prototype.fetchFromQueryParams = function () {
|
|
2613
|
-
this._fetchedParams = restoreItems(this._route.snapshot.queryParams, this._itemsStore.items,
|
|
2621
|
+
this._fetchedParams = restoreItems(this._route.snapshot.queryParams, __spreadArray(__spreadArray([], __read(this._itemsStore.items)), [
|
|
2622
|
+
this._itemsStore.sortByItem,
|
|
2623
|
+
this._itemsStore.sortDirectionItem,
|
|
2624
|
+
]), this._paramsCase);
|
|
2614
2625
|
};
|
|
2615
2626
|
return QueryParamsController;
|
|
2616
2627
|
}());
|
|
@@ -5023,7 +5034,9 @@
|
|
|
5023
5034
|
FilterComponent.prototype.init = function () {
|
|
5024
5035
|
var data = this._filterItems.valuesAsQuery();
|
|
5025
5036
|
this._sort = this._filterItems.getSort();
|
|
5026
|
-
this.config.init
|
|
5037
|
+
if (this.config.init) {
|
|
5038
|
+
this.config.init(data, this._sort);
|
|
5039
|
+
}
|
|
5027
5040
|
this._updateChipsVisibility();
|
|
5028
5041
|
};
|
|
5029
5042
|
FilterComponent.prototype.clear = function (event) {
|
|
@@ -5250,9 +5263,7 @@
|
|
|
5250
5263
|
return !pendingParams && itemsReady;
|
|
5251
5264
|
}), operators.takeUntil(this._destroy$))
|
|
5252
5265
|
.subscribe(function () {
|
|
5253
|
-
|
|
5254
|
-
_this.init();
|
|
5255
|
-
}
|
|
5266
|
+
_this.init();
|
|
5256
5267
|
_this._syncSearchInputWithKeyword();
|
|
5257
5268
|
_this.ready.emit();
|
|
5258
5269
|
});
|