2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-05-02 15:28:53 +00:00

Disable some more natty dialogs

This commit is contained in:
Oliver Walters 2021-02-04 23:56:06 +11:00
parent 1ee54a00de
commit e77b9539f9
2 changed files with 24 additions and 9 deletions

View File

@ -65,21 +65,26 @@ class BarcodeHandler {
); );
} }
Future<void> processBarcode(BuildContext context, QRViewController _controller, String barcode) { Future<void> processBarcode(BuildContext context, QRViewController _controller, String barcode, {String url = "barcode/", bool show_dialog = false}) {
this._context = context; this._context = context;
this._controller = _controller; this._controller = _controller;
print("Scanned barcode data: ${barcode}"); print("Scanned barcode data: ${barcode}");
showProgressDialog(context, "Scanning", "Sending barcode data to server"); if (show_dialog) {
showProgressDialog(context, "Scanning", "Sending barcode data to server");
}
// Send barcode request to server // Send barcode request to server
InvenTreeAPI().post( InvenTreeAPI().post(
"barcode/", url,
body: { body: {
"barcode": barcode "barcode": barcode
} }
).then((var response) { ).then((var response) {
hideProgressDialog(context);
if (show_dialog) {
hideProgressDialog(context);
}
if (response.statusCode != 200) { if (response.statusCode != 200) {
showErrorDialog( showErrorDialog(
@ -112,7 +117,11 @@ class BarcodeHandler {
}).timeout( }).timeout(
Duration(seconds: 5) Duration(seconds: 5)
).catchError((error) { ).catchError((error) {
hideProgressDialog(context);
if (show_dialog) {
hideProgressDialog(context);
}
showErrorDialog( showErrorDialog(
context, context,
"Error", "Error",

View File

@ -149,7 +149,7 @@ class InvenTreeModel {
} }
// POST data to update the model // POST data to update the model
Future<bool> update(BuildContext context, {Map<String, String> values}) async { Future<bool> update(BuildContext context, {Map<String, String> values, bool show_dialog = false}) async {
var addr = path.join(URL, pk.toString()); var addr = path.join(URL, pk.toString());
@ -157,13 +157,17 @@ class InvenTreeModel {
addr += "/"; addr += "/";
} }
showProgressDialog(context, "Updating ${NAME}", "Sending data to server"); if (show_dialog) {
showProgressDialog(context, "Updating ${NAME}", "Sending data to server");
}
var response = await api.patch(addr, body: values) var response = await api.patch(addr, body: values)
.timeout(Duration(seconds: 10)) .timeout(Duration(seconds: 10))
.catchError((e) { .catchError((e) {
hideProgressDialog(context); if (show_dialog) {
hideProgressDialog(context);
}
if (e is TimeoutException) { if (e is TimeoutException) {
showErrorDialog(context, "Timeout", "No response from server"); showErrorDialog(context, "Timeout", "No response from server");
@ -176,7 +180,9 @@ class InvenTreeModel {
if (response == null) return false; if (response == null) return false;
hideProgressDialog(context); if (show_dialog) {
hideProgressDialog(context);
}
if (response.statusCode != 200) { if (response.statusCode != 200) {
print("Error updating ${NAME}: Status code ${response.statusCode}"); print("Error updating ${NAME}: Status code ${response.statusCode}");