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:
@@ -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}
|
||||
/>
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user