All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Updated InventoryOverview to include additional statistics for part stock, filament stock, product stock, and stock events, improving data visibility. - Refactored InfoCollapse components to support new statistics and ensure proper state management for collapsible sections. - Enhanced ModelHistoryDisplay to support both line and bar chart types, providing more flexibility in data visualization. - Added new stats definitions for FilamentStock, PartStock, ProductStock, and StockEvent models to support the expanded inventory features.
222 lines
4.8 KiB
JavaScript
222 lines
4.8 KiB
JavaScript
import { createElement, lazy } from 'react'
|
|
|
|
const FilamentStockInfo = lazy(
|
|
() =>
|
|
import('../../components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo')
|
|
)
|
|
const NewFilamentStock = lazy(
|
|
() => import('../../components/Dashboard/Inventory/FilamentStocks/NewFilamentStock')
|
|
)
|
|
import FilamentStockIcon from '../../components/Icons/FilamentStockIcon'
|
|
import PlusIcon from '../../components/Icons/PlusIcon'
|
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
|
import ListIcon from '../../components/Icons/ListIcon'
|
|
|
|
export const FilamentStock = {
|
|
name: 'filamentStock',
|
|
label: 'Filament Stock',
|
|
labelPlural: 'Filament Stocks',
|
|
url: '/dashboard/inventory/filamentstocks',
|
|
prefix: 'FLS',
|
|
readOnly: true,
|
|
icon: FilamentStockIcon,
|
|
actions: [
|
|
{
|
|
name: 'new',
|
|
type: 'modal',
|
|
pageName: 'list',
|
|
modalWidth: 800,
|
|
label: 'New Filament Stock',
|
|
icon: PlusIcon,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(NewFilamentStock, { 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
|
|
}
|
|
],
|
|
pages: [
|
|
{
|
|
name: 'info',
|
|
content: () => createElement(FilamentStockInfo)
|
|
}
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'state',
|
|
'currentWeight',
|
|
'startingWeight',
|
|
'filament',
|
|
'filamentSku',
|
|
'stockLocation',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
filters: [
|
|
'filament',
|
|
'filamentSku',
|
|
'state',
|
|
'startingWeight',
|
|
'currentWeight',
|
|
'stockLocation',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: ['createdAt', 'updatedAt', 'filament', 'filamentSku', 'state'],
|
|
group: ['filament', 'filamentSku'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
columnFixed: 'left',
|
|
objectType: 'filamentStock',
|
|
showCopy: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'filamentStock',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'state',
|
|
label: 'State',
|
|
type: 'state',
|
|
objectType: 'filamentStock',
|
|
readOnly: true,
|
|
columnWidth: 260
|
|
},
|
|
{
|
|
name: 'filament',
|
|
label: 'Filament',
|
|
type: 'object',
|
|
value: null,
|
|
objectType: 'filament',
|
|
required: true,
|
|
showHyperlink: true,
|
|
columnWidth: 200,
|
|
initial: true
|
|
},
|
|
{
|
|
name: 'filamentSku',
|
|
label: 'Filament SKU',
|
|
type: 'object',
|
|
objectType: 'filamentSku',
|
|
readOnly: true,
|
|
initial: true,
|
|
required: true,
|
|
showHyperlink: true,
|
|
columnWidth: 200,
|
|
masterFilter: (objectData) => {
|
|
return {
|
|
filament: objectData?.filament?._id
|
|
}
|
|
}
|
|
},
|
|
{
|
|
name: 'stockLocation',
|
|
label: 'Stock location',
|
|
type: 'object',
|
|
objectType: 'stockLocation',
|
|
required: true,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'currentWeight',
|
|
label: 'Current Weight',
|
|
type: 'netGross',
|
|
suffix: 'g',
|
|
readOnly: true,
|
|
required: true,
|
|
columnWidth: 300,
|
|
value: (objectData) => {
|
|
if (objectData?.state?.type === 'unconsumed') {
|
|
return objectData?.startingWeight
|
|
} else {
|
|
return objectData.currentWeight
|
|
}
|
|
}
|
|
},
|
|
{
|
|
name: 'startingWeight',
|
|
label: 'Starting Weight',
|
|
type: 'netGross',
|
|
suffix: 'g',
|
|
readOnly: true,
|
|
initial: true,
|
|
required: true,
|
|
columnWidth: 300,
|
|
difference: (objectData) => {
|
|
return objectData?.filamentSku?.filament?.emptySpoolWeight
|
|
}
|
|
}
|
|
],
|
|
stats: [
|
|
{
|
|
name: 'unconsumed.count',
|
|
label: 'Unconsumed',
|
|
type: 'number',
|
|
color: 'success',
|
|
history: false
|
|
},
|
|
{
|
|
name: 'used.count',
|
|
label: 'Used',
|
|
type: 'number',
|
|
color: 'warning',
|
|
history: false
|
|
},
|
|
{
|
|
name: 'consumed.count',
|
|
label: 'Consumed',
|
|
type: 'number',
|
|
color: 'default',
|
|
history: false
|
|
},
|
|
{
|
|
name: 'totalCurrentWeight.sum',
|
|
label: 'Total Current Weight',
|
|
type: 'number',
|
|
roundNumber: 2,
|
|
suffix: 'g',
|
|
cardWidth: 200
|
|
}
|
|
]
|
|
}
|