From f2f652bfdc3321b504e07cd355ad399172caf19f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 26 Mar 2022 11:24:56 +1100 Subject: [PATCH] Send label printing information to the server --- lib/l10n | 2 +- lib/widget/stock_detail.dart | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/l10n b/lib/l10n index 8717eeeb..42662619 160000 --- a/lib/l10n +++ b/lib/l10n @@ -1 +1 @@ -Subproject commit 8717eeeb0d2ac2d406aec95cd9d0fcdf8609eb23 +Subproject commit 42662619b3d094e9bd41d3f715cac2beff7cf6f6 diff --git a/lib/widget/stock_detail.dart b/lib/widget/stock_detail.dart index 98264a4c..36f67dcb 100644 --- a/lib/widget/stock_detail.dart +++ b/lib/widget/stock_detail.dart @@ -205,9 +205,27 @@ class _StockItemDisplayState extends RefreshableState { "", fields, icon: FontAwesomeIcons.print, - onSuccess: (data) async { - print("Printing..."); - print(data.toString()); + onSuccess: (Map data) async { + int labelId = (data["label"] ?? -1) as int; + String pluginKey = (data["plugin"] ?? "") as String; + + if (labelId != -1 && pluginKey.isNotEmpty) { + String url = "/label/stock/${labelId}/print/?item=${item.pk}&plugin=${pluginKey}"; + + InvenTreeAPI().get(url).then((APIResponse response) { + if (response.isValid() && response.statusCode == 200) { + showSnackIcon( + L10().printLabelSuccess, + success: true + ); + } else { + showSnackIcon( + L10().printLabelFailure, + success: false, + ); + } + }); + } }, ); }