Merge pull request '#2406 - Sort by occurrences' (#364) from 2406-catalog_sort_by_occurrences into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #364
Reviewed-by: Carlos Jimenez <carlosjr@verdnatura.es>
This commit is contained in:
Carlos Jimenez Ruiz 2020-09-09 09:05:34 +00:00
commit 99b32ab3ad
3 changed files with 10 additions and 8 deletions

View File

@ -63,7 +63,7 @@
ng-model="$ctrl.orderField" ng-model="$ctrl.orderField"
selection="$ctrl.orderSelection" selection="$ctrl.orderSelection"
translate-fields="['name']" translate-fields="['name']"
order="name" order="priority DESC"
show-field="name" show-field="name"
value-field="field" value-field="field"
label="Order by" label="Order by"

View File

@ -14,10 +14,10 @@ class Controller extends Section {
{way: 'DESC', name: 'Descendant'}, {way: 'DESC', name: 'Descendant'},
]; ];
this.defaultOrderFields = [ this.defaultOrderFields = [
{field: 'relevancy DESC, name', name: 'Relevancy'}, {field: 'relevancy DESC, name', name: 'Relevancy', priority: 999},
{field: 'showOrder, price', name: 'Color and price'}, {field: 'showOrder, price', name: 'Color and price', priority: 999},
{field: 'name', name: 'Name'}, {field: 'name', name: 'Name', priority: 999},
{field: 'price', name: 'Price'} {field: 'price', name: 'Price', priority: 999}
]; ];
this.orderFields = [].concat(this.defaultOrderFields); this.orderFields = [].concat(this.defaultOrderFields);
this._orderWay = this.orderWays[0].way; this._orderWay = this.orderWays[0].way;
@ -312,9 +312,11 @@ class Controller extends Section {
tags.push({ tags.push({
name: itemTag.name, name: itemTag.name,
field: itemTag.tagFk, field: itemTag.tagFk,
isTag: true isTag: true,
priority: 1
}); });
} } else
tags[alreadyAdded].priority += 1;
}); });
}); });
let newFilterList = [].concat(this.defaultOrderFields); let newFilterList = [].concat(this.defaultOrderFields);

View File

@ -45,7 +45,7 @@ describe('Order', () => {
jest.spyOn(controller, 'buildTagsFilter'); jest.spyOn(controller, 'buildTagsFilter');
jest.spyOn(controller, 'buildOrderFilter'); 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: [ const items = [{id: 1, name: 'My Item', tags: [
{tagFk: 4, name: 'Length'}, {tagFk: 4, name: 'Length'},
{tagFk: 5, name: 'Color'} {tagFk: 5, name: 'Color'}