mirror of
https://github.com/inventree/inventree-app.git
synced 2025-05-06 09:18:54 +00:00
More complex lookup
This commit is contained in:
parent
9d929c7741
commit
56bdf83692
@ -180,6 +180,11 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
nm = jsondata['part_detail']['full_name'] ?? '';
|
||||
}
|
||||
|
||||
// Backup if first value fails
|
||||
if (nm.isEmpty) {
|
||||
nm = jsondata['part__name'] ?? '';
|
||||
}
|
||||
|
||||
return nm;
|
||||
}
|
||||
|
||||
@ -212,9 +217,23 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
return img;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Part thumbnail for this stock item.
|
||||
*/
|
||||
String get partThumbnail {
|
||||
String thumb = jsondata['part__thumbnail'] as String ?? '';
|
||||
|
||||
String thumb;
|
||||
|
||||
if (jsondata.containsKey('part_detail')) {
|
||||
thumb = jsondata['part_detail']['thumbnail'] as String ?? '';
|
||||
}
|
||||
|
||||
// Try a different approach
|
||||
if (thumb.isEmpty) {
|
||||
jsondata['part__thumbnail'] as String ?? '';
|
||||
}
|
||||
|
||||
// Still no thumbnail? Use the 'no image' image
|
||||
if (thumb.isEmpty) thumb = InvenTreeAPI.staticThumb;
|
||||
|
||||
return thumb;
|
||||
|
Loading…
x
Reference in New Issue
Block a user