Implement modal for adding new order items in PurchaseOrderInfo component
- Integrated NewOrderItem component within a modal to facilitate the addition of new order items. - Managed modal visibility state with useState hook. - Updated ObjectTable to display order items associated with the purchase order.
This commit is contained in:
parent
8945bb9a17
commit
8508442d2e
@ -1,6 +1,6 @@
|
|||||||
import { useRef, useState } from 'react'
|
import { useRef, useState } from 'react'
|
||||||
import { useLocation } from 'react-router-dom'
|
import { useLocation } from 'react-router-dom'
|
||||||
import { Space, Flex, Card } from 'antd'
|
import { Space, Flex, Card, Modal } from 'antd'
|
||||||
import { LoadingOutlined } from '@ant-design/icons'
|
import { LoadingOutlined } from '@ant-design/icons'
|
||||||
import loglevel from 'loglevel'
|
import loglevel from 'loglevel'
|
||||||
import config from '../../../../config.js'
|
import config from '../../../../config.js'
|
||||||
@ -21,9 +21,8 @@ import ObjectTable from '../../common/ObjectTable.jsx'
|
|||||||
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
|
import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx'
|
||||||
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
|
import DocumentPrintButton from '../../common/DocumentPrintButton.jsx'
|
||||||
import ScrollBox from '../../common/ScrollBox.jsx'
|
import ScrollBox from '../../common/ScrollBox.jsx'
|
||||||
import { getModelProperty } from '../../../../database/ObjectModels.js'
|
import OrderItemsIcon from '../../../Icons/OrderItemIcon.jsx'
|
||||||
import ObjectProperty from '../../common/ObjectProperty.jsx'
|
import NewOrderItem from '../OrderItems/NewOrderItem.jsx'
|
||||||
import OrderItemsIcon from '../../../Icons/OrderItemsIcon.jsx'
|
|
||||||
|
|
||||||
const log = loglevel.getLogger('PurchaseOrderInfo')
|
const log = loglevel.getLogger('PurchaseOrderInfo')
|
||||||
log.setLevel(config.logLevel)
|
log.setLevel(config.logLevel)
|
||||||
@ -32,6 +31,7 @@ const PurchaseOrderInfo = () => {
|
|||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const objectFormRef = useRef(null)
|
const objectFormRef = useRef(null)
|
||||||
const actionHandlerRef = useRef(null)
|
const actionHandlerRef = useRef(null)
|
||||||
|
const [newOrderItemOpen, setNewOrderItemOpen] = useState(false)
|
||||||
const purchaseOrderId = new URLSearchParams(location.search).get(
|
const purchaseOrderId = new URLSearchParams(location.search).get(
|
||||||
'purchaseOrderId'
|
'purchaseOrderId'
|
||||||
)
|
)
|
||||||
@ -73,6 +73,10 @@ const PurchaseOrderInfo = () => {
|
|||||||
delete: () => {
|
delete: () => {
|
||||||
objectFormRef?.current?.handleDelete?.()
|
objectFormRef?.current?.handleDelete?.()
|
||||||
return true
|
return true
|
||||||
|
},
|
||||||
|
newOrderItem: () => {
|
||||||
|
setNewOrderItemOpen(true)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,11 +184,10 @@ const PurchaseOrderInfo = () => {
|
|||||||
}
|
}
|
||||||
collapseKey='info'
|
collapseKey='info'
|
||||||
>
|
>
|
||||||
<ObjectProperty
|
<ObjectTable
|
||||||
{...getModelProperty('purchaseOrder', 'items')}
|
type='orderItem'
|
||||||
isEditing={isEditing}
|
masterFilter={{ 'order._id': purchaseOrderId }}
|
||||||
objectData={objectData}
|
visibleColumns={{ order: false }}
|
||||||
loading={loading}
|
|
||||||
/>
|
/>
|
||||||
</InfoCollapse>
|
</InfoCollapse>
|
||||||
</Flex>
|
</Flex>
|
||||||
@ -224,6 +227,27 @@ const PurchaseOrderInfo = () => {
|
|||||||
</Flex>
|
</Flex>
|
||||||
</ScrollBox>
|
</ScrollBox>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
<Modal
|
||||||
|
open={newOrderItemOpen}
|
||||||
|
onCancel={() => {
|
||||||
|
setNewOrderItemOpen(false)
|
||||||
|
}}
|
||||||
|
width={800}
|
||||||
|
footer={null}
|
||||||
|
destroyOnHidden={true}
|
||||||
|
>
|
||||||
|
<NewOrderItem
|
||||||
|
onOk={() => {
|
||||||
|
setNewOrderItemOpen(false)
|
||||||
|
}}
|
||||||
|
reset={newOrderItemOpen}
|
||||||
|
defaultValues={{
|
||||||
|
order: { _id: purchaseOrderId },
|
||||||
|
orderType: 'purchaseOrder',
|
||||||
|
syncAmount: 'itemCost'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user