Skip to content

Commit d8b30b4

Browse files
authored
Merge pull request #215 from jmontoyaa/patch-3
Fix sort when using vuetify
2 parents 7ba36fc + d55c0be commit d8b30b4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

templates/vue-common/mixins/ListMixin.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default {
99
return {
1010
options: {
1111
sortBy: [],
12-
descending: false,
12+
sortDesc: [],
1313
page: 1,
1414
itemsPerPage: 15
1515
},
@@ -32,24 +32,23 @@ export default {
3232
},
3333

3434
methods: {
35-
onUpdateOptions(props) {
36-
const { page, itemsPerPage, sortBy, descending, totalItems } = props;
35+
onUpdateOptions({ page, itemsPerPage, sortBy, sortDesc, totalItems } = {}) {
3736
let params = {
3837
...this.filters
3938
};
4039
if (itemsPerPage > 0) {
4140
params = { ...params, itemsPerPage, page };
4241
}
4342

44-
if (!isEmpty(sortBy)) {
45-
params[`order[${sortBy}]`] = descending ? 'desc' : 'asc';
43+
if (!isEmpty(sortBy) && !isEmpty(sortDesc)) {
44+
params[`order[${sortBy[0]}]`] = sortDesc[0] ? 'desc' : 'asc'
4645
}
4746

4847
this.resetList = true;
4948

5049
this.getPage(params).then(() => {
5150
this.options.sortBy = sortBy;
52-
this.options.descending = descending;
51+
this.options.sortDesc = sortDesc;
5352
this.options.itemsPerPage = itemsPerPage;
5453
this.options.totalItems = totalItems;
5554
});

0 commit comments

Comments
 (0)