2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 05:26:47 +00:00

Request list of labels defined for a given stock item

This commit is contained in:
Oliver Walters 2022-03-25 22:16:36 +11:00
parent f0c5fb8355
commit 8e8015abe9
4 changed files with 58 additions and 6 deletions

View File

@ -333,6 +333,7 @@ class InvenTreeAPI {
// Default API version is 1 if not provided
_apiVersion = (data["apiVersion"] ?? 1) as int;
_pluginsEnabled = (data["plugins_enabled"] ?? false) as bool;
if (_apiVersion < _minApiVersion) {
@ -347,14 +348,12 @@ class InvenTreeAPI {
showServerError(
L10().serverOld,
message
message,
);
return false;
}
_pluginsEnabled = (data["plugins_enabled"] ?? false) as bool;
/**
* Request user token information from the server
* This is the stage that we check username:password credentials!

@ -1 +1 @@
Subproject commit 2396ebd447a616b5eebddd8d4ee407253d678d2f
Subproject commit 8717eeeb0d2ac2d406aec95cd9d0fcdf8609eb23

View File

@ -227,6 +227,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
List<Widget> children = [];
// TODO: Add in this option once the SupplierPart detail view is implemented
/*
children.add(
SimpleDialogOption(
onPressed: () {
@ -240,6 +242,7 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
)
)
);
*/
if (order.isPlaced && InvenTreeAPI().supportPoReceive()) {
children.add(

View File

@ -84,6 +84,10 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
// StockItem object
final InvenTreeStockItem item;
// Is label printing enabled for this StockItem?
// This will be determined when the widget is loaded
List<Map<String, dynamic>> labels = [];
// Part object
InvenTreePart? part;
@ -103,8 +107,41 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
// Request part information
part = await InvenTreePart().get(item.partId) as InvenTreePart?;
// Request test results...
await item.getTestResults();
// Request test results (async)
item.getTestResults().then((value) {
setState(() {
// Update
});
});
// Request information on labels available for this stock item
if (InvenTreeAPI().pluginsEnabled()) {
_getLabels();
}
}
Future <void> _getLabels() async {
// Clear the existing labels list
labels.clear();
InvenTreeAPI().get(
"/label/stock/",
params: {
"enabled": "true",
"item": "${item.pk}",
},
).then((APIResponse response) {
if (response.isValid() && response.statusCode == 200) {
for (var label in response.data) {
if (label is Map<String, dynamic>) {
labels.add(label);
}
}
setState(() {
});
}
});
}
Future <void> _editStockItem(BuildContext context) async {
@ -859,6 +896,19 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
);
}
// Print label (if label printing plugins exist)
if (labels.isNotEmpty) {
tiles.add(
ListTile(
title: Text(L10().printLabel),
leading: FaIcon(FontAwesomeIcons.print, color: COLOR_CLICK),
onTap: () {
// TODO
},
),
);
}
return tiles;
}