Tom Butcher 5ed086cf8b Enhance Sidebar and Object Models with List Action Integration
- Added a 'list' action to various object models, including AppPassword, AuditLog, Client, and more, to standardize access to list views across the application.
- Updated the ObjectModels.js to include a new label for the 'list' action, improving clarity in the permission matrix.
- Refactored Sidebar.js to incorporate user profile permissions for sidebar item visibility, enhancing user experience based on access rights.
- Introduced utility functions for normalizing paths and filtering sidebar items based on user permissions, streamlining sidebar management.
- Improved the overall structure and readability of the Sidebar and ObjectModels components.
2026-08-20 20:14:57 +01:00

206 lines
4.3 KiB
JavaScript

import { createElement, lazy } from 'react'
const CourierInfo = lazy(
() => import('../../components/Dashboard/Management/Couriers/CourierInfo')
)
const NewCourier = lazy(
() => import('../../components/Dashboard/Management/Couriers/NewCourier')
)
import CourierIcon from '../../components/Icons/CourierIcon'
import PlusIcon from '../../components/Icons/PlusIcon'
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import EditIcon from '../../components/Icons/EditIcon'
import CheckIcon from '../../components/Icons/CheckIcon'
import XMarkIcon from '../../components/Icons/XMarkIcon'
import BinIcon from '../../components/Icons/BinIcon'
import ListIcon from '../../components/Icons/ListIcon'
export const Courier = {
name: 'courier',
label: 'Courier',
labelPlural: 'Couriers',
url: '/dashboard/management/couriers',
prefix: 'COR',
icon: CourierIcon,
actions: [
{
name: 'new',
type: 'modal',
pageName: 'list',
modalWidth: 700,
label: 'New Courier',
icon: PlusIcon,
content: (objectData, { onOk } = {}) => {
return createElement(NewCourier, { defaultValues: objectData, onOk, reset: true })
}
},
{
name: 'list',
type: 'page',
pageName: 'list',
label: 'List',
icon: ListIcon
},
{
name: 'info',
type: 'page',
pageName: 'info',
label: 'Info',
default: true,
row: true,
icon: InfoCircleIcon
},
{
name: 'edit',
type: 'page',
pageName: 'info',
label: 'Edit',
row: true,
icon: EditIcon,
visible: (objectData) => {
return !(objectData?._isEditing && objectData?._isEditing == true)
}
},
{
name: 'cancelEdit',
label: 'Cancel Edits',
type: 'page',
pageName: 'info',
icon: XMarkIcon,
visible: (objectData) => {
return objectData?._isEditing && objectData?._isEditing == true
}
},
{
name: 'finishEdit',
label: 'Save Edits',
type: 'page',
pageName: 'info',
icon: CheckIcon,
visible: (objectData) => {
return objectData?._isEditing && objectData?._isEditing == true
}
},
{ type: 'divider' },
{
name: 'delete',
type: 'page',
pageName: 'info',
label: 'Delete',
icon: BinIcon,
danger: true
}
],
pages: [
{
name: 'info',
content: () => createElement(CourierInfo)
}
],
columns: ['_reference', 'name', 'country', 'email', 'website', 'createdAt', 'updatedAt'],
filters: [
'name',
'website',
'email',
'phone',
'contact',
'country',
'createdAt',
'updatedAt',
'_reference'
],
sorters: [
'name',
'country',
'email',
'createdAt',
'_id',
'updatedAt'
],
group: ['country'],
properties: [
{
name: '_id',
label: 'ID',
columnFixed: 'left',
type: 'id',
objectType: 'courier',
showCopy: true,
columnWidth: 140
},
{
name: 'createdAt',
label: 'Created At',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{
name: '_reference',
label: 'Reference',
type: 'reference',
columnFixed: 'left',
objectType: 'courier',
showCopy: true,
readOnly: false,
required: true,
columnWidth: 180
},
{
name: 'name',
label: 'Name',
columnFixed: 'left',
required: true,
type: 'text',
columnWidth: 200
},
{
name: 'updatedAt',
label: 'Updated At',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{
name: 'contact',
label: 'Contact',
type: 'text',
readOnly: false,
required: false,
columnWidth: 150
},
{
name: 'country',
label: 'Country',
type: 'country',
readOnly: false,
required: false,
columnWidth: 150
},
{
name: 'email',
label: 'Email',
columnWidth: 300,
type: 'email',
readOnly: false,
required: false
},
{
name: 'phone',
label: 'Phone',
type: 'phone',
readOnly: false,
required: false,
columnWidth: 140
},
{
name: 'website',
label: 'Website',
columnWidth: 300,
type: 'url',
readOnly: false,
required: false
}
]
}