mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Further improvements for stock view
This commit is contained in:
parent
5e3793b3ba
commit
948c9c1d23
@ -15,6 +15,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
|
||||
headers["part_detail"] = "true";
|
||||
headers["location_detail"] = "true";
|
||||
headers["supplier_detail"] = "true";
|
||||
|
||||
return headers;
|
||||
}
|
||||
@ -25,6 +26,10 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
// TODO
|
||||
}
|
||||
|
||||
int get partId => jsondata['part'] ?? -1;
|
||||
|
||||
int get trackingItemCount => jsondata['tracking_items'] as int ?? 0;
|
||||
|
||||
String get partName {
|
||||
|
||||
String nm = '';
|
||||
@ -78,12 +83,58 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
return thumb;
|
||||
}
|
||||
|
||||
int get supplierPartId => jsondata['supplier_part'] as int ?? -1;
|
||||
|
||||
String get supplierImage {
|
||||
String thumb = '';
|
||||
|
||||
if (jsondata.containsKey("supplier_detail")) {
|
||||
thumb = jsondata['supplier_detail']['supplier_logo'] ?? '';
|
||||
}
|
||||
|
||||
return thumb;
|
||||
}
|
||||
|
||||
String get supplierName {
|
||||
String sname = '';
|
||||
|
||||
if (jsondata.containsKey("supplier_detail")) {
|
||||
sname = jsondata["supplier_detail"]["supplier_name"] ?? '';
|
||||
}
|
||||
|
||||
return sname;
|
||||
}
|
||||
|
||||
String get supplierSKU {
|
||||
String sku = '';
|
||||
|
||||
if (jsondata.containsKey("supplier_detail")) {
|
||||
sku = jsondata["supplier_detail"]["SKU"] ?? '';
|
||||
}
|
||||
|
||||
return sku;
|
||||
}
|
||||
|
||||
int get serialNumber => jsondata['serial'] as int ?? null;
|
||||
|
||||
double get quantity => jsondata['quantity'] as double ?? 0.0;
|
||||
double get quantity => double.tryParse(jsondata['quantity'].toString() ?? '0');
|
||||
|
||||
int get locationId => jsondata['location'] as int ?? -1;
|
||||
|
||||
String get locationName {
|
||||
String loc = '';
|
||||
|
||||
if (jsondata.containsKey('location_detail')) {
|
||||
loc = jsondata['location_detail']['name'] ?? '';
|
||||
}
|
||||
|
||||
if (loc.isEmpty) {
|
||||
loc = jsondata['location__name'] ?? '';
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
String get displayQuantity {
|
||||
// Display either quantity or serial number!
|
||||
|
||||
|
@ -61,9 +61,12 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
||||
subtitle: Text("${part.categoryName}"),
|
||||
leading: FaIcon(FontAwesomeIcons.stream),
|
||||
onTap: () {
|
||||
if (part.categoryId > 0) {
|
||||
InvenTreePartCategory().get(part.categoryId).then((var cat) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(cat)));
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => CategoryDisplayWidget(cat)));
|
||||
});
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
|
@ -1,6 +1,9 @@
|
||||
|
||||
|
||||
import 'package:InvenTree/inventree/stock.dart';
|
||||
import 'package:InvenTree/inventree/part.dart';
|
||||
import 'package:InvenTree/widget/location_display.dart';
|
||||
import 'package:InvenTree/widget/part_display.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -52,6 +55,100 @@ class _StockItemDisplayState extends State<StockItemDisplayWidget> {
|
||||
)
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("Part"),
|
||||
subtitle: Text("${item.partName}"),
|
||||
leading: FaIcon(FontAwesomeIcons.shapes),
|
||||
onTap: () {
|
||||
if (item.partId > 0) {
|
||||
InvenTreePart().get(item.partId).then((var part) {
|
||||
if (part is InvenTreePart) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => PartDisplayWidget(part)));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
// Quantity information
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("Quantity"),
|
||||
leading: FaIcon(FontAwesomeIcons.cubes),
|
||||
trailing: Text("${item.quantity}"),
|
||||
)
|
||||
);
|
||||
|
||||
// Location information
|
||||
if (item.locationName.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("Stock Location"),
|
||||
subtitle: Text("${item.locationName}"),
|
||||
leading: FaIcon(FontAwesomeIcons.mapMarkerAlt),
|
||||
onTap: () {
|
||||
if (item.locationId > 0) {
|
||||
InvenTreeStockLocation().get(item.locationId).then((var loc) {
|
||||
Navigator.push(context, MaterialPageRoute(
|
||||
builder: (context) => LocationDisplayWidget(loc)));
|
||||
});
|
||||
}
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Supplier part?
|
||||
if (item.supplierPartId > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${item.supplierName}"),
|
||||
subtitle: Text("${item.supplierSKU}"),
|
||||
leading: FaIcon(FontAwesomeIcons.industry),
|
||||
trailing: Image(
|
||||
image: InvenTreeAPI().getImage(item.supplierImage),
|
||||
height: 32,
|
||||
),
|
||||
onTap: null,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (item.link.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("${item.link}"),
|
||||
leading: FaIcon(FontAwesomeIcons.link),
|
||||
trailing: Text(""),
|
||||
onTap: null,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (item.trackingItemCount > 0) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("History"),
|
||||
leading: FaIcon(FontAwesomeIcons.history),
|
||||
trailing: Text("${item.trackingItemCount}"),
|
||||
onTap: null,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (item.notes.isNotEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text("Notes"),
|
||||
leading: FaIcon(FontAwesomeIcons.stickyNote),
|
||||
trailing: Text(""),
|
||||
onTap: null,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user