mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-09 03:03:41 +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:
@@ -197,6 +197,27 @@ export default function BuildDetail() {
|
|||||||
defaultValue: {}
|
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 buildStatus = useStatusCodes({ modelType: ModelType.build });
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -540,7 +561,7 @@ export default function BuildDetail() {
|
|||||||
name: 'child-orders',
|
name: 'child-orders',
|
||||||
label: t`Child Build Orders`,
|
label: t`Child Build Orders`,
|
||||||
icon: <IconSitemap />,
|
icon: <IconSitemap />,
|
||||||
hidden: (subassemblyLineData?.count ?? 0) <= 0, // Hide if no sub-assembly items
|
hidden: !showChildBuilds,
|
||||||
content: build.pk ? (
|
content: build.pk ? (
|
||||||
<BuildOrderTable parentBuildId={build.pk} />
|
<BuildOrderTable parentBuildId={build.pk} />
|
||||||
) : (
|
) : (
|
||||||
@@ -578,7 +599,7 @@ export default function BuildDetail() {
|
|||||||
user,
|
user,
|
||||||
buildStatus,
|
buildStatus,
|
||||||
globalSettings,
|
globalSettings,
|
||||||
subassemblyLineData,
|
showChildBuilds,
|
||||||
buildLineQuery.isFetching,
|
buildLineQuery.isFetching,
|
||||||
buildLineQuery.isLoading,
|
buildLineQuery.isLoading,
|
||||||
buildLineData
|
buildLineData
|
||||||
|
|||||||
@@ -437,6 +437,12 @@ test('Build Order - Auto Allocate Tracked', async ({ browser }) => {
|
|||||||
url: 'manufacturing/build-order/27/consumed-stock'
|
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 loadTab(page, 'Incomplete Outputs');
|
||||||
|
|
||||||
await page.getByRole('cell', { name: '0 / 6' }).waitFor();
|
await page.getByRole('cell', { name: '0 / 6' }).waitFor();
|
||||||
|
|||||||
Reference in New Issue
Block a user