Tom Butcher ebcf959e85
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
Add Bulk Object Actions to Management and Dashboard Components
- Integrated BulkObjectActions component across various management and dashboard components for improved batch processing capabilities.
- Updated components including Invoices, PaymentPolicies, Payments, TaxRecords, and multiple Inventory and Management sections to include bulk action functionality.
- Enhanced user experience by allowing users to perform actions on multiple items simultaneously, streamlining workflows and improving efficiency.
2026-09-13 17:12:50 +01:00

185 lines
4.3 KiB
JavaScript

import { createElement, lazy } from 'react'
const MaterialInfo = lazy(
() => import('../../components/Dashboard/Management/Materials/MaterialInfo')
)
const NewMaterial = lazy(
() => import('../../components/Dashboard/Management/Materials/NewMaterial')
)
const DeleteObject = lazy(
() => import('../../components/Dashboard/common/DeleteObject')
)
import MaterialIcon from '../../components/Icons/MaterialIcon'
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'
import DuplicateIcon from '../../components/Icons/DuplicateIcon'
export const Material = {
name: 'material',
label: 'Material',
labelPlural: 'Materials',
url: '/dashboard/management/materials',
prefix: 'MAT',
icon: MaterialIcon,
actions: [
{
name: 'new',
type: 'modal',
pageName: 'list',
modalWidth: 700,
label: 'New Material',
icon: PlusIcon,
content: (objectData, { onOk } = {}) => {
return createElement(NewMaterial, {
defaultValues: objectData,
onOk,
reset: true
})
}
},
{
name: 'duplicate',
type: 'alias',
objectType: 'material',
aliasAction: 'new',
pageName: 'info',
label: 'Duplicate',
icon: DuplicateIcon,
objectData: (objectData) => objectData
},
{
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',
bulk: true,
type: 'modal',
modalWidth: 520,
modalCentered: true,
label: 'Delete',
icon: BinIcon,
danger: true,
content: (objectData, { onOk } = {}) => {
return createElement(DeleteObject, { objectData, onOk })
}
}
],
pages: [
{
name: 'info',
content: () => createElement(MaterialInfo)
}
],
columns: ['_reference', 'name', 'tags', 'createdAt', 'updatedAt'],
filters: ['_id', 'name', 'tags', 'createdAt', 'updatedAt', '_reference'],
sorters: ['name', 'createdAt', 'updatedAt', '_id'],
group: ['tags'],
properties: [
{
name: '_id',
label: 'ID',
columnFixed: 'left',
type: 'id',
objectType: 'material',
showCopy: true,
columnWidth: 140
},
{
name: 'createdAt',
label: 'Created At',
type: 'dateTime',
readOnly: true,
columnWidth: 200
},
{
name: '_reference',
label: 'Reference',
type: 'reference',
columnFixed: 'left',
objectType: 'material',
showCopy: true,
readOnly: 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: 200
},
{
name: 'tags',
label: 'Tags',
required: false,
type: 'tags',
columnWidth: 200
},
{
name: 'url',
label: 'Link',
required: false,
type: 'url',
columnWidth: 300
}
]
}