mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Improve breadcrumbs using new path API (#5570)
This commit is contained in:
parent
c60efd9a1d
commit
6f70f6d244
@ -29,7 +29,7 @@ export default function CategoryDetail({}: {}) {
|
|||||||
instance: category,
|
instance: category,
|
||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery
|
instanceQuery
|
||||||
} = useInstance('/part/category/', id);
|
} = useInstance('/part/category/', id, { path_detail: true });
|
||||||
|
|
||||||
const categoryPanels: PanelType[] = useMemo(
|
const categoryPanels: PanelType[] = useMemo(
|
||||||
() => [
|
() => [
|
||||||
@ -69,24 +69,24 @@ export default function CategoryDetail({}: {}) {
|
|||||||
[category, id]
|
[category, id]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const breadcrumbs = useMemo(
|
||||||
|
() => [
|
||||||
|
{ name: t`Parts`, url: '/part' },
|
||||||
|
...(category.path ?? []).map((c: any) => ({
|
||||||
|
name: c.name,
|
||||||
|
url: `/part/category/${c.pk}`
|
||||||
|
}))
|
||||||
|
],
|
||||||
|
[category]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack spacing="xs">
|
<Stack spacing="xs">
|
||||||
<LoadingOverlay visible={instanceQuery.isFetching} />
|
<LoadingOverlay visible={instanceQuery.isFetching} />
|
||||||
<PageDetail
|
<PageDetail
|
||||||
title={t`Part Category`}
|
title={t`Part Category`}
|
||||||
detail={<Text>{category.name ?? 'Top level'}</Text>}
|
detail={<Text>{category.name ?? 'Top level'}</Text>}
|
||||||
breadcrumbs={
|
breadcrumbs={breadcrumbs}
|
||||||
category.pk
|
|
||||||
? [
|
|
||||||
{ name: t`Parts`, url: '/part' },
|
|
||||||
{ name: '...', url: '' },
|
|
||||||
{
|
|
||||||
name: category.name ?? t`Top level`,
|
|
||||||
url: `/part/category/${category.pk}`
|
|
||||||
}
|
|
||||||
]
|
|
||||||
: []
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<PanelGroup panels={categoryPanels} />
|
<PanelGroup panels={categoryPanels} />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
@ -16,22 +16,17 @@ import {
|
|||||||
IconTruckDelivery,
|
IconTruckDelivery,
|
||||||
IconVersions
|
IconVersions
|
||||||
} from '@tabler/icons-react';
|
} from '@tabler/icons-react';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import React from 'react';
|
||||||
import React, { useEffect, useState } from 'react';
|
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { api } from '../../App';
|
|
||||||
import { PlaceholderPanel } from '../../components/items/Placeholder';
|
import { PlaceholderPanel } from '../../components/items/Placeholder';
|
||||||
import { PageDetail } from '../../components/nav/PageDetail';
|
import { PageDetail } from '../../components/nav/PageDetail';
|
||||||
import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
|
import { PanelGroup, PanelType } from '../../components/nav/PanelGroup';
|
||||||
import { AttachmentTable } from '../../components/tables/AttachmentTable';
|
import { AttachmentTable } from '../../components/tables/AttachmentTable';
|
||||||
import { RelatedPartTable } from '../../components/tables/part/RelatedPartTable';
|
import { RelatedPartTable } from '../../components/tables/part/RelatedPartTable';
|
||||||
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
import { StockItemTable } from '../../components/tables/stock/StockItemTable';
|
||||||
import {
|
import { NotesEditor } from '../../components/widgets/MarkdownEditor';
|
||||||
MarkdownEditor,
|
|
||||||
NotesEditor
|
|
||||||
} from '../../components/widgets/MarkdownEditor';
|
|
||||||
import { editPart } from '../../functions/forms/PartForms';
|
import { editPart } from '../../functions/forms/PartForms';
|
||||||
import { useInstance } from '../../hooks/UseInstance';
|
import { useInstance } from '../../hooks/UseInstance';
|
||||||
|
|
||||||
@ -45,7 +40,7 @@ export default function PartDetail() {
|
|||||||
instance: part,
|
instance: part,
|
||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery
|
instanceQuery
|
||||||
} = useInstance('/part/', id);
|
} = useInstance('/part/', id, { path_detail: true });
|
||||||
|
|
||||||
// Part data panels (recalculate when part data changes)
|
// Part data panels (recalculate when part data changes)
|
||||||
const partPanels: PanelType[] = useMemo(() => {
|
const partPanels: PanelType[] = useMemo(() => {
|
||||||
@ -174,6 +169,18 @@ export default function PartDetail() {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const breadcrumbs = useMemo(
|
||||||
|
() => [
|
||||||
|
{ name: t`Parts`, url: '/part' },
|
||||||
|
...(part.category_path ?? []).map((c: any) => ({
|
||||||
|
name: c.name,
|
||||||
|
url: `/part/category/${c.pk}`
|
||||||
|
}))
|
||||||
|
],
|
||||||
|
[part]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack spacing="xs">
|
<Stack spacing="xs">
|
||||||
@ -186,11 +193,7 @@ export default function PartDetail() {
|
|||||||
<Text>TODO: Part details</Text>
|
<Text>TODO: Part details</Text>
|
||||||
</Alert>
|
</Alert>
|
||||||
}
|
}
|
||||||
breadcrumbs={[
|
breadcrumbs={breadcrumbs}
|
||||||
{ name: t`Parts`, url: '/part' },
|
|
||||||
{ name: '...', url: '' },
|
|
||||||
{ name: part.name, url: `/part/${part.pk}` }
|
|
||||||
]}
|
|
||||||
actions={[
|
actions={[
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
@ -17,7 +17,7 @@ export default function Stock() {
|
|||||||
instance: location,
|
instance: location,
|
||||||
refreshInstance,
|
refreshInstance,
|
||||||
instanceQuery
|
instanceQuery
|
||||||
} = useInstance('/stock/location/', id);
|
} = useInstance('/stock/location/', id, { path_detail: true });
|
||||||
|
|
||||||
const locationPanels: PanelType[] = useMemo(() => {
|
const locationPanels: PanelType[] = useMemo(() => {
|
||||||
return [
|
return [
|
||||||
@ -48,6 +48,17 @@ export default function Stock() {
|
|||||||
];
|
];
|
||||||
}, [location, id]);
|
}, [location, id]);
|
||||||
|
|
||||||
|
const breadcrumbs = useMemo(
|
||||||
|
() => [
|
||||||
|
{ name: t`Stock`, url: '/stock' },
|
||||||
|
...(location.path ?? []).map((l: any) => ({
|
||||||
|
name: l.name,
|
||||||
|
url: `/stock/location/${l.pk}`
|
||||||
|
}))
|
||||||
|
],
|
||||||
|
[location]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack>
|
<Stack>
|
||||||
@ -55,18 +66,7 @@ export default function Stock() {
|
|||||||
<PageDetail
|
<PageDetail
|
||||||
title={t`Stock Items`}
|
title={t`Stock Items`}
|
||||||
detail={<Text>{location.name ?? 'Top level'}</Text>}
|
detail={<Text>{location.name ?? 'Top level'}</Text>}
|
||||||
breadcrumbs={
|
breadcrumbs={breadcrumbs}
|
||||||
location.pk
|
|
||||||
? [
|
|
||||||
{ name: t`Stock`, url: '/stock' },
|
|
||||||
{ name: '...', url: '' },
|
|
||||||
{
|
|
||||||
name: location.name ?? t`Top level`,
|
|
||||||
url: `/stock/location/${location.pk}`
|
|
||||||
}
|
|
||||||
]
|
|
||||||
: []
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<PanelGroup panels={locationPanels} />
|
<PanelGroup panels={locationPanels} />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
@ -29,7 +29,8 @@ export default function StockDetail() {
|
|||||||
instanceQuery
|
instanceQuery
|
||||||
} = useInstance('/stock/', id, {
|
} = useInstance('/stock/', id, {
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
location_detail: true
|
location_detail: true,
|
||||||
|
path_detail: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const stockPanels: PanelType[] = useMemo(() => {
|
const stockPanels: PanelType[] = useMemo(() => {
|
||||||
@ -91,6 +92,17 @@ export default function StockDetail() {
|
|||||||
];
|
];
|
||||||
}, [stockitem, id]);
|
}, [stockitem, id]);
|
||||||
|
|
||||||
|
const breadcrumbs = useMemo(
|
||||||
|
() => [
|
||||||
|
{ name: t`Stock`, url: '/stock' },
|
||||||
|
...(stockitem.location_path ?? []).map((l: any) => ({
|
||||||
|
name: l.name,
|
||||||
|
url: `/stock/location/${l.pk}`
|
||||||
|
}))
|
||||||
|
],
|
||||||
|
[stockitem]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack>
|
<Stack>
|
||||||
<LoadingOverlay visible={instanceQuery.isFetching} />
|
<LoadingOverlay visible={instanceQuery.isFetching} />
|
||||||
@ -102,14 +114,7 @@ export default function StockDetail() {
|
|||||||
<Text>Quantity: {stockitem.quantity ?? 'idk'}</Text>
|
<Text>Quantity: {stockitem.quantity ?? 'idk'}</Text>
|
||||||
</Alert>
|
</Alert>
|
||||||
}
|
}
|
||||||
breadcrumbs={[
|
breadcrumbs={breadcrumbs}
|
||||||
{ name: t`Stock`, url: '/stock' },
|
|
||||||
{ name: '...', url: '' },
|
|
||||||
{
|
|
||||||
name: stockitem.part_detail?.full_name ?? 'name goes here',
|
|
||||||
url: `/stock/item/${stockitem.pk}`
|
|
||||||
}
|
|
||||||
]}
|
|
||||||
/>
|
/>
|
||||||
<PanelGroup panels={stockPanels} />
|
<PanelGroup panels={stockPanels} />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user