31 lines
821 B
TypeScript
Raw Normal View History

import Component from '@ember/component';
2019-08-31 20:51:14 -07:00
import { computed } from '@ember/object';
import { ISearchFacet, IFacetSelections } from '@datahub/data-models/types/entity/facets';
2018-09-14 16:47:28 -07:00
/**
* Presentation component of a facet
*/
export default class SearchFacet extends Component {
2018-09-17 23:03:32 -07:00
/**
* Facet to display
*/
facet!: ISearchFacet;
2018-09-14 16:47:28 -07:00
/**
* Facet selections
*/
2018-09-17 23:03:32 -07:00
selections!: IFacetSelections;
2018-09-14 16:47:28 -07:00
/**
* Computed property to check if there is any selection in the
* facet. If that is the case, a clear button will show up.
*/
@computed('selections')
2018-09-17 10:54:11 -07:00
get showClearBtn(): boolean {
const selections = this.selections || {};
2018-09-17 10:54:11 -07:00
return Object.keys(selections).reduce((willShowClearBtn: boolean, selectionKey: string) => {
return willShowClearBtn || selections[selectionKey];
}, false);
}
}