- Adjusted width of Stock Transfers modal for better UI consistency. - Enhanced New Stock Transfer form with default transfer name generation and improved validation handling. - Added Product Categories to Management Sidebar and updated routing for better navigation. - Implemented delete functionality in Host Info component. - Improved User Info layout for mobile responsiveness and added ObjectProperty component for better data display. - Updated FileUpload and FileList components to support minimal display mode. - Enhanced ObjectTable with subscription filtering and improved rendering logic. - Added new properties and filters to Stock Transfer and Product models for better data management.
265 lines
6.8 KiB
JavaScript
265 lines
6.8 KiB
JavaScript
import StockTransferIcon from '../../components/Icons/StockTransferIcon'
|
|
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'
|
|
|
|
export const StockTransfer = {
|
|
name: 'stockTransfer',
|
|
label: 'Stock Transfer',
|
|
prefix: 'STT',
|
|
icon: StockTransferIcon,
|
|
actions: [
|
|
{
|
|
name: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/stocktransfers/info?stockTransferId=${_id}`
|
|
},
|
|
{
|
|
name: 'edit',
|
|
label: 'Edit',
|
|
type: 'button',
|
|
icon: EditIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/stocktransfers/info?stockTransferId=${_id}&action=edit`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
},
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
}
|
|
},
|
|
{
|
|
name: 'cancelEdit',
|
|
label: 'Cancel Edit',
|
|
type: 'button',
|
|
icon: XMarkIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/stocktransfers/info?stockTransferId=${_id}&action=cancelEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Finish Edit',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/stocktransfers/info?stockTransferId=${_id}&action=finishEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'delete',
|
|
label: 'Delete',
|
|
type: 'button',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/stocktransfers/info?stockTransferId=${_id}&action=delete`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
},
|
|
disabled: (objectData) => {
|
|
return objectData?.state?.type != 'draft'
|
|
}
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'post',
|
|
label: 'Post',
|
|
type: 'button',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/inventory/stocktransfers/info?stockTransferId=${_id}&action=post`,
|
|
visible: (objectData) => {
|
|
return objectData?.state?.type == 'draft'
|
|
}
|
|
}
|
|
],
|
|
url: (id) => `/dashboard/inventory/stocktransfers/info?stockTransferId=${id}`,
|
|
filters: ['_id', 'name', 'state'],
|
|
sorters: ['name', 'createdAt', 'postedAt'],
|
|
columns: ['_reference', 'name', 'state', 'postedAt', 'createdAt', 'updatedAt'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
type: 'id',
|
|
objectType: 'stockTransfer',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'stockTransfer',
|
|
showCopy: true,
|
|
readOnly: true
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
type: 'text',
|
|
required: true,
|
|
columnWidth: 220,
|
|
columnFixed: 'left'
|
|
},
|
|
{
|
|
name: 'state',
|
|
label: 'State',
|
|
type: 'state',
|
|
readOnly: true,
|
|
columnWidth: 120
|
|
},
|
|
{
|
|
name: 'postedAt',
|
|
label: 'Posted At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'lines',
|
|
label: 'Lines',
|
|
type: 'objectChildren',
|
|
required: false,
|
|
canAddRemove: true,
|
|
columns: [
|
|
'fromStockType',
|
|
'fromStock',
|
|
'quantity',
|
|
'toStockLocation',
|
|
'toStockType',
|
|
'toStock'
|
|
],
|
|
properties: [
|
|
{
|
|
name: 'fromStockType',
|
|
label: 'From type',
|
|
type: 'objectType',
|
|
required: true,
|
|
columnWidth: 180,
|
|
masterFilter: ['filamentStock', 'partStock', 'productStock']
|
|
},
|
|
{
|
|
name: 'fromStock',
|
|
label: 'From stock',
|
|
type: 'object',
|
|
objectType: (row) => row?.fromStockType,
|
|
required: true,
|
|
showHyperlink: true,
|
|
columnWidth: 230
|
|
},
|
|
{
|
|
name: 'quantity',
|
|
label: 'Quantity',
|
|
type: 'number',
|
|
required: true,
|
|
min: 0,
|
|
columnWidth: 140,
|
|
suffix: (row) =>
|
|
row?.fromStockType === 'filamentStock' ? 'g net' : null
|
|
},
|
|
{
|
|
name: 'available',
|
|
label: 'Available',
|
|
type: 'number',
|
|
readOnly: true,
|
|
columnWidth: 140,
|
|
value: (row) => {
|
|
if (row?.fromStockType === 'filamentStock') {
|
|
return row?.fromStock?.currentWeight?.net ?? 0
|
|
} else {
|
|
return row?.fromStock?.currentQuantity ?? 0
|
|
}
|
|
},
|
|
suffix: (row) =>
|
|
row?.fromStockType === 'filamentStock' ? 'g net' : null
|
|
},
|
|
{
|
|
name: 'remaining',
|
|
label: 'Remaining',
|
|
type: 'number',
|
|
readOnly: true,
|
|
columnWidth: 140,
|
|
value: (row) => {
|
|
const quantity = row?.quantity ?? 0
|
|
if (row?.fromStockType === 'filamentStock') {
|
|
return (row?.fromStock?.currentWeight?.net ?? 0) - quantity
|
|
}
|
|
return (row?.fromStock?.currentQuantity ?? 0) - quantity
|
|
},
|
|
suffix: (row) =>
|
|
row?.fromStockType === 'filamentStock' ? 'g net' : null
|
|
},
|
|
{
|
|
name: 'toStockLocation',
|
|
label: 'To location',
|
|
type: 'object',
|
|
objectType: 'stockLocation',
|
|
required: true,
|
|
showHyperlink: true,
|
|
columnWidth: 230
|
|
},
|
|
{
|
|
name: 'toStockType',
|
|
label: 'To type',
|
|
type: 'objectType',
|
|
readOnly: true,
|
|
columnWidth: 180,
|
|
visible: (row) => Boolean(row?.toStockType)
|
|
},
|
|
{
|
|
name: 'toStock',
|
|
label: 'To stock',
|
|
type: 'object',
|
|
objectType: (row) => row?.toStockType,
|
|
readOnly: true,
|
|
showHyperlink: true,
|
|
columnWidth: 230,
|
|
visible: (row) => Boolean(row?.toStock)
|
|
}
|
|
]
|
|
}
|
|
],
|
|
stats: [
|
|
{
|
|
name: 'draft.count',
|
|
label: 'Draft',
|
|
type: 'number',
|
|
color: 'default'
|
|
},
|
|
{
|
|
name: 'posted.count',
|
|
label: 'Posted',
|
|
type: 'number',
|
|
color: 'success'
|
|
}
|
|
]
|
|
}
|