2018-06-07 21:47:19 +00:00
|
|
|
import ngModule from '../module';
|
2018-12-27 11:54:16 +00:00
|
|
|
import SearchPanel from 'core/components/searchbar/search-panel';
|
2018-06-07 21:47:19 +00:00
|
|
|
|
|
|
|
class Controller extends SearchPanel {
|
2019-10-18 19:36:30 +00:00
|
|
|
constructor($scope, $element) {
|
|
|
|
super($scope, $element);
|
2019-03-08 12:12:13 +00:00
|
|
|
this.$ = $scope;
|
|
|
|
this.moreFields = [
|
|
|
|
{field: 'id'},
|
|
|
|
{field: 'description'},
|
|
|
|
{field: 'name'}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
initializeMoreFields() {
|
|
|
|
if (!this.$.filter.moreFields || !this.$.filter.moreFields.length)
|
|
|
|
this.$.filter.moreFields = [{}];
|
|
|
|
}
|
|
|
|
|
2018-06-07 21:47:19 +00:00
|
|
|
set filter(value) {
|
2019-01-16 14:29:01 +00:00
|
|
|
if (!value)
|
|
|
|
value = {};
|
|
|
|
if (!value.tags)
|
|
|
|
value.tags = [{}];
|
2018-06-07 21:47:19 +00:00
|
|
|
|
|
|
|
this.$.filter = value;
|
|
|
|
}
|
|
|
|
|
2019-02-14 10:24:04 +00:00
|
|
|
get itemTypes() {
|
|
|
|
if (this.$.filter) {
|
|
|
|
if (!this.$.filter.categoryFk)
|
2019-10-24 22:53:53 +00:00
|
|
|
return 'ItemTypes';
|
|
|
|
return `ItemCategories/${this.$.filter.categoryFk}/itemTypes`;
|
2019-02-14 10:24:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-07 21:47:19 +00:00
|
|
|
get filter() {
|
2019-03-08 12:12:13 +00:00
|
|
|
if (this.$.filter.moreFields) {
|
|
|
|
this.$.filter.moreFields.forEach(element => {
|
|
|
|
this.$.filter[element.field] = element.value;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
let filter = Object.assign({}, this.$.filter);
|
|
|
|
delete filter.moreFields;
|
|
|
|
return filter;
|
2018-06-07 21:47:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getSourceTable(selection) {
|
|
|
|
if (!selection || selection.isFree === true)
|
|
|
|
return null;
|
|
|
|
|
2019-01-15 13:53:38 +00:00
|
|
|
if (selection.sourceTable) {
|
2019-10-24 22:53:53 +00:00
|
|
|
return ''
|
2018-06-07 21:47:19 +00:00
|
|
|
+ selection.sourceTable.charAt(0).toUpperCase()
|
|
|
|
+ selection.sourceTable.substring(1) + 's';
|
2019-01-15 13:53:38 +00:00
|
|
|
} else if (selection.sourceTable == null)
|
2019-10-24 22:53:53 +00:00
|
|
|
return `ItemTags/filterItemTags/${selection.id}`;
|
2018-06-07 21:47:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('vnItemSearchPanel', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller
|
|
|
|
});
|