- Added 'additionalCost' and 'additionalCostWithTax' fields to CourierService model. - Introduced 'connection.port' field in DocumentPrinter model. - Updated Filament model with 'density' and 'emptySpoolWeight' fields. - Enhanced Part, PartSku, Product, and ProductSku models by adding 'cost', 'costWithTax', 'price', 'margin', and 'priceWithTax' fields for improved pricing structure.
301 lines
6.5 KiB
JavaScript
301 lines
6.5 KiB
JavaScript
import { createElement, lazy } from 'react'
|
|
|
|
const FilamentInfo = lazy(
|
|
() => import('../../components/Dashboard/Management/Filaments/FilamentInfo')
|
|
)
|
|
const NewFilament = lazy(
|
|
() => import('../../components/Dashboard/Management/Filaments/NewFilament')
|
|
)
|
|
const DeleteObject = lazy(
|
|
() => import('../../components/Dashboard/common/DeleteObject')
|
|
)
|
|
import EditIcon from '../../components/Icons/EditIcon'
|
|
import PlusIcon from '../../components/Icons/PlusIcon'
|
|
import CheckIcon from '../../components/Icons/CheckIcon'
|
|
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
|
import FilamentIcon from '../../components/Icons/FilamentIcon'
|
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
|
import BinIcon from '../../components/Icons/BinIcon'
|
|
import ListIcon from '../../components/Icons/ListIcon'
|
|
|
|
export const Filament = {
|
|
name: 'filament',
|
|
label: 'Filament',
|
|
labelPlural: 'Filaments',
|
|
url: '/dashboard/management/filaments',
|
|
prefix: 'FIL',
|
|
icon: FilamentIcon,
|
|
actions: [
|
|
{
|
|
name: 'new',
|
|
type: 'modal',
|
|
pageName: 'list',
|
|
modalWidth: 700,
|
|
label: 'New Filament',
|
|
icon: PlusIcon,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(NewFilament, { 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: 'newFilamentSku',
|
|
type: 'alias',
|
|
objectType: 'filamentSku',
|
|
aliasAction: 'new',
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
},
|
|
objectData: (objectData) => ({ filament: objectData })
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'delete',
|
|
type: 'modal',
|
|
modalWidth: 520,
|
|
modalCentered: true,
|
|
label: 'Delete',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
},
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(DeleteObject, { objectData, onOk })
|
|
}
|
|
}
|
|
],
|
|
pages: [
|
|
{
|
|
name: 'info',
|
|
content: () => createElement(FilamentInfo)
|
|
}
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'name',
|
|
'vendor',
|
|
'material',
|
|
'density',
|
|
'diameter',
|
|
'cost',
|
|
'costWithTax',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
filters: [
|
|
'_id',
|
|
'material',
|
|
'diameter',
|
|
'name',
|
|
'density',
|
|
'emptySpoolWeight',
|
|
'cost',
|
|
'costWithTax',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: [
|
|
'name',
|
|
'createdAt',
|
|
'vendor',
|
|
'material',
|
|
'diameter',
|
|
'density',
|
|
'emptySpoolWeight',
|
|
'cost',
|
|
'costWithTax',
|
|
'updatedAt'
|
|
],
|
|
group: ['diameter', 'material'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
columnFixed: 'left',
|
|
type: 'id',
|
|
objectType: 'filament',
|
|
showCopy: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'filament',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
columnFixed: 'left',
|
|
required: true,
|
|
type: 'text',
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'vendor',
|
|
label: 'Vendor',
|
|
type: 'object',
|
|
objectType: 'vendor',
|
|
required: false,
|
|
showHyperlink: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'material',
|
|
label: 'Material',
|
|
required: true,
|
|
columnWidth: 150,
|
|
type: 'object',
|
|
objectType: 'material',
|
|
showHyperlink: true
|
|
},
|
|
{
|
|
name: 'diameter',
|
|
label: 'Diameter',
|
|
columnWidth: 150,
|
|
required: true,
|
|
type: 'number',
|
|
suffix: 'mm'
|
|
},
|
|
{
|
|
name: 'density',
|
|
label: 'Density',
|
|
columnWidth: 150,
|
|
required: true,
|
|
type: 'number',
|
|
suffix: 'g/cm³'
|
|
},
|
|
{
|
|
name: 'emptySpoolWeight',
|
|
label: 'Spool Weight',
|
|
required: true,
|
|
columnWidth: 150,
|
|
type: 'number',
|
|
suffix: 'g'
|
|
},
|
|
{
|
|
name: 'cost',
|
|
label: 'Cost',
|
|
required: true,
|
|
columnWidth: 100,
|
|
type: 'number',
|
|
prefix: '£',
|
|
min: 0,
|
|
step: 0.01
|
|
},
|
|
{
|
|
name: 'costWithTax',
|
|
label: 'Cost w/ Tax',
|
|
required: true,
|
|
readOnly: true,
|
|
type: 'number',
|
|
prefix: '£',
|
|
min: 0,
|
|
step: 0.01,
|
|
columnWidth: 150,
|
|
value: (objectData) => {
|
|
const cost = objectData?.cost
|
|
if (!cost) return 0
|
|
if (objectData?.costTaxRate?.rateType == 'percentage') {
|
|
return (
|
|
(cost * (1 + objectData?.costTaxRate?.rate / 100)).toFixed(2) || 0
|
|
)
|
|
} else if (objectData?.costTaxRate?.rateType == 'amount') {
|
|
return (cost + objectData?.costTaxRate?.rate).toFixed(2) || 0
|
|
}
|
|
return cost
|
|
}
|
|
},
|
|
{
|
|
name: 'costTaxRate',
|
|
label: 'Cost Tax Rate',
|
|
required: true,
|
|
type: 'object',
|
|
objectType: 'taxRate',
|
|
showHyperlink: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'url',
|
|
label: 'Link',
|
|
required: false,
|
|
type: 'url',
|
|
columnWidth: 300
|
|
},
|
|
{
|
|
name: 'barcode',
|
|
label: 'Barcode',
|
|
required: false,
|
|
type: 'text',
|
|
columnWidth: 150
|
|
}
|
|
]
|
|
}
|