@firestitch/filter 12.1.0 → 12.1.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.
@@ -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 = "system_sort_by";
7
- export declare const SORT_DIRECTION_FIELD = "system_sort_direction";
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 = 'system_sort_by';
980
- var SORT_DIRECTION_FIELD = 'system_sort_direction';
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._createSortingItems(p);
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._createSortingItems = function (p) {
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,7 @@
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, this._paramsCase);
2557
+ this._value.data = restoreItems(this._value.data, [this._itemsStore.items, this._itemsStore.sortByItem, this._itemsStore.sortDirectionItem], this._paramsCase);
2553
2558
  }
2554
2559
  };
2555
2560
  return PersistanceParamsController;
@@ -2610,7 +2615,7 @@
2610
2615
  * Parse query and update filter values
2611
2616
  */
2612
2617
  QueryParamsController.prototype.fetchFromQueryParams = function () {
2613
- this._fetchedParams = restoreItems(this._route.snapshot.queryParams, this._itemsStore.items, this._paramsCase);
2618
+ this._fetchedParams = restoreItems(this._route.snapshot.queryParams, [this._itemsStore.items, this._itemsStore.sortByItem, this._itemsStore.sortDirectionItem], this._paramsCase);
2614
2619
  };
2615
2620
  return QueryParamsController;
2616
2621
  }());