From 541060aa0390bbf25fbd55e8bf4e76a3caad34bb Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 15 May 2024 20:19:34 +1000 Subject: [PATCH] Print label key (#491) * We now use the plugin key for printing labels * Bump API version for modern label printing * Fix typo --- lib/api.dart | 2 +- lib/labels.dart | 6 +++--- lib/widget/part/part_detail.dart | 4 ++-- lib/widget/stock/location_display.dart | 4 ++-- lib/widget/stock/stock_detail.dart | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/api.dart b/lib/api.dart index 67b076f8..1c960f3e 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -346,7 +346,7 @@ class InvenTreeAPI { bool get supportsCompanyActiveStatus => isConnected() && apiVersion >= 189; // Does the server support the "modern" (consolidated) label printing API? - bool get supportsModenLabelPrinting => isConnected() && apiVersion >= 197; + bool get supportsModernLabelPrinting => isConnected() && apiVersion >= 198; // Cached list of plugins (refreshed when we connect to the server) List _plugins = []; diff --git a/lib/labels.dart b/lib/labels.dart index c8fadd09..668bbf9d 100644 --- a/lib/labels.dart +++ b/lib/labels.dart @@ -59,7 +59,7 @@ Future selectAndPrintLabel( for (var plugin in plugins) { plugin_options.add({ "display_name": plugin.humanName, - "value": InvenTreeAPI().supportsModenLabelPrinting ? plugin.pk : plugin.key + "value": plugin.key, }); } @@ -100,7 +100,7 @@ Future selectAndPrintLabel( showLoadingOverlay(context); - if (InvenTreeAPI().supportsModenLabelPrinting) { + if (InvenTreeAPI().supportsModernLabelPrinting) { // Modern label printing API uses a POST request to a single API endpoint. await InvenTreeAPI().post( @@ -178,7 +178,7 @@ Future>> getLabelTemplates( String url = "/label/template/"; - if (InvenTreeAPI().supportsModenLabelPrinting) { + if (InvenTreeAPI().supportsModernLabelPrinting) { data["model_type"] = labelType; } else { // Legacy label printing API endpoint diff --git a/lib/widget/part/part_detail.dart b/lib/widget/part/part_detail.dart index f9693a1f..c310a598 100644 --- a/lib/widget/part/part_detail.dart +++ b/lib/widget/part/part_detail.dart @@ -250,8 +250,8 @@ class _PartDisplayState extends RefreshableState { if (allowLabelPrinting) { - String model_type = api.supportsModenLabelPrinting ? InvenTreePart().MODEL_TYPE : "part"; - String item_key = api.supportsModenLabelPrinting ? "items" : "part"; + String model_type = api.supportsModernLabelPrinting ? InvenTreePart().MODEL_TYPE : "part"; + String item_key = api.supportsModernLabelPrinting ? "items" : "part"; _labels = await getLabelTemplates( model_type, diff --git a/lib/widget/stock/location_display.dart b/lib/widget/stock/location_display.dart index dcb13720..ece7c277 100644 --- a/lib/widget/stock/location_display.dart +++ b/lib/widget/stock/location_display.dart @@ -249,8 +249,8 @@ class _LocationDisplayState extends RefreshableState { if (widget.location != null) { - String model_type = api.supportsModenLabelPrinting ? InvenTreeStockLocation().MODEL_TYPE : "location"; - String item_key = api.supportsModenLabelPrinting ? "items" : "location"; + String model_type = api.supportsModernLabelPrinting ? InvenTreeStockLocation().MODEL_TYPE : "location"; + String item_key = api.supportsModernLabelPrinting ? "items" : "location"; _labels = await getLabelTemplates( model_type, diff --git a/lib/widget/stock/stock_detail.dart b/lib/widget/stock/stock_detail.dart index f44f0dd0..12c7deaa 100644 --- a/lib/widget/stock/stock_detail.dart +++ b/lib/widget/stock/stock_detail.dart @@ -266,8 +266,8 @@ class _StockItemDisplayState extends RefreshableState { // Request information on labels available for this stock item if (allowLabelPrinting) { - String model_type = api.supportsModenLabelPrinting ? InvenTreeStockLocation().MODEL_TYPE : "stock"; - String item_key = api.supportsModenLabelPrinting ? "items" : "item"; + String model_type = api.supportsModernLabelPrinting ? InvenTreeStockLocation().MODEL_TYPE : "stock"; + String item_key = api.supportsModernLabelPrinting ? "items" : "item"; // Clear the existing labels list _labels = await getLabelTemplates(