mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Support url and email fields
This commit is contained in:
@ -187,6 +187,21 @@ function ApiFormField({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case 'url':
|
case 'url':
|
||||||
|
return (
|
||||||
|
<TextInput
|
||||||
|
{...definition}
|
||||||
|
type="url"
|
||||||
|
onChange={(event) => onChange(event.currentTarget.value)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
case 'email':
|
||||||
|
return (
|
||||||
|
<TextInput
|
||||||
|
{...definition}
|
||||||
|
type="email"
|
||||||
|
onChange={(event) => onChange(event.currentTarget.value)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
case 'string':
|
case 'string':
|
||||||
return (
|
return (
|
||||||
<TextInput
|
<TextInput
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Trans } from '@lingui/macro';
|
import { Trans } from '@lingui/macro';
|
||||||
import { Group } from '@mantine/core';
|
import { Group, Stack } from '@mantine/core';
|
||||||
import { Button } from '@mantine/core';
|
import { Button } from '@mantine/core';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
@ -10,6 +10,7 @@ import { StylishText } from '../../components/items/StylishText';
|
|||||||
export default function Home() {
|
export default function Home() {
|
||||||
const [partFormOpened, setPartFormOpened] = useState(false);
|
const [partFormOpened, setPartFormOpened] = useState(false);
|
||||||
const [poFormOpened, setPoFormOpened] = useState(false);
|
const [poFormOpened, setPoFormOpened] = useState(false);
|
||||||
|
const [companyFormOpened, setCompanyFormOpened] = useState(false);
|
||||||
|
|
||||||
const partFields: ApiFormFieldType[] = [
|
const partFields: ApiFormFieldType[] = [
|
||||||
{
|
{
|
||||||
@ -50,6 +51,27 @@ export default function Home() {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const companyFields: ApiFormFieldType[] = [
|
||||||
|
{
|
||||||
|
name: 'name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'description'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'website'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'email'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'contact'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'is_customer'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Group>
|
<Group>
|
||||||
@ -80,6 +102,18 @@ export default function Home() {
|
|||||||
onClose={() => setPoFormOpened(false)}
|
onClose={() => setPoFormOpened(false)}
|
||||||
fetchInitialData={true}
|
fetchInitialData={true}
|
||||||
/>
|
/>
|
||||||
|
<ApiForm
|
||||||
|
name="company-edit"
|
||||||
|
url="/company/"
|
||||||
|
pk={1}
|
||||||
|
fields={companyFields}
|
||||||
|
method="PUT"
|
||||||
|
title="Edit Company"
|
||||||
|
opened={companyFormOpened}
|
||||||
|
onClose={() => setCompanyFormOpened(false)}
|
||||||
|
fetchInitialData={true}
|
||||||
|
/>
|
||||||
|
<Stack align="flex-start" spacing="xs">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => setPartFormOpened(true)}
|
onClick={() => setPartFormOpened(true)}
|
||||||
variant="outline"
|
variant="outline"
|
||||||
@ -94,6 +128,14 @@ export default function Home() {
|
|||||||
>
|
>
|
||||||
Edit Purchase Order Form
|
Edit Purchase Order Form
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
color="blue"
|
||||||
|
onClick={() => setCompanyFormOpened(true)}
|
||||||
|
>
|
||||||
|
Edit Company Form
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user