2
0
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:
Oliver Walters 2020-05-30 21:09:31 +10:00
parent 9d929c7741
commit 56bdf83692

View File

@ -180,6 +180,11 @@ class InvenTreeStockItem extends InvenTreeModel {
nm = jsondata['part_detail']['full_name'] ?? ''; nm = jsondata['part_detail']['full_name'] ?? '';
} }
// Backup if first value fails
if (nm.isEmpty) {
nm = jsondata['part__name'] ?? '';
}
return nm; return nm;
} }
@ -212,9 +217,23 @@ class InvenTreeStockItem extends InvenTreeModel {
return img; return img;
} }
/**
* Return the Part thumbnail for this stock item.
*/
String get partThumbnail { 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; if (thumb.isEmpty) thumb = InvenTreeAPI.staticThumb;
return thumb; return thumb;