2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 13:36:50 +00:00

Building context menu for purchase order line item

This commit is contained in:
Oliver 2021-10-02 11:53:45 +10:00
parent d433e6327b
commit 86584b366f
4 changed files with 50 additions and 2 deletions

View File

@ -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:
*

@ -1 +1 @@
Subproject commit ed69d6efe7672770ee27f4d1b4fc8ab7793266da
Subproject commit bdaf7a516cc40caf6ee1110fea6af073a61d7829

View File

@ -246,11 +246,13 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
_showPurchaseOrders(context);
}
),
/*
_iconButton(
context,
L10().salesOrders,
FontAwesomeIcons.truck,
),
*/
_iconButton(
context,
L10().suppliers,

View File

@ -172,6 +172,43 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
}
void lineItemMenu(BuildContext context, InvenTreePOLineItem lineItem) {
List<Widget> 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<Widget> lineTiles(BuildContext context) {
List<Widget> tiles = [];
@ -190,7 +227,10 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
title: Text(supplierPart.SKU),
subtitle: Text(supplierPart.partName),
leading: InvenTreeAPI().getImage(supplierPart.partImage, width: 40, height: 40),
trailing: Text("${line.quantity}"),
trailing: Text("${line.outstanding}"),
onLongPress: () {
lineItemMenu(context, line);
},
)
);
}