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,
|
modelPathPrefix: String,
|
||||||
labelRenderer: Function,
|
labelRenderer: Function,
|
||||||
apiIndexUrl: String,
|
apiIndexUrl: String,
|
||||||
apiIndexSort: Object,
|
apiIndexSort: [Array, Object],
|
||||||
apiIndexFilters: Array,
|
apiIndexFilters: Array,
|
||||||
|
nativeSort: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
allowCreate: {
|
allowCreate: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -94,8 +98,12 @@ export default {
|
||||||
fetchData() {
|
fetchData() {
|
||||||
let params = {
|
let params = {
|
||||||
filters: JSON.stringify(this.apiIndexFilters),
|
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) {
|
if (this.paginated) {
|
||||||
params.per_page = this.perPage
|
params.per_page = this.perPage
|
||||||
|
@ -111,6 +119,11 @@ export default {
|
||||||
type: 'is-danger',
|
type: 'is-danger',
|
||||||
})
|
})
|
||||||
this.$router.push('/')
|
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 {
|
} else {
|
||||||
this.$buefy.toast.open({
|
this.$buefy.toast.open({
|
||||||
message: "Failed to fetch page data!",
|
message: "Failed to fetch page data!",
|
||||||
|
|
Loading…
Reference in a new issue