235 lines
5.4 KiB
JavaScript
235 lines
5.4 KiB
JavaScript
import EditIcon from '../../components/Icons/EditIcon'
|
|
import FilamentIcon from '../../components/Icons/FilamentIcon'
|
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
|
import CheckIcon from '../../components/Icons/CheckIcon'
|
|
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
|
import PlusIcon from '../../components/Icons/PlusIcon'
|
|
import BinIcon from '../../components/Icons/BinIcon'
|
|
|
|
export const Filament = {
|
|
name: 'filament',
|
|
label: 'Filament',
|
|
labelPlural: 'Filaments',
|
|
url: '/dashboard/management/filaments',
|
|
prefix: 'FIL',
|
|
icon: FilamentIcon,
|
|
actions: [
|
|
{
|
|
name: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon,
|
|
url: (_id) => `/dashboard/management/filaments/info?filamentId=${_id}`
|
|
},
|
|
{
|
|
name: 'edit',
|
|
label: 'Edit',
|
|
row: true,
|
|
icon: EditIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/filaments/info?filamentId=${_id}&action=edit`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Save Edits',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/filaments/info?filamentId=${_id}&action=finishEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'cancelEdit',
|
|
label: 'Cancel Edits',
|
|
icon: XMarkIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/filaments/info?filamentId=${_id}&action=cancelEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'newFilamentSku',
|
|
label: 'New Filament SKU',
|
|
type: 'button',
|
|
icon: PlusIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/filaments/info?filamentId=${_id}&action=newFilamentSku`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
}
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'delete',
|
|
label: 'Delete',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/management/filaments/info?filamentId=${_id}&action=delete`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
}
|
|
}
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'name',
|
|
'material',
|
|
'density',
|
|
'diameter',
|
|
'cost',
|
|
'costWithTax',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
filters: ['_id', 'name', 'material', 'cost', 'costWithTax'],
|
|
sorters: [
|
|
'name',
|
|
'createdAt',
|
|
'material',
|
|
'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: 'name',
|
|
label: 'Name',
|
|
columnFixed: 'left',
|
|
required: true,
|
|
type: 'text',
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
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
|
|
}
|
|
]
|
|
}
|