mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Bug fix for part without a category defined
This commit is contained in:
parent
153bb1c077
commit
72512329e9
@ -132,6 +132,14 @@ class InvenTreePart extends InvenTreeModel {
|
|||||||
@override
|
@override
|
||||||
String URL = "part/";
|
String URL = "part/";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, String> defaultListFilters() {
|
||||||
|
return {
|
||||||
|
"cascade": "false",
|
||||||
|
"active": "true",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, String> defaultGetFilters() {
|
Map<String, String> defaultGetFilters() {
|
||||||
return {
|
return {
|
||||||
@ -202,11 +210,20 @@ class InvenTreePart extends InvenTreeModel {
|
|||||||
int get categoryId => jsondata['category'] as int ?? null;
|
int get categoryId => jsondata['category'] as int ?? null;
|
||||||
|
|
||||||
// Get the category name for the Part instance
|
// Get the category name for the Part instance
|
||||||
String get categoryName => jsondata['category_detail']['name'] as String ?? '';
|
String get categoryName {
|
||||||
|
if (categoryId == null) return '';
|
||||||
|
if (!jsondata.containsKey('category_detail')) return '';
|
||||||
|
|
||||||
|
return jsondata['category_detail']['name'] as String ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
// Get the category description for the Part instance
|
// Get the category description for the Part instance
|
||||||
String get categoryDescription => jsondata['category_detail']['description'] as String ?? '';
|
String get categoryDescription {
|
||||||
|
if (categoryId == null) return '';
|
||||||
|
if (!jsondata.containsKey('category_detail')) return '';
|
||||||
|
|
||||||
|
return jsondata['category_detail']['description'] as String ?? '';
|
||||||
|
}
|
||||||
// Get the image URL for the Part instance
|
// Get the image URL for the Part instance
|
||||||
String get _image => jsondata['image'] ?? '';
|
String get _image => jsondata['image'] ?? '';
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
ListTile(
|
ListTile(
|
||||||
title: Text("Part Category"),
|
title: Text("Part Category"),
|
||||||
subtitle: Text("${part.categoryName}"),
|
subtitle: Text("${part.categoryName}"),
|
||||||
leading: FaIcon(FontAwesomeIcons.stream),
|
leading: FaIcon(FontAwesomeIcons.sitemap),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (part.categoryId > 0) {
|
if (part.categoryId > 0) {
|
||||||
InvenTreePartCategory().get(context, part.categoryId).then((var cat) {
|
InvenTreePartCategory().get(context, part.categoryId).then((var cat) {
|
||||||
@ -151,8 +151,11 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text("Part Category"),
|
title: Text("Part Category"),
|
||||||
subtitle: Text("No category set"),
|
subtitle: Text("Top level part category"),
|
||||||
leading: FaIcon(FontAwesomeIcons.stream),
|
leading: FaIcon(FontAwesomeIcons.sitemap),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (context) => CategoryDisplayWidget(null)));
|
||||||
|
},
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user