diff --git a/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx b/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx index 6c80884c..14757a46 100644 --- a/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx +++ b/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx @@ -26,7 +26,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' -import { getModelProperty } from '../../../../database/ObjectModels.js' +import { getModelProperty, getModelByName } from '../../../../database/ObjectModels.js' import OrderItemIcon from '../../../Icons/OrderItemIcon.jsx' import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx' @@ -38,7 +38,6 @@ const InvoiceInfo = () => { const objectFormRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -82,215 +81,218 @@ const InvoiceInfo = () => { delete: () => { objectFormRef?.current?.handleDelete?.() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - } - isEditing={isEditing} - type='invoice' - labelWidth='225px' - objectData={objectData} - visibleProperties={{ - invoiceOrderItems: false, - invoiceShipments: false - }} - /> - - } - active={collapseState.invoiceOrderItems} - onToggle={(expanded) => - updateCollapseState('invoiceOrderItems', expanded) - } - collapseKey='invoiceOrderItems' - > - - - } - active={collapseState.invoiceShipments} - onToggle={(expanded) => - updateCollapseState('invoiceShipments', expanded) - } - collapseKey='invoiceShipments' - > - - - - )} - - - } - active={collapseState.payments} - onToggle={(expanded) => updateCollapseState('payments', expanded)} - collapseKey='payments' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + } + active={collapseState.info} + onToggle={(expanded) => + updateCollapseState('info', expanded) + } + collapseKey='info' + > + } + isEditing={isEditing} + type='invoice' + labelWidth='225px' + objectData={objectData} + visibleProperties={{ + invoiceOrderItems: false, + invoiceShipments: false + }} + /> + + } + active={collapseState.invoiceOrderItems} + onToggle={(expanded) => + updateCollapseState('invoiceOrderItems', expanded) + } + collapseKey='invoiceOrderItems' + > + + + } + active={collapseState.invoiceShipments} + onToggle={(expanded) => + updateCollapseState('invoiceShipments', expanded) + } + collapseKey='invoiceShipments' + > + + + + )} + + + } + active={collapseState.payments} + onToggle={(expanded) => updateCollapseState('payments', expanded)} + collapseKey='payments' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx b/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx index eff571e2..8164eced 100644 --- a/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx +++ b/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx @@ -23,6 +23,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('PaymentInfo') @@ -33,7 +34,6 @@ const PaymentInfo = () => { const objectFormRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -74,157 +74,160 @@ const PaymentInfo = () => { delete: () => { objectFormRef?.current?.handleDelete?.() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - } - isEditing={isEditing} - type='payment' - labelWidth='225px' - objectData={objectData} - /> - - - )} - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + } + active={collapseState.info} + onToggle={(expanded) => + updateCollapseState('info', expanded) + } + collapseKey='info' + > + } + isEditing={isEditing} + type='payment' + labelWidth='225px' + objectData={objectData} + /> + + + )} + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx b/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx index 6bfd892b..6cf21942 100644 --- a/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx +++ b/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx @@ -21,6 +21,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('TaxRecordInfo') @@ -199,8 +200,13 @@ const TaxRecordInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo.jsx b/src/components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo.jsx index 40a3ce79..99b4746d 100644 --- a/src/components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo.jsx +++ b/src/components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo.jsx @@ -22,6 +22,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder' import DocumentPrintButton from '../../common/DocumentPrintButton' import UserNotifierToggle from '../../common/UserNotifierToggle' import ScrollBox from '../../common/ScrollBox' +import { getModelByName } from '../../../../database/ObjectModels.js' import HistoryDisplay from '../../common/HistoryDisplay' const FilamentStockInfo = () => { @@ -186,7 +187,7 @@ const FilamentStockInfo = () => { ) : ( )} @@ -234,8 +235,13 @@ const FilamentStockInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Inventory/OrderItems/OrderItemInfo.jsx b/src/components/Dashboard/Inventory/OrderItems/OrderItemInfo.jsx index 8ca14ddf..a4b763ea 100644 --- a/src/components/Dashboard/Inventory/OrderItems/OrderItemInfo.jsx +++ b/src/components/Dashboard/Inventory/OrderItems/OrderItemInfo.jsx @@ -21,6 +21,7 @@ import ObjectActions from '../../common/ObjectActions.jsx' import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('OrderItemInfo') @@ -205,8 +206,13 @@ const OrderItemInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Inventory/PartStocks/PartStockInfo.jsx b/src/components/Dashboard/Inventory/PartStocks/PartStockInfo.jsx index 79d3d598..0cff01a1 100644 --- a/src/components/Dashboard/Inventory/PartStocks/PartStockInfo.jsx +++ b/src/components/Dashboard/Inventory/PartStocks/PartStockInfo.jsx @@ -25,6 +25,7 @@ import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' import HistoryDisplay from '../../common/HistoryDisplay.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import PartStockIcon from '../../../Icons/PartStockIcon.jsx' const log = loglevel.getLogger('PartStockInfo') @@ -204,7 +205,7 @@ const PartStockInfo = () => { ) : ( )} @@ -255,8 +256,13 @@ const PartStockInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx b/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx index 1a25900c..dbdd3c71 100644 --- a/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx +++ b/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx @@ -10,7 +10,7 @@ import InfoCollapse from '../../common/InfoCollapse.jsx' import ObjectInfo from '../../common/ObjectInfo.jsx' import ObjectProperty from '../../common/ObjectProperty.jsx' import ViewButton from '../../common/ViewButton.jsx' -import { getModelProperty } from '../../../../database/ObjectModels.js' +import { getModelProperty, getModelByName } from '../../../../database/ObjectModels.js' import InfoCircleIcon from '../../../Icons/InfoCircleIcon.jsx' import NoteIcon from '../../../Icons/NoteIcon.jsx' import AuditLogIcon from '../../../Icons/AuditLogIcon.jsx' @@ -39,7 +39,6 @@ const ProductStockInfo = () => { const objectFormRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -88,217 +87,220 @@ const ProductStockInfo = () => { delete: () => { objectFormRef?.current.handleDelete?.() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - } - isEditing={isEditing} - type='productStock' - objectData={objectData} - labelWidth='175px' - visibleProperties={{ partStocks: false }} - /> - - } - active={collapseState.partStocks} - onToggle={(expanded) => - updateCollapseState('partStocks', expanded) - } - collapseKey='partStocks' - > - - - - )} - - - - } - active={collapseState.events} - onToggle={(expanded) => updateCollapseState('events', expanded)} - collapseKey='events' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - } - active={collapseState.history} - onToggle={(expanded) => updateCollapseState('history', expanded)} - collapseKey='history' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + } + active={collapseState.info} + onToggle={(expanded) => + updateCollapseState('info', expanded) + } + collapseKey='info' + > + } + isEditing={isEditing} + type='productStock' + objectData={objectData} + labelWidth='175px' + visibleProperties={{ partStocks: false }} + /> + + } + active={collapseState.partStocks} + onToggle={(expanded) => + updateCollapseState('partStocks', expanded) + } + collapseKey='partStocks' + > + + + + )} + + + + } + active={collapseState.events} + onToggle={(expanded) => updateCollapseState('events', expanded)} + collapseKey='events' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + } + active={collapseState.history} + onToggle={(expanded) => updateCollapseState('history', expanded)} + collapseKey='history' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx b/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx index 633174e0..38d1a309 100644 --- a/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx +++ b/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx @@ -27,6 +27,7 @@ import ScrollBox from '../../common/ScrollBox.jsx' import OrderItemsIcon from '../../../Icons/OrderItemIcon.jsx' import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx' import InvoiceIcon from '../../../Icons/InvoiceIcon.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import StockEventIcon from '../../../Icons/StockEventIcon.jsx' const log = loglevel.getLogger('PurchaseOrderInfo') @@ -39,7 +40,6 @@ const PurchaseOrderInfo = () => { const shipmentsTableRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -92,244 +92,247 @@ const PurchaseOrderInfo = () => { delete: () => { objectFormRef?.current?.handleDelete?.() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - } - isEditing={isEditing} - type='purchaseOrder' - labelWidth='225px' - objectData={objectData} - visibleProperties={{ - items: false - }} - /> - - } - active={collapseState.orderItems} - onToggle={(expanded) => - updateCollapseState('orderItems', expanded) - } - collapseKey='orderItems' - > - - - } - active={collapseState.shipments} - onToggle={(expanded) => - updateCollapseState('shipments', expanded) - } - collapseKey='shipments' - > - - - } - active={collapseState.invoices} - onToggle={(expanded) => - updateCollapseState('invoices', expanded) - } - collapseKey='invoices' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - } - active={collapseState.stockEvents} - onToggle={(expanded) => - updateCollapseState('stockEvents', expanded) - } - collapseKey='stockEvents' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - )} - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + } + active={collapseState.info} + onToggle={(expanded) => + updateCollapseState('info', expanded) + } + collapseKey='info' + > + } + isEditing={isEditing} + type='purchaseOrder' + labelWidth='225px' + objectData={objectData} + visibleProperties={{ + items: false + }} + /> + + } + active={collapseState.orderItems} + onToggle={(expanded) => + updateCollapseState('orderItems', expanded) + } + collapseKey='orderItems' + > + + + } + active={collapseState.shipments} + onToggle={(expanded) => + updateCollapseState('shipments', expanded) + } + collapseKey='shipments' + > + + + } + active={collapseState.invoices} + onToggle={(expanded) => + updateCollapseState('invoices', expanded) + } + collapseKey='invoices' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + } + active={collapseState.stockEvents} + onToggle={(expanded) => + updateCollapseState('stockEvents', expanded) + } + collapseKey='stockEvents' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + )} + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx b/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx index da36785d..bcc8cbd1 100644 --- a/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx +++ b/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx @@ -27,6 +27,7 @@ import NewOrderItem from '../OrderItems/NewOrderItem.jsx' import NewShipment from './NewShipment.jsx' import PostPurchaseOrder from '../PurchaseOrders/PostPurchaseOrder.jsx' import AcknowledgePurchaseOrder from '../PurchaseOrders/AcknowledgePurchaseOrder.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx' const log = loglevel.getLogger('PurchaseOrderInfo') @@ -227,7 +228,7 @@ const PurchaseOrderInfo = () => { { { ) : ( )} diff --git a/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx b/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx index b24b8bfa..926761b0 100644 --- a/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx +++ b/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx @@ -24,6 +24,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import OrderItemIcon from '../../../Icons/OrderItemIcon.jsx' const log = loglevel.getLogger('ShipmentInfo') @@ -34,7 +35,6 @@ const ShipmentInfo = () => { const objectFormRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -77,179 +77,182 @@ const ShipmentInfo = () => { delete: () => { objectFormRef?.current?.handleDelete?.() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - } - isEditing={isEditing} - type='shipment' - objectData={objectData} - visibleProperties={{ - items: false - }} - labelWidth='175px' - /> - - } - active={collapseState.orderItems} - onToggle={(expanded) => - updateCollapseState('orderItems', expanded) - } - collapseKey='orderItems' - > - - - - )} - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + } + active={collapseState.info} + onToggle={(expanded) => + updateCollapseState('info', expanded) + } + collapseKey='info' + > + } + isEditing={isEditing} + type='shipment' + objectData={objectData} + visibleProperties={{ + items: false + }} + labelWidth='175px' + /> + + } + active={collapseState.orderItems} + onToggle={(expanded) => + updateCollapseState('orderItems', expanded) + } + collapseKey='orderItems' + > + + + + )} + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Inventory/StockAudits/StockAuditInfo.jsx b/src/components/Dashboard/Inventory/StockAudits/StockAuditInfo.jsx index e2155b74..d86ffd8c 100644 --- a/src/components/Dashboard/Inventory/StockAudits/StockAuditInfo.jsx +++ b/src/components/Dashboard/Inventory/StockAudits/StockAuditInfo.jsx @@ -22,6 +22,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('StockAuditInfo') @@ -211,8 +212,13 @@ const StockAuditInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Inventory/StockLocations/StockLocationInfo.jsx b/src/components/Dashboard/Inventory/StockLocations/StockLocationInfo.jsx index d3479f94..659ebc91 100644 --- a/src/components/Dashboard/Inventory/StockLocations/StockLocationInfo.jsx +++ b/src/components/Dashboard/Inventory/StockLocations/StockLocationInfo.jsx @@ -22,6 +22,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('StockLocationInfo') @@ -209,8 +210,13 @@ const StockLocationInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx b/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx index 36fd0cde..05c792de 100644 --- a/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx +++ b/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx @@ -8,7 +8,7 @@ import InfoCollapse from '../../common/InfoCollapse.jsx' import ObjectInfo from '../../common/ObjectInfo.jsx' import ObjectProperty from '../../common/ObjectProperty.jsx' import ViewButton from '../../common/ViewButton.jsx' -import { getModelProperty } from '../../../../database/ObjectModels.js' +import { getModelProperty, getModelByName } from '../../../../database/ObjectModels.js' import InfoCircleIcon from '../../../Icons/InfoCircleIcon.jsx' import NoteIcon from '../../../Icons/NoteIcon.jsx' import AuditLogIcon from '../../../Icons/AuditLogIcon.jsx' @@ -31,7 +31,6 @@ const StockTransferInfo = () => { const objectFormRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -78,178 +77,181 @@ const StockTransferInfo = () => { delete: () => { objectFormRef?.current.handleDelete?.() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - } - isEditing={isEditing} - type='stockTransfer' - objectData={objectData} - labelWidth='175px' - visibleProperties={{ lines: false }} - /> - - } - active={collapseState.lines} - onToggle={(expanded) => - updateCollapseState('lines', expanded) - } - collapseKey='lines' - > - - - - )} - - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + } + active={collapseState.info} + onToggle={(expanded) => + updateCollapseState('info', expanded) + } + collapseKey='info' + > + } + isEditing={isEditing} + type='stockTransfer' + objectData={objectData} + labelWidth='175px' + visibleProperties={{ lines: false }} + /> + + } + active={collapseState.lines} + onToggle={(expanded) => + updateCollapseState('lines', expanded) + } + collapseKey='lines' + > + + + + )} + + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Management/AppPasswords/AppPasswordInfo.jsx b/src/components/Dashboard/Management/AppPasswords/AppPasswordInfo.jsx index d8d18a94..f9e95fb5 100644 --- a/src/components/Dashboard/Management/AppPasswords/AppPasswordInfo.jsx +++ b/src/components/Dashboard/Management/AppPasswords/AppPasswordInfo.jsx @@ -19,6 +19,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const AppPasswordInfo = () => { @@ -26,7 +27,6 @@ const AppPasswordInfo = () => { const objectFormRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -70,132 +70,135 @@ const AppPasswordInfo = () => { } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - } - active={collapseState.info} - onToggle={(expanded) => updateCollapseState('info', expanded)} - collapseKey='info' - > - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - } - isEditing={isEditing} - type='appPassword' - objectData={objectData} - /> - )} - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + } + active={collapseState.info} + onToggle={(expanded) => updateCollapseState('info', expanded)} + collapseKey='info' + > + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + } + isEditing={isEditing} + type='appPassword' + objectData={objectData} + /> + )} + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx b/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx index b784f04f..08430416 100644 --- a/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx +++ b/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx @@ -21,6 +21,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('CourierServiceInfo') @@ -201,8 +202,13 @@ const CourierServiceInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/Couriers/CourierInfo.jsx b/src/components/Dashboard/Management/Couriers/CourierInfo.jsx index b82d2f98..7e9434e2 100644 --- a/src/components/Dashboard/Management/Couriers/CourierInfo.jsx +++ b/src/components/Dashboard/Management/Couriers/CourierInfo.jsx @@ -22,6 +22,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import CourierServiceIcon from '../../../Icons/CourierServiceIcon.jsx' const log = loglevel.getLogger('CourierInfo') @@ -186,10 +187,10 @@ const CourierInfo = () => { ) : ( )} @@ -219,8 +220,13 @@ const CourierInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/DocumentJobs/DocumentJobInfo.jsx b/src/components/Dashboard/Management/DocumentJobs/DocumentJobInfo.jsx index 1c16bc32..1048ab3f 100644 --- a/src/components/Dashboard/Management/DocumentJobs/DocumentJobInfo.jsx +++ b/src/components/Dashboard/Management/DocumentJobs/DocumentJobInfo.jsx @@ -22,6 +22,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('DocumentJobInfo') @@ -199,8 +200,13 @@ const DocumentJobInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/DocumentPrinters/DocumentPrinterInfo.jsx b/src/components/Dashboard/Management/DocumentPrinters/DocumentPrinterInfo.jsx index 4eb238c4..7f4c12ca 100644 --- a/src/components/Dashboard/Management/DocumentPrinters/DocumentPrinterInfo.jsx +++ b/src/components/Dashboard/Management/DocumentPrinters/DocumentPrinterInfo.jsx @@ -22,6 +22,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('DocumentPrinterInfo') @@ -213,8 +214,13 @@ const DocumentPrinterInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/DocumentSizes/DocumentSizeInfo.jsx b/src/components/Dashboard/Management/DocumentSizes/DocumentSizeInfo.jsx index 06d72eef..0bcc856a 100644 --- a/src/components/Dashboard/Management/DocumentSizes/DocumentSizeInfo.jsx +++ b/src/components/Dashboard/Management/DocumentSizes/DocumentSizeInfo.jsx @@ -22,6 +22,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('DocumentSizeInfo') @@ -200,8 +201,13 @@ const DocumentSizeInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/DocumentTemplates/DocumentTemplateInfo.jsx b/src/components/Dashboard/Management/DocumentTemplates/DocumentTemplateInfo.jsx index dfbc55f2..0d3e2adb 100644 --- a/src/components/Dashboard/Management/DocumentTemplates/DocumentTemplateInfo.jsx +++ b/src/components/Dashboard/Management/DocumentTemplates/DocumentTemplateInfo.jsx @@ -22,6 +22,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('DocumentTemplateInfo') @@ -214,8 +215,13 @@ const DocumentTemplateInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx b/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx index 8e190a9f..02229089 100644 --- a/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx +++ b/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx @@ -19,6 +19,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const FilamentSkuInfo = () => { @@ -196,8 +197,13 @@ const FilamentSkuInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx b/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx index 08e8a493..d9461371 100644 --- a/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx +++ b/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx @@ -25,6 +25,7 @@ import FilamentIcon from '../../../Icons/FilamentIcon.jsx' import FilamentSkuIcon from '../../../Icons/FilamentSkuIcon.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import ScrollBox from '../../common/ScrollBox.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' const log = loglevel.getLogger('FilamentInfo') @@ -214,7 +215,7 @@ const FilamentInfo = () => { )} @@ -232,7 +233,7 @@ const FilamentInfo = () => { ) : ( { ) : ( )} diff --git a/src/components/Dashboard/Management/Files/FileInfo.jsx b/src/components/Dashboard/Management/Files/FileInfo.jsx index ec51bcb3..fe3b4dc5 100644 --- a/src/components/Dashboard/Management/Files/FileInfo.jsx +++ b/src/components/Dashboard/Management/Files/FileInfo.jsx @@ -28,7 +28,7 @@ import { ApiServerContext } from '../../context/ApiServerContext.jsx' import ScrollBox from '../../common/ScrollBox.jsx' import JsonObjectIcon from '../../../Icons/JsonObjectIcon.jsx' import ObjectProperty from '../../common/ObjectProperty.jsx' -import { getModelProperty } from '../../../../database/ObjectModels.js' +import { getModelProperty, getModelByName } from '../../../../database/ObjectModels.js' const log = loglevel.getLogger('FileInfo') log.setLevel(config.logLevel) @@ -250,8 +250,13 @@ const FileInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/Hosts/HostInfo.jsx b/src/components/Dashboard/Management/Hosts/HostInfo.jsx index 673678dc..b04f01e5 100644 --- a/src/components/Dashboard/Management/Hosts/HostInfo.jsx +++ b/src/components/Dashboard/Management/Hosts/HostInfo.jsx @@ -25,6 +25,7 @@ import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import PrinterIcon from '../../../Icons/PrinterIcon.jsx' import DocumentPrinterIcon from '../../../Icons/DocumentPrinterIcon.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('HostInfo') @@ -35,7 +36,6 @@ const HostInfo = () => { const objectFormRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -81,198 +81,201 @@ const HostInfo = () => { } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - - } - active={collapseState.info} - onToggle={(expanded) => updateCollapseState('info', expanded)} - collapseKey='info' - > - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => { - return ( - } - isEditing={isEditing} - type='host' - objectData={objectData} - labelWidth='175px' - /> - ) - }} - - - - - } - active={collapseState.printers} - onToggle={(expanded) => updateCollapseState('printers', expanded)} - collapseKey='printers' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - } - active={collapseState.documentPrinters} - onToggle={(expanded) => - updateCollapseState('documentPrinters', expanded) - } - collapseKey='documentPrinters' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + } + active={collapseState.info} + onToggle={(expanded) => updateCollapseState('info', expanded)} + collapseKey='info' + > + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => { + return ( + } + isEditing={isEditing} + type='host' + objectData={objectData} + labelWidth='175px' + /> + ) + }} + + + + + } + active={collapseState.printers} + onToggle={(expanded) => updateCollapseState('printers', expanded)} + collapseKey='printers' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + } + active={collapseState.documentPrinters} + onToggle={(expanded) => + updateCollapseState('documentPrinters', expanded) + } + collapseKey='documentPrinters' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Management/Materials/MaterialInfo.jsx b/src/components/Dashboard/Management/Materials/MaterialInfo.jsx index 073d1f71..580a886b 100644 --- a/src/components/Dashboard/Management/Materials/MaterialInfo.jsx +++ b/src/components/Dashboard/Management/Materials/MaterialInfo.jsx @@ -21,6 +21,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('MaterialInfo') @@ -199,8 +200,13 @@ const MaterialInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/NoteTypes/NoteTypeInfo.jsx b/src/components/Dashboard/Management/NoteTypes/NoteTypeInfo.jsx index 3b3c8c8c..71ccabbb 100644 --- a/src/components/Dashboard/Management/NoteTypes/NoteTypeInfo.jsx +++ b/src/components/Dashboard/Management/NoteTypes/NoteTypeInfo.jsx @@ -18,6 +18,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const NoteTypeInfo = () => { @@ -177,8 +178,13 @@ const NoteTypeInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/Notes/NewNote.jsx b/src/components/Dashboard/Management/Notes/NewNote.jsx index bb43c984..980ed4f1 100644 --- a/src/components/Dashboard/Management/Notes/NewNote.jsx +++ b/src/components/Dashboard/Management/Notes/NewNote.jsx @@ -15,7 +15,7 @@ const NewNote = ({ onOk, defaultValues = {} }) => { { ) : ( )} diff --git a/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx b/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx index aa203ae7..d0e3a2fa 100644 --- a/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx +++ b/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx @@ -19,6 +19,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const PartSkuInfo = () => { @@ -191,8 +192,13 @@ const PartSkuInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/Parts/PartInfo.jsx b/src/components/Dashboard/Management/Parts/PartInfo.jsx index aaec3401..c17e500e 100644 --- a/src/components/Dashboard/Management/Parts/PartInfo.jsx +++ b/src/components/Dashboard/Management/Parts/PartInfo.jsx @@ -21,6 +21,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import PartSkuIcon from '../../../Icons/PartSkuIcon.jsx' const PartInfo = () => { @@ -30,7 +31,6 @@ const PartInfo = () => { const partId = new URLSearchParams(location.search).get('partId') const partSkusTableRef = useRef() - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -70,166 +70,165 @@ const PartInfo = () => { } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - - - )} - - } - active={collapseState.partSkus} - onToggle={(expanded) => - updateCollapseState('partSkus', expanded) - } - collapseKey='partSkus' - > - {objectFormState.loading ? ( - - ) : ( - ( + } + active={collapseState.info} + onToggle={(expanded) => updateCollapseState('info', expanded)} + collapseKey='info' + > + - )} - - + + )} + } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' + title='Part SKUs' + icon={} + active={collapseState.partSkus} + onToggle={(expanded) => updateCollapseState('partSkus', expanded)} + collapseKey='partSkus' > {objectFormState.loading ? ( ) : ( )} - - - + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx b/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx index 91d2d513..5e84b0fd 100644 --- a/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx +++ b/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx @@ -19,6 +19,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const ProductCategoryInfo = () => { @@ -196,8 +197,13 @@ const ProductCategoryInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx b/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx index a107542f..2a124b83 100644 --- a/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx +++ b/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx @@ -21,7 +21,7 @@ import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' import ObjectProperty from '../../common/ObjectProperty.jsx' -import { getModelProperty } from '../../../../database/ObjectModels.js' +import { getModelProperty, getModelByName } from '../../../../database/ObjectModels.js' import PartIcon from '../../../Icons/PartIcon.jsx' const ProductSkuInfo = () => { @@ -224,8 +224,13 @@ const ProductSkuInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/Products/ProductInfo.jsx b/src/components/Dashboard/Management/Products/ProductInfo.jsx index 57b3fd3d..43ecd564 100644 --- a/src/components/Dashboard/Management/Products/ProductInfo.jsx +++ b/src/components/Dashboard/Management/Products/ProductInfo.jsx @@ -21,6 +21,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ProductSkuIcon from '../../../Icons/ProductSkuIcon.jsx' const ProductInfo = () => { @@ -36,7 +37,6 @@ const ProductInfo = () => { }) const productSkusTableRef = useRef() - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -70,169 +70,172 @@ const ProductInfo = () => { } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - - - } - active={collapseState.productSkus} - onToggle={(expanded) => - updateCollapseState('productSkus', expanded) - } - collapseKey='productSkus' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - )} - - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + } + active={collapseState.info} + onToggle={(expanded) => + updateCollapseState('info', expanded) + } + collapseKey='info' + > + + + } + active={collapseState.productSkus} + onToggle={(expanded) => + updateCollapseState('productSkus', expanded) + } + collapseKey='productSkus' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + )} + + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx b/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx index 5dc4050e..b9f79f62 100644 --- a/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx +++ b/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx @@ -21,6 +21,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('TaxRateInfo') @@ -196,8 +197,13 @@ const TaxRateInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/Users/UserInfo.jsx b/src/components/Dashboard/Management/Users/UserInfo.jsx index 2a331063..d65ccc59 100644 --- a/src/components/Dashboard/Management/Users/UserInfo.jsx +++ b/src/components/Dashboard/Management/Users/UserInfo.jsx @@ -23,7 +23,7 @@ import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' import ObjectProperty from '../../common/ObjectProperty.jsx' -import { getModelProperty } from '../../../../database/ObjectModels.js' +import { getModelProperty, getModelByName } from '../../../../database/ObjectModels.js' import { useMediaQuery } from 'react-responsive' const UserInfo = () => { @@ -206,7 +206,7 @@ const UserInfo = () => { ) : ( @@ -227,9 +227,7 @@ const UserInfo = () => { title='Audit Logs' icon={} active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} collapseKey='auditLogs' > {objectFormState.loading ? ( @@ -237,8 +235,13 @@ const UserInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Management/Vendors/VendorInfo.jsx b/src/components/Dashboard/Management/Vendors/VendorInfo.jsx index ddfa2a52..318ad71f 100644 --- a/src/components/Dashboard/Management/Vendors/VendorInfo.jsx +++ b/src/components/Dashboard/Management/Vendors/VendorInfo.jsx @@ -21,6 +21,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('VendorInfo') @@ -196,8 +197,13 @@ const VendorInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx b/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx index f3daf2ed..65ba07b1 100644 --- a/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx +++ b/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx @@ -27,6 +27,7 @@ import SettingsIcon from '../../../Icons/SettingsIcon' import UserNotifierToggle from '../../common/UserNotifierToggle' import ViewButton from '../../common/ViewButton' import useCollapseState from '../../hooks/useCollapseState' +import { getModelByName } from '../../../../database/ObjectModels.js' import { FILAMENT_PROFILE_BED_TEMPERATURE_PROPERTIES, FILAMENT_PROFILE_COMPATIBILITY_PROPERTIES, @@ -160,7 +161,9 @@ const FilamentProfileInfo = () => { actionHandlerRef.current.callAction('finishEdit')} + handleUpdate={() => + actionHandlerRef.current.callAction('finishEdit') + } cancelEditing={() => actionHandlerRef.current.callAction('cancelEdit') } @@ -533,8 +536,13 @@ const FilamentProfileInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Production/GCodeFiles/GCodeFileInfo.jsx b/src/components/Dashboard/Production/GCodeFiles/GCodeFileInfo.jsx index 5c38e1f4..e3ff1e55 100644 --- a/src/components/Dashboard/Production/GCodeFiles/GCodeFileInfo.jsx +++ b/src/components/Dashboard/Production/GCodeFiles/GCodeFileInfo.jsx @@ -24,7 +24,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' -import { getModelProperty } from '../../../../database/ObjectModels.js' +import { getModelProperty, getModelByName } from '../../../../database/ObjectModels.js' import PartIcon from '../../../Icons/PartIcon.jsx' const log = loglevel.getLogger('GCodeFileInfo') @@ -235,8 +235,13 @@ const GCodeFileInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Production/Jobs/DeployJob.jsx b/src/components/Dashboard/Production/Jobs/DeployJob.jsx index bbe40b7c..43b38fc8 100644 --- a/src/components/Dashboard/Production/Jobs/DeployJob.jsx +++ b/src/components/Dashboard/Production/Jobs/DeployJob.jsx @@ -4,6 +4,7 @@ import WizardView from '../../common/WizardView' import { ApiServerContext } from '../../context/ApiServerContext' import { Descriptions, Flex, Typography } from 'antd' import ObjectTable from '../../common/ObjectTable' +import { getModelByName } from '../../../../database/ObjectModels.js' import ObjectProperty from '../../common/ObjectProperty' const { Text } = Typography const DeployJob = ({ @@ -26,7 +27,7 @@ const DeployJob = ({ while (hasMore == true) { const subJobsPage = await fetchObjects('subJob', { page: currentPage, - filter: { 'job._id': job._id } + filter: { job: job._id } }) subJobs = [...subJobs, ...subJobsPage.data] if (subJobsPage.data.length >= 25) { @@ -150,7 +151,7 @@ const DeployJob = ({ printer: false, job: false }} - masterFilter={{ 'job._id': job?._id }} + masterFilter={{ job: getModelByName('job').prefix + ':' + job?._id }} size={'small'} showActions={!slicerIntegration} /> diff --git a/src/components/Dashboard/Production/Jobs/JobInfo.jsx b/src/components/Dashboard/Production/Jobs/JobInfo.jsx index 29160232..5666fc69 100644 --- a/src/components/Dashboard/Production/Jobs/JobInfo.jsx +++ b/src/components/Dashboard/Production/Jobs/JobInfo.jsx @@ -24,6 +24,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import JobIcon from '../../../Icons/JobIcon.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('JobInfo') @@ -34,7 +35,6 @@ const JobInfo = () => { const objectFormRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -74,169 +74,172 @@ const JobInfo = () => { finishEdit: () => { objectFormRef?.current.handleUpdate() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - - } - active={collapseState.info} - onToggle={(expanded) => updateCollapseState('info', expanded)} - collapseKey='info' - > - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - } - isEditing={isEditing} - type='job' - objectData={objectData} - /> - )} - - - - - } - active={collapseState.subJobs} - onToggle={(expanded) => updateCollapseState('subJobs', expanded)} - collapseKey='subJobs' - > - - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + } + active={collapseState.info} + onToggle={(expanded) => updateCollapseState('info', expanded)} + collapseKey='info' + > + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + } + isEditing={isEditing} + type='job' + objectData={objectData} + /> + )} + + + + + } + active={collapseState.subJobs} + onToggle={(expanded) => updateCollapseState('subJobs', expanded)} + collapseKey='subJobs' + > + + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx b/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx index 3ed23845..325a6e38 100644 --- a/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx +++ b/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx @@ -26,7 +26,7 @@ import UserNotifierToggle from '../../common/UserNotifierToggle' import ViewButton from '../../common/ViewButton' import useCollapseState from '../../hooks/useCollapseState' import ObjectProperty from '../../common/ObjectProperty' -import { getModelProperty } from '../../../../database/ObjectModels' +import { getModelProperty, getModelByName } from '../../../../database/ObjectModels' import GCodeFileIcon from '../../../Icons/GCodeFileIcon' import SettingsIcon from '../../../Icons/SettingsIcon' import ExclamationOctagonIcon from '../../../Icons/ExclamationOctagonIcon' @@ -133,7 +133,9 @@ const PrinterProfileInfo = () => { actionHandlerRef.current.callAction('finishEdit')} + handleUpdate={() => + actionHandlerRef.current.callAction('finishEdit') + } cancelEditing={() => actionHandlerRef.current.callAction('cancelEdit') } @@ -385,8 +387,13 @@ const PrinterProfileInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Production/Printers/PrinterInfo.jsx b/src/components/Dashboard/Production/Printers/PrinterInfo.jsx index 34bf0c10..1eb66263 100644 --- a/src/components/Dashboard/Production/Printers/PrinterInfo.jsx +++ b/src/components/Dashboard/Production/Printers/PrinterInfo.jsx @@ -24,6 +24,7 @@ import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' import PrinterProfileIcon from '../../../Icons/PrinterProfileIcon.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ObjectTableNavigationButtons from '../../common/ObjectTableNavigationButtons.jsx' const log = loglevel.getLogger('PrinterInfo') log.setLevel(config.logLevel) @@ -34,7 +35,6 @@ const PrinterInfo = () => { const profilesTableRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() const printerId = new URLSearchParams(location.search).get('printerId') const [collapseState, updateCollapseState] = useCollapseState('PrinterInfo', { @@ -75,188 +75,191 @@ const PrinterInfo = () => { finishEdit: () => { objectFormRef?.current.handleUpdate() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - - } - active={collapseState.info} - onToggle={(expanded) => updateCollapseState('info', expanded)} - collapseKey='info' - > - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - } - isEditing={isEditing} - type='printer' - objectData={objectData} - labelWidth='175px' - visibleProperties={{ - currentFilamentStock: false, - 'currentFilamentStock._id': false, - currentJob: false, - 'currentJob._id': false, - currentSubJob: false, - 'currentSubJob._id': false, - alerts: false, - pendingSlicerUploads: false - }} - /> - )} - - - - - } - active={collapseState.profiles} - onToggle={(expanded) => updateCollapseState('profiles', expanded)} - collapseKey='profiles' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + } + active={collapseState.info} + onToggle={(expanded) => updateCollapseState('info', expanded)} + collapseKey='info' + > + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + } + isEditing={isEditing} + type='printer' + objectData={objectData} + labelWidth='175px' + visibleProperties={{ + currentFilamentStock: false, + 'currentFilamentStock._id': false, + currentJob: false, + 'currentJob._id': false, + currentSubJob: false, + 'currentSubJob._id': false, + alerts: false, + pendingSlicerUploads: false + }} + /> + )} + + + + + } + active={collapseState.profiles} + onToggle={(expanded) => updateCollapseState('profiles', expanded)} + collapseKey='profiles' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Production/SubJobs/SubJobInfo.jsx b/src/components/Dashboard/Production/SubJobs/SubJobInfo.jsx index 99d846f3..a7ca0842 100644 --- a/src/components/Dashboard/Production/SubJobs/SubJobInfo.jsx +++ b/src/components/Dashboard/Production/SubJobs/SubJobInfo.jsx @@ -21,6 +21,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import StockEventIcon from '../../../Icons/StockEventIcon.jsx' const SubJobInfo = () => { @@ -173,9 +174,9 @@ const SubJobInfo = () => { ) : ( { ) : ( )} diff --git a/src/components/Dashboard/Sales/Clients/ClientInfo.jsx b/src/components/Dashboard/Sales/Clients/ClientInfo.jsx index a8385ea2..9f3bd754 100644 --- a/src/components/Dashboard/Sales/Clients/ClientInfo.jsx +++ b/src/components/Dashboard/Sales/Clients/ClientInfo.jsx @@ -21,6 +21,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('ClientInfo') @@ -196,8 +197,13 @@ const ClientInfo = () => { ) : ( )} diff --git a/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx b/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx index 17d573e7..9eb81b18 100644 --- a/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx +++ b/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx @@ -23,6 +23,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' const log = loglevel.getLogger('ListingVarientInfo') log.setLevel(config.logLevel) @@ -32,7 +33,6 @@ const ListingVarientInfo = () => { const objectFormRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -77,151 +77,154 @@ const ListingVarientInfo = () => { delete: () => { objectFormRef?.current?.handleDelete?.() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - - - - )} - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + } + active={collapseState.info} + onToggle={(expanded) => + updateCollapseState('info', expanded) + } + collapseKey='info' + > + + + + )} + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Sales/Listings/ListingInfo.jsx b/src/components/Dashboard/Sales/Listings/ListingInfo.jsx index d4955fa6..35c3c6ab 100644 --- a/src/components/Dashboard/Sales/Listings/ListingInfo.jsx +++ b/src/components/Dashboard/Sales/Listings/ListingInfo.jsx @@ -23,6 +23,7 @@ import ObjectTable from '../../common/ObjectTable.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import ScrollBox from '../../common/ScrollBox.jsx' const log = loglevel.getLogger('ListingInfo') @@ -34,7 +35,6 @@ const ListingInfo = () => { const listingVarientsTableRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -75,171 +75,174 @@ const ListingInfo = () => { delete: () => { objectFormRef?.current?.handleDelete?.() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - - - } - active={collapseState.listingVarients} - onToggle={(expanded) => - updateCollapseState('listingVarients', expanded) - } - collapseKey='listingVarients' - > - - - - )} - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + } + active={collapseState.info} + onToggle={(expanded) => + updateCollapseState('info', expanded) + } + collapseKey='info' + > + + + } + active={collapseState.listingVarients} + onToggle={(expanded) => + updateCollapseState('listingVarients', expanded) + } + collapseKey='listingVarients' + > + + + + )} + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx b/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx index 3d54630f..c91d703e 100644 --- a/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx +++ b/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx @@ -1,4 +1,4 @@ -import { useContext, useRef, useState , useEffect} from 'react' +import { useContext, useRef, useState, useEffect } from 'react' import { useLocation } from 'react-router-dom' import { Card, Flex, message, Space } from 'antd' import loglevel from 'loglevel' @@ -25,6 +25,7 @@ import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import ScrollBox from '../../common/ScrollBox.jsx' import { ApiServerContext } from '../../context/ApiServerContext.jsx' import { ElectronContext } from '../../context/ElectronContext.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import { buildMarketplaceAuthState, storeMarketplaceAuthState @@ -38,7 +39,6 @@ const MarketplaceInfo = () => { const objectFormRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -148,144 +148,147 @@ const MarketplaceInfo = () => { } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - } - active={collapseState.info} - onToggle={(expanded) => updateCollapseState('info', expanded)} - collapseKey='info' - > - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - )} - - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + } + active={collapseState.info} + onToggle={(expanded) => updateCollapseState('info', expanded)} + collapseKey='info' + > + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + )} + + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx b/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx index f2d96691..ea2087cb 100644 --- a/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx +++ b/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx @@ -27,6 +27,7 @@ import ScrollBox from '../../common/ScrollBox.jsx' import OrderItemsIcon from '../../../Icons/OrderItemIcon.jsx' import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx' import InvoiceIcon from '../../../Icons/InvoiceIcon.jsx' +import { getModelByName } from '../../../../database/ObjectModels.js' import StockEventIcon from '../../../Icons/StockEventIcon.jsx' const log = loglevel.getLogger('SalesOrderInfo') @@ -39,7 +40,6 @@ const SalesOrderInfo = () => { const shipmentsTableRef = useRef(null) const actionHandlerRef = useRef(null) - const { setOnModalOk } = useActions() useEffect(() => { setOnModalOk(() => () => { @@ -90,244 +90,247 @@ const SalesOrderInfo = () => { delete: () => { objectFormRef?.current?.handleDelete?.() return true - }, + } } return ( - - + + + - - - - - - - + + + - - { - actionHandlerRef.current.callAction('finishEdit') - }} - cancelEditing={() => { - actionHandlerRef.current.callAction('cancelEdit') - }} - startEditing={() => { - actionHandlerRef.current.callAction('edit') - }} - editLoading={objectFormState.editLoading} - formValid={objectFormState.formValid} - disabled={ - objectFormState.beingEditedByOther || - objectFormState.loading || - objectFormState.editDisabled - } - loading={objectFormState.editLoading} - /> - - - - - - - - { - setEditFormState((prev) => ({ ...prev, ...state })) - }} - > - {({ loading, isEditing, objectData }) => ( - - } - active={collapseState.info} - onToggle={(expanded) => - updateCollapseState('info', expanded) - } - collapseKey='info' - > - } - isEditing={isEditing} - type='salesOrder' - labelWidth='225px' - objectData={objectData} - visibleProperties={{ - items: false - }} - /> - - } - active={collapseState.orderItems} - onToggle={(expanded) => - updateCollapseState('orderItems', expanded) - } - collapseKey='orderItems' - > - - - } - active={collapseState.shipments} - onToggle={(expanded) => - updateCollapseState('shipments', expanded) - } - collapseKey='shipments' - > - - - } - active={collapseState.invoices} - onToggle={(expanded) => - updateCollapseState('invoices', expanded) - } - collapseKey='invoices' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - } - active={collapseState.stockEvents} - onToggle={(expanded) => - updateCollapseState('stockEvents', expanded) - } - collapseKey='stockEvents' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - )} - - - } - active={collapseState.notes} - onToggle={(expanded) => updateCollapseState('notes', expanded)} - collapseKey='notes' - > - - - - - } - active={collapseState.auditLogs} - onToggle={(expanded) => - updateCollapseState('auditLogs', expanded) - } - collapseKey='auditLogs' - > - {objectFormState.loading ? ( - - ) : ( - - )} - - - + + + + { + actionHandlerRef.current.callAction('finishEdit') + }} + cancelEditing={() => { + actionHandlerRef.current.callAction('cancelEdit') + }} + startEditing={() => { + actionHandlerRef.current.callAction('edit') + }} + editLoading={objectFormState.editLoading} + formValid={objectFormState.formValid} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } + loading={objectFormState.editLoading} + /> + + + + + + + { + setEditFormState((prev) => ({ ...prev, ...state })) + }} + > + {({ loading, isEditing, objectData }) => ( + + } + active={collapseState.info} + onToggle={(expanded) => + updateCollapseState('info', expanded) + } + collapseKey='info' + > + } + isEditing={isEditing} + type='salesOrder' + labelWidth='225px' + objectData={objectData} + visibleProperties={{ + items: false + }} + /> + + } + active={collapseState.orderItems} + onToggle={(expanded) => + updateCollapseState('orderItems', expanded) + } + collapseKey='orderItems' + > + + + } + active={collapseState.shipments} + onToggle={(expanded) => + updateCollapseState('shipments', expanded) + } + collapseKey='shipments' + > + + + } + active={collapseState.invoices} + onToggle={(expanded) => + updateCollapseState('invoices', expanded) + } + collapseKey='invoices' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + } + active={collapseState.stockEvents} + onToggle={(expanded) => + updateCollapseState('stockEvents', expanded) + } + collapseKey='stockEvents' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + )} + + + } + active={collapseState.notes} + onToggle={(expanded) => updateCollapseState('notes', expanded)} + collapseKey='notes' + > + + + + + } + active={collapseState.auditLogs} + onToggle={(expanded) => updateCollapseState('auditLogs', expanded)} + collapseKey='auditLogs' + > + {objectFormState.loading ? ( + + ) : ( + + )} + + + + ) } diff --git a/src/components/Dashboard/common/ElipsisText.jsx b/src/components/Dashboard/common/ElipsisText.jsx index 2fa75343..fd06cd72 100644 --- a/src/components/Dashboard/common/ElipsisText.jsx +++ b/src/components/Dashboard/common/ElipsisText.jsx @@ -78,9 +78,7 @@ const ElipsisText = ({ children, style, className, title, code, ...rest }) => { style={style} > diff --git a/src/components/Dashboard/common/NoteItem.jsx b/src/components/Dashboard/common/NoteItem.jsx index a1aab744..1db08aaf 100644 --- a/src/components/Dashboard/common/NoteItem.jsx +++ b/src/components/Dashboard/common/NoteItem.jsx @@ -71,7 +71,9 @@ const NoteItem = ({ setChildNotesLoading(true) try { const childNotesData = await fetchObjects('note', { - filter: { 'parent._id': note._id } + filter: { + parent: getModelByName('note').prefix + ':' + note._id + } }) setChildNotes(childNotesData.data) } catch (error) { @@ -105,7 +107,7 @@ const NoteItem = ({ if (isExpanded == true) { subscribeToObjectTypeUpdatesRef.current = subscribeToObjectTypeUpdates( 'note', - { 'parent._id': note._id }, + { parent: getModelByName('note').prefix + ':' + note._id }, () => { if (isExpanded == true) { handleNoteExpand() diff --git a/src/components/Dashboard/common/NotesPanel.jsx b/src/components/Dashboard/common/NotesPanel.jsx index 2ac574ec..75d3284a 100644 --- a/src/components/Dashboard/common/NotesPanel.jsx +++ b/src/components/Dashboard/common/NotesPanel.jsx @@ -19,6 +19,7 @@ import InfoCircleIcon from '../../Icons/InfoCircleIcon' import ReloadIcon from '../../Icons/ReloadIcon' import NewNote from '../Management/Notes/NewNote' import NoteItem from './NoteItem' +import { getModelByName } from '../../../database/ObjectModels.js' const { Text } = Typography @@ -40,14 +41,14 @@ const NotesPanel = ({ _id, type }) => { const fetchData = useCallback( async (id) => { try { - const newData = await fetchNotes(id) + const newData = await fetchNotes(id, type) return newData } catch (error) { setError(error) return null } }, - [fetchNotes] + [fetchNotes, type] ) const generateNotes = useCallback( @@ -98,7 +99,7 @@ const NotesPanel = ({ _id, type }) => { if (connected == true && subscribeToObjectTypeUpdatesRef.current == null) { subscribeToObjectTypeUpdatesRef.current = subscribeToObjectTypeUpdates( 'note', - { 'parent._id': _id }, + { parent: getModelByName(type).prefix + ':' + _id }, () => handleReloadData() ) } diff --git a/src/components/Dashboard/context/ApiServerContext.jsx b/src/components/Dashboard/context/ApiServerContext.jsx index e0117e02..9c152c2a 100644 --- a/src/components/Dashboard/context/ApiServerContext.jsx +++ b/src/components/Dashboard/context/ApiServerContext.jsx @@ -1543,12 +1543,12 @@ const ApiServerProvider = ({ children }) => { } // Fetch notes for a specific parent - const fetchNotes = async (parentId) => { - logger.debug('Fetching notes for parent:', parentId) + const fetchNotes = async (parentId, parentType) => { + logger.debug('Fetching notes for parent:', parentId, parentType) try { const response = await axios.get(`${config.backendUrl}/notes`, { params: { - 'parent._id': parentId, + parent: getModelByName(parentType).prefix + ':' + parentId, sort: 'createdAt', order: 'ascend' }, @@ -1564,7 +1564,7 @@ const ApiServerProvider = ({ children }) => { } catch (err) { console.error(err) showError(err, () => { - fetchNotes(parentId) + fetchNotes(parentId, parentType) }) } } diff --git a/src/database/models/AppPassword.js b/src/database/models/AppPassword.js index d8af56cf..4657e6ea 100644 --- a/src/database/models/AppPassword.js +++ b/src/database/models/AppPassword.js @@ -97,7 +97,6 @@ export const AppPassword = { 'name', 'user', 'active', - 'user._id', 'createdAt', 'updatedAt', '_reference' diff --git a/src/database/models/AuditLog.js b/src/database/models/AuditLog.js index 899de787..621561b3 100644 --- a/src/database/models/AuditLog.js +++ b/src/database/models/AuditLog.js @@ -17,8 +17,8 @@ export const AuditLog = { 'createdAt' ], filters: [ - 'parent._id', - 'owner._id', + 'parent', + 'owner', 'operation', 'createdAt', 'updatedAt', diff --git a/src/database/models/CourierService.js b/src/database/models/CourierService.js index eaf191d1..e5b186d5 100644 --- a/src/database/models/CourierService.js +++ b/src/database/models/CourierService.js @@ -89,7 +89,6 @@ export const CourierService = { filters: [ '_id', 'courier', - 'courier._id', 'name', 'active', 'tracked', diff --git a/src/database/models/Filament.js b/src/database/models/Filament.js index c762174f..dff1d7eb 100644 --- a/src/database/models/Filament.js +++ b/src/database/models/Filament.js @@ -110,7 +110,6 @@ export const Filament = { filters: [ '_id', 'material', - 'material._id', 'diameter', 'name', 'cost', diff --git a/src/database/models/FilamentSku.js b/src/database/models/FilamentSku.js index d908eedf..3aced3df 100644 --- a/src/database/models/FilamentSku.js +++ b/src/database/models/FilamentSku.js @@ -90,7 +90,6 @@ export const FilamentSku = { '_id', 'barcode', 'filament', - 'filament._id', 'name', 'color', 'cost', diff --git a/src/database/models/FilamentStock.js b/src/database/models/FilamentStock.js index 6f1abbfd..2358474d 100644 --- a/src/database/models/FilamentStock.js +++ b/src/database/models/FilamentStock.js @@ -45,14 +45,11 @@ export const FilamentStock = { ], filters: [ 'filament', - 'filament._id', 'filamentSku', 'state', 'startingWeight', 'currentWeight', - 'filamentSku._id', 'stockLocation', - 'stockLocation._id', 'createdAt', 'updatedAt', '_reference' diff --git a/src/database/models/GCodeFile.js b/src/database/models/GCodeFile.js index 193b4230..e1c861b8 100644 --- a/src/database/models/GCodeFile.js +++ b/src/database/models/GCodeFile.js @@ -101,9 +101,7 @@ export const GCodeFile = { '_id', 'name', 'filament', - 'filament._id', 'filamentSku', - 'filamentSku._id', 'createdAt', 'updatedAt', '_reference' diff --git a/src/database/models/Invoice.js b/src/database/models/Invoice.js index b0dceaea..e9cb406f 100644 --- a/src/database/models/Invoice.js +++ b/src/database/models/Invoice.js @@ -166,10 +166,7 @@ export const Invoice = { 'vendor', 'client', 'state', - 'vendor._id', - 'client._id', 'order', - 'order._id', 'orderType', 'createdAt', 'updatedAt', diff --git a/src/database/models/ListingVarient.js b/src/database/models/ListingVarient.js index 9368eda4..ed3973af 100644 --- a/src/database/models/ListingVarient.js +++ b/src/database/models/ListingVarient.js @@ -122,7 +122,6 @@ export const ListingVarient = { ], filters: [ 'listing', - 'listing._id', 'product', 'productSku', 'state', diff --git a/src/database/models/Note.js b/src/database/models/Note.js index 0c93eab7..75dda84d 100644 --- a/src/database/models/Note.js +++ b/src/database/models/Note.js @@ -56,12 +56,10 @@ export const Note = { filters: [ '_id', 'user', - 'user._id', 'parentType', 'parent', - 'parent._id', + 'parent', 'noteType', - 'noteType._id', 'createdAt', 'updatedAt', '_reference' diff --git a/src/database/models/OrderItem.js b/src/database/models/OrderItem.js index c089e52b..f4c616ec 100644 --- a/src/database/models/OrderItem.js +++ b/src/database/models/OrderItem.js @@ -87,12 +87,9 @@ export const OrderItem = { 'name', 'itemType', 'item', - 'item._id', 'order', - 'order._id', 'orderType', 'shipment', - 'shipment._id', 'state', 'createdAt', 'updatedAt', diff --git a/src/database/models/PartSku.js b/src/database/models/PartSku.js index 3ec88a76..0d34cf33 100644 --- a/src/database/models/PartSku.js +++ b/src/database/models/PartSku.js @@ -92,7 +92,6 @@ export const PartSku = { '_id', 'barcode', 'part', - 'part._id', 'name', 'cost', 'price', diff --git a/src/database/models/PartStock.js b/src/database/models/PartStock.js index 924467ac..baf15d96 100644 --- a/src/database/models/PartStock.js +++ b/src/database/models/PartStock.js @@ -36,9 +36,7 @@ export const PartStock = { 'state', 'startingQuantity', 'currentQuantity', - 'partSku._id', 'stockLocation', - 'stockLocation._id', 'createdAt', 'updatedAt', '_reference' diff --git a/src/database/models/Payment.js b/src/database/models/Payment.js index 2dc321ec..6f736644 100644 --- a/src/database/models/Payment.js +++ b/src/database/models/Payment.js @@ -163,10 +163,7 @@ export const Payment = { 'vendor', 'client', 'state', - 'vendor._id', - 'client._id', 'invoice', - 'invoice._id', 'createdAt', 'updatedAt', '_reference' diff --git a/src/database/models/Product.js b/src/database/models/Product.js index 8c86f194..80a5eccd 100644 --- a/src/database/models/Product.js +++ b/src/database/models/Product.js @@ -102,7 +102,6 @@ export const Product = { 'name', 'globalPrice', 'productCategory', - 'productCategory._id', 'createdAt', 'updatedAt', '_reference' diff --git a/src/database/models/ProductSku.js b/src/database/models/ProductSku.js index f9cf349b..7e23b5c0 100644 --- a/src/database/models/ProductSku.js +++ b/src/database/models/ProductSku.js @@ -92,7 +92,6 @@ export const ProductSku = { '_id', 'barcode', 'product', - 'product._id', 'name', 'cost', 'price', diff --git a/src/database/models/ProductStock.js b/src/database/models/ProductStock.js index 56131368..83c8727c 100644 --- a/src/database/models/ProductStock.js +++ b/src/database/models/ProductStock.js @@ -7,6 +7,7 @@ const PostProductStock = lazy( () => import('../../components/Dashboard/Inventory/ProductStocks/PostProductStock') ) import ProductStockIcon from '../../components/Icons/ProductStockIcon' +import { getModelByName } from '../ObjectModels.js' import InfoCircleIcon from '../../components/Icons/InfoCircleIcon' import EditIcon from '../../components/Icons/EditIcon' import CheckIcon from '../../components/Icons/CheckIcon' @@ -103,9 +104,7 @@ export const ProductStock = { 'productSku', 'state', 'currentQuantity', - 'productSku._id', 'stockLocation', - 'stockLocation._id', 'createdAt', 'updatedAt', '_reference' @@ -227,7 +226,9 @@ export const ProductStock = { masterFilter: (objectData) => { const partSkuId = objectData?.partSku?._id if (partSkuId == null) return {} - return { 'partSku._id': partSkuId } + return { + partSku: getModelByName('partSku').prefix + ':' + partSkuId + } } }, { diff --git a/src/database/models/PurchaseOrder.js b/src/database/models/PurchaseOrder.js index 6a89adf3..f9a721d8 100644 --- a/src/database/models/PurchaseOrder.js +++ b/src/database/models/PurchaseOrder.js @@ -231,7 +231,6 @@ export const PurchaseOrder = { 'vendor', 'state', 'value', - 'vendor._id', 'totalAmount', 'totalAmountWithTax', 'totalTaxAmount', diff --git a/src/database/models/SalesOrder.js b/src/database/models/SalesOrder.js index ef0e5a7b..8e803913 100644 --- a/src/database/models/SalesOrder.js +++ b/src/database/models/SalesOrder.js @@ -238,7 +238,6 @@ export const SalesOrder = { 'client', 'state', 'value', - 'client._id', 'createdAt', 'updatedAt', '_reference' diff --git a/src/database/models/Shipment.js b/src/database/models/Shipment.js index 484824e2..49b42d31 100644 --- a/src/database/models/Shipment.js +++ b/src/database/models/Shipment.js @@ -147,7 +147,6 @@ export const Shipment = { 'order', 'state', 'courierService', - 'order._id', 'taxRate', 'createdAt', 'updatedAt', diff --git a/src/database/models/StockEvent.js b/src/database/models/StockEvent.js index 2e66537c..e73640e3 100644 --- a/src/database/models/StockEvent.js +++ b/src/database/models/StockEvent.js @@ -9,14 +9,8 @@ export const StockEvent = { icon: StockEventIcon, actions: [], columns: ['_reference', 'owner', 'parent', 'value', 'createdAt', 'updatedAt'], - filters: [ - 'owner._id', - 'parent._id', - 'createdAt', - 'updatedAt', - '_reference' - ], - sorters: ['createdAt','updatedAt'], + filters: ['owner', 'parent', 'createdAt', 'updatedAt', '_reference'], + sorters: ['createdAt', 'updatedAt'], properties: [ { name: '_id',