From d2006e60bbee6af637c5073342a45964a49cf3d6 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 24 Apr 2019 09:21:24 +0200 Subject: [PATCH] fixed catalog filter bugs #1352 --- modules/order/front/catalog/index.html | 6 ++++-- modules/order/front/catalog/index.js | 6 ++---- modules/order/front/filter/index.js | 8 ++++---- modules/order/front/filter/index.spec.js | 2 ++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/order/front/catalog/index.html b/modules/order/front/catalog/index.html index 1d834a66cd..5ec0aeac08 100644 --- a/modules/order/front/catalog/index.html +++ b/modules/order/front/catalog/index.html @@ -23,7 +23,8 @@ order="name" show-field="name" value-field="field" - label="Order by"> + label="Order by" + disabled="!model.data"> + label="Order" + disabled="!model.data"> diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index bc9bd20d58..a21d9dc183 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -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(); } /** diff --git a/modules/order/front/filter/index.js b/modules/order/front/filter/index.js index 26495b025e..3a738ee5b3 100644 --- a/modules/order/front/filter/index.js +++ b/modules/order/front/filter/index.js @@ -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(); } diff --git a/modules/order/front/filter/index.spec.js b/modules/order/front/filter/index.spec.js index 88075e8203..6c9ecee345 100644 --- a/modules/order/front/filter/index.spec.js +++ b/modules/order/front/filter/index.spec.js @@ -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`, () => {