2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-30 22:46:49 +00:00

Request list of supplierparts

This commit is contained in:
Oliver 2021-08-02 14:00:39 +10:00
parent 21985584c2
commit 013e977031
2 changed files with 25 additions and 4 deletions

View File

@ -165,7 +165,30 @@ class InvenTreePart extends InvenTreeModel {
});
}
int get supplier_count => (jsondata['suppliers'] ?? 0) as int;
int get supplierCount => (jsondata['suppliers'] ?? 0) as int;
// Request supplier parts for this part
Future<List<InvenTreeSupplierPart>> getSupplierParts() async {
List<InvenTreeSupplierPart> _supplierParts = [];
final parts = await InvenTreeSupplierPart().list(
filters: {
"part": "${pk}",
"manufacturer_detail": "true",
"supplier_detail": "true",
"supplier_part_detail": "true"
}
);
for (result in parts) {
if (result is InvenTreeSupplierPart) {
_supplierParts.add(result);
}
}
return _supplierParts;
}
// Cached list of test templates
List<InvenTreePartTestTemplate> testingTemplates = [];

View File

@ -325,13 +325,11 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
// Tiles for "purchaseable" parts
if (part.isPurchaseable) {
// Suppliers (TODO)
if (part.supplier_count > 0) {
tiles.add(
ListTile(
title: Text(L10().suppliers),
leading: FaIcon(FontAwesomeIcons.industry),
trailing: Text("${part.supplier_count}"),
trailing: Text("${part.supplierCount}"),
onTap: () {
// TODO
},