@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.
@@ -419,8 +419,8 @@ class SimpleSelectItem extends BaseSelectItem {
419
419
  }
420
420
  }
421
421
 
422
- const SORT_BY_FIELD = 'system_sort_by';
423
- const SORT_DIRECTION_FIELD = 'system_sort_direction';
422
+ const SORT_BY_FIELD = 'sortName';
423
+ const SORT_DIRECTION_FIELD = 'sortDirection';
424
424
  class FsFilterConfig extends Model {
425
425
  constructor(data = {}) {
426
426
  super();
@@ -1495,7 +1495,7 @@ class FsFilterItemsStore {
1495
1495
  .forEach((item) => {
1496
1496
  item.initValues(p[item.name]);
1497
1497
  });
1498
- this._createSortingItems(p);
1498
+ this._initSortingItems(p);
1499
1499
  this.loadAsyncDefaults();
1500
1500
  this._subscribeToItemsChanges();
1501
1501
  }
@@ -1567,6 +1567,7 @@ class FsFilterItemsStore {
1567
1567
  this._itemsByName.set(item.name, filterItem);
1568
1568
  return filterItem;
1569
1569
  });
1570
+ this._createSortingItems();
1570
1571
  }
1571
1572
  _subscribeToItemsChanges() {
1572
1573
  var _a;
@@ -1599,7 +1600,13 @@ class FsFilterItemsStore {
1599
1600
  this._setKeywordItem();
1600
1601
  });
1601
1602
  }
1602
- _createSortingItems(p) {
1603
+ _initSortingItems(p) {
1604
+ if (this.sortByItem && this.sortDirectionItem) {
1605
+ this.sortByItem.initValues(p[this.sortByItem.name]);
1606
+ this.sortDirectionItem.initValues(p[this.sortDirectionItem.name]);
1607
+ }
1608
+ }
1609
+ _createSortingItems() {
1603
1610
  var _a;
1604
1611
  if (((_a = this._config.sortValues) === null || _a === void 0 ? void 0 : _a.length) > 0) {
1605
1612
  const sortByItem = {
@@ -1612,7 +1619,6 @@ class FsFilterItemsStore {
1612
1619
  sortByItem.default = this._config.sort.value;
1613
1620
  }
1614
1621
  this.sortByItem = new SimpleSelectItem(sortByItem, null);
1615
- this.sortByItem.initValues(p[this.sortByItem.name]);
1616
1622
  const sortDirectionItem = {
1617
1623
  name: SORT_DIRECTION_FIELD,
1618
1624
  type: ItemType.Select,
@@ -1626,7 +1632,6 @@ class FsFilterItemsStore {
1626
1632
  sortDirectionItem.default = this._config.sort.direction;
1627
1633
  }
1628
1634
  this.sortDirectionItem = new SimpleSelectItem(sortDirectionItem, null);
1629
- this.sortDirectionItem.initValues(p[this.sortDirectionItem.name]);
1630
1635
  }
1631
1636
  }
1632
1637
  _setKeywordItem() {
@@ -1800,7 +1805,11 @@ class PersistanceParamsController extends FsPersistanceStore {
1800
1805
  restore() {
1801
1806
  super.restore();
1802
1807
  if (this._value) {
1803
- this._value.data = restoreItems(this._value.data, this._itemsStore.items, this._paramsCase);
1808
+ this._value.data = restoreItems(this._value.data, [
1809
+ ...this._itemsStore.items,
1810
+ this._itemsStore.sortByItem,
1811
+ this._itemsStore.sortDirectionItem,
1812
+ ], this._paramsCase);
1804
1813
  }
1805
1814
  }
1806
1815
  }
@@ -1850,7 +1859,11 @@ class QueryParamsController {
1850
1859
  * Parse query and update filter values
1851
1860
  */
1852
1861
  fetchFromQueryParams() {
1853
- this._fetchedParams = restoreItems(this._route.snapshot.queryParams, this._itemsStore.items, this._paramsCase);
1862
+ this._fetchedParams = restoreItems(this._route.snapshot.queryParams, [
1863
+ ...this._itemsStore.items,
1864
+ this._itemsStore.sortByItem,
1865
+ this._itemsStore.sortDirectionItem,
1866
+ ], this._paramsCase);
1854
1867
  }
1855
1868
  }
1856
1869
  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 });
@@ -3974,7 +3987,9 @@ class FilterComponent {
3974
3987
  init() {
3975
3988
  const data = this._filterItems.valuesAsQuery();
3976
3989
  this._sort = this._filterItems.getSort();
3977
- this.config.init(data, this._sort);
3990
+ if (this.config.init) {
3991
+ this.config.init(data, this._sort);
3992
+ }
3978
3993
  this._updateChipsVisibility();
3979
3994
  }
3980
3995
  clear(event = null) {
@@ -4189,9 +4204,7 @@ class FilterComponent {
4189
4204
  ])
4190
4205
  .pipe(filter$1(([pendingParams, itemsReady]) => !pendingParams && itemsReady), takeUntil(this._destroy$))
4191
4206
  .subscribe(() => {
4192
- if (this.config.init) {
4193
- this.init();
4194
- }
4207
+ this.init();
4195
4208
  this._syncSearchInputWithKeyword();
4196
4209
  this.ready.emit();
4197
4210
  });