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

Get list of required tets

This commit is contained in:
Oliver Walters 2020-05-23 14:37:27 +10:00
parent 687b5ed8c7
commit 70ca369529
2 changed files with 29 additions and 1 deletions

View File

@ -71,6 +71,33 @@ class InvenTreePart extends InvenTreeModel {
@override
String URL = "part/";
List<dynamic> testTemplates;
int get testTemplateCount {
if (testTemplates == null) {
return 0;
} else {
return testTemplates.length;
}
}
Future<void> getTestTemplates() async {
var response = await api.get("/part/test-template/", params: {
"part": "${pk}",
})
.timeout(Duration(seconds: 10))
.catchError((e) {
return;
});
print("Status: " + response.statusCode.toString());
testTemplates = json.decode(response.body);
return;
}
// Get the number of stock on order for this Part
double get onOrder => double.tryParse(jsondata['ordering'].toString() ?? '0');

View File

@ -42,6 +42,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
@override
Future<void> request(BuildContext context) async {
await part.reload(context);
await part.getTestTemplates();
}
void _savePart(Map<String, String> values) async {
@ -219,7 +220,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
tiles.add(ListTile(
title: Text("Required Tests"),
leading: FaIcon(FontAwesomeIcons.tasks),
trailing: Text(""),
trailing: Text("${part.testTemplateCount}"),
onTap: null,
)
);