mirror of
https://github.com/inventree/InvenTree.git
synced 2026-06-11 19:27:02 +00:00
[UI] Update parametric data table hover (#12145)
- Display last update date - Display updating user - Improved formatting
This commit is contained in:
@@ -24,7 +24,8 @@ export function TableHoverCard({
|
|||||||
icon, // The icon to display
|
icon, // The icon to display
|
||||||
iconColor, // The icon color
|
iconColor, // The icon color
|
||||||
position, // The position of the hovercard
|
position, // The position of the hovercard
|
||||||
zIndex // Optional z-index for the hovercard
|
zIndex, // Optional z-index for the hovercard
|
||||||
|
minWidth // Optional minimum width for the dropdown
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
value: any;
|
value: any;
|
||||||
extra?: ReactNode;
|
extra?: ReactNode;
|
||||||
@@ -33,6 +34,7 @@ export function TableHoverCard({
|
|||||||
iconColor?: string;
|
iconColor?: string;
|
||||||
position?: FloatingPosition;
|
position?: FloatingPosition;
|
||||||
zIndex?: string | number;
|
zIndex?: string | number;
|
||||||
|
minWidth?: number;
|
||||||
}>) {
|
}>) {
|
||||||
const extraItems: ReactNode = useMemo(() => {
|
const extraItems: ReactNode = useMemo(() => {
|
||||||
if (Array.isArray(extra)) {
|
if (Array.isArray(extra)) {
|
||||||
@@ -74,7 +76,7 @@ export function TableHoverCard({
|
|||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
</HoverCard.Target>
|
</HoverCard.Target>
|
||||||
<HoverCard.Dropdown>
|
<HoverCard.Dropdown style={minWidth ? { minWidth } : undefined}>
|
||||||
<Stack gap='xs'>
|
<Stack gap='xs'>
|
||||||
<Group gap='xs' justify='left'>
|
<Group gap='xs' justify='left'>
|
||||||
<InvenTreeIcon
|
<InvenTreeIcon
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ import {
|
|||||||
import type { TableFilter } from '@lib/types/Filters';
|
import type { TableFilter } from '@lib/types/Filters';
|
||||||
import type { TableColumn } from '@lib/types/Tables';
|
import type { TableColumn } from '@lib/types/Tables';
|
||||||
import { t } from '@lingui/core/macro';
|
import { t } from '@lingui/core/macro';
|
||||||
import { Group } from '@mantine/core';
|
import { Divider, Group, Text } from '@mantine/core';
|
||||||
import { useHover } from '@mantine/hooks';
|
import { useHover } from '@mantine/hooks';
|
||||||
import { IconCirclePlus } from '@tabler/icons-react';
|
import { IconCirclePlus } from '@tabler/icons-react';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { type ReactNode, useCallback, useMemo, useState } from 'react';
|
import { type ReactNode, useCallback, useMemo, useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useApi } from '../../contexts/ApiContext';
|
import { useApi } from '../../contexts/ApiContext';
|
||||||
|
import { formatDate } from '../../defaults/formatters';
|
||||||
import { useParameterFields } from '../../forms/CommonForms';
|
import { useParameterFields } from '../../forms/CommonForms';
|
||||||
import {
|
import {
|
||||||
useCreateApiFormModal,
|
useCreateApiFormModal,
|
||||||
@@ -72,11 +73,41 @@ function ParameterCell({
|
|||||||
parameter.data_numeric != parameter.data
|
parameter.data_numeric != parameter.data
|
||||||
) {
|
) {
|
||||||
const numeric = formatDecimal(parameter.data_numeric, { digits: 15 });
|
const numeric = formatDecimal(parameter.data_numeric, { digits: 15 });
|
||||||
extra.push(`${numeric} [${template.units}]`);
|
|
||||||
|
extra.push(
|
||||||
|
<Group gap='xs' justify='space-between'>
|
||||||
|
<Text size='sm' fw='bold'>
|
||||||
|
{numeric}
|
||||||
|
</Text>
|
||||||
|
<Text size='xs'>[{template.units}]</Text>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameter?.updated) {
|
||||||
|
extra.push(
|
||||||
|
<Group gap='xs' justify='space-between'>
|
||||||
|
<Text size='sm' fw='bold'>{t`Last Updated`}</Text>
|
||||||
|
<Text size='xs'>{formatDate(parameter.updated)}</Text>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameter?.updated_by_detail?.username) {
|
||||||
|
extra.push(
|
||||||
|
<Group gap='xs' justify='space-between'>
|
||||||
|
<Text size='sm' fw='bold'>{t`Updated By`}</Text>
|
||||||
|
<Text size='xs'>{parameter.updated_by_detail.username}</Text>
|
||||||
|
</Group>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hovered && canEdit) {
|
if (hovered && canEdit) {
|
||||||
extra.push(t`Click to edit`);
|
if (extra.length > 0) {
|
||||||
|
extra.push(<Divider />);
|
||||||
|
}
|
||||||
|
|
||||||
|
extra.push(<Text size='xs'>{t`Click to edit`}</Text>);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -88,6 +119,7 @@ function ParameterCell({
|
|||||||
extra={extra}
|
extra={extra}
|
||||||
icon={hovered && canEdit ? 'edit' : 'info'}
|
icon={hovered && canEdit ? 'edit' : 'info'}
|
||||||
title={template.name}
|
title={template.name}
|
||||||
|
minWidth={250}
|
||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
Reference in New Issue
Block a user