diff --git a/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx b/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx index b5ae825..6c80884 100644 --- a/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx +++ b/src/components/Dashboard/Finance/Invoices/InvoiceInfo.jsx @@ -26,10 +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 { - getModelByName, - getModelProperty -} from '../../../../database/ObjectModels.js' +import { getModelProperty } from '../../../../database/ObjectModels.js' import OrderItemIcon from '../../../Icons/OrderItemIcon.jsx' import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx' @@ -65,6 +62,7 @@ const InvoiceInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -87,11 +85,6 @@ const InvoiceInfo = () => { }, } - const editDisabled = - getModelByName('invoice') - ?.actions?.find((action) => action.name === 'edit') - ?.disabled(objectFormState.objectData) ?? false - return ( { disabled={ objectFormState.beingEditedByOther || objectFormState.loading || - editDisabled + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx b/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx index 2532264..eff571e 100644 --- a/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx +++ b/src/components/Dashboard/Finance/Payments/PaymentInfo.jsx @@ -24,7 +24,6 @@ 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('PaymentInfo') log.setLevel(config.logLevel) @@ -55,6 +54,7 @@ const PaymentInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -77,11 +77,6 @@ const PaymentInfo = () => { }, } - const editDisabled = - getModelByName('payment') - ?.actions?.find((action) => action.name === 'edit') - ?.disabled(objectFormState.objectData) ?? false - return ( { disabled={ objectFormState.beingEditedByOther || objectFormState.loading || - editDisabled + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx b/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx index b1c19c6..6bfd892 100644 --- a/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx +++ b/src/components/Dashboard/Finance/TaxRecords/TaxRecordInfo.jsx @@ -45,6 +45,7 @@ const TaxRecordInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -124,7 +125,9 @@ const TaxRecordInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo.jsx b/src/components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo.jsx index ce5650f..40a3ce7 100644 --- a/src/components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo.jsx +++ b/src/components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo.jsx @@ -47,6 +47,7 @@ const FilamentStockInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -123,7 +124,11 @@ const FilamentStockInfo = () => { }} editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} - disabled={true} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } loading={objectFormState.editLoading} /> { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -123,7 +124,9 @@ const OrderItemInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Inventory/PartStocks/PartStockInfo.jsx b/src/components/Dashboard/Inventory/PartStocks/PartStockInfo.jsx index 810502a..79d3d59 100644 --- a/src/components/Dashboard/Inventory/PartStocks/PartStockInfo.jsx +++ b/src/components/Dashboard/Inventory/PartStocks/PartStockInfo.jsx @@ -52,6 +52,7 @@ const PartStockInfo = () => { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: {} }) @@ -132,7 +133,9 @@ const PartStockInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx b/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx index d031682..1a25900 100644 --- a/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx +++ b/src/components/Dashboard/Inventory/ProductStocks/ProductStockInfo.jsx @@ -10,10 +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, - getModelByName -} from '../../../../database/ObjectModels.js' +import { getModelProperty } from '../../../../database/ObjectModels.js' import InfoCircleIcon from '../../../Icons/InfoCircleIcon.jsx' import NoteIcon from '../../../Icons/NoteIcon.jsx' import AuditLogIcon from '../../../Icons/AuditLogIcon.jsx' @@ -71,6 +68,7 @@ const ProductStockInfo = () => { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: {} }) @@ -93,11 +91,6 @@ const ProductStockInfo = () => { }, } - const editDisabled = - getModelByName('productStock') - ?.actions?.find((action) => action.name === 'edit') - ?.disabled(objectFormState.objectData) ?? false - return ( { disabled={ objectFormState.beingEditedByOther || objectFormState.loading || - editDisabled + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx b/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx index e82da87..633174e 100644 --- a/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx +++ b/src/components/Dashboard/Inventory/PurchaseOrders/PurchaseOrderInfo.jsx @@ -28,7 +28,6 @@ import OrderItemsIcon from '../../../Icons/OrderItemIcon.jsx' import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx' import InvoiceIcon from '../../../Icons/InvoiceIcon.jsx' import StockEventIcon from '../../../Icons/StockEventIcon.jsx' -import { getModelByName } from '../../../../database/ObjectModels.js' const log = loglevel.getLogger('PurchaseOrderInfo') log.setLevel(config.logLevel) @@ -70,6 +69,7 @@ const PurchaseOrderInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -95,10 +95,6 @@ const PurchaseOrderInfo = () => { }, } - const editDisabled = getModelByName('purchaseOrder') - .actions.find((action) => action.name === 'edit') - .disabled(objectFormState.objectData) - return ( { disabled={ objectFormState.beingEditedByOther || objectFormState.loading || - editDisabled + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx b/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx index 915c3d7..da36785 100644 --- a/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx +++ b/src/components/Dashboard/Inventory/Shipments/PurchaseOrderInfo.jsx @@ -61,6 +61,7 @@ const PurchaseOrderInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -159,7 +160,9 @@ const PurchaseOrderInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx b/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx index dfa13ac..b24b8bf 100644 --- a/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx +++ b/src/components/Dashboard/Inventory/Shipments/ShipmentInfo.jsx @@ -58,6 +58,7 @@ const ShipmentInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) const actions = { @@ -138,7 +139,9 @@ const ShipmentInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Inventory/StockAudits/StockAuditInfo.jsx b/src/components/Dashboard/Inventory/StockAudits/StockAuditInfo.jsx index 2f9044f..e2155b7 100644 --- a/src/components/Dashboard/Inventory/StockAudits/StockAuditInfo.jsx +++ b/src/components/Dashboard/Inventory/StockAudits/StockAuditInfo.jsx @@ -48,6 +48,7 @@ const StockAuditInfo = () => { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: {} }) @@ -126,7 +127,9 @@ const StockAuditInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Inventory/StockLocations/StockLocationInfo.jsx b/src/components/Dashboard/Inventory/StockLocations/StockLocationInfo.jsx index eb3121f..d3479f9 100644 --- a/src/components/Dashboard/Inventory/StockLocations/StockLocationInfo.jsx +++ b/src/components/Dashboard/Inventory/StockLocations/StockLocationInfo.jsx @@ -49,6 +49,7 @@ const StockLocationInfo = () => { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: {} }) @@ -127,7 +128,9 @@ const StockLocationInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx b/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx index e973a8e..36fd0cd 100644 --- a/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx +++ b/src/components/Dashboard/Inventory/StockTransfers/StockTransferInfo.jsx @@ -8,10 +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, - getModelByName -} from '../../../../database/ObjectModels.js' +import { getModelProperty } from '../../../../database/ObjectModels.js' import InfoCircleIcon from '../../../Icons/InfoCircleIcon.jsx' import NoteIcon from '../../../Icons/NoteIcon.jsx' import AuditLogIcon from '../../../Icons/AuditLogIcon.jsx' @@ -61,6 +58,7 @@ const StockTransferInfo = () => { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: {} }) @@ -83,11 +81,6 @@ const StockTransferInfo = () => { }, } - const editDisabled = - getModelByName('stockTransfer') - ?.actions?.find((action) => action.name === 'edit') - ?.disabled(objectFormState.objectData) ?? false - return ( { disabled={ objectFormState.beingEditedByOther || objectFormState.loading || - editDisabled + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/AppPasswords/AppPasswordInfo.jsx b/src/components/Dashboard/Management/AppPasswords/AppPasswordInfo.jsx index 8440af8..d8d18a9 100644 --- a/src/components/Dashboard/Management/AppPasswords/AppPasswordInfo.jsx +++ b/src/components/Dashboard/Management/AppPasswords/AppPasswordInfo.jsx @@ -1,4 +1,4 @@ -import { useRef, useState, useEffect, useContext } from 'react' +import { useRef, useState, useEffect } from 'react' import { useLocation } from 'react-router-dom' import { Flex, Space } from 'antd' import { LoadingOutlined } from '@ant-design/icons' @@ -20,8 +20,6 @@ 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 { AuthContext } from '../../context/AuthContext.jsx' const AppPasswordInfo = () => { const location = useLocation() @@ -36,7 +34,6 @@ const AppPasswordInfo = () => { }) return () => setOnModalOk(null) }, [setOnModalOk]) - const { userProfile } = useContext(AuthContext) const appPasswordId = new URLSearchParams(location.search).get( 'appPasswordId' ) @@ -53,6 +50,7 @@ const AppPasswordInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -71,10 +69,6 @@ const AppPasswordInfo = () => { } } - const editDisabled = getModelByName('appPassword') - .actions.find((action) => action.name === 'edit') - .disabled({ ...objectFormState.objectData, _user: userProfile }) - return ( { disabled={ objectFormState.beingEditedByOther || objectFormState.loading || - editDisabled + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx b/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx index 8a5fdee..b784f04 100644 --- a/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx +++ b/src/components/Dashboard/Management/CourierServices/CourierServiceInfo.jsx @@ -47,6 +47,7 @@ const CourierServiceInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -126,7 +127,9 @@ const CourierServiceInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/Couriers/CourierInfo.jsx b/src/components/Dashboard/Management/Couriers/CourierInfo.jsx index cc72d44..b82d2f9 100644 --- a/src/components/Dashboard/Management/Couriers/CourierInfo.jsx +++ b/src/components/Dashboard/Management/Couriers/CourierInfo.jsx @@ -43,6 +43,7 @@ const CourierInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -122,7 +123,9 @@ const CourierInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/DocumentJobs/DocumentJobInfo.jsx b/src/components/Dashboard/Management/DocumentJobs/DocumentJobInfo.jsx index 3794874..1c16bc3 100644 --- a/src/components/Dashboard/Management/DocumentJobs/DocumentJobInfo.jsx +++ b/src/components/Dashboard/Management/DocumentJobs/DocumentJobInfo.jsx @@ -48,6 +48,7 @@ const DocumentJobInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -123,7 +124,9 @@ const DocumentJobInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/DocumentPrinters/DocumentPrinterInfo.jsx b/src/components/Dashboard/Management/DocumentPrinters/DocumentPrinterInfo.jsx index d5d5b99..4eb238c 100644 --- a/src/components/Dashboard/Management/DocumentPrinters/DocumentPrinterInfo.jsx +++ b/src/components/Dashboard/Management/DocumentPrinters/DocumentPrinterInfo.jsx @@ -50,6 +50,7 @@ const DocumentPrinterInfo = () => { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: {} }) @@ -131,7 +132,9 @@ const DocumentPrinterInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/DocumentSizes/DocumentSizeInfo.jsx b/src/components/Dashboard/Management/DocumentSizes/DocumentSizeInfo.jsx index ecd491a..06d72ee 100644 --- a/src/components/Dashboard/Management/DocumentSizes/DocumentSizeInfo.jsx +++ b/src/components/Dashboard/Management/DocumentSizes/DocumentSizeInfo.jsx @@ -48,6 +48,7 @@ const DocumentSizeInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -123,7 +124,9 @@ const DocumentSizeInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/DocumentTemplates/DocumentTemplateInfo.jsx b/src/components/Dashboard/Management/DocumentTemplates/DocumentTemplateInfo.jsx index 2306403..dfbc55f 100644 --- a/src/components/Dashboard/Management/DocumentTemplates/DocumentTemplateInfo.jsx +++ b/src/components/Dashboard/Management/DocumentTemplates/DocumentTemplateInfo.jsx @@ -50,6 +50,7 @@ const DocumentTemplateInfo = () => { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: {} }) @@ -128,7 +129,9 @@ const DocumentTemplateInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx b/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx index bfb95f6..8e190a9 100644 --- a/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx +++ b/src/components/Dashboard/Management/FilamentSkus/FilamentSkuInfo.jsx @@ -42,6 +42,7 @@ const FilamentSkuInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -121,7 +122,9 @@ const FilamentSkuInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx b/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx index dccc904..08e8a49 100644 --- a/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx +++ b/src/components/Dashboard/Management/Filaments/FilamentInfo.jsx @@ -61,6 +61,7 @@ const FilamentInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -144,7 +145,9 @@ const FilamentInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/Files/FileInfo.jsx b/src/components/Dashboard/Management/Files/FileInfo.jsx index 487eaae..b26cde2 100644 --- a/src/components/Dashboard/Management/Files/FileInfo.jsx +++ b/src/components/Dashboard/Management/Files/FileInfo.jsx @@ -49,6 +49,7 @@ const FileInfo = () => { formValid: false, lock: null, loading: true, + editDisabled: false objectData: { _id: fileId } @@ -137,7 +138,9 @@ const FileInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/Hosts/HostInfo.jsx b/src/components/Dashboard/Management/Hosts/HostInfo.jsx index cade824..673678d 100644 --- a/src/components/Dashboard/Management/Hosts/HostInfo.jsx +++ b/src/components/Dashboard/Management/Hosts/HostInfo.jsx @@ -57,6 +57,7 @@ const HostInfo = () => { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: {} }) @@ -140,7 +141,9 @@ const HostInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/Materials/MaterialInfo.jsx b/src/components/Dashboard/Management/Materials/MaterialInfo.jsx index 5617b97..073d1f7 100644 --- a/src/components/Dashboard/Management/Materials/MaterialInfo.jsx +++ b/src/components/Dashboard/Management/Materials/MaterialInfo.jsx @@ -45,6 +45,7 @@ const MaterialInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -124,7 +125,9 @@ const MaterialInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/NoteTypes/NoteTypeInfo.jsx b/src/components/Dashboard/Management/NoteTypes/NoteTypeInfo.jsx index 584b9af..3b3c8c8 100644 --- a/src/components/Dashboard/Management/NoteTypes/NoteTypeInfo.jsx +++ b/src/components/Dashboard/Management/NoteTypes/NoteTypeInfo.jsx @@ -38,6 +38,7 @@ const NoteTypeInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -112,7 +113,9 @@ const NoteTypeInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/Notes/NoteInfo.jsx b/src/components/Dashboard/Management/Notes/NoteInfo.jsx index a42e3f8..53bbc86 100644 --- a/src/components/Dashboard/Management/Notes/NoteInfo.jsx +++ b/src/components/Dashboard/Management/Notes/NoteInfo.jsx @@ -47,6 +47,7 @@ const NoteInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -127,7 +128,9 @@ const NoteInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx b/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx index 40a4308..aa203ae 100644 --- a/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx +++ b/src/components/Dashboard/Management/PartSkus/PartSkuInfo.jsx @@ -37,6 +37,7 @@ const PartSkuInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -116,7 +117,9 @@ const PartSkuInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/Parts/PartInfo.jsx b/src/components/Dashboard/Management/Parts/PartInfo.jsx index 6526790..aaec340 100644 --- a/src/components/Dashboard/Management/Parts/PartInfo.jsx +++ b/src/components/Dashboard/Management/Parts/PartInfo.jsx @@ -50,6 +50,7 @@ const PartInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -125,7 +126,9 @@ const PartInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx b/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx index 7b9c272..91d2d51 100644 --- a/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx +++ b/src/components/Dashboard/Management/ProductCategories/ProductCategoryInfo.jsx @@ -42,6 +42,7 @@ const ProductCategoryInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -121,7 +122,9 @@ const ProductCategoryInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx b/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx index 443f39a..a107542 100644 --- a/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx +++ b/src/components/Dashboard/Management/ProductSkus/ProductSkuInfo.jsx @@ -44,6 +44,7 @@ const ProductSkuInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -124,7 +125,9 @@ const ProductSkuInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/Products/ProductInfo.jsx b/src/components/Dashboard/Management/Products/ProductInfo.jsx index b0d8fdb..57b3fd3 100644 --- a/src/components/Dashboard/Management/Products/ProductInfo.jsx +++ b/src/components/Dashboard/Management/Products/ProductInfo.jsx @@ -50,6 +50,7 @@ const ProductInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -125,7 +126,9 @@ const ProductInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx b/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx index 782ac7d..5dc4050 100644 --- a/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx +++ b/src/components/Dashboard/Management/TaxRates/TaxRateInfo.jsx @@ -42,6 +42,7 @@ const TaxRateInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -121,7 +122,9 @@ const TaxRateInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/Users/UserInfo.jsx b/src/components/Dashboard/Management/Users/UserInfo.jsx index 2df0543..2a33106 100644 --- a/src/components/Dashboard/Management/Users/UserInfo.jsx +++ b/src/components/Dashboard/Management/Users/UserInfo.jsx @@ -44,6 +44,7 @@ const UserInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) const isMobile = useMediaQuery({ maxWidth: 768 }) @@ -120,7 +121,9 @@ const UserInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Management/Vendors/VendorInfo.jsx b/src/components/Dashboard/Management/Vendors/VendorInfo.jsx index 87c860c..ddfa2a5 100644 --- a/src/components/Dashboard/Management/Vendors/VendorInfo.jsx +++ b/src/components/Dashboard/Management/Vendors/VendorInfo.jsx @@ -42,6 +42,7 @@ const VendorInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -121,7 +122,9 @@ const VendorInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx b/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx index 5cb64ed..f3daf2e 100644 --- a/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx +++ b/src/components/Dashboard/Production/FilamentProfiles/FilamentProfileInfo.jsx @@ -80,6 +80,7 @@ const FilamentProfileInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -166,7 +167,11 @@ const FilamentProfileInfo = () => { startEditing={() => actionHandlerRef.current.callAction('edit')} editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} - disabled={objectFormState.beingEditedByOther || objectFormState.loading} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } loading={objectFormState.editLoading} /> { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: {} }) @@ -130,7 +131,9 @@ const GCodeFileInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Production/Jobs/JobInfo.jsx b/src/components/Dashboard/Production/Jobs/JobInfo.jsx index 37628af..2916023 100644 --- a/src/components/Dashboard/Production/Jobs/JobInfo.jsx +++ b/src/components/Dashboard/Production/Jobs/JobInfo.jsx @@ -25,7 +25,6 @@ import JobIcon from '../../../Icons/JobIcon.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('JobInfo') log.setLevel(config.logLevel) @@ -57,16 +56,12 @@ const JobInfo = () => { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: { _id: jobId } }) - const editDisabled = - getModelByName('job') - ?.actions?.find((action) => action.name === 'edit') - ?.disabled(objectFormState.objectData) ?? false - const actions = { edit: () => { objectFormRef?.current.startEditing() @@ -144,7 +139,7 @@ const JobInfo = () => { disabled={ objectFormState.beingEditedByOther || objectFormState.loading || - editDisabled + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx b/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx index a3fc445..3ed2384 100644 --- a/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx +++ b/src/components/Dashboard/Production/PrinterProfiles/PrinterProfileInfo.jsx @@ -59,6 +59,7 @@ const PrinterProfileInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -139,7 +140,11 @@ const PrinterProfileInfo = () => { startEditing={() => actionHandlerRef.current.callAction('edit')} editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} - disabled={objectFormState.beingEditedByOther || objectFormState.loading} + disabled={ + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled + } loading={objectFormState.editLoading} /> { formValid: false, activities: [], loading: false, + editDisabled: false, objectData: {} }) @@ -137,7 +138,9 @@ const PrinterInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Sales/Clients/ClientInfo.jsx b/src/components/Dashboard/Sales/Clients/ClientInfo.jsx index 8e1e812..a8385ea 100644 --- a/src/components/Dashboard/Sales/Clients/ClientInfo.jsx +++ b/src/components/Dashboard/Sales/Clients/ClientInfo.jsx @@ -42,6 +42,7 @@ const ClientInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -121,7 +122,9 @@ const ClientInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx b/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx index 7c278ce..17d573e 100644 --- a/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx +++ b/src/components/Dashboard/Sales/ListingVarients/ListingVarientInfo.jsx @@ -57,6 +57,7 @@ const ListingVarientInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -135,7 +136,9 @@ const ListingVarientInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Sales/Listings/ListingInfo.jsx b/src/components/Dashboard/Sales/Listings/ListingInfo.jsx index 6931b22..d4955fa 100644 --- a/src/components/Dashboard/Sales/Listings/ListingInfo.jsx +++ b/src/components/Dashboard/Sales/Listings/ListingInfo.jsx @@ -55,6 +55,7 @@ const ListingInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -134,7 +135,9 @@ const ListingInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx b/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx index f77c8d9..3d54630 100644 --- a/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx +++ b/src/components/Dashboard/Sales/Marketplaces/MarketplaceInfo.jsx @@ -66,6 +66,7 @@ const MarketplaceInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -202,7 +203,9 @@ const MarketplaceInfo = () => { editLoading={objectFormState.editLoading} formValid={objectFormState.formValid} disabled={ - objectFormState.beingEditedByOther || objectFormState.loading + objectFormState.beingEditedByOther || + objectFormState.loading || + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx b/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx index e898204..f2d9669 100644 --- a/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx +++ b/src/components/Dashboard/Sales/SalesOrders/SalesOrderInfo.jsx @@ -28,7 +28,6 @@ import OrderItemsIcon from '../../../Icons/OrderItemIcon.jsx' import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx' import InvoiceIcon from '../../../Icons/InvoiceIcon.jsx' import StockEventIcon from '../../../Icons/StockEventIcon.jsx' -import { getModelByName } from '../../../../database/ObjectModels.js' const log = loglevel.getLogger('SalesOrderInfo') log.setLevel(config.logLevel) @@ -68,6 +67,7 @@ const SalesOrderInfo = () => { formValid: false, lock: null, loading: false, + editDisabled: false, objectData: {} }) @@ -93,10 +93,6 @@ const SalesOrderInfo = () => { }, } - const editDisabled = getModelByName('salesOrder') - .actions.find((action) => action.name === 'edit') - .disabled(objectFormState.objectData) - return ( { disabled={ objectFormState.beingEditedByOther || objectFormState.loading || - editDisabled + objectFormState.editDisabled } loading={objectFormState.editLoading} /> diff --git a/src/components/Dashboard/common/ObjectActions.jsx b/src/components/Dashboard/common/ObjectActions.jsx index d5f7cc3..00c629d 100644 --- a/src/components/Dashboard/common/ObjectActions.jsx +++ b/src/components/Dashboard/common/ObjectActions.jsx @@ -6,7 +6,10 @@ import { useNavigate, useLocation } from 'react-router-dom' import { useActionsModal } from '../context/ActionsModalContext' import KeyboardShortcut from './KeyboardShortcut' import { AuthContext } from '../context/AuthContext' -import { buildActionUrl, stripPageActionParams } from '../../../utils/modelActions' +import { + buildActionUrl, + stripPageActionParams +} from '../../../utils/modelActions' // Recursively filter actions based on visibleActions function filterActionsByVisibility(actions, visibleActions) { @@ -238,7 +241,7 @@ const ObjectActions = ({