@annalib/anna-core 9.1.2 → 9.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.
@@ -3630,25 +3630,39 @@ class AnnaGtHelperService {
3630
3630
  }
3631
3631
  updateFiltersInURL() {
3632
3632
  let latestQueryParams = this.prepareQueryParamsOnFilter();
3633
- this.router.navigate([], {
3634
- queryParams: { filters: JSON.stringify(latestQueryParams) },
3635
- relativeTo: this.route.parent,
3636
- queryParamsHandling: 'merge'
3637
- });
3633
+ if (Object.keys(latestQueryParams).length > 0) {
3634
+ this.router.navigate([], {
3635
+ queryParams: { filters: JSON.stringify(latestQueryParams) },
3636
+ relativeTo: this.route.parent,
3637
+ queryParamsHandling: 'merge'
3638
+ });
3639
+ }
3640
+ else {
3641
+ this.router.navigate([], {
3642
+ relativeTo: this.route.parent,
3643
+ });
3644
+ }
3638
3645
  }
3639
3646
  prepareQueryParamsOnFilter() {
3640
- if (!this.annaFilterService.appliedFiltersArray.length &&
3641
- !this.annaFilterService.tooltipSelectedMap.size &&
3642
- !this.annaSortService.columnSortState.size) {
3643
- return null;
3644
- }
3645
- let query = {
3646
- appliedFilters: this.annaFilterService.appliedFiltersArray,
3647
- selectedFilterData: JSON.stringify(Array.from(this.annaFilterService.tooltipSelectedMap)),
3648
- sortState: JSON.stringify(Array.from(this.annaSortService.columnSortState))
3649
- };
3647
+ let query = {};
3648
+ if (this.annaFilterService.appliedFiltersArray.length > 0) {
3649
+ query["appliedFilters"] = this.annaFilterService.appliedFiltersArray;
3650
+ query["selectedFilterData"] = JSON.stringify(Array.from(this.annaFilterService.tooltipSelectedMap));
3651
+ }
3652
+ if (this.checkIfSortingIsApplied()) {
3653
+ query["sortState"] = JSON.stringify(Array.from(this.annaSortService.columnSortState));
3654
+ }
3650
3655
  return query;
3651
3656
  }
3657
+ checkIfSortingIsApplied() {
3658
+ let isSortingApplied = false;
3659
+ for (let val of this.annaSortService.columnSortState.values()) {
3660
+ if (val == "ASC" || val == "DESC") {
3661
+ isSortingApplied = true;
3662
+ }
3663
+ }
3664
+ return isSortingApplied;
3665
+ }
3652
3666
  initTableFilters(clonedTableData) {
3653
3667
  this.annaFilterService.tooltipSelectedMap = new Map();
3654
3668
  this.annaFilterService.selectedRadio = null;
@@ -3666,14 +3680,16 @@ class AnnaGtHelperService {
3666
3680
  if (isPersistingFilter) {
3667
3681
  usersTable = this.annaFilterService.filterData(clonedTable, "");
3668
3682
  this.annaSortService.noSortingAppliedData = cloneDeep(usersTable);
3669
- this.annaSortService.columnSortState = new Map(JSON.parse(filters.sortState));
3670
- this.annaFilterService.updateStateOfAllTheKeys(this.annaSortService.columnSortState);
3671
- usersTable = this.callSort(usersTable);
3672
3683
  }
3673
3684
  else {
3674
3685
  usersTable = clonedTable;
3675
3686
  this.annaSortService.noSortingAppliedData = cloneDeep(usersTable);
3676
3687
  }
3688
+ if (filters?.sortState) {
3689
+ this.annaSortService.columnSortState = new Map(JSON.parse(filters.sortState));
3690
+ usersTable = this.callSort(usersTable);
3691
+ }
3692
+ this.annaFilterService.updateStateOfAllTheKeys(this.annaSortService.columnSortState);
3677
3693
  return usersTable;
3678
3694
  }
3679
3695
  callSort(usersTable) {