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 [labelDialogOpen, setLabelDialogOpen] = useState<boolean>(false);
|
||||
|
||||
// Fetch available printing fields via OPTIONS request
|
||||
const printingFields = useQuery({
|
||||
enabled: labelPrintingEnabled,
|
||||
queryKey: ['printingFields', modelType, pluginKey],
|
||||
enabled: labelDialogOpen && !!modelType && !!labelPrintingEnabled,
|
||||
queryKey: ['printingFields', modelType, pluginKey, labelDialogOpen],
|
||||
gcTime: 500,
|
||||
queryFn: () =>
|
||||
api
|
||||
@@ -126,9 +128,11 @@ export function PrintingActions({
|
||||
fields: labelFields,
|
||||
timeout: 5000,
|
||||
onOpen: () => {
|
||||
setLabelDialogOpen(true);
|
||||
setItemIdList(items);
|
||||
},
|
||||
onClose: () => {
|
||||
setLabelDialogOpen(false);
|
||||
setPluginKey('');
|
||||
},
|
||||
submitText: t`Print`,
|
||||
|
||||
@@ -59,10 +59,12 @@ export default function useDataExport({
|
||||
return queryParams;
|
||||
}, [pluginKey, filters, searchTerm]);
|
||||
|
||||
const [exportDialogOpen, setExportDialogOpen] = useState<boolean>(false);
|
||||
|
||||
// Fetch available export fields via OPTIONS request
|
||||
const extraExportFields = useQuery({
|
||||
enabled: !!url && enabled,
|
||||
queryKey: ['export-fields', pluginKey, url, exportParams],
|
||||
enabled: !!url && enabled && exportDialogOpen,
|
||||
queryKey: ['export-fields', pluginKey, url, exportParams, exportDialogOpen],
|
||||
gcTime: 500,
|
||||
queryFn: () =>
|
||||
api
|
||||
@@ -112,6 +114,12 @@ export default function useDataExport({
|
||||
submitText: t`Export`,
|
||||
successMessage: null,
|
||||
timeout: 30 * 1000,
|
||||
onOpen: () => {
|
||||
setExportDialogOpen(true);
|
||||
},
|
||||
onClose: () => {
|
||||
setExportDialogOpen(false);
|
||||
},
|
||||
onFormSuccess: (response: any) => {
|
||||
setExportId(response.pk);
|
||||
setPluginKey('inventree-exporter');
|
||||
|
||||
Reference in New Issue
Block a user