mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-29 14:06:47 +00:00
PartTestTemplate is now class based
This commit is contained in:
parent
70ca369529
commit
0a5419eb6d
@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:InvenTree/api.dart';
|
import 'package:InvenTree/api.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
import 'model.dart';
|
import 'model.dart';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
@ -63,6 +64,28 @@ class InvenTreePartCategory extends InvenTreeModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class InvenTreePartTestTemplate extends InvenTreeModel {
|
||||||
|
|
||||||
|
@override
|
||||||
|
String NAME = "PartTestTemplate";
|
||||||
|
|
||||||
|
@override
|
||||||
|
String URL = "part/test-template/";
|
||||||
|
|
||||||
|
InvenTreePartTestTemplate() : super();
|
||||||
|
|
||||||
|
InvenTreePartTestTemplate.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||||
|
var template = InvenTreePartTestTemplate.fromJson(json);
|
||||||
|
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class InvenTreePart extends InvenTreeModel {
|
class InvenTreePart extends InvenTreeModel {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -71,31 +94,28 @@ class InvenTreePart extends InvenTreeModel {
|
|||||||
@override
|
@override
|
||||||
String URL = "part/";
|
String URL = "part/";
|
||||||
|
|
||||||
List<dynamic> testTemplates;
|
List<InvenTreePartTestTemplate> testingTemplates = List<InvenTreePartTestTemplate>();
|
||||||
|
|
||||||
int get testTemplateCount {
|
int get testTemplateCount => testingTemplates.length;
|
||||||
if (testTemplates == null) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return testTemplates.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> getTestTemplates() async {
|
Future<void> getTestTemplates(BuildContext context, {bool showDialog=false}) async {
|
||||||
|
|
||||||
var response = await api.get("/part/test-template/", params: {
|
InvenTreePartTestTemplate().list(
|
||||||
|
context,
|
||||||
|
filters: {
|
||||||
"part": "${pk}",
|
"part": "${pk}",
|
||||||
})
|
},
|
||||||
.timeout(Duration(seconds: 10))
|
dialog: showDialog,
|
||||||
.catchError((e) {
|
).then((var templates) {
|
||||||
return;
|
|
||||||
|
testingTemplates.clear();
|
||||||
|
|
||||||
|
for (var t in templates) {
|
||||||
|
if (t is InvenTreePartTestTemplate) {
|
||||||
|
testingTemplates.add(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
print("Status: " + response.statusCode.toString());
|
|
||||||
|
|
||||||
testTemplates = json.decode(response.body);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the number of stock on order for this Part
|
// Get the number of stock on order for this Part
|
||||||
|
@ -42,7 +42,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
@override
|
@override
|
||||||
Future<void> request(BuildContext context) async {
|
Future<void> request(BuildContext context) async {
|
||||||
await part.reload(context);
|
await part.reload(context);
|
||||||
await part.getTestTemplates();
|
await part.getTestTemplates(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _savePart(Map<String, String> values) async {
|
void _savePart(Map<String, String> values) async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user