mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Display part image in stock list
This commit is contained in:
parent
c8f09ed62e
commit
1d1bdb1a4b
@ -300,6 +300,10 @@ class InvenTreeAPI {
|
||||
*/
|
||||
AdvancedNetworkImage getImage(String imageUrl) {
|
||||
|
||||
if (imageUrl.isEmpty) {
|
||||
imageUrl = staticImage;
|
||||
}
|
||||
|
||||
return new AdvancedNetworkImage(makeUrl(imageUrl),
|
||||
header: defaultHeaders(),
|
||||
useDiskCache: true,
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'model.dart';
|
||||
|
||||
import 'package:InvenTree/api.dart';
|
||||
|
||||
class InvenTreeStockItem extends InvenTreeModel {
|
||||
@override
|
||||
@ -11,12 +12,28 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
// TODO
|
||||
}
|
||||
|
||||
String get partName => jsondata['part_name'] as String ?? '';
|
||||
String get partName => jsondata['part__name'] as String ?? '';
|
||||
|
||||
String get partDescription => jsondata['part__description'] as String ?? '';
|
||||
|
||||
String get partThumbnail => jsondata['part__thumbnail'] as String ?? InvenTreeAPI.staticThumb;
|
||||
|
||||
int get serialNumber => jsondata['serial'] as int ?? null;
|
||||
|
||||
double get quantity => jsondata['quantity'] as double ?? 0.0;
|
||||
|
||||
int get locationId => jsondata['location'] as int ?? -1;
|
||||
|
||||
String get displayQuantity {
|
||||
// Display either quantity or serial number!
|
||||
|
||||
if (serialNumber != null) {
|
||||
return "SN: $serialNumber";
|
||||
} else {
|
||||
return quantity.toString().trim();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
var item = InvenTreeStockItem.fromJson(json);
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
import 'package:InvenTree/api.dart';
|
||||
import 'package:InvenTree/inventree/stock.dart';
|
||||
import 'package:InvenTree/widget/drawer.dart';
|
||||
import 'package:InvenTree/widget/stock_display.dart';
|
||||
@ -175,8 +175,15 @@ class StockList extends StatelessWidget {
|
||||
InvenTreeStockItem item = _items[index];
|
||||
|
||||
return ListTile(
|
||||
title: Text("${item.quantity.toString()} x ${item.partName}"),
|
||||
subtitle: Text("${item.description}"),
|
||||
title: Text("${item.partName}"),
|
||||
subtitle: Text("${item.partDescription}"),
|
||||
leading: Image(
|
||||
image: InvenTreeAPI().getImage(item.partThumbnail),
|
||||
width: 48,
|
||||
),
|
||||
trailing: Text("${item.displayQuantity}",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
onTap: () {
|
||||
_openItem(context, item.pk);
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user