Ensure all search requests specify a sort field to avoid random sorting
This commit is contained in:
parent
e8b993b14c
commit
ce9feed5f2
|
@ -117,7 +117,7 @@ export default class DataFetch {
|
||||||
* Fetches a fresh set of data from the server, resetting pagination
|
* Fetches a fresh set of data from the server, resetting pagination
|
||||||
*/
|
*/
|
||||||
async getInitialData() {
|
async getInitialData() {
|
||||||
const { datasource, filter, sortColumn, paginate } = this.options
|
const { datasource, filter, paginate } = this.options
|
||||||
|
|
||||||
// Fetch datasource definition and determine feature flags
|
// Fetch datasource definition and determine feature flags
|
||||||
const definition = await this.getDefinition(datasource)
|
const definition = await this.getDefinition(datasource)
|
||||||
|
@ -135,6 +135,17 @@ export default class DataFetch {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no sort order, default to descending
|
||||||
|
if (!this.options.sortOrder) {
|
||||||
|
this.options.sortOrder = "ascending"
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no sort column, use the first field in the schema
|
||||||
|
if (!this.options.sortColumn) {
|
||||||
|
this.options.sortColumn = Object.keys(schema)[0]
|
||||||
|
}
|
||||||
|
const { sortColumn } = this.options
|
||||||
|
|
||||||
// Determine what sort type to use
|
// Determine what sort type to use
|
||||||
let sortType = "string"
|
let sortType = "string"
|
||||||
if (sortColumn) {
|
if (sortColumn) {
|
||||||
|
|
Loading…
Reference in New Issue