From 3d28f4059b3b7af62e9ffe8f0a38b2d061cd64da Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Thu, 22 Aug 2024 20:52:05 +0200 Subject: [PATCH 1/7] adjust breadcrumbs to include current item --- src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx | 8 +++++++- src/frontend/src/pages/sales/ReturnOrderDetail.tsx | 5 ++++- src/frontend/src/pages/sales/SalesOrderDetail.tsx | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx index 421ef4218c86..db66a3004731 100644 --- a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx +++ b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx @@ -465,7 +465,13 @@ export default function PurchaseOrderDetail() { title={t`Purchase Order` + `: ${order.reference}`} subtitle={order.description} imageUrl={order.supplier_detail?.image} - breadcrumbs={[{ name: t`Purchasing`, url: '/purchasing/' }]} + breadcrumbs={[ + { name: t`Purchasing`, url: '/purchasing/' }, + { + name: order.reference, + url: `/purchasing/purchase-order/${order.pk}` + } + ]} actions={poActions} badges={orderBadges} editAction={editPurchaseOrder.open} diff --git a/src/frontend/src/pages/sales/ReturnOrderDetail.tsx b/src/frontend/src/pages/sales/ReturnOrderDetail.tsx index bf5ddbcfbc58..df594ab15c71 100644 --- a/src/frontend/src/pages/sales/ReturnOrderDetail.tsx +++ b/src/frontend/src/pages/sales/ReturnOrderDetail.tsx @@ -456,7 +456,10 @@ export default function ReturnOrderDetail() { imageUrl={order.customer_detail?.image} badges={orderBadges} actions={orderActions} - breadcrumbs={[{ name: t`Sales`, url: '/sales/' }]} + breadcrumbs={[ + { name: t`Sales`, url: '/sales/' }, + { name: order.reference, url: `/sales/return-order/${order.pk}` } + ]} editAction={editReturnOrder.open} editEnabled={user.hasChangePermission(ModelType.returnorder)} /> diff --git a/src/frontend/src/pages/sales/SalesOrderDetail.tsx b/src/frontend/src/pages/sales/SalesOrderDetail.tsx index 2198652bd715..be037b77690c 100644 --- a/src/frontend/src/pages/sales/SalesOrderDetail.tsx +++ b/src/frontend/src/pages/sales/SalesOrderDetail.tsx @@ -507,7 +507,11 @@ export default function SalesOrderDetail() { imageUrl={order.customer_detail?.image} badges={orderBadges} actions={soActions} - breadcrumbs={[{ name: t`Sales`, url: '/sales/' }]} + breadcrumbs={[ + { name: t`Sales`, url: '/sales/' }, + + { name: order.reference, url: `/sales/sales-order/${order.pk}` } + ]} editAction={editSalesOrder.open} editEnabled={user.hasChangePermission(ModelType.salesorder)} /> From 411f31d7d88aef4776032238b8311a67d2e59fc9 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 28 Aug 2024 19:53:11 +0200 Subject: [PATCH 2/7] Add last breacdrumb to various pages --- src/frontend/src/pages/build/BuildDetail.tsx | 6 ++---- src/frontend/src/pages/company/ManufacturerPartDetail.tsx | 6 ++++++ src/frontend/src/pages/company/SupplierPartDetail.tsx | 6 ++++++ src/frontend/src/pages/part/PartDetail.tsx | 6 ++++++ src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx | 4 ++-- src/frontend/src/pages/sales/ReturnOrderDetail.tsx | 4 ++-- src/frontend/src/pages/sales/SalesOrderDetail.tsx | 5 ++--- src/frontend/src/pages/stock/LocationDetail.tsx | 6 ++++++ src/frontend/src/pages/stock/StockDetail.tsx | 6 ++++++ 9 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/frontend/src/pages/build/BuildDetail.tsx b/src/frontend/src/pages/build/BuildDetail.tsx index 9e52db71caed..dd502808d937 100644 --- a/src/frontend/src/pages/build/BuildDetail.tsx +++ b/src/frontend/src/pages/build/BuildDetail.tsx @@ -535,10 +535,8 @@ export default function BuildDetail() { editAction={editBuild.open} editEnabled={user.hasChangePermission(ModelType.part)} imageUrl={build.part_detail?.image ?? build.part_detail?.thumbnail} - breadcrumbs={[ - { name: t`Build Orders`, url: '/build' }, - { name: build.reference, url: `/build/${build.pk}` } - ]} + breadcrumbs={[{ name: t`Build Orders`, url: '/build' }]} + last_crumb={[{ name: build.reference, url: `/build/${build.pk}` }]} actions={buildActions} /> diff --git a/src/frontend/src/pages/company/ManufacturerPartDetail.tsx b/src/frontend/src/pages/company/ManufacturerPartDetail.tsx index d1120c32f91b..dd418a1b439e 100644 --- a/src/frontend/src/pages/company/ManufacturerPartDetail.tsx +++ b/src/frontend/src/pages/company/ManufacturerPartDetail.tsx @@ -281,6 +281,12 @@ export default function ManufacturerPartDetail() { title={t`ManufacturerPart`} subtitle={`${manufacturerPart.MPN} - ${manufacturerPart.part_detail?.name}`} breadcrumbs={breadcrumbs} + last_crumb={[ + { + name: manufacturerPart.MPN, + url: `/purchasing/manufacturer-part/${manufacturerPart.pk}/` + } + ]} actions={manufacturerPartActions} imageUrl={manufacturerPart?.part_detail?.thumbnail} editAction={editManufacturerPart.open} diff --git a/src/frontend/src/pages/company/SupplierPartDetail.tsx b/src/frontend/src/pages/company/SupplierPartDetail.tsx index 2f536ce93dfb..78d20d99c1c6 100644 --- a/src/frontend/src/pages/company/SupplierPartDetail.tsx +++ b/src/frontend/src/pages/company/SupplierPartDetail.tsx @@ -357,6 +357,12 @@ export default function SupplierPartDetail() { title={t`Supplier Part`} subtitle={`${supplierPart.SKU} - ${supplierPart?.part_detail?.name}`} breadcrumbs={breadcrumbs} + last_crumb={[ + { + name: supplierPart.SKU, + url: `/purchasing/supplier-part/${supplierPart.pk}/` + } + ]} badges={badges} actions={supplierPartActions} imageUrl={supplierPart?.part_detail?.thumbnail} diff --git a/src/frontend/src/pages/part/PartDetail.tsx b/src/frontend/src/pages/part/PartDetail.tsx index aec379ac31f5..1fa3ed3f48db 100644 --- a/src/frontend/src/pages/part/PartDetail.tsx +++ b/src/frontend/src/pages/part/PartDetail.tsx @@ -1082,6 +1082,12 @@ export default function PartDetail() { imageUrl={part.image} badges={badges} breadcrumbs={breadcrumbs} + last_crumb={[ + { + name: part.name, + url: `/part/${part.pk}/` + } + ]} breadcrumbAction={() => { setTreeOpen(true); }} diff --git a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx index db66a3004731..ddd5226b902c 100644 --- a/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx +++ b/src/frontend/src/pages/purchasing/PurchaseOrderDetail.tsx @@ -465,8 +465,8 @@ export default function PurchaseOrderDetail() { title={t`Purchase Order` + `: ${order.reference}`} subtitle={order.description} imageUrl={order.supplier_detail?.image} - breadcrumbs={[ - { name: t`Purchasing`, url: '/purchasing/' }, + breadcrumbs={[{ name: t`Purchasing`, url: '/purchasing/' }]} + last_crumb={[ { name: order.reference, url: `/purchasing/purchase-order/${order.pk}` diff --git a/src/frontend/src/pages/sales/ReturnOrderDetail.tsx b/src/frontend/src/pages/sales/ReturnOrderDetail.tsx index df594ab15c71..c71ab98904c5 100644 --- a/src/frontend/src/pages/sales/ReturnOrderDetail.tsx +++ b/src/frontend/src/pages/sales/ReturnOrderDetail.tsx @@ -456,8 +456,8 @@ export default function ReturnOrderDetail() { imageUrl={order.customer_detail?.image} badges={orderBadges} actions={orderActions} - breadcrumbs={[ - { name: t`Sales`, url: '/sales/' }, + breadcrumbs={[{ name: t`Sales`, url: '/sales/' }]} + last_crumb={[ { name: order.reference, url: `/sales/return-order/${order.pk}` } ]} editAction={editReturnOrder.open} diff --git a/src/frontend/src/pages/sales/SalesOrderDetail.tsx b/src/frontend/src/pages/sales/SalesOrderDetail.tsx index be037b77690c..10456cee7b0a 100644 --- a/src/frontend/src/pages/sales/SalesOrderDetail.tsx +++ b/src/frontend/src/pages/sales/SalesOrderDetail.tsx @@ -507,9 +507,8 @@ export default function SalesOrderDetail() { imageUrl={order.customer_detail?.image} badges={orderBadges} actions={soActions} - breadcrumbs={[ - { name: t`Sales`, url: '/sales/' }, - + breadcrumbs={[{ name: t`Sales`, url: '/sales/' }]} + last_crumb={[ { name: order.reference, url: `/sales/sales-order/${order.pk}` } ]} editAction={editSalesOrder.open} diff --git a/src/frontend/src/pages/stock/LocationDetail.tsx b/src/frontend/src/pages/stock/LocationDetail.tsx index 8bf3ee6cc171..15e25cf1825a 100644 --- a/src/frontend/src/pages/stock/LocationDetail.tsx +++ b/src/frontend/src/pages/stock/LocationDetail.tsx @@ -388,6 +388,12 @@ export default function Stock() { editAction={editLocation.open} editEnabled={user.hasChangePermission(ModelType.stocklocation)} breadcrumbs={breadcrumbs} + last_crumb={[ + { + name: location.name, + url: `/stock/location/${location.pk}/` + } + ]} breadcrumbAction={() => { setTreeOpen(true); }} diff --git a/src/frontend/src/pages/stock/StockDetail.tsx b/src/frontend/src/pages/stock/StockDetail.tsx index e787d210a40d..b680c811dd68 100644 --- a/src/frontend/src/pages/stock/StockDetail.tsx +++ b/src/frontend/src/pages/stock/StockDetail.tsx @@ -612,6 +612,12 @@ export default function StockDetail() { editEnabled={user.hasChangePermission(ModelType.stockitem)} badges={stockBadges} breadcrumbs={breadcrumbs} + last_crumb={[ + { + name: stockitem.name, + url: `/stock/item/${stockitem.pk}/` + } + ]} breadcrumbAction={() => { setTreeOpen(true); }} From 5e084b4322830222b88c9b9b9151168a90b3bf52 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 28 Aug 2024 19:55:04 +0200 Subject: [PATCH 3/7] Add user settings for last breadcrumb --- src/backend/InvenTree/common/models.py | 8 ++++++++ .../InvenTree/settings/user_display.html | 1 + .../src/components/nav/PageDetail.tsx | 19 ++++++++++++++++--- .../src/pages/Index/Settings/UserSettings.tsx | 3 ++- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/backend/InvenTree/common/models.py b/src/backend/InvenTree/common/models.py index ac13e8d3c638..57f460b66eab 100644 --- a/src/backend/InvenTree/common/models.py +++ b/src/backend/InvenTree/common/models.py @@ -2528,6 +2528,14 @@ class Meta: 'validator': [int, MinValueValidator(0)], 'default': 100, }, + 'ENABLE_LAST_BREADCRUMB': { + 'name': _('Show Last Breadcrumb'), + 'description': _( + 'Show the current page in breadcrumbs of the navigation bar (if available)' + ), + 'default': False, + 'validator': bool, + }, 'NOTIFICATION_ERROR_REPORT': { 'name': _('Receive error reports'), 'description': _('Receive notifications for system errors'), diff --git a/src/backend/InvenTree/templates/InvenTree/settings/user_display.html b/src/backend/InvenTree/templates/InvenTree/settings/user_display.html index ab2144939db3..b3849ed1e0ac 100644 --- a/src/backend/InvenTree/templates/InvenTree/settings/user_display.html +++ b/src/backend/InvenTree/templates/InvenTree/settings/user_display.html @@ -21,6 +21,7 @@ {% include "InvenTree/settings/setting.html" with key="DISPLAY_SCHEDULE_TAB" icon="fa-calendar-alt" user_setting=True %} {% include "InvenTree/settings/setting.html" with key="DISPLAY_STOCKTAKE_TAB" icon="fa-clipboard-check" user_setting=True %} {% include "InvenTree/settings/setting.html" with key="TABLE_STRING_MAX_LENGTH" icon="fa-table" user_setting=True %} + {% include "InvenTree/settings/setting.html" with key="ENABLE_LAST_BREADCRUMB" icon="fa-table" user_setting=True %} diff --git a/src/frontend/src/components/nav/PageDetail.tsx b/src/frontend/src/components/nav/PageDetail.tsx index de7a36556acd..4e2d9a2e9312 100644 --- a/src/frontend/src/components/nav/PageDetail.tsx +++ b/src/frontend/src/components/nav/PageDetail.tsx @@ -1,7 +1,8 @@ import { Group, Paper, Space, Stack, Text } from '@mantine/core'; import { useHotkeys } from '@mantine/hooks'; -import { Fragment, ReactNode } from 'react'; +import { Fragment, ReactNode, useMemo } from 'react'; +import { useUserSettingsState } from '../../states/SettingsState'; import { ApiImage } from '../images/ApiImage'; import { StylishText } from '../items/StylishText'; import { Breadcrumb, BreadcrumbList } from './BreadcrumbList'; @@ -14,6 +15,7 @@ interface PageDetailInterface { detail?: ReactNode; badges?: ReactNode[]; breadcrumbs?: Breadcrumb[]; + last_crumb?: Breadcrumb[]; breadcrumbAction?: () => void; actions?: ReactNode[]; editAction?: () => void; @@ -34,11 +36,13 @@ export function PageDetail({ badges, imageUrl, breadcrumbs, + last_crumb, breadcrumbAction, actions, editAction, editEnabled }: Readonly) { + const userSettings = useUserSettingsState(); useHotkeys([ [ 'mod+E', @@ -50,12 +54,21 @@ export function PageDetail({ ] ]); + // breadcrumb caching + const computedBreadcrumbs = useMemo(() => { + if (userSettings.isSet('ENABLE_LAST_BREADCRUMB')) { + return [...(breadcrumbs ?? []), ...(last_crumb ?? [])]; + } else { + return breadcrumbs; + } + }, [breadcrumbs, last_crumb, userSettings]); + return ( - {breadcrumbs && breadcrumbs.length > 0 && ( + {computedBreadcrumbs && computedBreadcrumbs.length > 0 && ( )} diff --git a/src/frontend/src/pages/Index/Settings/UserSettings.tsx b/src/frontend/src/pages/Index/Settings/UserSettings.tsx index 437091ac8342..75f6f45944d5 100644 --- a/src/frontend/src/pages/Index/Settings/UserSettings.tsx +++ b/src/frontend/src/pages/Index/Settings/UserSettings.tsx @@ -86,7 +86,8 @@ export default function UserSettings() { 'PART_SHOW_QUANTITY_IN_FORMS', 'DISPLAY_SCHEDULE_TAB', 'DISPLAY_STOCKTAKE_TAB', - 'TABLE_STRING_MAX_LENGTH' + 'TABLE_STRING_MAX_LENGTH', + 'ENABLE_LAST_BREADCRUMB' ]} /> ) From 327405f9637340b6195ad09d70c985e12ad0603b Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 28 Aug 2024 22:02:03 +0200 Subject: [PATCH 4/7] add breacrumbs to company subpages --- src/frontend/src/pages/company/CompanyDetail.tsx | 7 +++++++ src/frontend/src/pages/company/CustomerDetail.tsx | 1 + src/frontend/src/pages/company/ManufacturerDetail.tsx | 1 + src/frontend/src/pages/company/SupplierDetail.tsx | 1 + 4 files changed, 10 insertions(+) diff --git a/src/frontend/src/pages/company/CompanyDetail.tsx b/src/frontend/src/pages/company/CompanyDetail.tsx index 77e1f75f49c7..e346d9a69ab5 100644 --- a/src/frontend/src/pages/company/CompanyDetail.tsx +++ b/src/frontend/src/pages/company/CompanyDetail.tsx @@ -56,6 +56,7 @@ import { StockItemTable } from '../../tables/stock/StockItemTable'; export type CompanyDetailProps = { title: string; breadcrumbs: Breadcrumb[]; + last_crumb_url: string; }; /** @@ -341,6 +342,12 @@ export default function CompanyDetail(props: Readonly) { actions={companyActions} imageUrl={company.image} breadcrumbs={props.breadcrumbs} + last_crumb={[ + { + name: company.name, + url: `${props.last_crumb_url}/${company.pk}/` + } + ]} badges={badges} editAction={editCompany.open} editEnabled={user.hasChangePermission(ModelType.company)} diff --git a/src/frontend/src/pages/company/CustomerDetail.tsx b/src/frontend/src/pages/company/CustomerDetail.tsx index 2725180dbe20..ae6e034ae043 100644 --- a/src/frontend/src/pages/company/CustomerDetail.tsx +++ b/src/frontend/src/pages/company/CustomerDetail.tsx @@ -7,6 +7,7 @@ export default function CustomerDetail() { ); } diff --git a/src/frontend/src/pages/company/ManufacturerDetail.tsx b/src/frontend/src/pages/company/ManufacturerDetail.tsx index aa04b0405c07..47c3a4f2b20f 100644 --- a/src/frontend/src/pages/company/ManufacturerDetail.tsx +++ b/src/frontend/src/pages/company/ManufacturerDetail.tsx @@ -7,6 +7,7 @@ export default function ManufacturerDetail() { ); } diff --git a/src/frontend/src/pages/company/SupplierDetail.tsx b/src/frontend/src/pages/company/SupplierDetail.tsx index 5be35dda8ed4..30e64b6cf257 100644 --- a/src/frontend/src/pages/company/SupplierDetail.tsx +++ b/src/frontend/src/pages/company/SupplierDetail.tsx @@ -7,6 +7,7 @@ export default function SupplierDetail() { ); } From 481bd8b09e94a5d5aa5554104010f8b0fc54f220 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Wed, 28 Aug 2024 23:22:32 +0200 Subject: [PATCH 5/7] use getDetailUrl instead --- src/frontend/src/pages/company/ManufacturerPartDetail.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/pages/company/ManufacturerPartDetail.tsx b/src/frontend/src/pages/company/ManufacturerPartDetail.tsx index dd418a1b439e..35cf9115e76e 100644 --- a/src/frontend/src/pages/company/ManufacturerPartDetail.tsx +++ b/src/frontend/src/pages/company/ManufacturerPartDetail.tsx @@ -284,7 +284,10 @@ export default function ManufacturerPartDetail() { last_crumb={[ { name: manufacturerPart.MPN, - url: `/purchasing/manufacturer-part/${manufacturerPart.pk}/` + url: getDetailUrl( + ModelType.manufacturerpart, + manufacturerPart.pk + ) } ]} actions={manufacturerPartActions} From 16259c0e39468a00d5a21b75d07789c0591a5d03 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Fri, 30 Aug 2024 00:28:50 +0200 Subject: [PATCH 6/7] set default --- src/frontend/src/components/nav/PageDetail.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/components/nav/PageDetail.tsx b/src/frontend/src/components/nav/PageDetail.tsx index 4e2d9a2e9312..0ed283569fd8 100644 --- a/src/frontend/src/components/nav/PageDetail.tsx +++ b/src/frontend/src/components/nav/PageDetail.tsx @@ -56,7 +56,7 @@ export function PageDetail({ // breadcrumb caching const computedBreadcrumbs = useMemo(() => { - if (userSettings.isSet('ENABLE_LAST_BREADCRUMB')) { + if (userSettings.isSet('ENABLE_LAST_BREADCRUMB', false)) { return [...(breadcrumbs ?? []), ...(last_crumb ?? [])]; } else { return breadcrumbs; From b70cceb2f371cac8ab22f6cdb9dbaea67ba6d977 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Sun, 1 Sep 2024 12:16:37 +0200 Subject: [PATCH 7/7] change description --- src/backend/InvenTree/common/models.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/backend/InvenTree/common/models.py b/src/backend/InvenTree/common/models.py index 57f460b66eab..93d352563d19 100644 --- a/src/backend/InvenTree/common/models.py +++ b/src/backend/InvenTree/common/models.py @@ -2530,9 +2530,7 @@ class Meta: }, 'ENABLE_LAST_BREADCRUMB': { 'name': _('Show Last Breadcrumb'), - 'description': _( - 'Show the current page in breadcrumbs of the navigation bar (if available)' - ), + 'description': _('Show the current page in breadcrumbs'), 'default': False, 'validator': bool, },