mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-29 05:56:47 +00:00
Request list of labels defined for a given stock item
This commit is contained in:
parent
f0c5fb8355
commit
8e8015abe9
@ -333,6 +333,7 @@ class InvenTreeAPI {
|
|||||||
|
|
||||||
// Default API version is 1 if not provided
|
// Default API version is 1 if not provided
|
||||||
_apiVersion = (data["apiVersion"] ?? 1) as int;
|
_apiVersion = (data["apiVersion"] ?? 1) as int;
|
||||||
|
_pluginsEnabled = (data["plugins_enabled"] ?? false) as bool;
|
||||||
|
|
||||||
if (_apiVersion < _minApiVersion) {
|
if (_apiVersion < _minApiVersion) {
|
||||||
|
|
||||||
@ -347,14 +348,12 @@ class InvenTreeAPI {
|
|||||||
|
|
||||||
showServerError(
|
showServerError(
|
||||||
L10().serverOld,
|
L10().serverOld,
|
||||||
message
|
message,
|
||||||
);
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_pluginsEnabled = (data["plugins_enabled"] ?? false) as bool;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request user token information from the server
|
* Request user token information from the server
|
||||||
* This is the stage that we check username:password credentials!
|
* This is the stage that we check username:password credentials!
|
||||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
|||||||
Subproject commit 2396ebd447a616b5eebddd8d4ee407253d678d2f
|
Subproject commit 8717eeeb0d2ac2d406aec95cd9d0fcdf8609eb23
|
@ -227,6 +227,8 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
|||||||
|
|
||||||
List<Widget> children = [];
|
List<Widget> children = [];
|
||||||
|
|
||||||
|
// TODO: Add in this option once the SupplierPart detail view is implemented
|
||||||
|
/*
|
||||||
children.add(
|
children.add(
|
||||||
SimpleDialogOption(
|
SimpleDialogOption(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -240,6 +242,7 @@ class _PurchaseOrderDetailState extends RefreshableState<PurchaseOrderDetailWidg
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
if (order.isPlaced && InvenTreeAPI().supportPoReceive()) {
|
if (order.isPlaced && InvenTreeAPI().supportPoReceive()) {
|
||||||
children.add(
|
children.add(
|
||||||
|
@ -84,6 +84,10 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
// StockItem object
|
// StockItem object
|
||||||
final InvenTreeStockItem item;
|
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
|
// Part object
|
||||||
InvenTreePart? part;
|
InvenTreePart? part;
|
||||||
|
|
||||||
@ -103,8 +107,41 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
// Request part information
|
// Request part information
|
||||||
part = await InvenTreePart().get(item.partId) as InvenTreePart?;
|
part = await InvenTreePart().get(item.partId) as InvenTreePart?;
|
||||||
|
|
||||||
// Request test results...
|
// Request test results (async)
|
||||||
await item.getTestResults();
|
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 {
|
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;
|
return tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user