2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-09-13 06:01:35 +00:00

[UI] Details Table Fixes (#10263)

* Remove "copy" button from link

* Handle empty details group

* Tweak text

* Fix link in details field
This commit is contained in:
Oliver
2025-09-04 10:42:00 +10:00
committed by GitHub
parent bfdc49c591
commit 1eb4e4fb3d
2 changed files with 18 additions and 9 deletions

View File

@@ -22,7 +22,7 @@ import { YesNoButton } from '@lib/components/YesNoButton';
import { ApiEndpoints } from '@lib/enums/ApiEndpoints';
import { ModelType } from '@lib/enums/ModelType';
import { apiUrl } from '@lib/functions/Api';
import { getDetailUrl } from '@lib/functions/Navigation';
import { getBaseUrl, getDetailUrl } from '@lib/functions/Navigation';
import { navigateToLink } from '@lib/functions/Navigation';
import type { InvenTreeIconType } from '@lib/types/Icons';
import { useApi } from '../../contexts/ApiContext';
@@ -369,6 +369,10 @@ function TableAnchorValue(props: Readonly<FieldProps>) {
[detailUrl]
);
const absoluteUrl = useMemo(() => {
return `/${getBaseUrl()}${detailUrl}`;
}, [detailUrl]);
if (!data || data.isLoading || data.isFetching) {
return <Skeleton height={12} radius='md' />;
}
@@ -412,7 +416,7 @@ function TableAnchorValue(props: Readonly<FieldProps>) {
return (
<>
{make_link ? (
<Anchor href='#' onClick={handleLinkClick}>
<Anchor href={absoluteUrl} onClick={handleLinkClick}>
<Text>{value}</Text>
</Anchor>
) : (
@@ -518,6 +522,14 @@ export function DetailsTable({
fields: DetailsField[];
title?: string;
}>) {
const visibleFields = useMemo(() => {
return fields.filter((field) => !field.hidden);
}, [fields]);
if (!visibleFields?.length) {
return <div />;
}
return (
<Paper
p='xs'
@@ -528,9 +540,7 @@ export function DetailsTable({
{title && <StylishText size='lg'>{title}</StylishText>}
<Table striped verticalSpacing={5} horizontalSpacing='sm'>
<Table.Tbody>
{fields
.filter((field: DetailsField) => !field.hidden)
.map((field: DetailsField, index: number) => (
{visibleFields.map((field: DetailsField, index: number) => (
<DetailsTableField field={field} item={item} key={index} />
))}
</Table.Tbody>

View File

@@ -157,9 +157,8 @@ export default function SupplierPartDetail() {
type: 'link',
name: 'manufacturer_part',
model_field: 'MPN',
label: t`Manufacturer Part Number`,
label: t`Manufacturer Part`,
model: ModelType.manufacturerpart,
copy: true,
icon: 'reference',
hidden: !data.manufacturer_part
}