Implement editDisabled state across various components for improved editing control
Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit

- Added editDisabled state to multiple components, enhancing control over editing actions based on the current state.
- Updated the disabled property in relevant components to utilize the new editDisabled state, ensuring consistent behavior across the dashboard.
- Refactored imports to remove unused getModelByName function calls, streamlining the codebase.
This commit is contained in:
Tom Butcher 2026-08-09 23:33:34 +01:00
parent 7065cd312b
commit ed4f1c7505
49 changed files with 223 additions and 193 deletions

View File

@ -26,10 +26,7 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx'
import ScrollBox from '../../common/ScrollBox.jsx' import ScrollBox from '../../common/ScrollBox.jsx'
import { import { getModelProperty } from '../../../../database/ObjectModels.js'
getModelByName,
getModelProperty
} from '../../../../database/ObjectModels.js'
import OrderItemIcon from '../../../Icons/OrderItemIcon.jsx' import OrderItemIcon from '../../../Icons/OrderItemIcon.jsx'
import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx' import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx'
@ -65,6 +62,7 @@ const InvoiceInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -87,11 +85,6 @@ const InvoiceInfo = () => {
}, },
} }
const editDisabled =
getModelByName('invoice')
?.actions?.find((action) => action.name === 'edit')
?.disabled(objectFormState.objectData) ?? false
return ( return (
<Flex <Flex
gap='large' gap='large'
@ -156,7 +149,7 @@ const InvoiceInfo = () => {
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.beingEditedByOther ||
objectFormState.loading || objectFormState.loading ||
editDisabled objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -24,7 +24,6 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx'
import ScrollBox from '../../common/ScrollBox.jsx' import ScrollBox from '../../common/ScrollBox.jsx'
import { getModelByName } from '../../../../database/ObjectModels.js'
const log = loglevel.getLogger('PaymentInfo') const log = loglevel.getLogger('PaymentInfo')
log.setLevel(config.logLevel) log.setLevel(config.logLevel)
@ -55,6 +54,7 @@ const PaymentInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -77,11 +77,6 @@ const PaymentInfo = () => {
}, },
} }
const editDisabled =
getModelByName('payment')
?.actions?.find((action) => action.name === 'edit')
?.disabled(objectFormState.objectData) ?? false
return ( return (
<Flex <Flex
gap='large' gap='large'
@ -143,7 +138,7 @@ const PaymentInfo = () => {
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.beingEditedByOther ||
objectFormState.loading || objectFormState.loading ||
editDisabled objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -45,6 +45,7 @@ const TaxRecordInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -124,7 +125,9 @@ const TaxRecordInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -47,6 +47,7 @@ const FilamentStockInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -123,7 +124,11 @@ const FilamentStockInfo = () => {
}} }}
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={true} disabled={
objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
}
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />
<ObjectTableNavigationButtons <ObjectTableNavigationButtons

View File

@ -46,6 +46,7 @@ const OrderItemInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -123,7 +124,9 @@ const OrderItemInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -52,6 +52,7 @@ const PartStockInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -132,7 +133,9 @@ const PartStockInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -10,10 +10,7 @@ import InfoCollapse from '../../common/InfoCollapse.jsx'
import ObjectInfo from '../../common/ObjectInfo.jsx' import ObjectInfo from '../../common/ObjectInfo.jsx'
import ObjectProperty from '../../common/ObjectProperty.jsx' import ObjectProperty from '../../common/ObjectProperty.jsx'
import ViewButton from '../../common/ViewButton.jsx' import ViewButton from '../../common/ViewButton.jsx'
import { import { getModelProperty } from '../../../../database/ObjectModels.js'
getModelProperty,
getModelByName
} from '../../../../database/ObjectModels.js'
import InfoCircleIcon from '../../../Icons/InfoCircleIcon.jsx' import InfoCircleIcon from '../../../Icons/InfoCircleIcon.jsx'
import NoteIcon from '../../../Icons/NoteIcon.jsx' import NoteIcon from '../../../Icons/NoteIcon.jsx'
import AuditLogIcon from '../../../Icons/AuditLogIcon.jsx' import AuditLogIcon from '../../../Icons/AuditLogIcon.jsx'
@ -71,6 +68,7 @@ const ProductStockInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -93,11 +91,6 @@ const ProductStockInfo = () => {
}, },
} }
const editDisabled =
getModelByName('productStock')
?.actions?.find((action) => action.name === 'edit')
?.disabled(objectFormState.objectData) ?? false
return ( return (
<Flex <Flex
gap='large' gap='large'
@ -162,7 +155,7 @@ const ProductStockInfo = () => {
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.beingEditedByOther ||
objectFormState.loading || objectFormState.loading ||
editDisabled objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -28,7 +28,6 @@ import OrderItemsIcon from '../../../Icons/OrderItemIcon.jsx'
import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx' import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx'
import InvoiceIcon from '../../../Icons/InvoiceIcon.jsx' import InvoiceIcon from '../../../Icons/InvoiceIcon.jsx'
import StockEventIcon from '../../../Icons/StockEventIcon.jsx' import StockEventIcon from '../../../Icons/StockEventIcon.jsx'
import { getModelByName } from '../../../../database/ObjectModels.js'
const log = loglevel.getLogger('PurchaseOrderInfo') const log = loglevel.getLogger('PurchaseOrderInfo')
log.setLevel(config.logLevel) log.setLevel(config.logLevel)
@ -70,6 +69,7 @@ const PurchaseOrderInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -95,10 +95,6 @@ const PurchaseOrderInfo = () => {
}, },
} }
const editDisabled = getModelByName('purchaseOrder')
.actions.find((action) => action.name === 'edit')
.disabled(objectFormState.objectData)
return ( return (
<Flex <Flex
gap='large' gap='large'
@ -164,7 +160,7 @@ const PurchaseOrderInfo = () => {
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.beingEditedByOther ||
objectFormState.loading || objectFormState.loading ||
editDisabled objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -61,6 +61,7 @@ const PurchaseOrderInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -159,7 +160,9 @@ const PurchaseOrderInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -58,6 +58,7 @@ const ShipmentInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
const actions = { const actions = {
@ -138,7 +139,9 @@ const ShipmentInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -48,6 +48,7 @@ const StockAuditInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -126,7 +127,9 @@ const StockAuditInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -49,6 +49,7 @@ const StockLocationInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -127,7 +128,9 @@ const StockLocationInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -8,10 +8,7 @@ import InfoCollapse from '../../common/InfoCollapse.jsx'
import ObjectInfo from '../../common/ObjectInfo.jsx' import ObjectInfo from '../../common/ObjectInfo.jsx'
import ObjectProperty from '../../common/ObjectProperty.jsx' import ObjectProperty from '../../common/ObjectProperty.jsx'
import ViewButton from '../../common/ViewButton.jsx' import ViewButton from '../../common/ViewButton.jsx'
import { import { getModelProperty } from '../../../../database/ObjectModels.js'
getModelProperty,
getModelByName
} from '../../../../database/ObjectModels.js'
import InfoCircleIcon from '../../../Icons/InfoCircleIcon.jsx' import InfoCircleIcon from '../../../Icons/InfoCircleIcon.jsx'
import NoteIcon from '../../../Icons/NoteIcon.jsx' import NoteIcon from '../../../Icons/NoteIcon.jsx'
import AuditLogIcon from '../../../Icons/AuditLogIcon.jsx' import AuditLogIcon from '../../../Icons/AuditLogIcon.jsx'
@ -61,6 +58,7 @@ const StockTransferInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -83,11 +81,6 @@ const StockTransferInfo = () => {
}, },
} }
const editDisabled =
getModelByName('stockTransfer')
?.actions?.find((action) => action.name === 'edit')
?.disabled(objectFormState.objectData) ?? false
return ( return (
<Flex <Flex
gap='large' gap='large'
@ -150,7 +143,7 @@ const StockTransferInfo = () => {
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.beingEditedByOther ||
objectFormState.loading || objectFormState.loading ||
editDisabled objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -1,4 +1,4 @@
import { useRef, useState, useEffect, useContext } from 'react' import { useRef, useState, useEffect } from 'react'
import { useLocation } from 'react-router-dom' import { useLocation } from 'react-router-dom'
import { Flex, Space } from 'antd' import { Flex, Space } from 'antd'
import { LoadingOutlined } from '@ant-design/icons' import { LoadingOutlined } from '@ant-design/icons'
@ -20,8 +20,6 @@ import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx'
import ScrollBox from '../../common/ScrollBox.jsx' import ScrollBox from '../../common/ScrollBox.jsx'
import { getModelByName } from '../../../../database/ObjectModels.js'
import { AuthContext } from '../../context/AuthContext.jsx'
const AppPasswordInfo = () => { const AppPasswordInfo = () => {
const location = useLocation() const location = useLocation()
@ -36,7 +34,6 @@ const AppPasswordInfo = () => {
}) })
return () => setOnModalOk(null) return () => setOnModalOk(null)
}, [setOnModalOk]) }, [setOnModalOk])
const { userProfile } = useContext(AuthContext)
const appPasswordId = new URLSearchParams(location.search).get( const appPasswordId = new URLSearchParams(location.search).get(
'appPasswordId' 'appPasswordId'
) )
@ -53,6 +50,7 @@ const AppPasswordInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -71,10 +69,6 @@ const AppPasswordInfo = () => {
} }
} }
const editDisabled = getModelByName('appPassword')
.actions.find((action) => action.name === 'edit')
.disabled({ ...objectFormState.objectData, _user: userProfile })
return ( return (
<Flex <Flex
gap='large' gap='large'
@ -132,7 +126,7 @@ const AppPasswordInfo = () => {
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.beingEditedByOther ||
objectFormState.loading || objectFormState.loading ||
editDisabled objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -47,6 +47,7 @@ const CourierServiceInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -126,7 +127,9 @@ const CourierServiceInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -43,6 +43,7 @@ const CourierInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -122,7 +123,9 @@ const CourierInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -48,6 +48,7 @@ const DocumentJobInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -123,7 +124,9 @@ const DocumentJobInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -50,6 +50,7 @@ const DocumentPrinterInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -131,7 +132,9 @@ const DocumentPrinterInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -48,6 +48,7 @@ const DocumentSizeInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -123,7 +124,9 @@ const DocumentSizeInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -50,6 +50,7 @@ const DocumentTemplateInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -128,7 +129,9 @@ const DocumentTemplateInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -42,6 +42,7 @@ const FilamentSkuInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -121,7 +122,9 @@ const FilamentSkuInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -61,6 +61,7 @@ const FilamentInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -144,7 +145,9 @@ const FilamentInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -49,6 +49,7 @@ const FileInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: true, loading: true,
editDisabled: false
objectData: { objectData: {
_id: fileId _id: fileId
} }
@ -137,7 +138,9 @@ const FileInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -57,6 +57,7 @@ const HostInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -140,7 +141,9 @@ const HostInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -45,6 +45,7 @@ const MaterialInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -124,7 +125,9 @@ const MaterialInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -38,6 +38,7 @@ const NoteTypeInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -112,7 +113,9 @@ const NoteTypeInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -47,6 +47,7 @@ const NoteInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -127,7 +128,9 @@ const NoteInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -37,6 +37,7 @@ const PartSkuInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -116,7 +117,9 @@ const PartSkuInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -50,6 +50,7 @@ const PartInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -125,7 +126,9 @@ const PartInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -42,6 +42,7 @@ const ProductCategoryInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -121,7 +122,9 @@ const ProductCategoryInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -44,6 +44,7 @@ const ProductSkuInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -124,7 +125,9 @@ const ProductSkuInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -50,6 +50,7 @@ const ProductInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -125,7 +126,9 @@ const ProductInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -42,6 +42,7 @@ const TaxRateInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -121,7 +122,9 @@ const TaxRateInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -44,6 +44,7 @@ const UserInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
const isMobile = useMediaQuery({ maxWidth: 768 }) const isMobile = useMediaQuery({ maxWidth: 768 })
@ -120,7 +121,9 @@ const UserInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -42,6 +42,7 @@ const VendorInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -121,7 +122,9 @@ const VendorInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -80,6 +80,7 @@ const FilamentProfileInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -166,7 +167,11 @@ const FilamentProfileInfo = () => {
startEditing={() => actionHandlerRef.current.callAction('edit')} startEditing={() => actionHandlerRef.current.callAction('edit')}
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={objectFormState.beingEditedByOther || objectFormState.loading} disabled={
objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
}
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />
<ObjectTableNavigationButtons <ObjectTableNavigationButtons

View File

@ -51,6 +51,7 @@ const GCodeFileInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -130,7 +131,9 @@ const GCodeFileInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -25,7 +25,6 @@ import JobIcon from '../../../Icons/JobIcon.jsx'
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx'
import ScrollBox from '../../common/ScrollBox.jsx' import ScrollBox from '../../common/ScrollBox.jsx'
import { getModelByName } from '../../../../database/ObjectModels.js'
const log = loglevel.getLogger('JobInfo') const log = loglevel.getLogger('JobInfo')
log.setLevel(config.logLevel) log.setLevel(config.logLevel)
@ -57,16 +56,12 @@ const JobInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: { objectData: {
_id: jobId _id: jobId
} }
}) })
const editDisabled =
getModelByName('job')
?.actions?.find((action) => action.name === 'edit')
?.disabled(objectFormState.objectData) ?? false
const actions = { const actions = {
edit: () => { edit: () => {
objectFormRef?.current.startEditing() objectFormRef?.current.startEditing()
@ -144,7 +139,7 @@ const JobInfo = () => {
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.beingEditedByOther ||
objectFormState.loading || objectFormState.loading ||
editDisabled objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -59,6 +59,7 @@ const PrinterProfileInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -139,7 +140,11 @@ const PrinterProfileInfo = () => {
startEditing={() => actionHandlerRef.current.callAction('edit')} startEditing={() => actionHandlerRef.current.callAction('edit')}
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={objectFormState.beingEditedByOther || objectFormState.loading} disabled={
objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
}
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />
<ObjectTableNavigationButtons <ObjectTableNavigationButtons

View File

@ -51,6 +51,7 @@ const PrinterInfo = () => {
formValid: false, formValid: false,
activities: [], activities: [],
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -137,7 +138,9 @@ const PrinterInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -42,6 +42,7 @@ const ClientInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -121,7 +122,9 @@ const ClientInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -57,6 +57,7 @@ const ListingVarientInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -135,7 +136,9 @@ const ListingVarientInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -55,6 +55,7 @@ const ListingInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -134,7 +135,9 @@ const ListingInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -66,6 +66,7 @@ const MarketplaceInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -202,7 +203,9 @@ const MarketplaceInfo = () => {
editLoading={objectFormState.editLoading} editLoading={objectFormState.editLoading}
formValid={objectFormState.formValid} formValid={objectFormState.formValid}
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.loading objectFormState.beingEditedByOther ||
objectFormState.loading ||
objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -28,7 +28,6 @@ import OrderItemsIcon from '../../../Icons/OrderItemIcon.jsx'
import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx' import ShipmentIcon from '../../../Icons/ShipmentIcon.jsx'
import InvoiceIcon from '../../../Icons/InvoiceIcon.jsx' import InvoiceIcon from '../../../Icons/InvoiceIcon.jsx'
import StockEventIcon from '../../../Icons/StockEventIcon.jsx' import StockEventIcon from '../../../Icons/StockEventIcon.jsx'
import { getModelByName } from '../../../../database/ObjectModels.js'
const log = loglevel.getLogger('SalesOrderInfo') const log = loglevel.getLogger('SalesOrderInfo')
log.setLevel(config.logLevel) log.setLevel(config.logLevel)
@ -68,6 +67,7 @@ const SalesOrderInfo = () => {
formValid: false, formValid: false,
lock: null, lock: null,
loading: false, loading: false,
editDisabled: false,
objectData: {} objectData: {}
}) })
@ -93,10 +93,6 @@ const SalesOrderInfo = () => {
}, },
} }
const editDisabled = getModelByName('salesOrder')
.actions.find((action) => action.name === 'edit')
.disabled(objectFormState.objectData)
return ( return (
<Flex <Flex
gap='large' gap='large'
@ -162,7 +158,7 @@ const SalesOrderInfo = () => {
disabled={ disabled={
objectFormState.beingEditedByOther || objectFormState.beingEditedByOther ||
objectFormState.loading || objectFormState.loading ||
editDisabled objectFormState.editDisabled
} }
loading={objectFormState.editLoading} loading={objectFormState.editLoading}
/> />

View File

@ -6,7 +6,10 @@ import { useNavigate, useLocation } from 'react-router-dom'
import { useActionsModal } from '../context/ActionsModalContext' import { useActionsModal } from '../context/ActionsModalContext'
import KeyboardShortcut from './KeyboardShortcut' import KeyboardShortcut from './KeyboardShortcut'
import { AuthContext } from '../context/AuthContext' import { AuthContext } from '../context/AuthContext'
import { buildActionUrl, stripPageActionParams } from '../../../utils/modelActions' import {
buildActionUrl,
stripPageActionParams
} from '../../../utils/modelActions'
// Recursively filter actions based on visibleActions // Recursively filter actions based on visibleActions
function filterActionsByVisibility(actions, visibleActions) { function filterActionsByVisibility(actions, visibleActions) {
@ -238,7 +241,7 @@ const ObjectActions = ({
<Dropdown menu={menu} {...dropdownProps}> <Dropdown menu={menu} {...dropdownProps}>
<Button <Button
{...buttonProps} {...buttonProps}
disabled={disabled} disabled={disabled || filteredActions.length === 0}
onClick={() => showActionsModal(id, type, objectData)} onClick={() => showActionsModal(id, type, objectData)}
> >
Actions Actions

View File

@ -76,6 +76,23 @@ const buildObjectFromEntries = (entries = []) => {
}, {}) }, {})
} }
const getEditDisabled = (model, objectData, userProfile) => {
if (model?.readOnly === true) {
return true
}
const editAction = model?.actions?.find((action) => action.name === 'edit')
if (!editAction?.disabled) {
return false
}
if (typeof editAction.disabled === 'function') {
return (
editAction.disabled({ ...objectData, _user: userProfile }) ?? false
)
}
return !!editAction.disabled
}
/** /**
* ObjectForm is a reusable form component for editing any object type. * ObjectForm is a reusable form component for editing any object type.
* It handles fetching, updating, locking, unlocking, and validation logic. * It handles fetching, updating, locking, unlocking, and validation logic.
@ -85,9 +102,10 @@ const buildObjectFromEntries = (entries = []) => {
* - type: string (required) * - type: string (required)
* - formItems: array (for ObjectInfo/ObjectProperty items) * - formItems: array (for ObjectInfo/ObjectProperty items)
* - children: function({ * - children: function({
* loading, isEditing, startEditing, cancelEditing, handleUpdate, form, formValid, objectData, setIsEditing, setObjectData * loading, isEditing, startEditing, cancelEditing, handleUpdate, form, formValid, objectData, setIsEditing, setObjectData, editDisabled
* }) => ReactNode * }) => ReactNode
* - setCurrentObject: boolean (sync object data to ActionsContext) * - setCurrentObject: boolean (sync object data to ActionsContext)
* - onStateChange: receives form state including editDisabled (from model edit action)
*/ */
const ObjectForm = forwardRef( const ObjectForm = forwardRef(
( (
@ -388,20 +406,22 @@ const ObjectForm = forwardRef(
setFormValid(true) setFormValid(true)
onStateChangeRef.current({ onStateChangeRef.current({
formValid: true, formValid: true,
objectData: mergedObjectData objectData: mergedObjectData,
editDisabled: getEditDisabled(model, mergedObjectData, userProfile)
}) })
}) })
.catch(() => { .catch(() => {
setFormValid(false) setFormValid(false)
onStateChangeRef.current({ onStateChangeRef.current({
formValid: false, formValid: false,
objectData: mergedObjectData objectData: mergedObjectData,
editDisabled: getEditDisabled(model, mergedObjectData, userProfile)
}) })
}) })
}, 150) }, 150)
return () => clearTimeout(timeoutId) return () => clearTimeout(timeoutId)
}, [form, formUpdateValues]) }, [form, formUpdateValues, model, userProfile])
// Cleanup on unmount // Cleanup on unmount
useEffect(() => { useEffect(() => {
@ -592,10 +612,13 @@ const ObjectForm = forwardRef(
// Debounce objectData updates sent to parent to limit re-renders // Debounce objectData updates sent to parent to limit re-renders
useEffect(() => { useEffect(() => {
const timeoutId = setTimeout(() => { const timeoutId = setTimeout(() => {
onStateChangeRef.current({ objectData }) onStateChangeRef.current({
objectData,
editDisabled: getEditDisabled(model, objectData, userProfile)
})
}, 150) }, 150)
return () => clearTimeout(timeoutId) return () => clearTimeout(timeoutId)
}, [objectData]) }, [objectData, model, userProfile])
useEffect(() => { useEffect(() => {
if (!setCurrentObject) { if (!setCurrentObject) {
@ -651,13 +674,15 @@ const ObjectForm = forwardRef(
...computedValuesObject, ...computedValuesObject,
_isEditing: true _isEditing: true
})) }))
onStateChangeRef.current({ const nextObjectData = {
isEditing: true,
objectData: {
...objectData, ...objectData,
...computedValuesObject, ...computedValuesObject,
_isEditing: true _isEditing: true
} }
onStateChangeRef.current({
isEditing: true,
objectData: nextObjectData,
editDisabled: getEditDisabled(model, nextObjectData, userProfile)
}) })
} catch (err) { } catch (err) {
console.error(err) console.error(err)
@ -831,6 +856,7 @@ const ObjectForm = forwardRef(
setIsEditing, setIsEditing,
setObjectData, setObjectData,
editLoading, editLoading,
editDisabled: getEditDisabled(model, objectData, userProfile),
activities, activities,
handleFetchObject, handleFetchObject,
handleDelete handleDelete

View File

@ -1,13 +1,11 @@
import { createElement, lazy } from 'react' import { createElement, lazy } from 'react'
const FilamentStockInfo = lazy( const FilamentStockInfo = lazy(
() => import('../../components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo') () =>
import('../../components/Dashboard/Inventory/FilamentStocks/FilamentStockInfo')
) )
import FilamentStockIcon from '../../components/Icons/FilamentStockIcon' import FilamentStockIcon from '../../components/Icons/FilamentStockIcon'
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon' import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import EditIcon from '../../components/Icons/EditIcon'
import CheckIcon from '../../components/Icons/CheckIcon'
import XMarkIcon from '../../components/Icons/XMarkIcon'
export const FilamentStock = { export const FilamentStock = {
name: 'filamentStock', name: 'filamentStock',
@ -15,6 +13,7 @@ export const FilamentStock = {
labelPlural: 'Filament Stocks', labelPlural: 'Filament Stocks',
url: '/dashboard/inventory/filamentstocks', url: '/dashboard/inventory/filamentstocks',
prefix: 'FLS', prefix: 'FLS',
readOnly: true,
icon: FilamentStockIcon, icon: FilamentStockIcon,
actions: [ actions: [
{ {
@ -25,38 +24,7 @@ export const FilamentStock = {
default: true, default: true,
row: true, row: true,
icon: InfoCircleIcon icon: InfoCircleIcon
},
{
name: 'edit',
type: 'page',
pageName: 'info',
label: 'Edit',
row: true,
icon: EditIcon,
visible: (objectData) => {
return !(objectData?._isEditing && objectData?._isEditing == true)
} }
},
{
name: 'cancelEdit',
label: 'Cancel Edits',
type: 'page',
pageName: 'info',
icon: XMarkIcon,
visible: (objectData) => {
return objectData?._isEditing && objectData?._isEditing == true
}
},
{
name: 'finishEdit',
label: 'Save Edits',
type: 'page',
pageName: 'info',
icon: CheckIcon,
visible: (objectData) => {
return objectData?._isEditing && objectData?._isEditing == true
}
},
], ],
pages: [ pages: [
{ {
@ -89,13 +57,7 @@ export const FilamentStock = {
'updatedAt', 'updatedAt',
'_reference' '_reference'
], ],
sorters: [ sorters: ['createdAt', 'updatedAt', 'filament', 'filamentSku', 'state'],
'createdAt',
'updatedAt',
'filament',
'filamentSku',
'state'
],
group: ['filament', 'filamentSku'], group: ['filament', 'filamentSku'],
properties: [ properties: [
{ {

View File

@ -5,9 +5,6 @@ const PartStockInfo = lazy(
) )
import PartStockIcon from '../../components/Icons/PartStockIcon' import PartStockIcon from '../../components/Icons/PartStockIcon'
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon' import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
import EditIcon from '../../components/Icons/EditIcon'
import CheckIcon from '../../components/Icons/CheckIcon'
import XMarkIcon from '../../components/Icons/XMarkIcon'
export const PartStock = { export const PartStock = {
name: 'partStock', name: 'partStock',
@ -15,6 +12,7 @@ export const PartStock = {
labelPlural: 'Part Stocks', labelPlural: 'Part Stocks',
url: '/dashboard/inventory/partstocks', url: '/dashboard/inventory/partstocks',
prefix: 'PTS', prefix: 'PTS',
readOnly: true,
icon: PartStockIcon, icon: PartStockIcon,
actions: [ actions: [
{ {
@ -25,38 +23,7 @@ export const PartStock = {
default: true, default: true,
row: true, row: true,
icon: InfoCircleIcon icon: InfoCircleIcon
},
{
name: 'edit',
type: 'page',
pageName: 'info',
label: 'Edit',
row: true,
icon: EditIcon,
visible: (objectData) => {
return !(objectData?._isEditing && objectData?._isEditing == true)
} }
},
{
name: 'cancelEdit',
label: 'Cancel Edits',
type: 'page',
pageName: 'info',
icon: XMarkIcon,
visible: (objectData) => {
return objectData?._isEditing && objectData?._isEditing == true
}
},
{
name: 'finishEdit',
label: 'Save Edits',
type: 'page',
pageName: 'info',
icon: CheckIcon,
visible: (objectData) => {
return objectData?._isEditing && objectData?._isEditing == true
}
},
], ],
pages: [ pages: [
{ {