mirror of
https://github.com/inventree/InvenTree.git
synced 2025-12-18 02:08:22 +00:00
[ui] Table fix (#11022)
* Optimize printing actions - Don't fire API request until dialog is opened - This prevents a lot of unnecessary API calls from the UI * Do not fire export options query until required
This commit is contained in:
@@ -64,10 +64,12 @@ export function PrintingActions({
|
|||||||
|
|
||||||
const [itemIdList, setItemIdList] = useState<number[]>([]);
|
const [itemIdList, setItemIdList] = useState<number[]>([]);
|
||||||
|
|
||||||
|
const [labelDialogOpen, setLabelDialogOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
// Fetch available printing fields via OPTIONS request
|
// Fetch available printing fields via OPTIONS request
|
||||||
const printingFields = useQuery({
|
const printingFields = useQuery({
|
||||||
enabled: labelPrintingEnabled,
|
enabled: labelDialogOpen && !!modelType && !!labelPrintingEnabled,
|
||||||
queryKey: ['printingFields', modelType, pluginKey],
|
queryKey: ['printingFields', modelType, pluginKey, labelDialogOpen],
|
||||||
gcTime: 500,
|
gcTime: 500,
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api
|
api
|
||||||
@@ -126,9 +128,11 @@ export function PrintingActions({
|
|||||||
fields: labelFields,
|
fields: labelFields,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
onOpen: () => {
|
onOpen: () => {
|
||||||
|
setLabelDialogOpen(true);
|
||||||
setItemIdList(items);
|
setItemIdList(items);
|
||||||
},
|
},
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
|
setLabelDialogOpen(false);
|
||||||
setPluginKey('');
|
setPluginKey('');
|
||||||
},
|
},
|
||||||
submitText: t`Print`,
|
submitText: t`Print`,
|
||||||
|
|||||||
@@ -59,10 +59,12 @@ export default function useDataExport({
|
|||||||
return queryParams;
|
return queryParams;
|
||||||
}, [pluginKey, filters, searchTerm]);
|
}, [pluginKey, filters, searchTerm]);
|
||||||
|
|
||||||
|
const [exportDialogOpen, setExportDialogOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
// Fetch available export fields via OPTIONS request
|
// Fetch available export fields via OPTIONS request
|
||||||
const extraExportFields = useQuery({
|
const extraExportFields = useQuery({
|
||||||
enabled: !!url && enabled,
|
enabled: !!url && enabled && exportDialogOpen,
|
||||||
queryKey: ['export-fields', pluginKey, url, exportParams],
|
queryKey: ['export-fields', pluginKey, url, exportParams, exportDialogOpen],
|
||||||
gcTime: 500,
|
gcTime: 500,
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
api
|
api
|
||||||
@@ -112,6 +114,12 @@ export default function useDataExport({
|
|||||||
submitText: t`Export`,
|
submitText: t`Export`,
|
||||||
successMessage: null,
|
successMessage: null,
|
||||||
timeout: 30 * 1000,
|
timeout: 30 * 1000,
|
||||||
|
onOpen: () => {
|
||||||
|
setExportDialogOpen(true);
|
||||||
|
},
|
||||||
|
onClose: () => {
|
||||||
|
setExportDialogOpen(false);
|
||||||
|
},
|
||||||
onFormSuccess: (response: any) => {
|
onFormSuccess: (response: any) => {
|
||||||
setExportId(response.pk);
|
setExportId(response.pk);
|
||||||
setPluginKey('inventree-exporter');
|
setPluginKey('inventree-exporter');
|
||||||
|
|||||||
Reference in New Issue
Block a user