mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 19:45:46 +00:00
Add icon support
- Cannot hash react nodes!
This commit is contained in:
@ -32,6 +32,7 @@ export type ApiFormFieldType = {
|
|||||||
name: string;
|
name: string;
|
||||||
label?: string;
|
label?: string;
|
||||||
value?: any;
|
value?: any;
|
||||||
|
icon?: ReactNode;
|
||||||
fieldType?: string;
|
fieldType?: string;
|
||||||
api_url?: string;
|
api_url?: string;
|
||||||
model?: string;
|
model?: string;
|
||||||
@ -122,7 +123,7 @@ function RelatedModelField({
|
|||||||
|
|
||||||
const selectQuery = useQuery({
|
const selectQuery = useQuery({
|
||||||
enabled: !definition.disabled && !!definition.api_url && !definition.hidden,
|
enabled: !definition.disabled && !!definition.api_url && !definition.hidden,
|
||||||
queryKey: [`related-field-${definition.name}`, definition, searchText],
|
queryKey: [`related-field-${definition.name}`, searchText],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
console.log('Searching for', searchText);
|
console.log('Searching for', searchText);
|
||||||
}
|
}
|
||||||
@ -300,7 +301,7 @@ export function ApiForm({
|
|||||||
// Query manager for retrieving form definition from the server
|
// Query manager for retrieving form definition from the server
|
||||||
const definitionQuery = useQuery({
|
const definitionQuery = useQuery({
|
||||||
enabled: opened && !!url,
|
enabled: opened && !!url,
|
||||||
queryKey: ['form-definition', name, url, pk, fields],
|
queryKey: ['form-definition', name, url, pk],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
// Clear form construction error field
|
// Clear form construction error field
|
||||||
setError('');
|
setError('');
|
||||||
@ -320,7 +321,7 @@ export function ApiForm({
|
|||||||
// Query manager for retrieiving initial data from the server
|
// Query manager for retrieiving initial data from the server
|
||||||
const initialDataQuery = useQuery({
|
const initialDataQuery = useQuery({
|
||||||
enabled: fetchInitialData && opened && !!url && fieldDefinitions.length > 0,
|
enabled: fetchInitialData && opened && !!url && fieldDefinitions.length > 0,
|
||||||
queryKey: ['form-initial-data', name, url, pk, fields, fieldDefinitions],
|
queryKey: ['form-initial-data', name, url, pk],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
return api
|
return api
|
||||||
.get(getUrl())
|
.get(getUrl())
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
import { Trans } from '@lingui/macro';
|
import { Trans } from '@lingui/macro';
|
||||||
import { Group, Stack } from '@mantine/core';
|
import { Group, Stack } from '@mantine/core';
|
||||||
import { Button } from '@mantine/core';
|
import { Button } from '@mantine/core';
|
||||||
|
import {
|
||||||
|
IconBuilding,
|
||||||
|
IconGlobe,
|
||||||
|
IconKey,
|
||||||
|
IconMail,
|
||||||
|
IconUser
|
||||||
|
} from '@tabler/icons-react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import { ApiForm, ApiFormFieldType } from '../../components/forms/ApiForm';
|
import { ApiForm, ApiFormFieldType } from '../../components/forms/ApiForm';
|
||||||
@ -20,7 +27,8 @@ export default function Home() {
|
|||||||
name: 'description'
|
name: 'description'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'keywords'
|
name: 'keywords',
|
||||||
|
icon: <IconKey />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'category'
|
name: 'category'
|
||||||
@ -59,13 +67,16 @@ export default function Home() {
|
|||||||
name: 'description'
|
name: 'description'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'website'
|
name: 'website',
|
||||||
|
icon: <IconGlobe />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'email'
|
name: 'email',
|
||||||
|
icon: <IconMail />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'contact'
|
name: 'contact',
|
||||||
|
icon: <IconUser />
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'is_customer'
|
name: 'is_customer'
|
||||||
|
Reference in New Issue
Block a user