From a71eeb933e067d762ed05e2dd6d75b7d3b466c03 Mon Sep 17 00:00:00 2001 From: acondal Date: Tue, 10 Oct 2023 16:14:20 +0200 Subject: [PATCH] feat!: use config utils (facets) BREAKING CHANGE: setFacetsConfig mutation has been renamed/replaced by setConfig EMP-2328 --- .../x-modules/facets/store/__tests__/getters.spec.ts | 2 +- .../src/x-modules/facets/store/module.ts | 12 +++++------- .../x-components/src/x-modules/facets/store/types.ts | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/x-components/src/x-modules/facets/store/__tests__/getters.spec.ts b/packages/x-components/src/x-modules/facets/store/__tests__/getters.spec.ts index a8b8b63b0a..ede77ce1d7 100644 --- a/packages/x-components/src/x-modules/facets/store/__tests__/getters.spec.ts +++ b/packages/x-components/src/x-modules/facets/store/__tests__/getters.spec.ts @@ -239,7 +239,7 @@ describe('testing facets module getters', () => { ); const store = createFacetsStore([parentFilter, childFilter, parentFilterWithoutChild], []); - store.commit('setFacetsConfig', { + store.commit('setConfig', { filtersStrategyForRequest: 'leaves-only' }); diff --git a/packages/x-components/src/x-modules/facets/store/module.ts b/packages/x-components/src/x-modules/facets/store/module.ts index 3c6b55f875..e5ab79c1aa 100644 --- a/packages/x-components/src/x-modules/facets/store/module.ts +++ b/packages/x-components/src/x-modules/facets/store/module.ts @@ -1,9 +1,11 @@ import { Facet } from '@empathyco/x-types'; import Vue from 'vue'; +import { setConfig } from '../../../store/utils/config-store.utils'; +import { setQuery } from '../../../store/utils/query.utils'; import { facets } from './getters/facets.getter'; import { selectedFiltersByFacet } from './getters/selected-filters-by-facet.getter'; import { selectedFilters } from './getters/selected-filters.getter'; -import { FacetGroupEntry, FacetsConfig, FacetsXStoreModule } from './types'; +import { FacetGroupEntry, FacetsXStoreModule } from './types'; import { selectedFiltersForRequest } from './getters/selected-filters-for-request.getter'; /** @@ -55,12 +57,8 @@ export const facetsXStoreModule: FacetsXStoreModule = { setFacet(state, facet: Facet) { Vue.set(state.facets, facet.id, facet); }, - setFacetsConfig(state, config: FacetsConfig) { - state.config = config; - }, - setQuery(state, query) { - state.query = query; - }, + setConfig, + setQuery, setStickyFilter(state, filter) { if (!state.stickyFilters[filter.id]) { Vue.set(state.stickyFilters, filter.id, filter); diff --git a/packages/x-components/src/x-modules/facets/store/types.ts b/packages/x-components/src/x-modules/facets/store/types.ts index 713259e405..105f82fc17 100644 --- a/packages/x-components/src/x-modules/facets/store/types.ts +++ b/packages/x-components/src/x-modules/facets/store/types.ts @@ -114,7 +114,7 @@ export interface FacetsMutations { * * @param config - The new config. */ - setFacetsConfig(config: FacetsConfig): void; + setConfig(config: FacetsConfig): void; /** * Adds the filter to the {@link FacetsState.stickyFilters | sticky filters} record. *