2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

Fix for "installed in" display

- Allow "details" field to be passed custom params
This commit is contained in:
Oliver Walters
2024-11-13 02:05:20 +00:00
parent 246f17113f
commit 9943384156
2 changed files with 8 additions and 2 deletions

View File

@ -67,6 +67,7 @@ type InternalLinkField = {
model: ModelType; model: ModelType;
model_field?: string; model_field?: string;
model_formatter?: (value: any) => string; model_formatter?: (value: any) => string;
model_filters?: any;
backup_value?: string; backup_value?: string;
}; };
@ -234,7 +235,9 @@ function TableAnchorValue(props: Readonly<FieldProps>) {
const url = apiUrl(modelDef.api_endpoint, props.field_value); const url = apiUrl(modelDef.api_endpoint, props.field_value);
return api return api
.get(url) .get(url, {
params: props.field_data.model_filters ?? undefined
})
.then((response) => { .then((response) => {
switch (response.status) { switch (response.status) {
case 200: case 200:

View File

@ -211,6 +211,9 @@ export default function StockDetail() {
type: 'link', type: 'link',
name: 'belongs_to', name: 'belongs_to',
label: t`Installed In`, label: t`Installed In`,
model_filters: {
part_detail: true
},
model_formatter: (model: any) => { model_formatter: (model: any) => {
let text = model?.part_detail?.full_name ?? model?.name; let text = model?.part_detail?.full_name ?? model?.name;
if (model.serial && model.quantity == 1) { if (model.serial && model.quantity == 1) {