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

Render list of SupplierPart

This commit is contained in:
Oliver
2021-08-02 20:05:05 +10:00
parent 5429c06349
commit 71ef6b3c5a
4 changed files with 102 additions and 10 deletions

View File

@ -1,9 +1,12 @@
import 'package:inventree/api.dart';
import 'model.dart';
/*
* The InvenTreeCompany class repreents the Company model in the InvenTree database.
*/
class InvenTreeCompany extends InvenTreeModel {
@override
@ -14,7 +17,9 @@ class InvenTreeCompany extends InvenTreeModel {
InvenTreeCompany() : super();
String get image => jsondata['image'] ?? '';
String get image => jsondata['image'] ?? jsondata['thumbnail'] ?? InvenTreeAPI.staticImage;
String get thumbnail => jsondata['thumbnail'] ?? jsondata['image'] ?? InvenTreeAPI.staticThumb;
String get website => jsondata['website'] ?? '';
@ -44,14 +49,14 @@ class InvenTreeCompany extends InvenTreeModel {
*/
class InvenTreeSupplierPart extends InvenTreeModel {
@override
String url = "company/part/";
String URL = "company/part/";
@override
Map<String, String> defaultListFilters() {
return {
"manufacturer_detail": "true",
"supplier_detail": "true",
"supplier_part_detail": "true",
"manufacturer_part_detail": "true",
};
}
@ -61,12 +66,22 @@ class InvenTreeSupplierPart extends InvenTreeModel {
int get manufacturerId => (jsondata['manufacturer'] ?? -1) as int;
String get manufacturerName => jsondata['manufacturer_detail']['name'];
String get manufacturerImage => jsondata['manufacturer_detail']['image'] ?? jsondata['manufacturer_detail']['thumbnail'];
int get manufacturerPartId => (jsondata['manufacturer_part'] ?? -1) as int;
int get supplierId => (jsondata['supplier'] ?? -1) as int;
String get supplierName => jsondata['supplier_detail']['name'];
String get supplierImage => jsondata['supplier_detail']['image'] ?? jsondata['supplier_detail']['thumbnail'];
String get SKU => (jsondata['SKU'] ?? '') as String;
String get MPN => jsondata['MPN'] ?? '';
@override
InvenTreeModel createFromJson(Map<String, dynamic> json) {
var part = InvenTreeSupplierPart.fromJson(json);

View File

@ -1,5 +1,6 @@
import 'package:inventree/api.dart';
import 'package:inventree/inventree/stock.dart';
import 'package:inventree/inventree/company.dart';
import 'package:flutter/cupertino.dart';
import 'package:inventree/l10.dart';
@ -174,13 +175,10 @@ class InvenTreePart extends InvenTreeModel {
final parts = await InvenTreeSupplierPart().list(
filters: {
"part": "${pk}",
"manufacturer_detail": "true",
"supplier_detail": "true",
"supplier_part_detail": "true"
}
);
for (result in parts) {
for (var result in parts) {
if (result is InvenTreeSupplierPart) {
_supplierParts.add(result);
}
@ -196,7 +194,7 @@ class InvenTreePart extends InvenTreeModel {
int get testTemplateCount => testingTemplates.length;
// Request test templates from the serve
Future<void> getTestTemplates({bool showDialog=false}) async {
Future<void> getTestTemplates() async {
InvenTreePartTestTemplate().list(
filters: {