mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Moar features for "StockItem" class
This commit is contained in:
parent
59d2b9cf1a
commit
5e3793b3ba
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'model.dart';
|
import 'model.dart';
|
||||||
|
|
||||||
import 'package:InvenTree/api.dart';
|
import 'package:InvenTree/api.dart';
|
||||||
@ -23,9 +25,50 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
String get partName => jsondata['part__name'] as String ?? '';
|
String get partName {
|
||||||
|
|
||||||
String get partDescription => jsondata['part__description'] as String ?? '';
|
String nm = '';
|
||||||
|
|
||||||
|
// Use the detailed part information as priority
|
||||||
|
if (jsondata.containsKey('part_detail')) {
|
||||||
|
nm = jsondata['part_detail']['full_name'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nm.isEmpty) {
|
||||||
|
nm = jsondata['part__name'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return nm;
|
||||||
|
}
|
||||||
|
|
||||||
|
String get partDescription {
|
||||||
|
String desc = '';
|
||||||
|
|
||||||
|
// Use the detailed part description as priority
|
||||||
|
if (jsondata.containsKey('part_detail')) {
|
||||||
|
desc = jsondata['part_detail']['description'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (desc.isEmpty) {
|
||||||
|
desc = jsondata['part__description'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
String get partImage {
|
||||||
|
String img = '';
|
||||||
|
|
||||||
|
if (jsondata.containsKey('part_detail')) {
|
||||||
|
img = jsondata['part_detail']['thumbnail'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (img.isEmpty) {
|
||||||
|
img = jsondata['part__thumbnail'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
String get partThumbnail {
|
String get partThumbnail {
|
||||||
String thumb = jsondata['part__thumbnail'] as String ?? '';
|
String thumb = jsondata['part__thumbnail'] as String ?? '';
|
||||||
|
@ -4,7 +4,10 @@ import 'package:InvenTree/inventree/stock.dart';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'package:InvenTree/api.dart';
|
||||||
|
|
||||||
import 'package:InvenTree/widget/drawer.dart';
|
import 'package:InvenTree/widget/drawer.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
class StockItemDisplayWidget extends StatefulWidget {
|
class StockItemDisplayWidget extends StatefulWidget {
|
||||||
|
|
||||||
@ -25,14 +28,6 @@ class _StockItemDisplayState extends State<StockItemDisplayWidget> {
|
|||||||
|
|
||||||
final InvenTreeStockItem item;
|
final InvenTreeStockItem item;
|
||||||
|
|
||||||
String get _title {
|
|
||||||
if (item == null) {
|
|
||||||
return "Stock Item";
|
|
||||||
} else {
|
|
||||||
return "Item: x ${item.partName}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Construct a list of detail elements about this StockItem.
|
* Construct a list of detail elements about this StockItem.
|
||||||
* The number of elements may vary depending on the StockItem details
|
* The number of elements may vary depending on the StockItem details
|
||||||
@ -45,6 +40,14 @@ class _StockItemDisplayState extends State<StockItemDisplayWidget> {
|
|||||||
Card(
|
Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
title: Text("${item.partName}"),
|
title: Text("${item.partName}"),
|
||||||
|
subtitle: Text("${item.partDescription}"),
|
||||||
|
leading: Image(
|
||||||
|
image: InvenTreeAPI().getImage(item.partImage),
|
||||||
|
),
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: FaIcon(FontAwesomeIcons.edit),
|
||||||
|
onPressed: null,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -56,15 +59,12 @@ class _StockItemDisplayState extends State<StockItemDisplayWidget> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(_title),
|
title: Text("Stock Item"),
|
||||||
),
|
),
|
||||||
drawer: new InvenTreeDrawer(context),
|
drawer: new InvenTreeDrawer(context),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: ListView(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: stockTiles(),
|
||||||
children: <Widget>[
|
|
||||||
Text("Stock Item: hello"),
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user