mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Adds attachment support for the StockItem model
This commit is contained in:
parent
fcfda4ebff
commit
ada64f3971
@ -415,7 +415,9 @@ class InvenTreePart extends InvenTreeModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class representing an attachment file against a Part object
|
||||||
|
*/
|
||||||
class InvenTreePartAttachment extends InvenTreeAttachment {
|
class InvenTreePartAttachment extends InvenTreeAttachment {
|
||||||
|
|
||||||
InvenTreePartAttachment() : super();
|
InvenTreePartAttachment() : super();
|
||||||
|
@ -601,6 +601,29 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class representing an attachment file against a StockItem object
|
||||||
|
*/
|
||||||
|
class InvenTreeStockItemAttachment extends InvenTreeAttachment {
|
||||||
|
|
||||||
|
InvenTreeStockItemAttachment() : super();
|
||||||
|
|
||||||
|
InvenTreeStockItemAttachment.fromJson(Map<String, dynamic> json) : super.fromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get REFERENCE_FIELD => "stock_item";
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get URL => "stock/attachment/";
|
||||||
|
|
||||||
|
@override
|
||||||
|
InvenTreeModel createFromJson(Map<String, dynamic> json) {
|
||||||
|
return InvenTreeStockItemAttachment.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class InvenTreeStockLocation extends InvenTreeModel {
|
class InvenTreeStockLocation extends InvenTreeModel {
|
||||||
|
|
||||||
InvenTreeStockLocation() : super();
|
InvenTreeStockLocation() : super();
|
||||||
|
@ -7,6 +7,7 @@ import "package:inventree/barcode.dart";
|
|||||||
import "package:inventree/inventree/stock.dart";
|
import "package:inventree/inventree/stock.dart";
|
||||||
import "package:inventree/inventree/part.dart";
|
import "package:inventree/inventree/part.dart";
|
||||||
import "package:inventree/widget/dialogs.dart";
|
import "package:inventree/widget/dialogs.dart";
|
||||||
|
import "package:inventree/widget/attachment_widget.dart";
|
||||||
import "package:inventree/widget/location_display.dart";
|
import "package:inventree/widget/location_display.dart";
|
||||||
import "package:inventree/widget/part_detail.dart";
|
import "package:inventree/widget/part_detail.dart";
|
||||||
import "package:inventree/widget/progress.dart";
|
import "package:inventree/widget/progress.dart";
|
||||||
@ -94,6 +95,8 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
// Part object
|
// Part object
|
||||||
InvenTreePart? part;
|
InvenTreePart? part;
|
||||||
|
|
||||||
|
int attachmentCount = 0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> onBuild(BuildContext context) async {
|
Future<void> onBuild(BuildContext context) async {
|
||||||
|
|
||||||
@ -126,6 +129,12 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
attachmentCount = await InvenTreeStockItemAttachment().count(
|
||||||
|
filters: {
|
||||||
|
"stock_item": item.pk.toString()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Request information on labels available for this stock item
|
// Request information on labels available for this stock item
|
||||||
if (InvenTreeAPI().pluginsEnabled()) {
|
if (InvenTreeAPI().pluginsEnabled()) {
|
||||||
_getLabels();
|
_getLabels();
|
||||||
@ -694,6 +703,25 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
tiles.add(
|
||||||
|
ListTile(
|
||||||
|
title: Text(L10().attachments),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.fileAlt, color: COLOR_CLICK),
|
||||||
|
trailing: attachmentCount > 0 ? Text(attachmentCount.toString()) : null,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => AttachmentWidget(
|
||||||
|
InvenTreeStockItemAttachment(),
|
||||||
|
item.pk,
|
||||||
|
InvenTreeAPI().checkPermission("stock", "change"))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user