From 86584b366f68c1830762b899ff42eb5217bd6b88 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 2 Oct 2021 11:53:45 +1000 Subject: [PATCH] Building context menu for purchase order line item --- lib/api.dart | 6 ++++ lib/l10n | 2 +- lib/widget/home.dart | 2 ++ lib/widget/purchase_order_detail.dart | 42 ++++++++++++++++++++++++++- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/lib/api.dart b/lib/api.dart index 96202c3d..64993608 100644 --- a/lib/api.dart +++ b/lib/api.dart @@ -244,6 +244,12 @@ class InvenTreeAPI { // Ensure we only ever create a single instance of the API class static final InvenTreeAPI _api = InvenTreeAPI._internal(); + bool supportPoReceive() { + + // API endpoint for receiving purchase order line items was introduced in v12 + return _apiVersion >= 12; + } + /* * Connect to the remote InvenTree server: * diff --git a/lib/l10n b/lib/l10n index ed69d6ef..bdaf7a51 160000 --- a/lib/l10n +++ b/lib/l10n @@ -1 +1 @@ -Subproject commit ed69d6efe7672770ee27f4d1b4fc8ab7793266da +Subproject commit bdaf7a516cc40caf6ee1110fea6af073a61d7829 diff --git a/lib/widget/home.dart b/lib/widget/home.dart index 38623ff6..eba54768 100644 --- a/lib/widget/home.dart +++ b/lib/widget/home.dart @@ -246,11 +246,13 @@ class _InvenTreeHomePageState extends State { _showPurchaseOrders(context); } ), + /* _iconButton( context, L10().salesOrders, FontAwesomeIcons.truck, ), + */ _iconButton( context, L10().suppliers, diff --git a/lib/widget/purchase_order_detail.dart b/lib/widget/purchase_order_detail.dart index 41bbaeb8..b89117d9 100644 --- a/lib/widget/purchase_order_detail.dart +++ b/lib/widget/purchase_order_detail.dart @@ -172,6 +172,43 @@ class _PurchaseOrderDetailState extends RefreshableState children = []; + + if (InvenTreeAPI().supportPoReceive()) { + children.add( + SimpleDialogOption( + onPressed: () { + + }, + child: ListTile( + title: Text(L10().receiveItem), + leading: FaIcon(FontAwesomeIcons.signInAlt), + ) + ) + ); + } + + // No valid actions available + if (children.isEmpty) { + return; + } + + children.insert(0, Divider()); + + showDialog( + context: context, + builder: (BuildContext context) { + return SimpleDialog( + title: Text(L10().lineItem), + children: children, + ); + } + ); + + } + List lineTiles(BuildContext context) { List tiles = []; @@ -190,7 +227,10 @@ class _PurchaseOrderDetailState extends RefreshableState