mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Progress dialog is now a part of the model GET request
This commit is contained in:
parent
ca7505796d
commit
8bd022bccd
@ -98,14 +98,7 @@ void _handleBarcode(BuildContext context, Map<String, dynamic> data) {
|
||||
id = data['stocklocation']['id'] ?? null;
|
||||
|
||||
if (id != null) {
|
||||
// Try to open a stock location...
|
||||
|
||||
showProgressDialog(context, "Loading data", "Requesting stock location information from server");
|
||||
|
||||
InvenTreeStockLocation().get(id).then((var loc) {
|
||||
|
||||
hideProgressDialog(context);
|
||||
|
||||
InvenTreeStockLocation().get(context, id).then((var loc) {
|
||||
if (loc is InvenTreeStockLocation) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
||||
}
|
||||
@ -117,13 +110,7 @@ void _handleBarcode(BuildContext context, Map<String, dynamic> data) {
|
||||
id = data['stockitem']['id'] ?? null;
|
||||
|
||||
if (id != null) {
|
||||
|
||||
showProgressDialog(context, "Loading data", "Requesting stock item information from server");
|
||||
|
||||
InvenTreeStockItem().get(id).then((var item) {
|
||||
|
||||
hideProgressDialog(context);
|
||||
|
||||
InvenTreeStockItem().get(context, id).then((var item) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => StockDetailWidget(item)));
|
||||
});
|
||||
}
|
||||
@ -132,13 +119,7 @@ void _handleBarcode(BuildContext context, Map<String, dynamic> data) {
|
||||
id = data['part']['id'] ?? null;
|
||||
|
||||
if (id != null) {
|
||||
|
||||
showProgressDialog(context, "Loading data", "Requesting part information from server");
|
||||
|
||||
InvenTreePart().get(id).then((var part) {
|
||||
|
||||
hideProgressDialog(context);
|
||||
|
||||
InvenTreePart().get(context, id).then((var part) {
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
||||
});
|
||||
|
@ -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/";
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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/";
|
||||
|
||||
|
@ -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/";
|
||||
|
||||
|
@ -112,7 +112,7 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
||||
} else {
|
||||
// TODO - Refactor this code into the InvenTreePart class
|
||||
InvenTreePartCategory().get(category.parentId).then((var cat) {
|
||||
InvenTreePartCategory().get(context, category.parentId).then((var cat) {
|
||||
if (cat is InvenTreePartCategory) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat)));
|
||||
}
|
||||
@ -211,7 +211,7 @@ class SubcategoryList extends StatelessWidget {
|
||||
void _openCategory(BuildContext context, int pk) {
|
||||
|
||||
// Attempt to load the sub-category.
|
||||
InvenTreePartCategory().get(pk).then((var cat) {
|
||||
InvenTreePartCategory().get(context, pk).then((var cat) {
|
||||
if (cat is InvenTreePartCategory) {
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat)));
|
||||
@ -252,7 +252,7 @@ class PartList extends StatelessWidget {
|
||||
|
||||
void _openPart(BuildContext context, int pk) {
|
||||
// Attempt to load the part information
|
||||
InvenTreePart().get(pk).then((var part) {
|
||||
InvenTreePart().get(context, pk).then((var part) {
|
||||
if (part is InvenTreePart) {
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
||||
|
@ -85,7 +85,7 @@ class _CompanyListState extends State<CompanyListWidget> {
|
||||
),
|
||||
onTap: () {
|
||||
if (company.pk > 0) {
|
||||
InvenTreeCompany().get(company.pk).then((var c) {
|
||||
InvenTreeCompany().get(context, company.pk).then((var c) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyDetailWidget(c)));
|
||||
});
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
|
||||
if (location.parentId < 0) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(null)));
|
||||
} else {
|
||||
InvenTreeStockLocation().get(location.parentId).then((var loc) {
|
||||
InvenTreeStockLocation().get(context, location.parentId).then((var loc) {
|
||||
if (loc is InvenTreeStockLocation) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
||||
}
|
||||
@ -208,7 +208,7 @@ class SublocationList extends StatelessWidget {
|
||||
|
||||
void _openLocation(BuildContext context, int pk) {
|
||||
|
||||
InvenTreeStockLocation().get(pk).then((var loc) {
|
||||
InvenTreeStockLocation().get(context, pk).then((var loc) {
|
||||
if (loc is InvenTreeStockLocation) {
|
||||
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
||||
@ -244,7 +244,7 @@ class StockList extends StatelessWidget {
|
||||
StockList(this._items);
|
||||
|
||||
void _openItem(BuildContext context, int pk) {
|
||||
InvenTreeStockItem().get(pk).then((var item) {
|
||||
InvenTreeStockItem().get(context, pk).then((var item) {
|
||||
if (item is InvenTreeStockItem) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => StockDetailWidget(item)));
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class _PartDisplayState extends State<PartDetailWidget> {
|
||||
leading: FaIcon(FontAwesomeIcons.stream),
|
||||
onTap: () {
|
||||
if (part.categoryId > 0) {
|
||||
InvenTreePartCategory().get(part.categoryId).then((var cat) {
|
||||
InvenTreePartCategory().get(context, part.categoryId).then((var cat) {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => CategoryDisplayWidget(cat)));
|
||||
});
|
||||
|
@ -322,7 +322,7 @@ class _StockItemDisplayState extends State<StockDetailWidget> {
|
||||
leading: FaIcon(FontAwesomeIcons.shapes),
|
||||
onTap: () {
|
||||
if (item.partId > 0) {
|
||||
InvenTreePart().get(item.partId).then((var part) {
|
||||
InvenTreePart().get(context, item.partId).then((var part) {
|
||||
if (part is InvenTreePart) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
||||
}
|
||||
@ -362,7 +362,7 @@ class _StockItemDisplayState extends State<StockDetailWidget> {
|
||||
leading: FaIcon(FontAwesomeIcons.mapMarkerAlt),
|
||||
onTap: () {
|
||||
if (item.locationId > 0) {
|
||||
InvenTreeStockLocation().get(item.locationId).then((var loc) {
|
||||
InvenTreeStockLocation().get(context, item.locationId).then((var loc) {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => LocationDisplayWidget(loc)));
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user