mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-17 04:35:26 +00:00
Display part thumbnail in part list
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import 'package:InvenTree/api.dart';
|
||||
|
||||
import 'model.dart';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:http/http.dart' as http;
|
||||
@ -38,6 +38,31 @@ class InvenTreePart extends InvenTreeModel {
|
||||
|
||||
String get categoryName => jsondata['category__name'] ?? '';
|
||||
|
||||
String get _image => jsondata['image'] ?? '';
|
||||
|
||||
String get _thumbnail => jsondata['thumbnail'] ?? '';
|
||||
|
||||
// Return a fully-qualified path to the image for this Part
|
||||
String get image {
|
||||
String img = _image.isNotEmpty ? _image : _thumbnail;
|
||||
|
||||
if (img.isEmpty) {
|
||||
return InvenTreeAPI().makeUrl('/static/img/blank_image.png');
|
||||
} else {
|
||||
return InvenTreeAPI().makeUrl(img);
|
||||
}
|
||||
}
|
||||
|
||||
String get thumbnail {
|
||||
String img = _thumbnail.isNotEmpty ? _thumbnail : _image;
|
||||
|
||||
if (img.isEmpty) {
|
||||
return InvenTreeAPI().makeUrl('/static/img/blank_image.thumbnail.png');
|
||||
} else {
|
||||
return InvenTreeAPI().makeUrl(img);
|
||||
}
|
||||
}
|
||||
|
||||
InvenTreePart() : super();
|
||||
|
||||
InvenTreePart.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
@ -50,6 +75,5 @@ class InvenTreePart extends InvenTreeModel {
|
||||
var part = InvenTreePart.fromJson(json);
|
||||
|
||||
return part;
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user