Skip to content

Commit ff26153

Browse files
fix sorting
1 parent 72f1daf commit ff26153

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

generator/templates/Crud/src/components/Resource.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,6 @@ export default {
124124
required: false,
125125
},
126126
},
127-
created() {
128-
console.log(this.$attrs);
129-
},
130127
methods: {
131128
/***
132129
* @param pagination
@@ -135,13 +132,19 @@ export default {
135132
getDataFromApi(pagination, search) {
136133
const {sortBy, sortDesc, page, itemsPerPage} = pagination;
137134
return new Promise((resolve, reject) => {
135+
let sorting = {};
136+
if (sortBy[0]) {
137+
sorting = {
138+
sortBy: sortBy[0],
139+
desc: sortDesc[0] ? 1 : 0,
140+
};
141+
}
138142
this.$http.get(this.resourceUri, {
139143
params: {
140144
q: search,
141-
sortBy: sortBy[0],
142-
desc: sortDesc[0] ? 1 : 0,
143145
page: page,
144146
perPage: itemsPerPage,
147+
...sorting,
145148
},
146149
})
147150
.then((response) => {

0 commit comments

Comments
 (0)