- Updated lazy loading syntax for component imports across multiple models to enhance code clarity. - Reformatted content return statements in various components for better readability. - Adjusted column widths for date fields from 175 to 200 to improve layout consistency across models. - Ensured consistent formatting and structure in model definitions for better maintainability.
239 lines
6.2 KiB
JavaScript
239 lines
6.2 KiB
JavaScript
import { createElement, lazy } from 'react'
|
|
|
|
const StockAuditLevelInfo = lazy(
|
|
() =>
|
|
import('../../components/Dashboard/Management/StockAuditLevels/StockAuditLevelInfo')
|
|
)
|
|
const NewStockAuditLevel = lazy(
|
|
() =>
|
|
import('../../components/Dashboard/Management/StockAuditLevels/NewStockAuditLevel')
|
|
)
|
|
const DeleteObject = lazy(
|
|
() => import('../../components/Dashboard/common/DeleteObject')
|
|
)
|
|
import StockAuditLevelIcon from '../../components/Icons/StockAuditLevelIcon'
|
|
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 StockAuditLevel = {
|
|
name: 'stockAuditLevel',
|
|
label: 'Stock Audit Level',
|
|
labelPlural: 'Stock Audit Levels',
|
|
url: '/dashboard/management/stockauditlevels',
|
|
prefix: 'SAL',
|
|
icon: StockAuditLevelIcon,
|
|
actions: [
|
|
{
|
|
name: 'new',
|
|
type: 'modal',
|
|
pageName: 'list',
|
|
modalWidth: 700,
|
|
label: 'New Stock Audit Level',
|
|
icon: PlusIcon,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(NewStockAuditLevel, {
|
|
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: 'modal',
|
|
modalWidth: 520,
|
|
modalCentered: true,
|
|
label: 'Delete',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(DeleteObject, { objectData, onOk })
|
|
}
|
|
}
|
|
],
|
|
pages: [
|
|
{
|
|
name: 'info',
|
|
content: () => createElement(StockAuditLevelInfo)
|
|
}
|
|
],
|
|
columns: ['_reference', 'name', 'tags', 'createdAt', 'updatedAt'],
|
|
filters: ['name', 'tags', 'createdAt', 'updatedAt', '_reference'],
|
|
sorters: ['name', 'createdAt', 'updatedAt'],
|
|
group: ['tags'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
objectType: 'stockAuditLevel',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'stockAuditLevel',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
type: 'text',
|
|
required: true,
|
|
columnWidth: 220,
|
|
columnFixed: 'left'
|
|
},
|
|
{
|
|
name: 'tags',
|
|
label: 'Tags',
|
|
type: 'tags',
|
|
required: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'auditLines',
|
|
label: 'Audit Lines',
|
|
type: 'objectChildren',
|
|
required: false,
|
|
size: 'medium',
|
|
canAddRemove: true,
|
|
columns: ['itemType', 'allItems', 'item', 'allSkus', 'itemSku'],
|
|
properties: [
|
|
{
|
|
name: 'itemType',
|
|
label: 'Item Type',
|
|
type: 'objectType',
|
|
required: true,
|
|
columnWidth: 150,
|
|
masterFilter: ['filament', 'part', 'product']
|
|
},
|
|
{
|
|
name: 'allItems',
|
|
label: 'All Items',
|
|
type: 'bool',
|
|
columnWidth: 110
|
|
},
|
|
{
|
|
name: 'item',
|
|
label: 'Item',
|
|
type: 'object',
|
|
objectType: (row) => row?.itemType,
|
|
showHyperlink: true,
|
|
columnWidth: 220,
|
|
disabled: (row) => row?.allItems === true,
|
|
value: (row) => (row?.allItems ? null : row?.item)
|
|
},
|
|
{
|
|
name: 'allSkus',
|
|
label: 'All SKUs',
|
|
type: 'bool',
|
|
columnWidth: 110,
|
|
disabled: (row) => row?.allItems === true,
|
|
value: (row) => (row?.allItems ? true : row?.allSkus)
|
|
},
|
|
{
|
|
name: 'itemSku',
|
|
label: 'Item SKU',
|
|
type: 'object',
|
|
objectType: (row) => {
|
|
if (row?.itemType === 'filament') return 'filamentSku'
|
|
if (row?.itemType === 'part') return 'partSku'
|
|
if (row?.itemType === 'product') return 'productSku'
|
|
return undefined
|
|
},
|
|
showHyperlink: true,
|
|
columnWidth: 220,
|
|
disabled: (row) => row?.allItems === true || row?.allSkus === true,
|
|
value: (row) => (row?.allItems || row?.allSkus ? null : row?.itemSku),
|
|
masterFilter: (row) => {
|
|
const itemId = row?.item?._id ?? row?.item
|
|
if (row?.itemType === 'filament' && itemId) {
|
|
return { filament: itemId }
|
|
}
|
|
if (row?.itemType === 'part' && itemId) {
|
|
return { part: itemId }
|
|
}
|
|
if (row?.itemType === 'product' && itemId) {
|
|
return { product: itemId }
|
|
}
|
|
return undefined
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|