2026-07-13 08:39:13 +00:00
|
|
|
import type { ToolbarItem } from 'devextreme/ui/data_grid_types'
|
2026-06-18 11:23:15 +00:00
|
|
|
|
|
|
|
|
const orderedToolbarItemNames = [
|
|
|
|
|
'searchPanel',
|
|
|
|
|
'addRowButton',
|
|
|
|
|
'refreshButton',
|
|
|
|
|
'openDynamicGridReport',
|
2026-08-11 11:43:51 +00:00
|
|
|
'workflowReset',
|
2026-06-18 11:23:15 +00:00
|
|
|
'workflowStart',
|
|
|
|
|
'expandAllButton',
|
|
|
|
|
'collapseAllButton',
|
|
|
|
|
'fitColumns',
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const getToolbarItemPriority = (item: ToolbarItem) => {
|
|
|
|
|
const name = item.name ?? ''
|
|
|
|
|
|
|
|
|
|
if (name.startsWith('workflowApproval_')) {
|
|
|
|
|
return orderedToolbarItemNames.indexOf('workflowStart')
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-20 19:48:35 +00:00
|
|
|
if (name.includes('Redis') || name.includes('Hangfire') || name.includes('Swagger')) {
|
|
|
|
|
return orderedToolbarItemNames.indexOf('openDynamicGridReport') + 0.5
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-18 11:23:15 +00:00
|
|
|
const priority = orderedToolbarItemNames.indexOf(name)
|
|
|
|
|
return priority === -1 ? orderedToolbarItemNames.length : priority
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const orderListToolbarItems = (items: ToolbarItem[]) => {
|
|
|
|
|
return [...items].sort((left, right) => {
|
|
|
|
|
const priorityDiff = getToolbarItemPriority(left) - getToolbarItemPriority(right)
|
|
|
|
|
if (priorityDiff !== 0) {
|
|
|
|
|
return priorityDiff
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return items.indexOf(left) - items.indexOf(right)
|
|
|
|
|
})
|
|
|
|
|
}
|