mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-03 07:48:53 +00:00
Refactor upload of test result
This commit is contained in:
parent
4339f70d64
commit
e1a8ecc5f0
@ -58,7 +58,7 @@ class _PartStockDisplayState extends RefreshableState<PartStockDetailWidget> {
|
|||||||
title: Text(part.fullname),
|
title: Text(part.fullname),
|
||||||
subtitle: Text(part.description),
|
subtitle: Text(part.description),
|
||||||
leading: InvenTreeAPI().getImage(part.thumbnail),
|
leading: InvenTreeAPI().getImage(part.thumbnail),
|
||||||
trailing: Text('${part.inStock}'),
|
trailing: Text(part.inStockString),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
PartStockList(part.stockItems),
|
PartStockList(part.stockItems),
|
||||||
|
@ -4,6 +4,7 @@ import 'package:InvenTree/inventree/model.dart';
|
|||||||
import 'package:InvenTree/api.dart';
|
import 'package:InvenTree/api.dart';
|
||||||
import 'package:InvenTree/widget/dialogs.dart';
|
import 'package:InvenTree/widget/dialogs.dart';
|
||||||
import 'package:InvenTree/widget/fields.dart';
|
import 'package:InvenTree/widget/fields.dart';
|
||||||
|
import 'package:InvenTree/widget/snacks.dart';
|
||||||
|
|
||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
|
|
||||||
@ -46,24 +47,20 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
|||||||
|
|
||||||
void uploadTestResult(String name, bool result, String value, String notes, File attachment) async {
|
void uploadTestResult(String name, bool result, String value, String notes, File attachment) async {
|
||||||
|
|
||||||
item.uploadTestResult(
|
final success = await item.uploadTestResult(
|
||||||
context,
|
context, name, result,
|
||||||
name,
|
|
||||||
result,
|
|
||||||
value: value,
|
value: value,
|
||||||
notes: notes,
|
notes: notes,
|
||||||
attachment: attachment
|
attachment: attachment
|
||||||
).then((bool success) {
|
);
|
||||||
if (success) {
|
|
||||||
// TODO - Show a SnackBar here!
|
showSnackIcon(
|
||||||
refresh();
|
refreshableKey,
|
||||||
} else {
|
success ? "Test result uploaded" : "Could not upload test result",
|
||||||
showErrorDialog(
|
success: success
|
||||||
context,
|
);
|
||||||
I18N.of(context).error,
|
|
||||||
"Could not upload test result to server");
|
refresh();
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTestResult({String name = '', bool nameIsEditable = true, bool result = false, String value = '', bool valueRequired = false, bool attachmentRequired = false}) async {
|
void addTestResult({String name = '', bool nameIsEditable = true, bool result = false, String value = '', bool valueRequired = false, bool attachmentRequired = false}) async {
|
||||||
@ -76,24 +73,9 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
|||||||
|
|
||||||
showFormDialog(context, "Add Test Data",
|
showFormDialog(context, "Add Test Data",
|
||||||
key: _addResultKey,
|
key: _addResultKey,
|
||||||
actions: <Widget>[
|
callback: () {
|
||||||
FlatButton(
|
uploadTestResult(_name, _result, _value, _notes, _attachment);
|
||||||
child: Text(I18N.of(context).cancel),
|
},
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
FlatButton(
|
|
||||||
child: Text(I18N.of(context).save),
|
|
||||||
onPressed: () {
|
|
||||||
if (_addResultKey.currentState.validate()) {
|
|
||||||
_addResultKey.currentState.save();
|
|
||||||
Navigator.pop(context);
|
|
||||||
uploadTestResult(_name, _result, _value, _notes, _attachment);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
fields: <Widget>[
|
fields: <Widget>[
|
||||||
StringField(
|
StringField(
|
||||||
label: "Test Name",
|
label: "Test Name",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user