mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 21:15:41 +00:00
Cleanup build details page
This commit is contained in:
@ -102,6 +102,15 @@ export default function BuildDetail() {
|
|||||||
name: 'title',
|
name: 'title',
|
||||||
label: t`Description`,
|
label: t`Description`,
|
||||||
icon: '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: ModelType.salesorder,
|
||||||
model_field: 'reference',
|
model_field: 'reference',
|
||||||
hidden: !build.sales_order
|
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',
|
type: 'text',
|
||||||
name: 'issued_by',
|
name: 'issued_by',
|
||||||
label: t`Issued By`
|
label: t`Issued By`,
|
||||||
|
badge: 'user'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'text',
|
type: 'text',
|
||||||
name: 'responsible',
|
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>
|
</Grid>
|
||||||
<DetailsTable fields={tr} item={build} />
|
<DetailsTable fields={tr} item={build} />
|
||||||
<DetailsTable fields={bl} item={build} />
|
<DetailsTable fields={bl} item={build} />
|
||||||
|
<DetailsTable fields={br} item={build} />
|
||||||
</ItemDetailsGrid>
|
</ItemDetailsGrid>
|
||||||
);
|
);
|
||||||
}, [build, instanceQuery]);
|
}, [build, instanceQuery]);
|
||||||
|
@ -75,6 +75,7 @@ type InternalLinkField = {
|
|||||||
model: ModelType;
|
model: ModelType;
|
||||||
model_field?: string;
|
model_field?: string;
|
||||||
model_formatter?: (value: any) => string;
|
model_formatter?: (value: any) => string;
|
||||||
|
backup_value?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ExternalLinkField = {
|
type ExternalLinkField = {
|
||||||
@ -351,19 +352,27 @@ function TableAnchorValue(props: FieldProps) {
|
|||||||
return getDetailUrl(props.field_data.model, props.field_value);
|
return getDetailUrl(props.field_data.model, props.field_value);
|
||||||
}, [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
|
// Construct the "return value" for the fetched data
|
||||||
// Basic fallback value
|
let value = undefined;
|
||||||
let value = data?.name ?? 'No name defined';
|
|
||||||
|
|
||||||
if (props.field_data.model_formatter) {
|
if (props.field_data.model_formatter) {
|
||||||
value = props.field_data.model_formatter(data) ?? value;
|
value = props.field_data.model_formatter(data) ?? value;
|
||||||
} else if (props.field_data.model_field) {
|
} else if (props.field_data.model_field) {
|
||||||
value = data?.[props.field_data.model_field] ?? value;
|
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 (
|
return (
|
||||||
<Suspense fallback={<Skeleton width={200} height={20} radius="xl" />}>
|
<Suspense fallback={<Skeleton width={200} height={20} radius="xl" />}>
|
||||||
{props.field_data.link ?? true ? (
|
{make_link ? (
|
||||||
<Anchor
|
<Anchor
|
||||||
href={`/platform${detailUrl}`}
|
href={`/platform${detailUrl}`}
|
||||||
target={data?.external ? '_blank' : undefined}
|
target={data?.external ? '_blank' : undefined}
|
||||||
|
Reference in New Issue
Block a user