diff --git a/src/frontend/src/components/forms/fields/ApiFormField.tsx b/src/frontend/src/components/forms/fields/ApiFormField.tsx index e61c818072..e10f70fda4 100644 --- a/src/frontend/src/components/forms/fields/ApiFormField.tsx +++ b/src/frontend/src/components/forms/fields/ApiFormField.tsx @@ -5,6 +5,7 @@ import { useCallback, useEffect, useMemo } from 'react'; import { type Control, type FieldValues, useController } from 'react-hook-form'; import { ApiEndpoints } from '@lib/enums/ApiEndpoints'; +import { apiUrl } from '@lib/functions/Api'; import type { ApiFormFieldSet, ApiFormFieldType } from '@lib/types/Forms'; import { IconFileUpload } from '@tabler/icons-react'; import type { NavigateFunction } from 'react-router-dom'; @@ -122,15 +123,62 @@ export function ApiFormField({ // Construct the individual field const fieldInstance = useMemo(() => { switch (fieldDefinition.field_type) { - case 'related field': + case 'location': return ( - ); + case 'category': + return ( + + ); + case 'related field': + // Redirect location or category fields to the appropriate tree field + if ( + fieldDefinition.api_url == apiUrl(ApiEndpoints.stock_location_list) + ) { + return ( + + ); + } else if ( + fieldDefinition.api_url == apiUrl(ApiEndpoints.category_list) + ) { + return ( + + ); + } else { + return ( + + ); + } case 'email': case 'url': case 'string': @@ -256,26 +304,6 @@ export function ApiFormField({ return ( ); - case 'location': - return ( - - ); - case 'category': - return ( - - ); default: return ( diff --git a/src/frontend/src/forms/PartForms.tsx b/src/frontend/src/forms/PartForms.tsx index 6272f2b80d..311b64b18f 100644 --- a/src/frontend/src/forms/PartForms.tsx +++ b/src/frontend/src/forms/PartForms.tsx @@ -228,13 +228,11 @@ export function partCategoryFields({ const fields: ApiFormFieldSet = { parent: { description: t`Parent part category`, - required: false, - field_type: 'category' + required: false }, name: {}, description: {}, default_location: { - field_type: 'location', filters: { structural: false }