2021-01-18 13:16:39 +00:00
|
|
|
import ngModule from '../module';
|
|
|
|
import SearchPanel from 'core/components/searchbar/search-panel';
|
2023-03-27 07:11:29 +00:00
|
|
|
import './style.scss';
|
2021-01-18 13:16:39 +00:00
|
|
|
|
|
|
|
class Controller extends SearchPanel {
|
2023-03-27 07:11:29 +00:00
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2021-01-18 13:16:39 +00:00
|
|
|
}
|
|
|
|
|
2023-03-27 07:11:29 +00:00
|
|
|
$onInit() {
|
|
|
|
this.filter = {
|
|
|
|
tags: []
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
changeCategory(id) {
|
|
|
|
if (this.filter.categoryFk != id) {
|
|
|
|
this.filter.categoryFk = id;
|
|
|
|
this.addFilters();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
removeItemFilter(param) {
|
|
|
|
this.filter[param] = null;
|
|
|
|
if (param == 'categoryFk') this.filter['typeFk'] = null;
|
|
|
|
this.addFilters();
|
|
|
|
}
|
|
|
|
|
|
|
|
removeTag(tag) {
|
|
|
|
const index = this.filter.tags.indexOf(tag);
|
|
|
|
if (index > -1) this.filter.tags.splice(index, 1);
|
|
|
|
this.addFilters();
|
|
|
|
}
|
|
|
|
|
|
|
|
onKeyPress($event) {
|
|
|
|
if ($event.key === 'Enter')
|
|
|
|
this.addFilters();
|
|
|
|
}
|
2021-01-18 13:16:39 +00:00
|
|
|
|
2023-03-27 07:11:29 +00:00
|
|
|
addFilters() {
|
|
|
|
for (let i = 0; i < this.filter.tags.length; i++) {
|
|
|
|
if (!this.filter.tags[i].value)
|
|
|
|
this.filter.tags.splice(i, 1);
|
|
|
|
}
|
|
|
|
return this.model.addFilter({}, this.filter);
|
|
|
|
}
|
|
|
|
|
|
|
|
showTagInfo(itemTag) {
|
|
|
|
if (!itemTag.tagFk) return itemTag.value;
|
|
|
|
return `${this.tags.find(tag => tag.id == itemTag.tagFk).name}: ${itemTag.value}`;
|
2021-01-18 13:16:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.vnComponent('vnFixedPriceSearchPanel', {
|
|
|
|
template: require('./index.html'),
|
2023-03-27 07:11:29 +00:00
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
|
|
|
model: '<'
|
|
|
|
}
|
2021-01-18 13:16:39 +00:00
|
|
|
});
|