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"
selection="$ctrl.orderSelection"
translate-fields="['name']"
order="name"
order="priority DESC"
show-field="name"
value-field="field"
label="Order by"

View File

@ -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);

View File

@ -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'}