2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-17 04:35:26 +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

@ -5,6 +5,10 @@ import 'model.dart';
* The InvenTreeCompany class repreents the Company model in the InvenTree database.
*/
class InvenTreeCompany extends InvenTreeModel {
@override
String NAME = "Company";
@override
String URL = "company/";

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;

View File

@ -9,6 +9,10 @@ import 'package:path/path.dart' as path;
import 'package:http/http.dart' as http;
class InvenTreePartCategory extends InvenTreeModel {
@override
String NAME = "PartCategory";
@override
String URL = "part/category/";
@ -61,6 +65,9 @@ class InvenTreePartCategory extends InvenTreeModel {
class InvenTreePart extends InvenTreeModel {
@override
String Name = "Part";
@override
String URL = "part/";

View File

@ -6,6 +6,10 @@ import 'model.dart';
import 'package:InvenTree/api.dart';
class InvenTreeStockItem extends InvenTreeModel {
@override
String NAME = "StockItem";
@override
String URL = "stock/";
@ -208,6 +212,10 @@ class InvenTreeStockItem extends InvenTreeModel {
class InvenTreeStockLocation extends InvenTreeModel {
@override
String NAME = "StockLocation";
@override
String URL = "stock/location/";