mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
More display items for Part view:
- BOM count - Used in count - Notes
This commit is contained in:
parent
d1fba27f3a
commit
fbd52e1414
@ -41,6 +41,8 @@ class InvenTreeModel {
|
||||
|
||||
String get description => jsondata['description'] ?? '';
|
||||
|
||||
String get notes => jsondata['notes'] ?? '';
|
||||
|
||||
int get parentId => jsondata['parent'] ?? -1;
|
||||
|
||||
String get link => jsondata['URL'] ?? '';
|
||||
|
@ -45,6 +45,12 @@ class InvenTreePart extends InvenTreeModel {
|
||||
// Get the number of units being build for this Part
|
||||
double get building => double.tryParse(jsondata['building'].toString() ?? '0');
|
||||
|
||||
// Get the number of BOM items in this Part (if it is an assembly)
|
||||
int get bomItemCount => jsondata['bom_items'] as int ?? 0;
|
||||
|
||||
// Get the number of BOMs this Part is used in (if it is a component)
|
||||
int get usedInCount => jsondata['used_in'] as int ?? 0;
|
||||
|
||||
bool get isAssembly => jsondata['assembly'] ?? false;
|
||||
|
||||
bool get isComponent => jsondata['component'] ?? false;
|
||||
|
@ -10,6 +10,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_advanced_networkimage/provider.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
class CategoryDisplayWidget extends StatefulWidget {
|
||||
|
||||
@ -42,7 +43,7 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
|
||||
if (category == null) {
|
||||
return "Part Categories";
|
||||
} else {
|
||||
return "Part Category '${category.name}'";
|
||||
return "Part Category - ${category.name}";
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,6 +83,28 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget getCategoryDescriptionCard() {
|
||||
if (category == null) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text("Part Categories"),
|
||||
subtitle: Text("Top level part category"),
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
title: Text("${category.name}"),
|
||||
subtitle: Text("${category.description}"),
|
||||
trailing: IconButton(
|
||||
icon: FaIcon(FontAwesomeIcons.edit),
|
||||
onPressed: null,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -91,8 +114,10 @@ class _CategoryDisplayState extends State<CategoryDisplayWidget> {
|
||||
drawer: new InvenTreeDrawer(context),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
getCategoryDescriptionCard(),
|
||||
Text(
|
||||
"Subcategories - ${_subcategories.length}",
|
||||
textAlign: TextAlign.left,
|
||||
|
@ -44,7 +44,7 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
||||
image: InvenTreeAPI().getImage(part.image)
|
||||
),
|
||||
trailing: IconButton(
|
||||
icon: FaIcon(FontAwesomeIcons.edit),
|
||||
icon: FaIcon(FontAwesomeIcons.edit),
|
||||
onPressed: null,
|
||||
),
|
||||
)
|
||||
@ -73,7 +73,8 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
||||
tiles.add(
|
||||
Card(
|
||||
child: ListTile(
|
||||
title: Text("${part.categoryName}"),
|
||||
title: Text("Part Category"),
|
||||
subtitle: Text("${part.categoryName}"),
|
||||
leading: FaIcon(FontAwesomeIcons.stream),
|
||||
onTap: () {
|
||||
InvenTreePartCategory().get(part.categoryId).then((var cat) {
|
||||
@ -92,6 +93,8 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
||||
child: ListTile(
|
||||
title: Text("${part.link}"),
|
||||
leading: FaIcon(FontAwesomeIcons.link),
|
||||
trailing: Text(""),
|
||||
onTap: null,
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -103,10 +106,9 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
||||
child: ListTile(
|
||||
title: Text("In Stock"),
|
||||
leading: FaIcon(FontAwesomeIcons.boxes),
|
||||
trailing: FlatButton(
|
||||
child: Text("${part.inStock}")
|
||||
),
|
||||
)
|
||||
trailing: Text("${part.inStock}"),
|
||||
onTap: null,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
@ -118,6 +120,7 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
||||
title: Text("On Order"),
|
||||
leading: FaIcon(FontAwesomeIcons.shoppingCart),
|
||||
trailing: Text("${part.onOrder}"),
|
||||
onTap: null,
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -125,12 +128,52 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
||||
|
||||
// Parts being built
|
||||
if (part.isAssembly) {
|
||||
|
||||
tiles.add(
|
||||
Card(
|
||||
child: ListTile(
|
||||
title: Text("Bill of Materials"),
|
||||
leading: FaIcon(FontAwesomeIcons.thList),
|
||||
trailing: Text("${part.bomItemCount}"),
|
||||
onTap: null,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
tiles.add(
|
||||
Card(
|
||||
child: ListTile(
|
||||
title: Text("Building"),
|
||||
leading: FaIcon(FontAwesomeIcons.tools),
|
||||
trailing: Text("${part.building}"),
|
||||
onTap: null,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (part.isComponent) {
|
||||
tiles.add(
|
||||
Card(
|
||||
child: ListTile(
|
||||
title: Text("Used In"),
|
||||
leading: FaIcon(FontAwesomeIcons.sitemap),
|
||||
trailing: Text("${part.usedInCount}"),
|
||||
onTap: null,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Notes field?
|
||||
if (part.notes.isNotEmpty) {
|
||||
tiles.add(
|
||||
Card(
|
||||
child: ListTile(
|
||||
title: Text("Notes"),
|
||||
leading: FaIcon(FontAwesomeIcons.stickyNote),
|
||||
trailing: Text(""),
|
||||
onTap: null,
|
||||
)
|
||||
)
|
||||
);
|
||||
@ -152,7 +195,7 @@ class _PartDisplayState extends State<PartDisplayWidget> {
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: partTiles(),
|
||||
),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user