@empathyco/x-components
Version:
Empathy X Components
39 lines (36 loc) • 1.24 kB
JavaScript
import { isRawFilter } from '@empathyco/x-types';
/**
* Allows selecting and deselecting a filter of {@link @empathyco/x-types#RawFilter | RawFilter}.
*
* @internal
*/
class RawFilterEntity {
constructor(store) {
this.store = store;
}
/**
* It deselects the {@link @empathyco/x-types#RawFilter | RawFilter}.
*
* @param filterParam - The filter to deselect.
* @remarks As the {@link @empathyco/x-types#RawFilter.selected} is always true,
* the deselection just removes the filter from the store.
*/
deselect(filterParam) {
const filter = filterParam;
this.store.commit('x/facets/removeFilter', filter);
}
/**
* It selects the {@link @empathyco/x-types#RawFilter | RawFilter}.
*
* @param filterParam - The filter to select.
* @remarks As the {@link @empathyco/x-types#RawFilter.selected} is always true,
* there is no need to set this property.
*/
select(filterParam) {
const filter = filterParam;
this.store.commit('x/facets/mutateFilter', { filter, newFilterState: { selected: true } });
}
}
RawFilterEntity.accepts = isRawFilter;
export { RawFilterEntity };
//# sourceMappingURL=raw-filter.entity.js.map