@ecodev/natural 38.0.0 → 38.0.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.
@@ -3443,11 +3443,14 @@
3443
3443
  /**
3444
3444
  * Persist search and then launch whatever is required to refresh the list
3445
3445
  */
3446
- NaturalAbstractList.prototype.search = function (naturalSearchSelections, navigationExtras) {
3446
+ NaturalAbstractList.prototype.search = function (naturalSearchSelections, navigationExtras, resetPagination) {
3447
+ if (resetPagination === void 0) { resetPagination = true; }
3447
3448
  // Reset page index to restart the pagination (preserve pageSize)
3448
- this.variablesManager.merge('pagination', {
3449
- pagination: lodashEs.pick(this.defaultPagination, ['offset', 'pageIndex']),
3450
- });
3449
+ if (resetPagination) {
3450
+ this.variablesManager.merge('pagination', {
3451
+ pagination: lodashEs.pick(this.defaultPagination, ['offset', 'pageIndex']),
3452
+ });
3453
+ }
3451
3454
  // Persist if activated
3452
3455
  // Two parallel navigations conflict. We first persist the search, then the pagination
3453
3456
  if (this.persistSearch && !this.isPanel) {
@@ -3771,6 +3774,7 @@
3771
3774
  * Name of filter for child items to access ancestor item
3772
3775
  */
3773
3776
  _this.ancestorRelationName = 'parent';
3777
+ _this.oldAncertorId = null;
3774
3778
  _this.breadcrumbs = [];
3775
3779
  return _this;
3776
3780
  }
@@ -3781,27 +3785,30 @@
3781
3785
  // "na" is a trailing param, and should be considered only when there is no search
3782
3786
  this.route.params.subscribe(function (params) {
3783
3787
  // "ns" stands for natural-search to be shorter in url
3784
- if (!params['ns']) {
3785
- var navigationConditionValue = null;
3786
- // "na" stands for "navigation" (relation) in url
3787
- if (params['na']) {
3788
- navigationConditionValue = { have: { values: [params['na']] } };
3789
- _this.service.getOne(params['na']).subscribe(
3790
- // TODO casting should disappear and instead this class should enforce
3791
- // the service to support Tone with a new generic
3792
- function (ancestor) { return (_this.breadcrumbs = _this.getBreadcrumb(ancestor)); });
3793
- _this.clearSearch();
3794
- }
3795
- else {
3796
- navigationConditionValue = { empty: {} };
3797
- _this.breadcrumbs = [];
3798
- }
3799
- var condition = {};
3800
- condition[_this.ancestorRelationName] = navigationConditionValue;
3801
- var variables = { filter: { groups: [{ conditions: [condition] }] } };
3802
- // todo : check why without "as Vall" it errors. Vall is supposed to be QueryVariables, and filter too.
3803
- _this.variablesManager.set('navigation', variables);
3788
+ if (params['ns']) {
3789
+ return;
3790
+ }
3791
+ var navigationConditionValue = null;
3792
+ // "na" stands for "navigation" (relation) in url
3793
+ if (params['na']) {
3794
+ navigationConditionValue = { have: { values: [params['na']] } };
3795
+ _this.service.getOne(params['na']).subscribe(
3796
+ // TODO casting should disappear and instead this class should enforce
3797
+ // the service to support Tone with a new generic
3798
+ function (ancestor) { return (_this.breadcrumbs = _this.getBreadcrumb(ancestor)); });
3799
+ var hasAncestorChanged = params['na'] !== _this.oldAncertorId;
3800
+ _this.oldAncertorId = params['na'];
3801
+ _this.clearSearch(hasAncestorChanged);
3804
3802
  }
3803
+ else {
3804
+ navigationConditionValue = { empty: {} };
3805
+ _this.breadcrumbs = [];
3806
+ }
3807
+ var condition = {};
3808
+ condition[_this.ancestorRelationName] = navigationConditionValue;
3809
+ var variables = { filter: { groups: [{ conditions: [condition] }] } };
3810
+ // todo : check why without "as Vall" it errors. Vall is supposed to be QueryVariables, and filter too.
3811
+ _this.variablesManager.set('navigation', variables);
3805
3812
  });
3806
3813
  _super.prototype.ngOnInit.call(this);
3807
3814
  };
@@ -3834,11 +3841,19 @@
3834
3841
  }
3835
3842
  _super.prototype.translateSearchAndRefreshList.call(this, naturalSearchSelections);
3836
3843
  };
3837
- NaturalAbstractNavigableList.prototype.clearSearch = function () {
3844
+ NaturalAbstractNavigableList.prototype.clearSearch = function (resetPagination) {
3845
+ if (resetPagination === void 0) { resetPagination = true; }
3838
3846
  this.naturalSearchSelections = [[]];
3839
- this.search([[]]);
3847
+ _super.prototype.search.call(this, [[]], undefined, resetPagination);
3840
3848
  this.persistenceService.persistInStorage('ns', null, this.getStorageKey());
3841
3849
  };
3850
+ NaturalAbstractNavigableList.prototype.search = function (naturalSearchSelections, navigationExtras, resetPagination) {
3851
+ var _this = this;
3852
+ if (resetPagination === void 0) { resetPagination = true; }
3853
+ this.persistenceService.persistInUrl('na', null, this.route).then(function () {
3854
+ _super.prototype.search.call(_this, naturalSearchSelections, navigationExtras, resetPagination);
3855
+ });
3856
+ };
3842
3857
  /**
3843
3858
  * Return an array for router link usage
3844
3859
  */