mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Add model for InvenTreePartAttachment
This commit is contained in:
parent
40805b2aff
commit
ffd423cf9a
@ -9,9 +9,6 @@ import 'model.dart';
|
||||
|
||||
class InvenTreeCompany extends InvenTreeModel {
|
||||
|
||||
@override
|
||||
String NAME = "Company";
|
||||
|
||||
@override
|
||||
String get URL => "company/";
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:inventree/api.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:inventree/inventree/sentry.dart';
|
||||
@ -44,8 +45,6 @@ class InvenTreeModel {
|
||||
// Note: If the WEB_URL is the same (except for /api/) as URL then just leave blank
|
||||
String WEB_URL = "";
|
||||
|
||||
String NAME = "Model";
|
||||
|
||||
String get webUrl {
|
||||
|
||||
if (api.isConnected()) {
|
||||
@ -453,3 +452,60 @@ class InvenTreeModel {
|
||||
}
|
||||
|
||||
|
||||
class InvenTreeAttachment extends InvenTreeModel {
|
||||
// Class representing an "attachment" file
|
||||
|
||||
InvenTreeAttachment() : super();
|
||||
|
||||
String get attachment => jsondata["attachment"] ?? '';
|
||||
|
||||
// Return the filename of the attachment
|
||||
String get filename {
|
||||
return attachment.split("/").last;
|
||||
}
|
||||
|
||||
IconData get icon {
|
||||
String fn = filename.toLowerCase();
|
||||
|
||||
if (fn.endsWith(".pdf")) {
|
||||
return FontAwesomeIcons.filePdf;
|
||||
} else if (fn.endsWith(".csv")) {
|
||||
return FontAwesomeIcons.fileCsv;
|
||||
} else if (fn.endsWith(".doc") || fn.endsWith(".docx")) {
|
||||
return FontAwesomeIcons.fileWord;
|
||||
} else if (fn.endsWith(".xls") || fn.endsWith(".xlsx")) {
|
||||
return FontAwesomeIcons.fileExcel;
|
||||
}
|
||||
|
||||
// Image formats
|
||||
final List<String> img_formats = [
|
||||
".png",
|
||||
".jpg",
|
||||
".gif",
|
||||
".bmp",
|
||||
".svg",
|
||||
];
|
||||
|
||||
for (String fmt in img_formats) {
|
||||
if (fn.endsWith(fmt)) {
|
||||
return FontAwesomeIcons.fileImage;
|
||||
}
|
||||
}
|
||||
|
||||
return FontAwesomeIcons.fileAlt;
|
||||
}
|
||||
|
||||
String get comment => jsondata["comment"] ?? '';
|
||||
|
||||
DateTime? get uploadDate {
|
||||
if (jsondata.containsKey("upload_date")) {
|
||||
return DateTime.tryParse(jsondata["upload_date"] ?? '');
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
InvenTreeAttachment.fromJson(Map<String, dynamic> json) : super.fromJson(json);
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,9 +10,6 @@ import 'package:http/http.dart' as http;
|
||||
|
||||
class InvenTreePartCategory extends InvenTreeModel {
|
||||
|
||||
@override
|
||||
String NAME = "PartCategory";
|
||||
|
||||
@override
|
||||
String get URL => "part/category/";
|
||||
|
||||
@ -74,9 +71,6 @@ class InvenTreePartCategory extends InvenTreeModel {
|
||||
|
||||
class InvenTreePartTestTemplate extends InvenTreeModel {
|
||||
|
||||
@override
|
||||
String NAME = "PartTestTemplate";
|
||||
|
||||
@override
|
||||
String get URL => "part/test-template/";
|
||||
|
||||
@ -131,9 +125,6 @@ class InvenTreePartTestTemplate extends InvenTreeModel {
|
||||
|
||||
class InvenTreePart extends InvenTreeModel {
|
||||
|
||||
@override
|
||||
String NAME = "Part";
|
||||
|
||||
@override
|
||||
String get URL => "part/";
|
||||
|
||||
@ -396,4 +387,21 @@ class InvenTreePart extends InvenTreeModel {
|
||||
|
||||
return part;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class InvenTreePartAttachment extends InvenTreeAttachment {
|
||||
|
||||
InvenTreePartAttachment() : super();
|
||||
|
||||
@override
|
||||
String get URL => "part/attachment/";
|
||||
|
||||
InvenTreePartAttachment.fromJson(Map<String, dynamic> json) : super.fromJson(json);
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
return InvenTreePartAttachment.fromJson(json);
|
||||
}
|
||||
|
||||
}
|
@ -14,9 +14,6 @@ import 'package:inventree/api.dart';
|
||||
|
||||
class InvenTreeStockItemTestResult extends InvenTreeModel {
|
||||
|
||||
@override
|
||||
String NAME = "StockItemTestResult";
|
||||
|
||||
@override
|
||||
String get URL => "stock/test/";
|
||||
|
||||
@ -99,9 +96,6 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String NAME = "StockItem";
|
||||
|
||||
@override
|
||||
String get URL => "stock/";
|
||||
|
||||
@ -464,11 +458,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
var item = InvenTreeStockItem.fromJson(json);
|
||||
|
||||
// TODO?
|
||||
|
||||
return item;
|
||||
return InvenTreeStockItem.fromJson(json);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -553,9 +543,6 @@ class InvenTreeStockItem extends InvenTreeModel {
|
||||
|
||||
class InvenTreeStockLocation extends InvenTreeModel {
|
||||
|
||||
@override
|
||||
String NAME = "StockLocation";
|
||||
|
||||
@override
|
||||
String get URL => "stock/location/";
|
||||
|
||||
@ -591,9 +578,7 @@ class InvenTreeStockLocation extends InvenTreeModel {
|
||||
|
||||
InvenTreeStockLocation() : super();
|
||||
|
||||
InvenTreeStockLocation.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||
// TODO
|
||||
}
|
||||
InvenTreeStockLocation.fromJson(Map<String, dynamic> json) : super.fromJson(json);
|
||||
|
||||
@override
|
||||
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
||||
Subproject commit 94daf51226f555c1c3a7ad4893931727d0369dda
|
||||
Subproject commit 20dce387ab4088e22b67c6ffd1fb50b6a1f252e8
|
Loading…
x
Reference in New Issue
Block a user