Fix dynamic loading of nodes

This commit is contained in:
Oliver Walters 2026-06-19 01:17:53 +00:00
parent 593cb357b3
commit d7219cc9c5
4 changed files with 6 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import {
type RenderTreeNodePayload,
Space,
Stack,
Text,
TextInput,
Tree,
type TreeNodeData,
@ -176,7 +177,7 @@ export default function NavigationTree({
label: (
<Group gap='xs'>
<ApiIcon name={raw.icon} />
{raw.name}
<Text>{raw.name}</Text>
</Group>
),
value: raw.pk.toString(),
@ -216,7 +217,7 @@ export default function NavigationTree({
// After fetching (or in search mode where all data is already present), use actual children.
const hasChildren: boolean =
!debouncedSearch && !isFetched
? !!resolveItem(payload.node, childIdentifier ?? '')
? !!(childIdentifier && resolveItem(payload.node, childIdentifier))
: nodeInfo.children.length > 0;
return (

View File

@ -377,6 +377,7 @@ export default function CategoryDetail() {
modelType={ModelType.partcategory}
title={t`Part Categories`}
endpoint={ApiEndpoints.category_tree}
childIdentifier='subcategories'
opened={treeOpen}
onClose={() => {
setTreeOpen(false);

View File

@ -514,6 +514,7 @@ export default function Stock() {
title={t`Stock Locations`}
modelType={ModelType.stocklocation}
endpoint={ApiEndpoints.stock_location_tree}
childIdentifier='sublocations'
opened={treeOpen}
onClose={() => setTreeOpen(false)}
selectedId={location?.pk}

View File

@ -1066,6 +1066,7 @@ export default function StockDetail() {
title={t`Stock Locations`}
modelType={ModelType.stocklocation}
endpoint={ApiEndpoints.stock_location_tree}
childIdentifier='sublocations'
opened={treeOpen}
onClose={() => setTreeOpen(false)}
selectedId={stockitem?.location}