mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Add class for StockItemTestResult
This commit is contained in:
parent
0a5419eb6d
commit
868e1d20dc
@ -1,10 +1,34 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'model.dart';
|
import 'model.dart';
|
||||||
|
|
||||||
import 'package:InvenTree/api.dart';
|
import 'package:InvenTree/api.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class InvenTreeStockItemTestResult extends InvenTreeModel {
|
||||||
|
|
||||||
|
@override
|
||||||
|
String NAME = "StockItemTestResult";
|
||||||
|
|
||||||
|
@override
|
||||||
|
String URL = "stock/test/";
|
||||||
|
|
||||||
|
InvenTreeStockItemTestResult() : super();
|
||||||
|
|
||||||
|
InvenTreeStockItemTestResult.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
InvenTreeStockItemTestResult createFromJson(Map<String, dynamic> json) {
|
||||||
|
var result = InvenTreeStockItemTestResult.fromJson(json);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class InvenTreeStockItem extends InvenTreeModel {
|
class InvenTreeStockItem extends InvenTreeModel {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -43,6 +67,29 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<InvenTreeStockItemTestResult> testResults = List<InvenTreeStockItemTestResult>();
|
||||||
|
|
||||||
|
int get testResultCount => testResults.length;
|
||||||
|
|
||||||
|
Future<void> getTestResults(BuildContext context, {bool showDialog=false}) async {
|
||||||
|
InvenTreeStockItemTestResult().list(
|
||||||
|
context,
|
||||||
|
filters: {
|
||||||
|
"stock_item": "${pk}",
|
||||||
|
"user_detail": "true",
|
||||||
|
},
|
||||||
|
dialog: showDialog,
|
||||||
|
).then((var results) {
|
||||||
|
testResults.clear();
|
||||||
|
|
||||||
|
for (var r in results) {
|
||||||
|
if (r is InvenTreeStockItemTestResult) {
|
||||||
|
testResults.add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
int get partId => jsondata['part'] ?? -1;
|
int get partId => jsondata['part'] ?? -1;
|
||||||
|
|
||||||
int get trackingItemCount => jsondata['tracking_items'] as int ?? 0;
|
int get trackingItemCount => jsondata['tracking_items'] as int ?? 0;
|
||||||
|
@ -20,7 +20,7 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
|||||||
|
|
||||||
// Function called after the widget is first build
|
// Function called after the widget is first build
|
||||||
Future<void> onBuild(BuildContext context) async {
|
Future<void> onBuild(BuildContext context) async {
|
||||||
return;
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to request data for this page
|
// Function to request data for this page
|
||||||
|
@ -53,6 +53,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
@override
|
@override
|
||||||
Future<void> request(BuildContext context) async {
|
Future<void> request(BuildContext context) async {
|
||||||
await item.reload(context);
|
await item.reload(context);
|
||||||
|
await item.getTestResults(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _editStockItem() {
|
void _editStockItem() {
|
||||||
@ -423,6 +424,15 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tiles.add(
|
||||||
|
ListTile(
|
||||||
|
title: Text("Test Results"),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.tasks),
|
||||||
|
trailing: Text("${item.testResultCount}"),
|
||||||
|
onTap: null,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (item.trackingItemCount > 0) {
|
if (item.trackingItemCount > 0) {
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user