fixed order item category filter #1079

This commit is contained in:
Joan Sanchez 2019-02-05 09:21:29 +01:00
parent 333d853335
commit d87e2dbbf0
1 changed files with 26 additions and 10 deletions

View File

@ -26,6 +26,11 @@ class Controller {
return this._order;
}
/**
* Sets filter values from state params
*
* @param {Object} value - Order data
*/
set order(value) {
if (!value.id || this._order) return;
@ -57,20 +62,18 @@ class Controller {
this.itemTypes = [];
this.type = null;
if (!value || (this.category && this.category.id == value.id)) {
if (!value || (this.category && this.category.id == value.id))
this._category = null;
this.updateStateParams();
else
this._category = value;
return;
}
this._category = value;
this.updateStateParams();
const query = `/item/api/ItemCategories/${value.id}/itemTypes`;
this.$http.get(query).then(res => {
this.itemTypes = res.data;
});
if (this.tags.length > 0)
this.applyFilters();
if (value)
this.updateItemTypes();
}
get type() {
@ -91,6 +94,16 @@ class Controller {
this.applyFilters();
}
/**
* Refreshes item type dropdown data
*/
updateItemTypes() {
const query = `/item/api/ItemCategories/${this.category.id}/itemTypes`;
this.$http.get(query).then(res => {
this.itemTypes = res.data;
});
}
onSearch(event) {
if (event.key !== 'Enter') return;
this.tags.push({
@ -153,6 +166,9 @@ class Controller {
this.$panel = null;
}
/**
* Updates url state params from filter values
*/
updateStateParams() {
const params = {};