2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-17 04:35:26 +00:00

Bug fix for part without a category defined

This commit is contained in:
Oliver Walters
2021-01-20 23:12:51 +11:00
parent 153bb1c077
commit 72512329e9
2 changed files with 25 additions and 5 deletions

View File

@ -132,6 +132,14 @@ class InvenTreePart extends InvenTreeModel {
@override
String URL = "part/";
@override
Map<String, String> defaultListFilters() {
return {
"cascade": "false",
"active": "true",
};
}
@override
Map<String, String> defaultGetFilters() {
return {
@ -202,11 +210,20 @@ class InvenTreePart extends InvenTreeModel {
int get categoryId => jsondata['category'] as int ?? null;
// 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
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
String get _image => jsondata['image'] ?? '';