From 7df41fc63cef289ba173313f0103f7a5ba06fb82 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 9 Jan 2020 11:21:54 +0100 Subject: [PATCH] solved bug ordering by tag --- modules/order/front/catalog/index.js | 17 ++++++++--------- modules/order/front/filter/index.spec.js | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index 5e2e965557..40c60b5ea1 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -20,7 +20,7 @@ class Controller { ]; this.orderFields = [].concat(this.defaultOrderFields); this._orderWay = this.orderWays[0].way; - this._orderField = this.orderFields[0].field; + this.orderField = this.orderFields[0].field; } /** @@ -76,15 +76,13 @@ class Controller { if (value) this.applyOrder(); } - /** - * Get order fields - */ - get orderField() { - return this._orderField; + get orderSelection() { + return this._orderSelection; } - set orderField(value) { - this._orderField = value; + set orderSelection(value) { + this._orderSelection = value; + if (value) this.applyOrder(); } @@ -94,10 +92,11 @@ class Controller { * @return {Object} - Order param */ getOrderBy() { + const isTag = !!(this.orderSelection && this.orderSelection.isTag); return { field: this.orderField, way: this.orderWay, - isTag: (this.orderSelection && this.orderSelection.isTag) + isTag: isTag }; } diff --git a/modules/order/front/filter/index.spec.js b/modules/order/front/filter/index.spec.js index 079df4121f..72a0f206bc 100644 --- a/modules/order/front/filter/index.spec.js +++ b/modules/order/front/filter/index.spec.js @@ -146,8 +146,8 @@ describe('Order', () => { it(`should remove a tag from tags property and call applyFilters() if there's no more tags`, () => { spyOn(controller, 'applyFilters'); - controller._categoryId = {id: 1, value: 'My Category'}; - controller._type = {id: 1, value: 'My type'}; + controller._categoryId = 1; + controller._typeId = 1; controller.tags = [{tagFk: 1, value: 'Blue'}]; controller.remove(0);