diff --git a/modules/order/front/catalog/index.html b/modules/order/front/catalog/index.html index a13274484..ecce520a6 100644 --- a/modules/order/front/catalog/index.html +++ b/modules/order/front/catalog/index.html @@ -63,7 +63,7 @@ ng-model="$ctrl.orderField" selection="$ctrl.orderSelection" translate-fields="['name']" - order="name" + order="priority DESC" show-field="name" value-field="field" label="Order by" diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index ddfe69cc9..d5d944607 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -14,10 +14,10 @@ class Controller extends Section { {way: 'DESC', name: 'Descendant'}, ]; this.defaultOrderFields = [ - {field: 'relevancy DESC, name', name: 'Relevancy'}, - {field: 'showOrder, price', name: 'Color and price'}, - {field: 'name', name: 'Name'}, - {field: 'price', name: 'Price'} + {field: 'relevancy DESC, name', name: 'Relevancy', priority: 999}, + {field: 'showOrder, price', name: 'Color and price', priority: 999}, + {field: 'name', name: 'Name', priority: 999}, + {field: 'price', name: 'Price', priority: 999} ]; this.orderFields = [].concat(this.defaultOrderFields); this._orderWay = this.orderWays[0].way; @@ -312,9 +312,11 @@ class Controller extends Section { tags.push({ name: itemTag.name, field: itemTag.tagFk, - isTag: true + isTag: true, + priority: 1 }); - } + } else + tags[alreadyAdded].priority += 1; }); }); let newFilterList = [].concat(this.defaultOrderFields); diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index eceb3eb66..4ef9cbeb9 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -45,7 +45,7 @@ describe('Order', () => { jest.spyOn(controller, 'buildTagsFilter'); jest.spyOn(controller, 'buildOrderFilter'); - const expectedResult = [{field: 'showOrder, price', name: 'Color and price'}]; + const expectedResult = [{field: 'showOrder, price', name: 'Color and price', priority: 999}]; const items = [{id: 1, name: 'My Item', tags: [ {tagFk: 4, name: 'Length'}, {tagFk: 5, name: 'Color'}