From d9d52613b6f431aa2ee91f124f0fa90131c829d5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 15 Aug 2021 16:50:59 +1000 Subject: [PATCH] Display part attachments --- lib/widget/part_attachments_widget.dart | 37 ++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/widget/part_attachments_widget.dart b/lib/widget/part_attachments_widget.dart index 2f90c6ca..73483f53 100644 --- a/lib/widget/part_attachments_widget.dart +++ b/lib/widget/part_attachments_widget.dart @@ -26,6 +26,8 @@ class _PartAttachmentDisplayState extends RefreshableState attachments = []; + @override String getAppBarTitle(BuildContext context) => L10().attachments; @@ -48,7 +50,22 @@ class _PartAttachmentDisplayState extends RefreshableState request() async { - // TODO - Request part attachments from the server + + await InvenTreePartAttachment().list( + filters: { + "part": "${part.pk}" + } + ).then((var results) { + + attachments.clear(); + + for (var result in results) { + if (result is InvenTreePartAttachment) { + attachments.add(result); + } + } + }); + } @override @@ -68,6 +85,24 @@ class _PartAttachmentDisplayState extends RefreshableState tiles = []; + for (var attachment in attachments) { + tiles.add(ListTile( + title: Text(attachment.filename), + subtitle: Text(attachment.comment), + leading: FaIcon(attachment.icon), + )); + } + + if (tiles.length == 0) { + tiles.add(ListTile( + title: Text(L10().attachmentNone), + subtitle: Text( + L10().attachmentNonePartDetail, + style: TextStyle(fontStyle: FontStyle.italic), + ), + )); + } + return tiles; }