2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 13:36:50 +00:00

Display number of attachments on part view

This commit is contained in:
Oliver Walters 2022-06-04 00:15:34 +10:00
parent 10783cd1c4
commit fcfda4ebff

View File

@ -39,6 +39,8 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
InvenTreePart? parentPart; InvenTreePart? parentPart;
int attachmentCount = 0;
@override @override
String getAppBarTitle(BuildContext context) => L10().partDetails; String getAppBarTitle(BuildContext context) => L10().partDetails;
@ -110,6 +112,12 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
} }
await part.getTestTemplates(); await part.getTestTemplates();
attachmentCount = await InvenTreePartAttachment().count(
filters: {
"part": part.pk.toString()
}
);
} }
Future <void> _toggleStar() async { Future <void> _toggleStar() async {
@ -405,7 +413,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
ListTile( ListTile(
title: Text(L10().attachments), title: Text(L10().attachments),
leading: FaIcon(FontAwesomeIcons.fileAlt, color: COLOR_CLICK), leading: FaIcon(FontAwesomeIcons.fileAlt, color: COLOR_CLICK),
trailing: Text(""), trailing: attachmentCount > 0 ? Text(attachmentCount.toString()) : null,
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,