Add New Document Printer functionality to DocumentPrinters component, including modal integration and success message upon creation. Enhance dropdown menu with new action item for creating document printers.
This commit is contained in:
parent
7ac56cc69c
commit
64c4d25982
@ -1,5 +1,6 @@
|
|||||||
import { useRef } from 'react'
|
import { useRef, useState } from 'react'
|
||||||
import { Button, Flex, Space, Dropdown } from 'antd'
|
import { Button, Flex, Space, Dropdown, message, Modal } from 'antd'
|
||||||
|
import PlusIcon from '../../Icons/PlusIcon'
|
||||||
import ObjectTable from '../common/ObjectTable'
|
import ObjectTable from '../common/ObjectTable'
|
||||||
import ReloadIcon from '../../Icons/ReloadIcon'
|
import ReloadIcon from '../../Icons/ReloadIcon'
|
||||||
import useColumnVisibility from '../hooks/useColumnVisibility'
|
import useColumnVisibility from '../hooks/useColumnVisibility'
|
||||||
@ -7,10 +8,12 @@ import GridIcon from '../../Icons/GridIcon'
|
|||||||
import ListIcon from '../../Icons/ListIcon'
|
import ListIcon from '../../Icons/ListIcon'
|
||||||
import useViewMode from '../hooks/useViewMode'
|
import useViewMode from '../hooks/useViewMode'
|
||||||
import ColumnViewButton from '../common/ColumnViewButton'
|
import ColumnViewButton from '../common/ColumnViewButton'
|
||||||
|
import NewDocumentPrinter from './DocumentPrinters/NewDocumentPrinter'
|
||||||
|
|
||||||
const DocumentPrinters = () => {
|
const DocumentPrinters = () => {
|
||||||
|
const [messageApi, contextHolder] = message.useMessage()
|
||||||
const tableRef = useRef()
|
const tableRef = useRef()
|
||||||
|
const [newDocumentPrinterOpen, setNewDocumentPrinterOpen] = useState(false)
|
||||||
const [viewMode, setViewMode] = useViewMode('documentPrinter')
|
const [viewMode, setViewMode] = useViewMode('documentPrinter')
|
||||||
|
|
||||||
const [columnVisibility, setColumnVisibility] =
|
const [columnVisibility, setColumnVisibility] =
|
||||||
@ -18,6 +21,12 @@ const DocumentPrinters = () => {
|
|||||||
|
|
||||||
const actionItems = {
|
const actionItems = {
|
||||||
items: [
|
items: [
|
||||||
|
{
|
||||||
|
label: 'New Document Printer',
|
||||||
|
key: 'newDocumentPrinter',
|
||||||
|
icon: <PlusIcon />
|
||||||
|
},
|
||||||
|
{ type: 'divider' },
|
||||||
{
|
{
|
||||||
label: 'Reload List',
|
label: 'Reload List',
|
||||||
key: 'reloadList',
|
key: 'reloadList',
|
||||||
@ -27,6 +36,8 @@ const DocumentPrinters = () => {
|
|||||||
onClick: ({ key }) => {
|
onClick: ({ key }) => {
|
||||||
if (key === 'reloadList') {
|
if (key === 'reloadList') {
|
||||||
tableRef.current?.reload()
|
tableRef.current?.reload()
|
||||||
|
} else if (key === 'newDocumentPrinter') {
|
||||||
|
setNewDocumentPrinterOpen(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,6 +45,7 @@ const DocumentPrinters = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Flex vertical={'true'} gap='large'>
|
<Flex vertical={'true'} gap='large'>
|
||||||
|
{contextHolder}
|
||||||
<Flex justify={'space-between'}>
|
<Flex justify={'space-between'}>
|
||||||
<Space size='small'>
|
<Space size='small'>
|
||||||
<Dropdown menu={actionItems}>
|
<Dropdown menu={actionItems}>
|
||||||
@ -62,6 +74,22 @@ const DocumentPrinters = () => {
|
|||||||
cards={viewMode === 'cards'}
|
cards={viewMode === 'cards'}
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
<Modal
|
||||||
|
open={newDocumentPrinterOpen}
|
||||||
|
onCancel={() => setNewDocumentPrinterOpen(false)}
|
||||||
|
footer={null}
|
||||||
|
destroyOnHidden={true}
|
||||||
|
width={700}
|
||||||
|
>
|
||||||
|
<NewDocumentPrinter
|
||||||
|
onOk={() => {
|
||||||
|
setNewDocumentPrinterOpen(false)
|
||||||
|
messageApi.success('New note type created successfully.')
|
||||||
|
tableRef.current?.reload()
|
||||||
|
}}
|
||||||
|
reset={!newDocumentPrinterOpen}
|
||||||
|
/>
|
||||||
|
</Modal>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user