2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-05-09 11:08:54 +00:00

[UI] Fix child builds panel (#11886)

* [UI] Fix child builds panel

- Adjust logic for displaying or hiding child build panel

Co-authored-by: Copilot <copilot@github.com>

* Add brief playwright test

Co-authored-by: Copilot <copilot@github.com>

---------

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Oliver
2026-05-08 00:02:11 +10:00
committed by GitHub
parent 5c65cf901f
commit 3be740c019
2 changed files with 29 additions and 2 deletions
+23 -2
View File
@@ -197,6 +197,27 @@ export default function BuildDetail() {
defaultValue: {}
});
// Fetch the number of child build orders associated with this build order
const { instance: childBuildData } = useInstance({
endpoint: ApiEndpoints.build_order_list,
params: {
parent: id,
limit: 1
},
disabled: !id,
hasPrimaryKey: false,
defaultValue: {}
});
/**
* Display the "Child Build Orders" panel if either:
* - There are any child build orders (childBuildData.count > 0)
* - There are any sub-assembly items (subassemblyLineData.count > 0)
*/
const showChildBuilds = useMemo(() => {
return childBuildData?.count > 0 || subassemblyLineData?.count > 0;
}, [childBuildData, subassemblyLineData]);
const buildStatus = useStatusCodes({ modelType: ModelType.build });
const {
@@ -540,7 +561,7 @@ export default function BuildDetail() {
name: 'child-orders',
label: t`Child Build Orders`,
icon: <IconSitemap />,
hidden: (subassemblyLineData?.count ?? 0) <= 0, // Hide if no sub-assembly items
hidden: !showChildBuilds,
content: build.pk ? (
<BuildOrderTable parentBuildId={build.pk} />
) : (
@@ -578,7 +599,7 @@ export default function BuildDetail() {
user,
buildStatus,
globalSettings,
subassemblyLineData,
showChildBuilds,
buildLineQuery.isFetching,
buildLineQuery.isLoading,
buildLineData
@@ -437,6 +437,12 @@ test('Build Order - Auto Allocate Tracked', async ({ browser }) => {
url: 'manufacturing/build-order/27/consumed-stock'
});
// Check some tabs along the way
await loadTab(page, 'Child Build Orders');
await page
.getByRole('button', { name: 'action-button-add-build-order' })
.waitFor();
await loadTab(page, 'Incomplete Outputs');
await page.getByRole('cell', { name: '0 / 6' }).waitFor();