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

Driving the refactor tractor

- InvenTreeAPI() object now has a method to return a cache-backed image from the server
This commit is contained in:
Oliver Walters
2020-04-05 00:34:08 +11:00
parent 528215455d
commit cd4731833d
3 changed files with 25 additions and 17 deletions

View File

@ -42,25 +42,20 @@ class InvenTreePart extends InvenTreeModel {
String get _thumbnail => jsondata['thumbnail'] ?? '';
// Return a fully-qualified path to the image for this Part
// Return a path to the image for this Part
String get image {
// Use thumbnail as a backup
String img = _image.isNotEmpty ? _image : _thumbnail;
if (img.isEmpty) {
return InvenTreeAPI().makeUrl('/static/img/blank_image.png');
} else {
return InvenTreeAPI().makeUrl(img);
}
return img.isNotEmpty ? img : InvenTreeAPI.staticImage;
}
// Return a path to the thumbnail for this part
String get thumbnail {
// Use image as a backup
String img = _thumbnail.isNotEmpty ? _thumbnail : _image;
if (img.isEmpty) {
return InvenTreeAPI().makeUrl('/static/img/blank_image.thumbnail.png');
} else {
return InvenTreeAPI().makeUrl(img);
}
return img.isNotEmpty ? img : InvenTreeAPI.staticThumb;
}
InvenTreePart() : super();