2019-10-03 16:54:05 +00:00
|
|
|
import { Component, Vue, Prop, Provide } from 'vue-property-decorator';
|
2019-10-21 16:37:08 +00:00
|
|
|
import FilterItem from '../models/filter-item';
|
2019-10-03 16:54:05 +00:00
|
|
|
|
|
|
|
@Component
|
2020-02-27 16:25:03 +00:00
|
|
|
export default class ActiveFacetList extends Vue {
|
2019-10-10 10:58:13 +00:00
|
|
|
|
|
|
|
ITEMS_PER_FILTER = 2;
|
|
|
|
bar = '';
|
|
|
|
collapsed = true;
|
|
|
|
// filterItems = [];
|
2019-10-03 16:54:05 +00:00
|
|
|
|
|
|
|
@Prop()
|
|
|
|
data;
|
2019-10-10 10:58:13 +00:00
|
|
|
@Prop([String])
|
2019-10-04 17:00:31 +00:00
|
|
|
filterName;
|
2019-10-18 15:05:56 +00:00
|
|
|
// @Prop([String])
|
2019-10-10 10:58:13 +00:00
|
|
|
// alias;
|
|
|
|
|
2019-10-18 15:05:56 +00:00
|
|
|
get alias(): string {
|
2019-10-10 10:58:13 +00:00
|
|
|
return this.filterName == 'datatype' ? 'doctype' : this.filterName
|
|
|
|
}
|
|
|
|
// get filterItems() {
|
|
|
|
// var facetValues = this.data.map((facet, i) => {
|
|
|
|
// if (i % 2 === 0) {
|
|
|
|
// // var rObj = {};
|
|
|
|
// // rObj['value'] = facet;
|
|
|
|
// // rObj['count'] = solrArray[i +1];
|
|
|
|
// var rObj = { value: facet, count: this.data[i + 1], category: this.alias };
|
|
|
|
// return rObj;
|
|
|
|
// }
|
|
|
|
// }).filter(function (el) {
|
|
|
|
// return el != null && el.count > 0;
|
|
|
|
// });
|
|
|
|
// // var facetValues = this.data.language.filter(function(facet, i) {
|
|
|
|
// // return i % 2 === 0;
|
|
|
|
// // }).map(function (facet, i) {
|
|
|
|
// // var rObj = { value: facet, count: this.data.language[i + 1] };
|
|
|
|
// // return rObj;
|
|
|
|
// // }, this);
|
|
|
|
// return facetValues;
|
|
|
|
// }
|
2019-10-18 15:05:56 +00:00
|
|
|
get filterItems(): Array<FilterItem> {
|
2019-10-10 10:58:13 +00:00
|
|
|
return this.data;
|
|
|
|
}
|
2019-10-03 16:54:05 +00:00
|
|
|
|
2019-10-18 15:05:56 +00:00
|
|
|
get overflowing(): boolean {
|
2019-10-10 10:58:13 +00:00
|
|
|
//ko.observable(self.filterItems().length - self.activeFilterItems().length > ITEMS_PER_FILTER);
|
|
|
|
return (this.filterItems.length) > this.ITEMS_PER_FILTER;
|
|
|
|
}
|
2019-10-03 16:54:05 +00:00
|
|
|
|
2019-10-18 15:05:56 +00:00
|
|
|
get uncollapseLabelText() : string {
|
2019-10-10 10:58:13 +00:00
|
|
|
if (this.collapsed == true) {
|
|
|
|
// return myLabels.viewer.sidePanel.more; //"More results";
|
|
|
|
return "More results";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// return myLabels.viewer.sidePanel.collapse; //"Collapse";
|
|
|
|
return "Collapse";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-18 15:05:56 +00:00
|
|
|
toggle = function (): void {
|
2019-10-10 10:58:13 +00:00
|
|
|
if (this.collapsed == true) {
|
|
|
|
this.collapsed = false;
|
|
|
|
}
|
|
|
|
else if (this.collapsed == false) {
|
|
|
|
this.collapsed = true;
|
|
|
|
//list.children("li:gt(4)").hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-18 15:05:56 +00:00
|
|
|
activateItem = function (filterItem: FilterItem): void {
|
2019-10-10 10:58:13 +00:00
|
|
|
filterItem.Category = this.alias;
|
|
|
|
filterItem.Active = true;
|
|
|
|
this.$emit("filter", filterItem);
|
|
|
|
}
|
2019-10-04 17:00:31 +00:00
|
|
|
|
2019-10-10 10:58:13 +00:00
|
|
|
mounted() {
|
|
|
|
}
|
2019-10-03 16:54:05 +00:00
|
|
|
}
|