mirror of
https://github.com/inventree/InvenTree.git
synced 2026-12-01 12:01:20 +00:00
Show location description in the Stock Item/Stock Details Location field (#13297)
* Show location description in the Stock Item/Stock Details Location field * Display full stock location path as a hover tooltip in the Stock Item/Stock Details/Location view * Display category description next to the category name if set: - Part category details view parent category - Part details view category Display location description next to the location name if set: - Part category details view Default location and Parent default location - Part details view Default and Category default location - Build orders Source and Destination location - Purchaseorder Destination location - Stock location parent location
This commit is contained in:
1 parent
8f8502d0d9
commit
2a1e0cf0a4
7 files changed
+54
-3
No files matched your search
@@ -10,7 +10,8 @@ import {
|
|||||||
Skeleton,
|
Skeleton,
|
||||||
Stack,
|
Stack,
|
||||||
Table,
|
Table,
|
||||||
Text
|
Text,
|
||||||
|
Tooltip
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { getValueAtPath } from 'mantine-datatable';
|
import { getValueAtPath } from 'mantine-datatable';
|
||||||
@@ -39,6 +40,7 @@ export type DetailsField = {
|
|||||||
icon?: keyof InvenTreeIconType;
|
icon?: keyof InvenTreeIconType;
|
||||||
name: string;
|
name: string;
|
||||||
label?: string;
|
label?: string;
|
||||||
|
tooltip?: string;
|
||||||
badge?: BadgeType;
|
badge?: BadgeType;
|
||||||
copy?: boolean;
|
copy?: boolean;
|
||||||
value_formatter?: () => ValueFormatterReturn;
|
value_formatter?: () => ValueFormatterReturn;
|
||||||
@@ -441,7 +443,11 @@ function TableAnchorValue(props: Readonly<FieldProps>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Tooltip
|
||||||
|
label={props.field_data.tooltip}
|
||||||
|
disabled={!props.field_data.tooltip}
|
||||||
|
withArrow
|
||||||
|
>
|
||||||
{make_link ? (
|
{make_link ? (
|
||||||
<Anchor href={absoluteUrl} onClick={handleLinkClick}>
|
<Anchor href={absoluteUrl} onClick={handleLinkClick}>
|
||||||
<Text>{value}</Text>
|
<Text>{value}</Text>
|
||||||
@@ -449,7 +455,7 @@ function TableAnchorValue(props: Readonly<FieldProps>) {
|
|||||||
) : (
|
) : (
|
||||||
<Text c={color}>{value}</Text>
|
<Text c={color}>{value}</Text>
|
||||||
)}
|
)}
|
||||||
</>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -178,6 +178,10 @@ export function BuildOrderDetailsPanel({
|
|||||||
icon: 'location',
|
icon: 'location',
|
||||||
hidden: !instance?.take_from,
|
hidden: !instance?.take_from,
|
||||||
model: ModelType.stocklocation,
|
model: ModelType.stocklocation,
|
||||||
|
model_formatter: (location: any) =>
|
||||||
|
location?.description
|
||||||
|
? `${location.name} - ${location.description}`
|
||||||
|
: location?.name,
|
||||||
label: t`Source Location`,
|
label: t`Source Location`,
|
||||||
backup_value: t`Any location`
|
backup_value: t`Any location`
|
||||||
},
|
},
|
||||||
@@ -186,6 +190,10 @@ export function BuildOrderDetailsPanel({
|
|||||||
name: 'destination',
|
name: 'destination',
|
||||||
icon: 'location',
|
icon: 'location',
|
||||||
model: ModelType.stocklocation,
|
model: ModelType.stocklocation,
|
||||||
|
model_formatter: (location: any) =>
|
||||||
|
location?.description
|
||||||
|
? `${location.name} - ${location.description}`
|
||||||
|
: location?.name,
|
||||||
label: t`Destination Location`,
|
label: t`Destination Location`,
|
||||||
hidden: !instance?.destination
|
hidden: !instance?.destination
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ export function PartCategoryDetailsPanel({
|
|||||||
icon: 'location',
|
icon: 'location',
|
||||||
label: t`Parent Category`,
|
label: t`Parent Category`,
|
||||||
model: ModelType.partcategory,
|
model: ModelType.partcategory,
|
||||||
|
model_formatter: (category: any) =>
|
||||||
|
category?.description
|
||||||
|
? `${category.name} - ${category.description}`
|
||||||
|
: category?.name,
|
||||||
hidden: !instance?.parent
|
hidden: !instance?.parent
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -88,6 +92,10 @@ export function PartCategoryDetailsPanel({
|
|||||||
name: 'parent_default_location',
|
name: 'parent_default_location',
|
||||||
label: t`Parent default location`,
|
label: t`Parent default location`,
|
||||||
model: ModelType.stocklocation,
|
model: ModelType.stocklocation,
|
||||||
|
model_formatter: (location: any) =>
|
||||||
|
location?.description
|
||||||
|
? `${location.name} - ${location.description}`
|
||||||
|
: location?.name,
|
||||||
hidden:
|
hidden:
|
||||||
!instance?.parent_default_location || !!instance?.default_location
|
!instance?.parent_default_location || !!instance?.default_location
|
||||||
},
|
},
|
||||||
@@ -96,6 +104,10 @@ export function PartCategoryDetailsPanel({
|
|||||||
name: 'default_location',
|
name: 'default_location',
|
||||||
label: t`Default location`,
|
label: t`Default location`,
|
||||||
model: ModelType.stocklocation,
|
model: ModelType.stocklocation,
|
||||||
|
model_formatter: (location: any) =>
|
||||||
|
location?.description
|
||||||
|
? `${location.name} - ${location.description}`
|
||||||
|
: location?.name,
|
||||||
hidden: !instance?.default_location
|
hidden: !instance?.default_location
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -112,6 +112,10 @@ export function PartDetailsPanel({
|
|||||||
type: 'link',
|
type: 'link',
|
||||||
name: 'category',
|
name: 'category',
|
||||||
label: t`Category`,
|
label: t`Category`,
|
||||||
|
model_formatter: (category: any) =>
|
||||||
|
category?.description
|
||||||
|
? `${category.name} - ${category.description}`
|
||||||
|
: category?.name,
|
||||||
model: ModelType.partcategory
|
model: ModelType.partcategory
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -119,6 +123,10 @@ export function PartDetailsPanel({
|
|||||||
name: 'default_location',
|
name: 'default_location',
|
||||||
label: t`Default Location`,
|
label: t`Default Location`,
|
||||||
model: ModelType.stocklocation,
|
model: ModelType.stocklocation,
|
||||||
|
model_formatter: (default_location: any) =>
|
||||||
|
default_location?.description
|
||||||
|
? `${default_location.name} - ${default_location.description}`
|
||||||
|
: default_location?.name,
|
||||||
hidden: !instance?.default_location
|
hidden: !instance?.default_location
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -126,6 +134,10 @@ export function PartDetailsPanel({
|
|||||||
name: 'category_default_location',
|
name: 'category_default_location',
|
||||||
label: t`Category Default Location`,
|
label: t`Category Default Location`,
|
||||||
model: ModelType.stocklocation,
|
model: ModelType.stocklocation,
|
||||||
|
model_formatter: (location: any) =>
|
||||||
|
location?.description
|
||||||
|
? `${location.name} - ${location.description}`
|
||||||
|
: location?.name,
|
||||||
hidden: instance?.default_location || !instance?.category_default_location
|
hidden: instance?.default_location || !instance?.category_default_location
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -100,6 +100,10 @@ export function PurchaseOrderDetailsPanel({
|
|||||||
link: true,
|
link: true,
|
||||||
name: 'destination',
|
name: 'destination',
|
||||||
label: t`Destination`,
|
label: t`Destination`,
|
||||||
|
model_formatter: (location: any) =>
|
||||||
|
location?.description
|
||||||
|
? `${location.name} - ${location.description}`
|
||||||
|
: location?.name,
|
||||||
hidden: !instance?.destination
|
hidden: !instance?.destination
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -236,6 +236,11 @@ export function StockDetailsPanel({
|
|||||||
name: 'location',
|
name: 'location',
|
||||||
label: t`Location`,
|
label: t`Location`,
|
||||||
model: ModelType.stocklocation,
|
model: ModelType.stocklocation,
|
||||||
|
tooltip: instance?.location_detail?.pathstring,
|
||||||
|
model_formatter: (location: any) =>
|
||||||
|
location?.description
|
||||||
|
? `${location.name} - ${location.description}`
|
||||||
|
: location?.name,
|
||||||
hidden: !instance?.location
|
hidden: !instance?.location
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ export function StockLocationDetailsPanel({
|
|||||||
icon: 'location',
|
icon: 'location',
|
||||||
label: t`Parent Location`,
|
label: t`Parent Location`,
|
||||||
model: ModelType.stocklocation,
|
model: ModelType.stocklocation,
|
||||||
|
model_formatter: (location: any) =>
|
||||||
|
location?.description
|
||||||
|
? `${location.name} - ${location.description}`
|
||||||
|
: location?.name,
|
||||||
hidden: !instance?.parent
|
hidden: !instance?.parent
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in new issue
Block a user