@empathyco/x-components
Version:
Empathy X Components
38 lines (35 loc) • 1.18 kB
JavaScript
import { isSimpleFilter } from '@empathyco/x-types';
import { addFacetIfNotPresent } from './add-facet-if-not-present.js';
/**
* Allows selecting and deselecting a filter of {@link SimpleFilter}.
*
* @internal
*/
class SimpleFilterEntity {
constructor(store) {
this.store = store;
}
/**
* Deselects and saves to the store the given filter.
*
* @param filterParam - The filter to deselect.
*/
deselect(filterParam) {
const filter = filterParam;
this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: false } });
addFacetIfNotPresent(this.store, filter.facetId, 'SimpleFacet');
}
/**
* Selects and saves to the store the given filter.
*
* @param filterParam - The filter to select.
*/
select(filterParam) {
const filter = filterParam;
this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: true } });
addFacetIfNotPresent(this.store, filter.facetId, 'SimpleFacet');
}
}
SimpleFilterEntity.accepts = isSimpleFilter;
export { SimpleFilterEntity };
//# sourceMappingURL=simple-filter.entity.js.map