Allow for "native sort" params in model index
This commit is contained in:
parent
cebf7fc749
commit
a0a405f849
|
@ -56,8 +56,12 @@ export default {
|
|||
modelPathPrefix: String,
|
||||
labelRenderer: Function,
|
||||
apiIndexUrl: String,
|
||||
apiIndexSort: Object,
|
||||
apiIndexSort: [Array, Object],
|
||||
apiIndexFilters: Array,
|
||||
nativeSort: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
allowCreate: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
|
@ -94,8 +98,12 @@ export default {
|
|||
fetchData() {
|
||||
let params = {
|
||||
filters: JSON.stringify(this.apiIndexFilters),
|
||||
orderBy: this.apiIndexSort.field,
|
||||
ascending: (this.apiIndexSort.dir == 'asc') ? 1 : 0,
|
||||
}
|
||||
if (this.nativeSort) {
|
||||
params.nativeSort = JSON.stringify(this.apiIndexSort)
|
||||
} else {
|
||||
params.orderBy = this.apiIndexSort.field
|
||||
params.ascending = (this.apiIndexSort.dir == 'asc') ? 1 : 0
|
||||
}
|
||||
if (this.paginated) {
|
||||
params.per_page = this.perPage
|
||||
|
@ -111,6 +119,11 @@ export default {
|
|||
type: 'is-danger',
|
||||
})
|
||||
this.$router.push('/')
|
||||
} else if (response.status == 404) { // not found; display warning
|
||||
this.$buefy.toast.open({
|
||||
message: "Page data not found!",
|
||||
type: 'is-danger',
|
||||
})
|
||||
} else {
|
||||
this.$buefy.toast.open({
|
||||
message: "Failed to fetch page data!",
|
||||
|
|
Loading…
Reference in a new issue