@sinequa/atomic-angular 1.7.0 → 1.7.2

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.
@@ -1861,7 +1861,10 @@ function withQueryParamsFeatures() {
1861
1861
  return { ...state, path, text, filters, id, page, sort, spellingCorrectionMode, tab, basket, name };
1862
1862
  });
1863
1863
  },
1864
- _updateUrlQueryParams(state, audit) {
1864
+ _updateUrlQueryParams(state, audit, options) {
1865
+ // Opting out of URL sync keeps the store state authoritative without navigating.
1866
+ if (options?.syncUrl === false)
1867
+ return;
1865
1868
  const { filters, page, sort, tab, text, basket, name } = state;
1866
1869
  const queryParams = {
1867
1870
  f: filters && filters.length > 0 ? JSON.stringify(filters) : undefined,
@@ -1893,8 +1896,8 @@ function withQueryParamsFeatures() {
1893
1896
  *
1894
1897
  * The function calls the `updateFilter` method to add the filter to the state.
1895
1898
  */
1896
- addFilter(filter, audit) {
1897
- this.updateFilter(filter, audit);
1899
+ addFilter(filter, audit, options) {
1900
+ this.updateFilter(filter, audit, options);
1898
1901
  },
1899
1902
  /**
1900
1903
  * Updates the filter in the store's state.
@@ -1986,9 +1989,7 @@ function withQueryParamsFeatures() {
1986
1989
  }
1987
1990
  }
1988
1991
  }
1989
- if (options?.syncUrl !== false) {
1990
- this._updateUrlQueryParams(newState || state, audit);
1991
- }
1992
+ this._updateUrlQueryParams(newState || state, audit, options);
1992
1993
  return newState || state;
1993
1994
  });
1994
1995
  },
@@ -2003,9 +2004,7 @@ function withQueryParamsFeatures() {
2003
2004
  patchState(store, (state) => {
2004
2005
  const filters = state.filters?.filter((f) => f.field !== field);
2005
2006
  const newState = { ...state, filters };
2006
- if (options?.syncUrl !== false) {
2007
- this._updateUrlQueryParams(newState);
2008
- }
2007
+ this._updateUrlQueryParams(newState, undefined, options);
2009
2008
  return newState;
2010
2009
  });
2011
2010
  },
@@ -2025,9 +2024,7 @@ function withQueryParamsFeatures() {
2025
2024
  patchState(store, (state) => {
2026
2025
  const filters = state.filters?.filter((f) => f.name !== name);
2027
2026
  const newState = { ...state, filters };
2028
- if (options?.syncUrl !== false) {
2029
- this._updateUrlQueryParams(newState);
2030
- }
2027
+ this._updateUrlQueryParams(newState, undefined, options);
2031
2028
  return newState;
2032
2029
  });
2033
2030
  },
@@ -2038,10 +2035,10 @@ function withQueryParamsFeatures() {
2038
2035
  * along with the basket going undefined
2039
2036
  * It uses the `patchState` function to apply the state change.
2040
2037
  */
2041
- clearFilters() {
2038
+ clearFilters(options) {
2042
2039
  patchState(store, (state) => {
2043
2040
  const newState = { ...state, filters: [], basket: undefined };
2044
- this._updateUrlQueryParams(newState);
2041
+ this._updateUrlQueryParams(newState, undefined, options);
2045
2042
  return newState;
2046
2043
  });
2047
2044
  },
@@ -2051,10 +2048,10 @@ function withQueryParamsFeatures() {
2051
2048
  * This method updates the state by setting the `basket` property to undefined.
2052
2049
  * It uses the `patchState` function to apply the state change.
2053
2050
  */
2054
- clearBasket() {
2051
+ clearBasket(options) {
2055
2052
  patchState(store, (state) => {
2056
2053
  const newState = { ...state, basket: undefined };
2057
- this._updateUrlQueryParams(newState);
2054
+ this._updateUrlQueryParams(newState, undefined, options);
2058
2055
  return newState;
2059
2056
  });
2060
2057
  },
@@ -2063,12 +2060,12 @@ function withQueryParamsFeatures() {
2063
2060
  *
2064
2061
  * @param params - A partial object containing the query parameters to be updated.
2065
2062
  */
2066
- patch(params, audit) {
2063
+ patch(params, audit, options) {
2067
2064
  patchState(store, (state) => {
2068
2065
  // get the hash path without the query params and without the leading '#'
2069
2066
  const path = window.location.hash.split("?")[0].replace(/^#/, "");
2070
2067
  const newState = { ...state, ...params, path };
2071
- this._updateUrlQueryParams(newState, audit);
2068
+ this._updateUrlQueryParams(newState, audit, options);
2072
2069
  return newState;
2073
2070
  });
2074
2071
  },
@@ -2893,7 +2890,7 @@ function withSavedSearchesFeatures() {
2893
2890
  return { ...state, savedSearches: [...savedSearches] };
2894
2891
  });
2895
2892
  },
2896
- getSavedSearch(search) {
2893
+ getSavedSearch(search, tab) {
2897
2894
  if (!search)
2898
2895
  return undefined;
2899
2896
  const savedSearches = store.savedSearches();
@@ -2902,7 +2899,15 @@ function withSavedSearchesFeatures() {
2902
2899
  if (!queryParams)
2903
2900
  return false;
2904
2901
  const q = queryParams.split('&').find(qp => qp.startsWith('q='));
2905
- return !!q && decodeURI(q.substring(2)) === search;
2902
+ const qMatch = !!q && decodeURI(q.substring(2)) === search;
2903
+ if (!qMatch)
2904
+ return false;
2905
+ // If tab is provided, check it; otherwise accept any tab
2906
+ if (tab) {
2907
+ const t = queryParams.split('&').find(qp => qp.startsWith('t='));
2908
+ return !!t && decodeURI(t.substring(2)) === tab;
2909
+ }
2910
+ return true;
2906
2911
  });
2907
2912
  }
2908
2913
  })));
@@ -4721,9 +4726,10 @@ class SavedSearchesService {
4721
4726
  *
4722
4727
  * @throws {Error} If saving an empty search is attempted.
4723
4728
  */
4724
- saveSearch(saveName) {
4725
- const { text } = getState(this.queryParamsStore);
4729
+ saveSearch(saveName, saveTab) {
4730
+ const { text, tab } = getState(this.queryParamsStore);
4726
4731
  const display = saveName || text;
4732
+ const tabName = saveTab || tab;
4727
4733
  if (!display) {
4728
4734
  console.error("Saving empty search is not allowed");
4729
4735
  return;
@@ -4731,6 +4737,7 @@ class SavedSearchesService {
4731
4737
  const savedSearch = {
4732
4738
  url: window.location.hash.substring(1),
4733
4739
  date: new Date().toISOString(),
4740
+ tab: tabName,
4734
4741
  display
4735
4742
  };
4736
4743
  const savedSearches = this.userSettingsStore.savedSearches();
@@ -5734,9 +5741,7 @@ class CollectionsDialog {
5734
5741
  closed = output();
5735
5742
  createInputElement = viewChild("createInput", ...(ngDevMode ? [{ debugName: "createInputElement" }] : []));
5736
5743
  dialogElement = viewChild(DialogComponent, ...(ngDevMode ? [{ debugName: "dialogElement" }] : []));
5737
- queryParamStore = inject(QueryParamsStore);
5738
5744
  userSettingsStore = inject(UserSettingsStore);
5739
- collection = signal(undefined, ...(ngDevMode ? [{ debugName: "collection" }] : []));
5740
5745
  article = signal([], ...(ngDevMode ? [{ debugName: "article" }] : []));
5741
5746
  newCollectionName = signal("", ...(ngDevMode ? [{ debugName: "newCollectionName" }] : []));
5742
5747
  creating = signal(false, ...(ngDevMode ? [{ debugName: "creating" }] : []));
@@ -5753,8 +5758,6 @@ class CollectionsDialog {
5753
5758
  this.article.set([article]);
5754
5759
  else
5755
5760
  this.article.set(article);
5756
- const { basket } = getState(this.queryParamStore);
5757
- this.collection.set(basket);
5758
5761
  this.dialogElement()?.showModal();
5759
5762
  }
5760
5763
  containsArticleByName(collectionName) {
@@ -5803,6 +5806,7 @@ class CollectionsDialog {
5803
5806
  // remove it
5804
5807
  const articleIds = this.article().map((a) => a.id);
5805
5808
  collection.ids = collection.ids?.filter((id) => !articleIds.includes(id)) ?? [];
5809
+ this.removedFromCollection.set(true);
5806
5810
  }
5807
5811
  else {
5808
5812
  // add it
@@ -5814,8 +5818,6 @@ class CollectionsDialog {
5814
5818
  }
5815
5819
  try {
5816
5820
  await this.userSettingsStore.updateBasket(collection, collectionIndex);
5817
- const currentCollection = this.collection();
5818
- this.removedFromCollection.set(!!currentCollection && !this.containsArticleByName(currentCollection));
5819
5821
  }
5820
5822
  catch (e) {
5821
5823
  error("Error updating collection:", e);
@@ -15269,7 +15271,7 @@ class FiltersBarComponent {
15269
15271
  @if (currentBasket()) {
15270
15272
  <button
15271
15273
  variant="destructive"
15272
- class="max-w-40 size-9"
15274
+ class="max-w-40 h-9"
15273
15275
  role="listitem"
15274
15276
  [title]="'filters.clearBasket' | transloco"
15275
15277
  (click)="clearBasket()"
@@ -15341,7 +15343,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
15341
15343
  @if (currentBasket()) {
15342
15344
  <button
15343
15345
  variant="destructive"
15344
- class="max-w-40 size-9"
15346
+ class="max-w-40 h-9"
15345
15347
  role="listitem"
15346
15348
  [title]="'filters.clearBasket' | transloco"
15347
15349
  (click)="clearBasket()"
@@ -16171,7 +16173,7 @@ class SavedSearchDialog {
16171
16173
  this.dialog()?.showModal();
16172
16174
  }
16173
16175
  async confirm() {
16174
- this.savedSearchesService.saveSearch(this.saveName());
16176
+ this.savedSearchesService.saveSearch(this.saveName(), this.queryParamsStore.tab?.());
16175
16177
  notify.success(this.transloco.translate("searches.saved.saved"), { duration: 2000 });
16176
16178
  // emit close output of the component
16177
16179
  this.dialog()?.close("dialog-confirm");