mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Show warning for insufficient stock (#7916)
This commit is contained in:
parent
9fbaeba2ab
commit
0ee06ec13e
@ -27,6 +27,7 @@ import {
|
|||||||
IconCornerUpRightDouble,
|
IconCornerUpRightDouble,
|
||||||
IconCurrencyDollar,
|
IconCurrencyDollar,
|
||||||
IconDots,
|
IconDots,
|
||||||
|
IconExclamationCircle,
|
||||||
IconExternalLink,
|
IconExternalLink,
|
||||||
IconFileUpload,
|
IconFileUpload,
|
||||||
IconFlag,
|
IconFlag,
|
||||||
@ -109,6 +110,7 @@ const icons = {
|
|||||||
keywords: IconTag,
|
keywords: IconTag,
|
||||||
status: IconInfoCircle,
|
status: IconInfoCircle,
|
||||||
info: IconInfoCircle,
|
info: IconInfoCircle,
|
||||||
|
exclamation: IconExclamationCircle,
|
||||||
details: IconInfoCircle,
|
details: IconInfoCircle,
|
||||||
parameters: IconList,
|
parameters: IconList,
|
||||||
list: IconList,
|
list: IconList,
|
||||||
|
@ -3,6 +3,8 @@ import { Divider, Group, HoverCard, Stack, Text } from '@mantine/core';
|
|||||||
import { IconInfoCircle } from '@tabler/icons-react';
|
import { IconInfoCircle } from '@tabler/icons-react';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
import { InvenTreeIcon, InvenTreeIconType } from '../functions/icons';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A custom hovercard element for displaying extra information in a table cell.
|
* A custom hovercard element for displaying extra information in a table cell.
|
||||||
* If a table cell has extra information available,
|
* If a table cell has extra information available,
|
||||||
@ -11,11 +13,15 @@ import { ReactNode } from 'react';
|
|||||||
export function TableHoverCard({
|
export function TableHoverCard({
|
||||||
value, // The value of the cell
|
value, // The value of the cell
|
||||||
extra, // The extra information to display
|
extra, // The extra information to display
|
||||||
title // The title of the hovercard
|
title, // The title of the hovercard
|
||||||
|
icon, // The icon to display
|
||||||
|
iconColor // The icon color
|
||||||
}: {
|
}: {
|
||||||
value: any;
|
value: any;
|
||||||
extra?: ReactNode;
|
extra?: ReactNode;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
icon?: InvenTreeIconType;
|
||||||
|
iconColor?: string;
|
||||||
}) {
|
}) {
|
||||||
// If no extra information presented, just return the raw value
|
// If no extra information presented, just return the raw value
|
||||||
if (!extra) {
|
if (!extra) {
|
||||||
@ -31,7 +37,10 @@ export function TableHoverCard({
|
|||||||
<HoverCard.Target>
|
<HoverCard.Target>
|
||||||
<Group gap="xs" justify="space-between" wrap="nowrap">
|
<Group gap="xs" justify="space-between" wrap="nowrap">
|
||||||
{value}
|
{value}
|
||||||
<IconInfoCircle size="16" color="blue" />
|
<InvenTreeIcon
|
||||||
|
icon={icon ?? 'info'}
|
||||||
|
iconProps={{ size: 16, color: iconColor ?? 'blue' }}
|
||||||
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
</HoverCard.Target>
|
</HoverCard.Target>
|
||||||
<HoverCard.Dropdown>
|
<HoverCard.Dropdown>
|
||||||
|
@ -126,8 +126,20 @@ export default function BuildLineTable({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sufficient = available >= record.quantity - record.allocated;
|
||||||
|
|
||||||
|
if (!sufficient) {
|
||||||
|
extra.push(
|
||||||
|
<Text key="insufficient" c="orange" size="sm">
|
||||||
|
{t`Insufficient stock`}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableHoverCard
|
<TableHoverCard
|
||||||
|
icon={sufficient ? 'info' : 'exclamation'}
|
||||||
|
iconColor={sufficient ? 'blue' : 'orange'}
|
||||||
value={
|
value={
|
||||||
available > 0 ? (
|
available > 0 ? (
|
||||||
available
|
available
|
||||||
|
Loading…
Reference in New Issue
Block a user