mirror of
https://github.com/strapi/strapi.git
synced 2025-12-04 19:13:20 +00:00
Merge pull request #16675 from strapi/fix/list-view-sort
Fix: Fix toOne sorting in CM list-view
This commit is contained in:
commit
aa749f4022
@ -34,7 +34,12 @@ export default (layout) => {
|
||||
}),
|
||||
searchable: false,
|
||||
sortable: true,
|
||||
mainField: 'name',
|
||||
mainField: {
|
||||
name: 'name',
|
||||
schema: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
cellFormatter({ strapi_reviewWorkflows_stage }) {
|
||||
// if entities are created e.g. through lifecycle methods
|
||||
|
||||
@ -52,7 +52,7 @@ const TableHead = ({
|
||||
// relations always have to be sorted by their main field instead of only the
|
||||
// attribute name; sortBy e.g. looks like: &sortBy=attributeName[mainField]:ASC
|
||||
if (fieldSchema?.type === 'relation' && mainField) {
|
||||
isSorted = sortBy === `${name}[${mainField}]`;
|
||||
isSorted = sortBy === `${name.split('.')[0]}[${mainField.name}]`;
|
||||
}
|
||||
|
||||
const sortLabel = formatMessage(
|
||||
@ -67,7 +67,7 @@ const TableHead = ({
|
||||
// relations always have to be sorted by their main field instead of only the
|
||||
// attribute name; nextSort e.g. looks like: &nextSort=attributeName[mainField]:ASC
|
||||
if (fieldSchema?.type === 'relation' && mainField) {
|
||||
nextSort = `${name}[${mainField}]`;
|
||||
nextSort = `${name.split('.')[0]}[${mainField.name}]`;
|
||||
}
|
||||
|
||||
setQuery({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user