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:
@ -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'] ?? '';
|
||||
|
||||
|
Reference in New Issue
Block a user