2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-22 14:50:53 +00:00

Add support for pre-form and post-form content

This commit is contained in:
Oliver Walters
2023-07-27 20:52:39 +10:00
parent 502e78d1ad
commit a3b6cb36a0
2 changed files with 13 additions and 1 deletions

View File

@ -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">

View File

@ -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"