This commit is contained in:
parent
b7db5f969b
commit
d11a51b3f1
|
@ -75,9 +75,9 @@ export default class ArrayModel extends ModelProxy {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
data.sort((a, b) => this.sortFunc(a, b, orderComp));
|
data = data.sort((a, b) => this.sortFunc(a, b, orderComp));
|
||||||
} else if (typeof order === 'function')
|
} else if (typeof order === 'function')
|
||||||
data.sort(order);
|
data = data.sort(order);
|
||||||
|
|
||||||
this.skip = skip;
|
this.skip = skip;
|
||||||
|
|
||||||
|
|
|
@ -14,4 +14,8 @@ vn-check {
|
||||||
md-checkbox.md-checked .md-icon {
|
md-checkbox.md-checked .md-icon {
|
||||||
background-color: $color-main;
|
background-color: $color-main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
md-checkbox {
|
||||||
|
margin-bottom: 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ module.exports = Self => {
|
||||||
FROM tmp.ticketCalculateItem tci
|
FROM tmp.ticketCalculateItem tci
|
||||||
JOIN vn.item i ON i.id = tci.itemFk
|
JOIN vn.item i ON i.id = tci.itemFk
|
||||||
JOIN vn.itemType it ON it.id = i.typeFk
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
|
JOIN vn.ink ON ink.id = i.inkFk
|
||||||
JOIN vn.worker w on w.id = it.workerFk`);
|
JOIN vn.worker w on w.id = it.workerFk`);
|
||||||
|
|
||||||
// Apply order by tag
|
// Apply order by tag
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
initial-data="$ctrl.field"
|
initial-data="$ctrl.field"
|
||||||
field="$ctrl.field"
|
field="$ctrl.field"
|
||||||
translate-fields="['name']"
|
translate-fields="['name']"
|
||||||
|
order="name"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
value-field="field"
|
value-field="field"
|
||||||
label="Order by">
|
label="Order by">
|
||||||
|
|
|
@ -12,7 +12,9 @@ class Controller {
|
||||||
{way: 'DESC', name: 'Descendant'},
|
{way: 'DESC', name: 'Descendant'},
|
||||||
];
|
];
|
||||||
this.defaultFieldList = [
|
this.defaultFieldList = [
|
||||||
{field: 'relevancy DESC, name', name: 'Name'},
|
{field: 'relevancy DESC, name', name: 'Default'},
|
||||||
|
{field: 'showOrder, price', name: 'Color'},
|
||||||
|
{field: 'name', name: 'Name'},
|
||||||
{field: 'price', name: 'Price'}
|
{field: 'price', name: 'Price'}
|
||||||
];
|
];
|
||||||
this.fieldList = [];
|
this.fieldList = [];
|
||||||
|
@ -27,20 +29,18 @@ class Controller {
|
||||||
*/
|
*/
|
||||||
onDataChange() {
|
onDataChange() {
|
||||||
const items = this.$scope.model.data;
|
const items = this.$scope.model.data;
|
||||||
|
const newFilterList = [];
|
||||||
if (!items) return;
|
if (!items) return;
|
||||||
|
|
||||||
this.fieldList = [];
|
|
||||||
this.fieldList = this.fieldList.concat(this.defaultFieldList);
|
|
||||||
|
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
|
// Add new tag filters
|
||||||
item.tags.forEach(itemTag => {
|
item.tags.forEach(itemTag => {
|
||||||
const alreadyAdded = this.fieldList.find(order => {
|
const alreadyAdded = newFilterList.findIndex(filter => {
|
||||||
return order.field == itemTag.tagFk;
|
return filter.field == itemTag.tagFk;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!alreadyAdded) {
|
if (alreadyAdded == -1) {
|
||||||
this.fieldList.push({
|
newFilterList.push({
|
||||||
name: itemTag.name,
|
name: itemTag.name,
|
||||||
field: itemTag.tagFk,
|
field: itemTag.tagFk,
|
||||||
isTag: true
|
isTag: true
|
||||||
|
@ -48,6 +48,20 @@ class Controller {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add default filters - Replaces tags with same name
|
||||||
|
this.defaultFieldList.forEach(defaultField => {
|
||||||
|
const index = newFilterList.findIndex(newfield => {
|
||||||
|
return newfield.name == defaultField.name;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (index > -1)
|
||||||
|
newFilterList[index] = defaultField;
|
||||||
|
else
|
||||||
|
newFilterList.push(defaultField);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.fieldList = newFilterList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,18 +17,17 @@ describe('Order', () => {
|
||||||
|
|
||||||
describe('onDataChange()', () => {
|
describe('onDataChange()', () => {
|
||||||
it(`should return an object with order params`, () => {
|
it(`should return an object with order params`, () => {
|
||||||
let expectedList = [
|
|
||||||
{field: 'relevancy DESC, name', name: 'Name'},
|
|
||||||
{field: 'price', name: 'Price'},
|
|
||||||
{field: 4, name: 'Length', isTag: true}
|
|
||||||
];
|
|
||||||
$scope.model.data = [{id: 1, name: 'My Item', tags: [
|
$scope.model.data = [{id: 1, name: 'My Item', tags: [
|
||||||
{tagFk: 4, name: 'Length'}
|
{tagFk: 4, name: 'Length'},
|
||||||
|
{tagFk: 5, name: 'Color'}
|
||||||
]}];
|
]}];
|
||||||
|
let expectedResult = [{field: 'showOrder, price', name: 'Color'}];
|
||||||
|
let unexpectedResult = [{tagFk: 5, name: 'Color'}];
|
||||||
controller.onDataChange();
|
controller.onDataChange();
|
||||||
|
|
||||||
expect(controller.fieldList).toEqual(expectedList);
|
expect(controller.fieldList.length).toEqual(5);
|
||||||
|
expect(controller.fieldList).toEqual(jasmine.arrayContaining(expectedResult));
|
||||||
|
expect(controller.fieldList).not.toEqual(jasmine.arrayContaining(unexpectedResult));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue