2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-10-03 15:52:51 +00:00

Add info badge to part renderer (#10409)

- Show extra information about ordering and building
- Closes https://github.com/inventree/InvenTree/issues/10380
This commit is contained in:
Oliver
2025-09-27 14:16:13 +10:00
committed by GitHub
parent e897222e07
commit 230e1edc00
2 changed files with 42 additions and 7 deletions

View File

@@ -34,18 +34,53 @@ export function RenderPart(
badgeColor = instance.minimum_stock > stock ? 'yellow' : 'green';
}
const badge = !!badgeText ? (
const extra: ReactNode[] = [];
// For active parts, we can display some extra information here
if (instance.active) {
if (instance.ordering) {
extra.push(
<Text size='xs'>
{t`On Order`}: {formatDecimal(instance.ordering)}{' '}
</Text>
);
}
if (instance.building) {
extra.push(
<Text size='xs'>
{t`In Production`}: {formatDecimal(instance.building)}{' '}
</Text>
);
}
}
const suffix: ReactNode = (
<Group gap='xs' wrap='nowrap'>
{badgeText && (
<Badge size='xs' color={badgeColor}>
{badgeText}
</Badge>
) : null;
)}
{extra && (
<TableHoverCard
value=''
position='bottom-end'
zIndex={10000}
icon='info'
title={t`Details`}
extra={extra}
/>
)}
</Group>
);
return (
<RenderInlineModel
{...props}
primary={instance.full_name ?? instance.name}
secondary={instance.description}
suffix={badge}
suffix={suffix}
image={instance.thumbnail || instance.image}
url={props.link ? getDetailUrl(ModelType.part, instance.pk) : undefined}
/>

View File

@@ -130,7 +130,7 @@ export function RenderStockItem(
zIndex={10000}
icon='sitemap'
title={t`Location`}
extra={[<Text>{location.pathstring}</Text>]}
extra={[<Text size='xs'>{location.pathstring}</Text>]}
/>
)}
</Group>