mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Cleanup build details page
This commit is contained in:
parent
30b45a917c
commit
2ec7b74f6d
@ -102,6 +102,15 @@ export default function BuildDetail() {
|
||||
name: 'title',
|
||||
label: t`Description`,
|
||||
icon: 'description'
|
||||
},
|
||||
{
|
||||
type: 'link',
|
||||
name: 'parent',
|
||||
icon: 'builds',
|
||||
label: t`Parent Build`,
|
||||
model_field: 'reference',
|
||||
model: ModelType.build,
|
||||
hidden: !build.parent
|
||||
}
|
||||
];
|
||||
|
||||
@ -127,13 +136,6 @@ export default function BuildDetail() {
|
||||
model: ModelType.salesorder,
|
||||
model_field: 'reference',
|
||||
hidden: !build.sales_order
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'issued_by',
|
||||
label: t`Issued By`,
|
||||
badge: 'user',
|
||||
icon: 'user'
|
||||
}
|
||||
];
|
||||
|
||||
@ -141,12 +143,34 @@ export default function BuildDetail() {
|
||||
{
|
||||
type: 'text',
|
||||
name: 'issued_by',
|
||||
label: t`Issued By`
|
||||
label: t`Issued By`,
|
||||
badge: 'user'
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'responsible',
|
||||
label: t`Responsible`
|
||||
label: t`Responsible`,
|
||||
badge: 'owner',
|
||||
hidden: !build.responsible
|
||||
}
|
||||
];
|
||||
|
||||
let br: DetailsField[] = [
|
||||
{
|
||||
type: 'link',
|
||||
name: 'take_from',
|
||||
icon: 'location',
|
||||
model: ModelType.stocklocation,
|
||||
label: t`Source Location`,
|
||||
backup_value: t`Any location`
|
||||
},
|
||||
{
|
||||
type: 'link',
|
||||
name: 'destination',
|
||||
icon: 'location',
|
||||
model: ModelType.stocklocation,
|
||||
label: t`Destination Location`,
|
||||
hidden: !build.destination
|
||||
}
|
||||
];
|
||||
|
||||
@ -167,6 +191,7 @@ export default function BuildDetail() {
|
||||
</Grid>
|
||||
<DetailsTable fields={tr} item={build} />
|
||||
<DetailsTable fields={bl} item={build} />
|
||||
<DetailsTable fields={br} item={build} />
|
||||
</ItemDetailsGrid>
|
||||
);
|
||||
}, [build, instanceQuery]);
|
||||
|
@ -75,6 +75,7 @@ type InternalLinkField = {
|
||||
model: ModelType;
|
||||
model_field?: string;
|
||||
model_formatter?: (value: any) => string;
|
||||
backup_value?: string;
|
||||
};
|
||||
|
||||
type ExternalLinkField = {
|
||||
@ -351,19 +352,27 @@ function TableAnchorValue(props: FieldProps) {
|
||||
return getDetailUrl(props.field_data.model, props.field_value);
|
||||
}, [props.field_data.model, props.field_value]);
|
||||
|
||||
let make_link = props.field_data?.link ?? true;
|
||||
|
||||
// Construct the "return value" for the fetched data
|
||||
// Basic fallback value
|
||||
let value = data?.name ?? 'No name defined';
|
||||
let value = undefined;
|
||||
|
||||
if (props.field_data.model_formatter) {
|
||||
value = props.field_data.model_formatter(data) ?? value;
|
||||
} else if (props.field_data.model_field) {
|
||||
value = data?.[props.field_data.model_field] ?? value;
|
||||
} else {
|
||||
value = data?.name;
|
||||
}
|
||||
|
||||
if (value === undefined) {
|
||||
value = data?.name ?? props.field_data?.backup_value ?? 'No name defined';
|
||||
make_link = false;
|
||||
}
|
||||
|
||||
return (
|
||||
<Suspense fallback={<Skeleton width={200} height={20} radius="xl" />}>
|
||||
{props.field_data.link ?? true ? (
|
||||
{make_link ? (
|
||||
<Anchor
|
||||
href={`/platform${detailUrl}`}
|
||||
target={data?.external ? '_blank' : undefined}
|
||||
|
Loading…
Reference in New Issue
Block a user