mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Refactor test result display
This commit is contained in:
parent
54f045afd8
commit
393863957e
@ -181,76 +181,55 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
|||||||
var results = getTestResults();
|
var results = getTestResults();
|
||||||
|
|
||||||
for (var item in results) {
|
for (var item in results) {
|
||||||
|
|
||||||
|
bool _required = false;
|
||||||
|
String _test;
|
||||||
|
bool _result = null;
|
||||||
|
String _value;
|
||||||
|
String _notes;
|
||||||
|
FaIcon _icon = FaIcon(FontAwesomeIcons.questionCircle, color: Color.fromRGBO(0, 0, 250, 1));
|
||||||
|
bool _valueRequired = false;
|
||||||
|
bool _attachmentRequired = false;
|
||||||
|
|
||||||
if (item is InvenTreePartTestTemplate) {
|
if (item is InvenTreePartTestTemplate) {
|
||||||
var template = item as InvenTreePartTestTemplate;
|
_result = item.passFailStatus();
|
||||||
|
_test = item.testName;
|
||||||
|
_required = item.required;
|
||||||
|
_value = item.latestResult()?.value ?? '';
|
||||||
|
_notes = item.latestResult()?.notes ?? '';
|
||||||
|
_valueRequired = item.requiresValue;
|
||||||
|
_attachmentRequired = item.requiresAttachment;
|
||||||
|
} else if (item is InvenTreeStockItemTestResult) {
|
||||||
|
_result = item.result;
|
||||||
|
_test = item.testName;
|
||||||
|
_required = false;
|
||||||
|
_value = item.value;
|
||||||
|
_notes = item.notes;
|
||||||
|
}
|
||||||
|
|
||||||
var status = template.passFailStatus();
|
if (_result == true) {
|
||||||
|
_icon = FaIcon(FontAwesomeIcons.checkCircle,
|
||||||
FaIcon icon;
|
|
||||||
|
|
||||||
if (status == null) {
|
|
||||||
icon = FaIcon(FontAwesomeIcons.questionCircle,
|
|
||||||
color: Color.fromRGBO(0, 0, 250, 0.8)
|
|
||||||
);
|
|
||||||
} else if (status == true) {
|
|
||||||
icon = FaIcon(FontAwesomeIcons.checkCircle,
|
|
||||||
color: Color.fromRGBO(0, 250, 0, 0.8)
|
color: Color.fromRGBO(0, 250, 0, 0.8)
|
||||||
);
|
);
|
||||||
} else {
|
} else if (_result == false) {
|
||||||
icon = FaIcon(FontAwesomeIcons.timesCircle,
|
_icon = FaIcon(FontAwesomeIcons.timesCircle,
|
||||||
color: Color.fromRGBO(250, 0, 0, 0.8)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
String subtitle = template.latestResult()?.value ?? '';
|
|
||||||
|
|
||||||
tiles.add(ListTile(
|
|
||||||
title: Text("${template.testName}",
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
subtitle: Text(subtitle),
|
|
||||||
trailing: icon,
|
|
||||||
onLongPress: () {
|
|
||||||
addTestResult(
|
|
||||||
name: template.testName,
|
|
||||||
nameIsEditable: false,
|
|
||||||
valueRequired: template.requiresValue,
|
|
||||||
attachmentRequired: template.requiresAttachment,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (item is InvenTreeStockItemTestResult) {
|
|
||||||
var result = item as InvenTreeStockItemTestResult;
|
|
||||||
|
|
||||||
FaIcon icon;
|
|
||||||
|
|
||||||
if (result.result == true) {
|
|
||||||
icon = FaIcon(FontAwesomeIcons.checkCircle,
|
|
||||||
color: Color.fromRGBO(0, 250, 0, 0.8)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
icon = FaIcon(FontAwesomeIcons.timesCircle,
|
|
||||||
color: Color.fromRGBO(250, 0, 0, 0.8)
|
color: Color.fromRGBO(250, 0, 0, 0.8)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles.add(ListTile(
|
tiles.add(ListTile(
|
||||||
title: Text("${result.testName}"),
|
title: Text(_test, style: TextStyle(fontWeight: _required ? FontWeight.bold : FontWeight.normal)),
|
||||||
subtitle: Text("${result.value}"),
|
subtitle: Text(_value),
|
||||||
trailing: icon,
|
trailing: _icon,
|
||||||
onLongPress: () {
|
onLongPress: () {
|
||||||
addTestResult(
|
addTestResult(
|
||||||
name: result.testName,
|
name: _test,
|
||||||
nameIsEditable: false,
|
nameIsEditable: !_required,
|
||||||
valueRequired: false,
|
valueRequired: _valueRequired,
|
||||||
attachmentRequired: false
|
attachmentRequired: _attachmentRequired
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tiles.isEmpty) {
|
if (tiles.isEmpty) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user