mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +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;
|
id = data['stocklocation']['id'] ?? null;
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
// Try to open a stock location...
|
InvenTreeStockLocation().get(context, id).then((var loc) {
|
||||||
|
|
||||||
showProgressDialog(context, "Loading data", "Requesting stock location information from server");
|
|
||||||
|
|
||||||
InvenTreeStockLocation().get(id).then((var loc) {
|
|
||||||
|
|
||||||
hideProgressDialog(context);
|
|
||||||
|
|
||||||
if (loc is InvenTreeStockLocation) {
|
if (loc is InvenTreeStockLocation) {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
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;
|
id = data['stockitem']['id'] ?? null;
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
|
InvenTreeStockItem().get(context, id).then((var item) {
|
||||||
showProgressDialog(context, "Loading data", "Requesting stock item information from server");
|
|
||||||
|
|
||||||
InvenTreeStockItem().get(id).then((var item) {
|
|
||||||
|
|
||||||
hideProgressDialog(context);
|
|
||||||
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => StockDetailWidget(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;
|
id = data['part']['id'] ?? null;
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
|
InvenTreePart().get(context, id).then((var part) {
|
||||||
showProgressDialog(context, "Loading data", "Requesting part information from server");
|
|
||||||
|
|
||||||
InvenTreePart().get(id).then((var part) {
|
|
||||||
|
|
||||||
hideProgressDialog(context);
|
|
||||||
|
|
||||||
Navigator.push(context,
|
Navigator.push(context,
|
||||||
MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
||||||
});
|
});
|
||||||
|
@ -5,6 +5,10 @@ import 'model.dart';
|
|||||||
* The InvenTreeCompany class repreents the Company model in the InvenTree database.
|
* The InvenTreeCompany class repreents the Company model in the InvenTree database.
|
||||||
*/
|
*/
|
||||||
class InvenTreeCompany extends InvenTreeModel {
|
class InvenTreeCompany extends InvenTreeModel {
|
||||||
|
|
||||||
|
@override
|
||||||
|
String NAME = "Company";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String URL = "company/";
|
String URL = "company/";
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import 'package:InvenTree/api.dart';
|
import 'package:InvenTree/api.dart';
|
||||||
|
import 'package:InvenTree/widget/dialogs.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
@ -15,6 +17,8 @@ class InvenTreeModel {
|
|||||||
// Override the endpoint URL for each subclass
|
// Override the endpoint URL for each subclass
|
||||||
String URL = "";
|
String URL = "";
|
||||||
|
|
||||||
|
String NAME = "Model";
|
||||||
|
|
||||||
// JSON data which defines this object
|
// JSON data which defines this object
|
||||||
Map<String, dynamic> jsondata = {};
|
Map<String, dynamic> jsondata = {};
|
||||||
|
|
||||||
@ -100,7 +104,7 @@ class InvenTreeModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return the detail view for the associated pk
|
// 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 "timeout"
|
||||||
// TODO - Add error catching
|
// TODO - Add error catching
|
||||||
@ -122,8 +126,12 @@ class InvenTreeModel {
|
|||||||
|
|
||||||
print("GET: $addr ${params.toString()}");
|
print("GET: $addr ${params.toString()}");
|
||||||
|
|
||||||
|
showProgressDialog(context, "Requesting Data", "Requesting ${NAME} data from server");
|
||||||
|
|
||||||
var response = await api.get(addr, params: params);
|
var response = await api.get(addr, params: params);
|
||||||
|
|
||||||
|
hideProgressDialog(context);
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
if (response.statusCode != 200) {
|
||||||
print("Error retrieving data");
|
print("Error retrieving data");
|
||||||
return null;
|
return null;
|
||||||
|
@ -9,6 +9,10 @@ import 'package:path/path.dart' as path;
|
|||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
class InvenTreePartCategory extends InvenTreeModel {
|
class InvenTreePartCategory extends InvenTreeModel {
|
||||||
|
|
||||||
|
@override
|
||||||
|
String NAME = "PartCategory";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String URL = "part/category/";
|
String URL = "part/category/";
|
||||||
|
|
||||||
@ -61,6 +65,9 @@ class InvenTreePartCategory extends InvenTreeModel {
|
|||||||
|
|
||||||
class InvenTreePart extends InvenTreeModel {
|
class InvenTreePart extends InvenTreeModel {
|
||||||
|
|
||||||
|
@override
|
||||||
|
String Name = "Part";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String URL = "part/";
|
String URL = "part/";
|
||||||
|
|
||||||
|
@ -6,6 +6,10 @@ import 'model.dart';
|
|||||||
import 'package:InvenTree/api.dart';
|
import 'package:InvenTree/api.dart';
|
||||||
|
|
||||||
class InvenTreeStockItem extends InvenTreeModel {
|
class InvenTreeStockItem extends InvenTreeModel {
|
||||||
|
|
||||||
|
@override
|
||||||
|
String NAME = "StockItem";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String URL = "stock/";
|
String URL = "stock/";
|
||||||
|
|
||||||
@ -208,6 +212,10 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
|
|
||||||
|
|
||||||
class InvenTreeStockLocation extends InvenTreeModel {
|
class InvenTreeStockLocation extends InvenTreeModel {
|
||||||
|
|
||||||
|
@override
|
||||||
|
String NAME = "StockLocation";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String URL = "stock/location/";
|
String URL = "stock/location/";
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
|
|||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
||||||
} else {
|
} else {
|
||||||
// TODO - Refactor this code into the InvenTreePart class
|
// 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) {
|
if (cat is InvenTreePartCategory) {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat)));
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ class SubcategoryList extends StatelessWidget {
|
|||||||
void _openCategory(BuildContext context, int pk) {
|
void _openCategory(BuildContext context, int pk) {
|
||||||
|
|
||||||
// Attempt to load the sub-category.
|
// Attempt to load the sub-category.
|
||||||
InvenTreePartCategory().get(pk).then((var cat) {
|
InvenTreePartCategory().get(context, pk).then((var cat) {
|
||||||
if (cat is InvenTreePartCategory) {
|
if (cat is InvenTreePartCategory) {
|
||||||
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat)));
|
||||||
@ -252,7 +252,7 @@ class PartList extends StatelessWidget {
|
|||||||
|
|
||||||
void _openPart(BuildContext context, int pk) {
|
void _openPart(BuildContext context, int pk) {
|
||||||
// Attempt to load the part information
|
// Attempt to load the part information
|
||||||
InvenTreePart().get(pk).then((var part) {
|
InvenTreePart().get(context, pk).then((var part) {
|
||||||
if (part is InvenTreePart) {
|
if (part is InvenTreePart) {
|
||||||
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
||||||
|
@ -85,7 +85,7 @@ class _CompanyListState extends State<CompanyListWidget> {
|
|||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (company.pk > 0) {
|
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)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => CompanyDetailWidget(c)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ class _LocationDisplayState extends State<LocationDisplayWidget> {
|
|||||||
if (location.parentId < 0) {
|
if (location.parentId < 0) {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(null)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(null)));
|
||||||
} else {
|
} else {
|
||||||
InvenTreeStockLocation().get(location.parentId).then((var loc) {
|
InvenTreeStockLocation().get(context, location.parentId).then((var loc) {
|
||||||
if (loc is InvenTreeStockLocation) {
|
if (loc is InvenTreeStockLocation) {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ class SublocationList extends StatelessWidget {
|
|||||||
|
|
||||||
void _openLocation(BuildContext context, int pk) {
|
void _openLocation(BuildContext context, int pk) {
|
||||||
|
|
||||||
InvenTreeStockLocation().get(pk).then((var loc) {
|
InvenTreeStockLocation().get(context, pk).then((var loc) {
|
||||||
if (loc is InvenTreeStockLocation) {
|
if (loc is InvenTreeStockLocation) {
|
||||||
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => LocationDisplayWidget(loc)));
|
||||||
@ -244,7 +244,7 @@ class StockList extends StatelessWidget {
|
|||||||
StockList(this._items);
|
StockList(this._items);
|
||||||
|
|
||||||
void _openItem(BuildContext context, int pk) {
|
void _openItem(BuildContext context, int pk) {
|
||||||
InvenTreeStockItem().get(pk).then((var item) {
|
InvenTreeStockItem().get(context, pk).then((var item) {
|
||||||
if (item is InvenTreeStockItem) {
|
if (item is InvenTreeStockItem) {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => StockDetailWidget(item)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => StockDetailWidget(item)));
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class _PartDisplayState extends State<PartDetailWidget> {
|
|||||||
leading: FaIcon(FontAwesomeIcons.stream),
|
leading: FaIcon(FontAwesomeIcons.stream),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (part.categoryId > 0) {
|
if (part.categoryId > 0) {
|
||||||
InvenTreePartCategory().get(part.categoryId).then((var cat) {
|
InvenTreePartCategory().get(context, part.categoryId).then((var cat) {
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (context) => CategoryDisplayWidget(cat)));
|
builder: (context) => CategoryDisplayWidget(cat)));
|
||||||
});
|
});
|
||||||
|
@ -322,7 +322,7 @@ class _StockItemDisplayState extends State<StockDetailWidget> {
|
|||||||
leading: FaIcon(FontAwesomeIcons.shapes),
|
leading: FaIcon(FontAwesomeIcons.shapes),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (item.partId > 0) {
|
if (item.partId > 0) {
|
||||||
InvenTreePart().get(item.partId).then((var part) {
|
InvenTreePart().get(context, item.partId).then((var part) {
|
||||||
if (part is InvenTreePart) {
|
if (part is InvenTreePart) {
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
Navigator.push(context, MaterialPageRoute(builder: (context) => PartDetailWidget(part)));
|
||||||
}
|
}
|
||||||
@ -362,7 +362,7 @@ class _StockItemDisplayState extends State<StockDetailWidget> {
|
|||||||
leading: FaIcon(FontAwesomeIcons.mapMarkerAlt),
|
leading: FaIcon(FontAwesomeIcons.mapMarkerAlt),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (item.locationId > 0) {
|
if (item.locationId > 0) {
|
||||||
InvenTreeStockLocation().get(item.locationId).then((var loc) {
|
InvenTreeStockLocation().get(context, item.locationId).then((var loc) {
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (context) => LocationDisplayWidget(loc)));
|
builder: (context) => LocationDisplayWidget(loc)));
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user