mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-22 06:40:54 +00:00
Add support for pre-form and post-form content
This commit is contained in:
@ -38,6 +38,10 @@ export interface ApiFormProps {
|
|||||||
fetchInitialData?: boolean;
|
fetchInitialData?: boolean;
|
||||||
method?: string;
|
method?: string;
|
||||||
opened: boolean;
|
opened: boolean;
|
||||||
|
preFormContent?: JSX.Element;
|
||||||
|
preFormContentFunc?: () => JSX.Element;
|
||||||
|
postFormContent?: JSX.Element;
|
||||||
|
postFormContentFunc?: () => JSX.Element;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
onFormSuccess?: () => void;
|
onFormSuccess?: () => void;
|
||||||
onFormError?: () => void;
|
onFormError?: () => void;
|
||||||
@ -201,6 +205,8 @@ export function ApiForm(props: ApiFormProps) {
|
|||||||
{error}
|
{error}
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
|
{props.preFormContent && props.preFormContent}
|
||||||
|
{props.preFormContentFunc ? props.preFormContentFunc() : null}
|
||||||
{canRender && (
|
{canRender && (
|
||||||
<ScrollArea>
|
<ScrollArea>
|
||||||
<Stack spacing="md">
|
<Stack spacing="md">
|
||||||
@ -218,6 +224,8 @@ export function ApiForm(props: ApiFormProps) {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
)}
|
)}
|
||||||
|
{props.postFormContent && props.postFormContent}
|
||||||
|
{props.postFormContentFunc ? props.postFormContentFunc() : null}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Divider />
|
<Divider />
|
||||||
<Group position="right">
|
<Group position="right">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Trans } from '@lingui/macro';
|
import { Trans } from '@lingui/macro';
|
||||||
import { Group, Stack } from '@mantine/core';
|
import { Alert, Group, Stack } from '@mantine/core';
|
||||||
import { Button } from '@mantine/core';
|
import { Button } from '@mantine/core';
|
||||||
import {
|
import {
|
||||||
IconBuilding,
|
IconBuilding,
|
||||||
@ -143,6 +143,10 @@ export default function Home() {
|
|||||||
fields={[]}
|
fields={[]}
|
||||||
opened={stockFormOpened}
|
opened={stockFormOpened}
|
||||||
onClose={() => setStockFormOpened(false)}
|
onClose={() => setStockFormOpened(false)}
|
||||||
|
preFormContent={<Alert color="red">Are you sure?</Alert>}
|
||||||
|
postFormContentFunc={() => (
|
||||||
|
<Alert color="blue">Post form content!</Alert>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
<CreateApiForm
|
<CreateApiForm
|
||||||
name="sales-order-create"
|
name="sales-order-create"
|
||||||
|
Reference in New Issue
Block a user