tango-app-ui-shared 3.3.1-beta.63 → 3.3.1-beta.64

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.
@@ -3636,49 +3636,69 @@ class TrafficHeaderComponent {
3636
3636
  const data = { city, clusters: group, clientId: this.users.clientId ? this.users.clientId : this.selectedFilters.client };
3637
3637
  this.auth.getHeaderStores(data).subscribe({
3638
3638
  next: (res) => {
3639
- this.stores = res.data.storesData;
3640
- // Retrieve checked store IDs from selectedFilters
3641
- const checkedStoreIds = this.selectedFilters?.stores
3642
- ? this.selectedFilters.stores.filter((store) => store.checked).map((store) => store.storeId)
3643
- : [];
3644
- this.stores.forEach(store => {
3645
- if (checkedStoreIds.includes(store.storeId)) {
3646
- store.checked = true; // Sync the checked state with full store list
3647
- }
3648
- });
3649
- // Map the stores and retain the 'checked' status
3650
- if (this.searchStoreText.length) {
3651
- this.filteredStores = this.stores?.filter(store => store.storeName.toLowerCase().includes(this.searchStoreText));
3652
- }
3653
- else {
3654
- this.filteredStores = this.stores;
3655
- }
3656
- // Ensure selectedFilters is in sync with filteredStores
3657
- if (!this.selectedFilters.stores || !this.selectedFilters.stores.length) {
3639
+ if (res && res.code === 200) {
3640
+ this.stores = res.data.storesData;
3641
+ // Retrieve checked store IDs from selectedFilters
3642
+ const checkedStoreIds = this.selectedFilters?.stores
3643
+ ? this.selectedFilters.stores.filter((store) => store.checked).map((store) => store.storeId)
3644
+ : [];
3658
3645
  this.stores.forEach(store => {
3659
- store.checked = true; // Sync the checked state with full store list
3646
+ if (checkedStoreIds.includes(store.storeId)) {
3647
+ store.checked = true; // Sync the checked state with full store list
3648
+ }
3660
3649
  });
3661
- // No previously selected stores, mark all as checked
3662
- this.filteredStores = this.selectedFilters.stores = this.filteredStores.map(store => ({
3663
- ...store,
3664
- checked: true
3665
- }));
3650
+ // Map the stores and retain the 'checked' status
3651
+ if (this.searchStoreText.length) {
3652
+ this.filteredStores = this.stores?.filter(store => store.storeName.toLowerCase().includes(this.searchStoreText));
3653
+ }
3654
+ else {
3655
+ this.filteredStores = this.stores;
3656
+ }
3657
+ // Ensure selectedFilters is in sync with filteredStores
3658
+ if (!this.selectedFilters.stores || !this.selectedFilters.stores.length) {
3659
+ this.stores.forEach(store => {
3660
+ store.checked = true; // Sync the checked state with full store list
3661
+ });
3662
+ // No previously selected stores, mark all as checked
3663
+ this.filteredStores = this.selectedFilters.stores = this.filteredStores.map(store => ({
3664
+ ...store,
3665
+ checked: true
3666
+ }));
3667
+ }
3668
+ else {
3669
+ // Update selectedFilters to reflect current state of stores
3670
+ this.selectedFilters.stores = this.filteredStores.map(store => ({
3671
+ ...store,
3672
+ checked: store.checked
3673
+ }));
3674
+ }
3675
+ // Update localStorage with the latest selectedFilters
3676
+ localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
3677
+ // Emit data via service
3678
+ // this.gs.dataRangeValue.next(this.selectedFilters);
3679
+ // Trigger change detection to reflect changes in the UI
3680
+ this.cd.detectChanges();
3666
3681
  }
3667
3682
  else {
3668
- // Update selectedFilters to reflect current state of stores
3683
+ this.stores = [];
3684
+ this.selectedFilters.stores = [];
3685
+ this.filteredStores = [];
3669
3686
  this.selectedFilters.stores = this.filteredStores.map(store => ({
3670
3687
  ...store,
3671
- checked: store.checked
3688
+ checked: false
3672
3689
  }));
3690
+ localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
3673
3691
  }
3674
- // Update localStorage with the latest selectedFilters
3675
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
3676
- // Emit data via service
3677
- // this.gs.dataRangeValue.next(this.selectedFilters);
3678
- // Trigger change detection to reflect changes in the UI
3679
- this.cd.detectChanges();
3680
3692
  },
3681
3693
  error: (err) => {
3694
+ this.stores = [];
3695
+ this.selectedFilters.stores = this.filteredStores.map(store => ({
3696
+ ...store,
3697
+ checked: false
3698
+ }));
3699
+ this.filteredStores = [];
3700
+ this.selectedFilters.stores = [];
3701
+ localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
3682
3702
  console.error("Failed to fetch stores", err);
3683
3703
  },
3684
3704
  });
@@ -4417,49 +4437,69 @@ class TraxHeaderComponent {
4417
4437
  const data = { city, clusters: group, clientId: this.users.clientId ? this.users.clientId : this.selectedFilters.client };
4418
4438
  this.auth.getHeaderStores(data).subscribe({
4419
4439
  next: (res) => {
4420
- this.stores = res.data.storesData;
4421
- // Retrieve checked store IDs from selectedFilters
4422
- const checkedStoreIds = this.selectedFilters?.stores
4423
- ? this.selectedFilters.stores.filter((store) => store.checked).map((store) => store.storeId)
4424
- : [];
4425
- this.stores.forEach(store => {
4426
- if (checkedStoreIds.includes(store.storeId)) {
4427
- store.checked = true; // Sync the checked state with full store list
4428
- }
4429
- });
4430
- // Map the stores and retain the 'checked' status
4431
- if (this.searchStoreText.length) {
4432
- this.filteredStores = this.stores?.filter(store => store.storeName.toLowerCase().includes(this.searchStoreText));
4433
- }
4434
- else {
4435
- this.filteredStores = this.stores;
4436
- }
4437
- // Ensure selectedFilters is in sync with filteredStores
4438
- if (!this.selectedFilters.stores || !this.selectedFilters.stores.length) {
4440
+ if (res && res.code === 200) {
4441
+ this.stores = res.data.storesData;
4442
+ // Retrieve checked store IDs from selectedFilters
4443
+ const checkedStoreIds = this.selectedFilters?.stores
4444
+ ? this.selectedFilters.stores.filter((store) => store.checked).map((store) => store.storeId)
4445
+ : [];
4439
4446
  this.stores.forEach(store => {
4440
- store.checked = true; // Sync the checked state with full store list
4447
+ if (checkedStoreIds.includes(store.storeId)) {
4448
+ store.checked = true; // Sync the checked state with full store list
4449
+ }
4441
4450
  });
4442
- // No previously selected stores, mark all as checked
4443
- this.filteredStores = this.selectedFilters.stores = this.filteredStores.map(store => ({
4444
- ...store,
4445
- checked: true
4446
- }));
4451
+ // Map the stores and retain the 'checked' status
4452
+ if (this.searchStoreText.length) {
4453
+ this.filteredStores = this.stores?.filter(store => store.storeName.toLowerCase().includes(this.searchStoreText));
4454
+ }
4455
+ else {
4456
+ this.filteredStores = this.stores;
4457
+ }
4458
+ // Ensure selectedFilters is in sync with filteredStores
4459
+ if (!this.selectedFilters.stores || !this.selectedFilters.stores.length) {
4460
+ this.stores.forEach(store => {
4461
+ store.checked = true; // Sync the checked state with full store list
4462
+ });
4463
+ // No previously selected stores, mark all as checked
4464
+ this.filteredStores = this.selectedFilters.stores = this.filteredStores.map(store => ({
4465
+ ...store,
4466
+ checked: true
4467
+ }));
4468
+ }
4469
+ else {
4470
+ // Update selectedFilters to reflect current state of stores
4471
+ this.selectedFilters.stores = this.filteredStores.map(store => ({
4472
+ ...store,
4473
+ checked: store.checked
4474
+ }));
4475
+ }
4476
+ // Update localStorage with the latest selectedFilters
4477
+ localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
4478
+ // Emit data via service
4479
+ // this.gs.dataRangeValue.next(this.selectedFilters);
4480
+ // Trigger change detection to reflect changes in the UI
4481
+ this.cd.detectChanges();
4447
4482
  }
4448
4483
  else {
4449
- // Update selectedFilters to reflect current state of stores
4484
+ this.stores = [];
4485
+ this.selectedFilters.stores = [];
4486
+ this.filteredStores = [];
4450
4487
  this.selectedFilters.stores = this.filteredStores.map(store => ({
4451
4488
  ...store,
4452
- checked: store.checked
4489
+ checked: false
4453
4490
  }));
4491
+ localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
4454
4492
  }
4455
- // Update localStorage with the latest selectedFilters
4456
- localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
4457
- // Emit data via service
4458
- // this.gs.dataRangeValue.next(this.selectedFilters);
4459
- // Trigger change detection to reflect changes in the UI
4460
- this.cd.detectChanges();
4461
4493
  },
4462
4494
  error: (err) => {
4495
+ this.stores = [];
4496
+ this.selectedFilters.stores = [];
4497
+ this.filteredStores = [];
4498
+ this.selectedFilters.stores = this.filteredStores.map(store => ({
4499
+ ...store,
4500
+ checked: false
4501
+ }));
4502
+ localStorage.setItem('header-filters', JSON.stringify(this.selectedFilters));
4463
4503
  console.error("Failed to fetch stores", err);
4464
4504
  },
4465
4505
  });
@@ -4816,8 +4856,11 @@ class ToolbarComponent {
4816
4856
  this.appPageTitleDescription = this.layout.getProp("app.pageTitle.description", config);
4817
4857
  document.body.setAttribute("data-kt-app-toolbar-enabled", "true");
4818
4858
  }
4859
+ destroy$ = new Subject();
4819
4860
  ngOnDestroy() {
4820
4861
  this.unsubscribe.forEach((sb) => sb.unsubscribe());
4862
+ this.destroy$.next(true);
4863
+ this.destroy$.complete();
4821
4864
  }
4822
4865
  showPageTitle() {
4823
4866
  let URL = "";