mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Adds option for deleting attachments from the app (#222)
* Adds option for deleting attachments from the app Closes https://github.com/inventree/inventree-app/issues/153 * Add entry to release notes
This commit is contained in:
parent
15b4cbc67a
commit
207e5ec6c5
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
- Add support for structural part categories
|
- Add support for structural part categories
|
||||||
- Add support for structural stock locations
|
- Add support for structural stock locations
|
||||||
|
- Allow deletion of attachments via app
|
||||||
- Updated translations
|
- Updated translations
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,12 +208,18 @@
|
|||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
"@delete": {},
|
"@delete": {},
|
||||||
|
|
||||||
|
"deleteFailed": "Delete operation failed",
|
||||||
|
"@deleteFailed": {},
|
||||||
|
|
||||||
"deletePart": "Delete Part",
|
"deletePart": "Delete Part",
|
||||||
"@deletePart": {},
|
"@deletePart": {},
|
||||||
|
|
||||||
"deletePartDetail": "Remove this part from the database",
|
"deletePartDetail": "Remove this part from the database",
|
||||||
"@deletePartDetail": {},
|
"@deletePartDetail": {},
|
||||||
|
|
||||||
|
"deleteSuccess": "Delete operation successful",
|
||||||
|
"@deleteSuccess": {},
|
||||||
|
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
"@description": {},
|
"@description": {},
|
||||||
|
|
||||||
|
@ -79,6 +79,49 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
|||||||
refresh(context);
|
refresh(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Delete the specified attachment
|
||||||
|
*/
|
||||||
|
Future<void> deleteAttachment(BuildContext context, InvenTreeAttachment attachment) async {
|
||||||
|
|
||||||
|
final bool result = await attachment.delete();
|
||||||
|
|
||||||
|
showSnackIcon(
|
||||||
|
result ? L10().deleteSuccess : L10().deleteFailed,
|
||||||
|
success: result
|
||||||
|
);
|
||||||
|
|
||||||
|
refresh(context);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display an option context menu for the selected attachment
|
||||||
|
*/
|
||||||
|
Future<void> showOptionsMenu(BuildContext context, InvenTreeAttachment attachment) async {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext ctx) {
|
||||||
|
return SimpleDialog(
|
||||||
|
title: Text(L10().attachments),
|
||||||
|
children: [
|
||||||
|
Divider(),
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () async {
|
||||||
|
Navigator.of(ctx).pop();
|
||||||
|
deleteAttachment(context, attachment);
|
||||||
|
},
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(L10().delete),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.trashAlt),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> request(BuildContext context) async {
|
Future<void> request(BuildContext context) async {
|
||||||
|
|
||||||
@ -128,6 +171,9 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
|||||||
await attachment.downloadAttachment();
|
await attachment.downloadAttachment();
|
||||||
hideLoadingOverlay();
|
hideLoadingOverlay();
|
||||||
},
|
},
|
||||||
|
onLongPress: () {
|
||||||
|
showOptionsMenu(context, attachment);
|
||||||
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +186,10 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
|||||||
if (await canLaunch(attachment.link)) {
|
if (await canLaunch(attachment.link)) {
|
||||||
await launch(attachment.link);
|
await launch(attachment.link);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
onLongPress: () {
|
||||||
|
showOptionsMenu(context, attachment);
|
||||||
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user