2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 10:15:32 +00:00

Display overlay screen for blocking operations (#186)

* Catch state error in homepage widget

* Add flutter_overlay_loader lib

- Displays an overlay screen to indicate blocking operation

* Wrap blocking widget transitions in a loading overlay

- Prevents user from doing other things while loading
- Shows the user that something is happening

* Linting fixes

* Show overlay when uploading attachment file

* Show overlay when downloading file also

* Show overlay when loading or submitting API forms

- Major improvements to usability "feel"

* UI improvements for stock item test results widget

* Fix API_FORM bug

- onSuccess function was not being called
This commit is contained in:
Oliver
2022-07-20 09:05:21 +10:00
committed by GitHub
parent 277193ecb0
commit 01dd046dd1
20 changed files with 150 additions and 183 deletions

View File

@ -18,6 +18,7 @@ import "package:inventree/widget/fields.dart";
import "package:inventree/l10.dart";
import "package:flutter/material.dart";
import "package:inventree/widget/progress.dart";
import "package:inventree/widget/snacks.dart";
@ -859,7 +860,9 @@ Future<void> launchApiForm(
if (url.isNotEmpty) {
showLoadingOverlay(context);
var options = await InvenTreeAPI().options(url);
hideLoadingOverlay();
// Invalid response from server
if (!options.isValid()) {
@ -902,7 +905,7 @@ Future<void> launchApiForm(
field.definition = extractFieldDefinition(serverFields, field.lookupPath);
// Skip fields with empty definitions
if (field.definition.isEmpty) {
if (url.isNotEmpty && field.definition.isEmpty) {
print("Warning: Empty field definition for field '${fieldName}'");
}
@ -987,8 +990,6 @@ class _APIFormWidgetState extends State<APIFormWidget> {
List<String> nonFieldErrors = [];
Function(Map<String, dynamic>)? onSuccess;
bool spacerRequired = false;
List<Widget> _buildForm() {
@ -1102,20 +1103,25 @@ class _APIFormWidgetState extends State<APIFormWidget> {
}
if (widget.method == "POST") {
showLoadingOverlay(context);
final response = await InvenTreeAPI().post(
widget.url,
body: data,
expectedStatusCode: null
);
hideLoadingOverlay();
return response;
} else {
showLoadingOverlay(context);
final response = await InvenTreeAPI().patch(
widget.url,
body: data,
expectedStatusCode: null
);
hideLoadingOverlay();
return response;
}
@ -1259,7 +1265,7 @@ class _APIFormWidgetState extends State<APIFormWidget> {
}
// Run custom onSuccess function
var successFunc = onSuccess;
var successFunc = widget.onSuccess;
// An "empty" URL means we don't want to submit the form anywhere
// Perhaps we just want to process the data?
@ -1398,4 +1404,4 @@ class _APIFormWidgetState extends State<APIFormWidget> {
);
}
}
}