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

Progress dialog is now a part of the model GET request

This commit is contained in:
Oliver Walters
2020-04-14 22:18:05 +10:00
parent ca7505796d
commit 8bd022bccd
10 changed files with 41 additions and 33 deletions

View File

@@ -1,4 +1,6 @@
import 'package:InvenTree/api.dart';
import 'package:InvenTree/widget/dialogs.dart';
import 'package:flutter/cupertino.dart';
import 'dart:convert';
@@ -15,6 +17,8 @@ class InvenTreeModel {
// Override the endpoint URL for each subclass
String URL = "";
String NAME = "Model";
// JSON data which defines this object
Map<String, dynamic> jsondata = {};
@@ -100,7 +104,7 @@ class InvenTreeModel {
}
// Return the detail view for the associated pk
Future<InvenTreeModel> get(int pk, {Map<String, String> filters}) async {
Future<InvenTreeModel> get(BuildContext context, int pk, {Map<String, String> filters}) async {
// TODO - Add "timeout"
// TODO - Add error catching
@@ -122,8 +126,12 @@ class InvenTreeModel {
print("GET: $addr ${params.toString()}");
showProgressDialog(context, "Requesting Data", "Requesting ${NAME} data from server");
var response = await api.get(addr, params: params);
hideProgressDialog(context);
if (response.statusCode != 200) {
print("Error retrieving data");
return null;