fix(09): WR-06 default a relation list to its first sortable column
This commit is contained in:
@@ -544,10 +544,17 @@ func normalizeRelationQuery(schema *RelationSchema, candidates bool, in Relation
|
||||
panel = schema.Manage
|
||||
}
|
||||
sortKey := in.Sort
|
||||
if sortKey == "" && len(panel.List.Columns) > 0 {
|
||||
sortKey = panel.List.Columns[0].Key
|
||||
}
|
||||
if sortKey != "" {
|
||||
if sortKey == "" {
|
||||
// No explicit sort: use the first sortable column, or none (the
|
||||
// primary key then orders the page). Only a sort the client names is
|
||||
// validated, so a panel whose first column is not sortable still loads.
|
||||
for _, col := range panel.List.Columns {
|
||||
if col.Sortable {
|
||||
sortKey = col.Key
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
valid := false
|
||||
for _, col := range panel.List.Columns {
|
||||
if col.Key == sortKey && col.Sortable {
|
||||
|
||||
Reference in New Issue
Block a user