mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-03 15:52:51 +00:00
@@ -62,6 +62,8 @@ export function PrintingActions({
|
|||||||
id: reportId
|
id: reportId
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [itemIdList, setItemIdList] = useState<number[]>([]);
|
||||||
|
|
||||||
// Fetch available printing fields via OPTIONS request
|
// Fetch available printing fields via OPTIONS request
|
||||||
const printingFields = useQuery({
|
const printingFields = useQuery({
|
||||||
enabled: labelPrintingEnabled,
|
enabled: labelPrintingEnabled,
|
||||||
@@ -89,13 +91,13 @@ export function PrintingActions({
|
|||||||
filters: {
|
filters: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
model_type: modelType,
|
model_type: modelType,
|
||||||
items: items.join(',')
|
items: itemIdList.join(',')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fields.items = {
|
fields.items = {
|
||||||
...fields.items,
|
...fields.items,
|
||||||
value: items,
|
value: itemIdList,
|
||||||
hidden: true
|
hidden: true
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -115,7 +117,7 @@ export function PrintingActions({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}, [defaultLabelPlugin, pluginKey, printingFields.data, items]);
|
}, [defaultLabelPlugin, pluginKey, printingFields.data, itemIdList]);
|
||||||
|
|
||||||
const labelModal = useCreateApiFormModal({
|
const labelModal = useCreateApiFormModal({
|
||||||
url: apiUrl(ApiEndpoints.label_print),
|
url: apiUrl(ApiEndpoints.label_print),
|
||||||
@@ -123,6 +125,9 @@ export function PrintingActions({
|
|||||||
modalId: 'print-labels',
|
modalId: 'print-labels',
|
||||||
fields: labelFields,
|
fields: labelFields,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
|
onOpen: () => {
|
||||||
|
setItemIdList(items);
|
||||||
|
},
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
setPluginKey('');
|
setPluginKey('');
|
||||||
},
|
},
|
||||||
@@ -134,24 +139,31 @@ export function PrintingActions({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const reportModal = useCreateApiFormModal({
|
const reportFields: ApiFormFieldSet = useMemo(() => {
|
||||||
url: apiUrl(ApiEndpoints.report_print),
|
return {
|
||||||
title: t`Print Report`,
|
|
||||||
modalId: 'print-reports',
|
|
||||||
timeout: 5000,
|
|
||||||
fields: {
|
|
||||||
template: {
|
template: {
|
||||||
autoFill: true,
|
autoFill: true,
|
||||||
filters: {
|
filters: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
model_type: modelType,
|
model_type: modelType,
|
||||||
items: items.join(',')
|
items: itemIdList.join(',')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
items: {
|
items: {
|
||||||
hidden: true,
|
hidden: true,
|
||||||
value: items
|
value: itemIdList
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}, [itemIdList, modelType]);
|
||||||
|
|
||||||
|
const reportModal = useCreateApiFormModal({
|
||||||
|
url: apiUrl(ApiEndpoints.report_print),
|
||||||
|
title: t`Print Report`,
|
||||||
|
modalId: 'print-reports',
|
||||||
|
timeout: 5000,
|
||||||
|
fields: reportFields,
|
||||||
|
onOpen: () => {
|
||||||
|
setItemIdList(items);
|
||||||
},
|
},
|
||||||
submitText: t`Print`,
|
submitText: t`Print`,
|
||||||
successMessage: null,
|
successMessage: null,
|
||||||
|
Reference in New Issue
Block a user