-
Notifications
You must be signed in to change notification settings - Fork 0
Update default sort order for ItemTable #150
Comments
The default sort order of the ItemTable seems to be set by this function: export function defaultOrderByFn(arr, funcs, dirs) {
return [...arr].sort((rowA, rowB) => {
for (let i = 0; i < funcs.length; i += 1) {
const sortFn = funcs[i]
const desc = dirs[i] === false || dirs[i] === 'desc'
const sortInt = sortFn(rowA, rowB)
if (sortInt !== 0) {
return desc ? -sortInt : sortInt
}
}
return dirs[0] ? rowA.index - rowB.index : rowB.index - rowA.index
})
} The orderByFn should allow us to set the way that the ItemTable is sorted by default. |
The initial sort by state can be set in the initialState: {
sortBy: [{ id: 'number', desc: false },]
} The only problem that this presents is that because the Item Numbers are being sorted that style is being applied to the sorting icons by default. |
After receiving some feedback from other ECN staff, we were given the suggestion to keep the default sort order the same as it is in the current webqueue. According to @harley the default sort order is to sort by Item Number regardless of queues selected. It was also suggested that we also sort by last updated as well. These default sorting preferences should be implemented with the same logic as before. the other thing that needs to be addressed is how the sort icons are styled. The columns that we set the default sort order on have the active sort styles. These should have the inactive sort styles until the user sorts themselves. |
After further inspection of the react-table docs for the useSortBy hook we found that when using the initialState.sortBy prop if the |
Let's set the default sort order to be:
|
Need to make Last Edited and Date Received columned sort by ascending when the ascending arrow is clicked. |
In order to get the Date Received and Last Updated cells to sort in the desired directions the Last Updated column with {
Header: 'Last Updated',
accessor: 'lastUpdated',
sortInverted: true,
Cell: ({ value }) => <RelativeTime value={value} />
}, Date Received column with {
Header: 'Date Received',
accessor: 'dateReceived',
sortInverted: true,
Cell: ({ value }) => <RelativeTime value={value} />
}, |
The current default sort method for ItemTable is unclear. We should set a sane default based on user's workflow. Some proposed defaults include:
More feedback is needed.
The text was updated successfully, but these errors were encountered: