2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-29 14:06:47 +00:00

Display part attachments

This commit is contained in:
Oliver 2021-08-15 16:50:59 +10:00
parent ffd423cf9a
commit d9d52613b6

View File

@ -26,6 +26,8 @@ class _PartAttachmentDisplayState extends RefreshableState<PartAttachmentsWidget
final InvenTreePart part; final InvenTreePart part;
List<InvenTreePartAttachment> attachments = [];
@override @override
String getAppBarTitle(BuildContext context) => L10().attachments; String getAppBarTitle(BuildContext context) => L10().attachments;
@ -48,7 +50,22 @@ class _PartAttachmentDisplayState extends RefreshableState<PartAttachmentsWidget
@override @override
Future<void> request() async { Future<void> 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 @override
@ -68,6 +85,24 @@ class _PartAttachmentDisplayState extends RefreshableState<PartAttachmentsWidget
List<Widget> tiles = []; List<Widget> 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; return tiles;
} }