mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 11:36:24 +00:00
Display part thumbnail in part list
This commit is contained in:
parent
44a0c3e18d
commit
528215455d
7 changed files with 119 additions and 19 deletions
|
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue