fixed catalog filter bugs #1352

This commit is contained in:
Joan Sanchez 2019-04-24 09:21:24 +02:00
parent 2c5dd324ea
commit d2006e60bb
4 changed files with 12 additions and 10 deletions

View File

@ -23,7 +23,8 @@
order="name"
show-field="name"
value-field="field"
label="Order by">
label="Order by"
disabled="!model.data">
</vn-autocomplete>
<vn-autocomplete vn-one
data="$ctrl.wayList"
@ -32,7 +33,8 @@
translate-fields="['name']"
show-field="name"
value-field="way"
label="Order">
label="Order"
disabled="!model.data">
</vn-autocomplete>
</vn-auto>
</vn-horizontal>

View File

@ -74,8 +74,7 @@ class Controller {
set way(value) {
this._way = value;
if (value)
this.applyOrder();
if (value) this.applyOrder();
}
/**
@ -88,8 +87,7 @@ class Controller {
set field(value) {
this._field = value;
if (value)
this.applyOrder();
if (value) this.applyOrder();
}
/**

View File

@ -64,7 +64,7 @@ class Controller {
if (this.tags.length > 0)
this.applyFilters();
if (value)
if (this._category)
this.updateItemTypes();
}
@ -97,8 +97,8 @@ class Controller {
}
onSearchById(event) {
if (event.key !== 'Enter' || !this.itemFk) return;
this.applyFilters();
if (event.key === 'Enter' && (this.tags.length > 0 || this.itemFk || this.type))
this.applyFilters();
}
onSearchByTag(event) {
@ -113,7 +113,7 @@ class Controller {
remove(index) {
this.tags.splice(index, 1);
if (this.tags.length == 0 && this.category && this.type)
if (this.tags.length >= 0 || this.itemFk || this.type)
this.applyFilters();
}

View File

@ -137,11 +137,13 @@ describe('Order', () => {
describe('remove()', () => {
it(`should remove a tag from tags property`, () => {
spyOn(controller, 'applyFilters');
controller.tags = [{tagFk: 1, value: 'Blue'}, {tagFk: 2, value: '70'}];
controller.remove(0);
expect(controller.tags.length).toEqual(1);
expect(controller.tags[0].tagFk).toEqual(2);
expect(controller.applyFilters).toHaveBeenCalledWith();
});
it(`should remove a tag from tags property and call applyFilters() if there's no more tags`, () => {