mirror of
https://github.com/ansible/awx.git
synced 2026-03-18 01:17:35 -02:30
Add id to table sort headers
This commit is contained in:
@@ -41,6 +41,7 @@ export default function HeaderRow({ qsConfig, isExpandable, children }) {
|
|||||||
index: sortKey || qsConfig.defaultParams?.order_by,
|
index: sortKey || qsConfig.defaultParams?.order_by,
|
||||||
direction: params.order_by?.startsWith('-') ? 'desc' : 'asc',
|
direction: params.order_by?.startsWith('-') ? 'desc' : 'asc',
|
||||||
};
|
};
|
||||||
|
const idPrefix = `${qsConfig.namespace}-table-sort`;
|
||||||
|
|
||||||
// empty first Th aligns with checkboxes in table rows
|
// empty first Th aligns with checkboxes in table rows
|
||||||
return (
|
return (
|
||||||
@@ -56,6 +57,7 @@ export default function HeaderRow({ qsConfig, isExpandable, children }) {
|
|||||||
onSort,
|
onSort,
|
||||||
sortBy,
|
sortBy,
|
||||||
columnIndex: child.props.sortKey,
|
columnIndex: child.props.sortKey,
|
||||||
|
idPrefix,
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
</Tr>
|
</Tr>
|
||||||
@@ -63,7 +65,14 @@ export default function HeaderRow({ qsConfig, isExpandable, children }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HeaderCell({ sortKey, onSort, sortBy, columnIndex, children }) {
|
export function HeaderCell({
|
||||||
|
sortKey,
|
||||||
|
onSort,
|
||||||
|
sortBy,
|
||||||
|
columnIndex,
|
||||||
|
idPrefix,
|
||||||
|
children,
|
||||||
|
}) {
|
||||||
const sort = sortKey
|
const sort = sortKey
|
||||||
? {
|
? {
|
||||||
onSort: (event, key, order) => onSort(sortKey, order),
|
onSort: (event, key, order) => onSort(sortKey, order),
|
||||||
@@ -71,5 +80,9 @@ export function HeaderCell({ sortKey, onSort, sortBy, columnIndex, children }) {
|
|||||||
columnIndex,
|
columnIndex,
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
return <Th sort={sort}>{children}</Th>;
|
return (
|
||||||
|
<Th sort={sort} id={sortKey ? `${idPrefix}-${sortKey}` : null}>
|
||||||
|
{children}
|
||||||
|
</Th>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user