mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-27 21:16:48 +00:00
Edit attachment (#598)
* Edit attachment - Allow editing of attachments once updloaed * Update release notes * Remove duplicate func
This commit is contained in:
parent
94d43bc377
commit
1363f7ee3a
@ -2,6 +2,8 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- Fixes bug which prevent dialog boxes from being dismissed correctly
|
- Fixes bug which prevent dialog boxes from being dismissed correctly
|
||||||
|
- Enable editing of attachment comments
|
||||||
|
- Updated translations
|
||||||
|
|
||||||
### 0.17.2 - December 2024
|
### 0.17.2 - December 2024
|
||||||
---
|
---
|
||||||
|
@ -324,6 +324,8 @@ class InvenTreeModel {
|
|||||||
// Legacy API provided external link as "URL", while newer API uses "link"
|
// Legacy API provided external link as "URL", while newer API uses "link"
|
||||||
String get link => (jsondata["link"] ?? jsondata["URL"] ?? "") as String;
|
String get link => (jsondata["link"] ?? jsondata["URL"] ?? "") as String;
|
||||||
|
|
||||||
|
bool get hasLink => link.isNotEmpty;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attempt to extract a custom icon for this model.
|
* Attempt to extract a custom icon for this model.
|
||||||
* If icon data is provided, attempt to convert to a TablerIcon icon
|
* If icon data is provided, attempt to convert to a TablerIcon icon
|
||||||
@ -946,6 +948,20 @@ class InvenTreeAttachment extends InvenTreeModel {
|
|||||||
@override
|
@override
|
||||||
String get URL => "attachment/";
|
String get URL => "attachment/";
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, Map<String, dynamic>> formFields() {
|
||||||
|
Map<String, Map<String, dynamic>> fields = {
|
||||||
|
"link": {},
|
||||||
|
"comment": {}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!hasLink) {
|
||||||
|
fields.remove("link");
|
||||||
|
}
|
||||||
|
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
// Override this reference field for any subclasses
|
// Override this reference field for any subclasses
|
||||||
// Note: This is used for the *legacy* attachment API
|
// Note: This is used for the *legacy* attachment API
|
||||||
String get REFERENCE_FIELD => "";
|
String get REFERENCE_FIELD => "";
|
||||||
@ -955,7 +971,9 @@ class InvenTreeAttachment extends InvenTreeModel {
|
|||||||
String get REF_MODEL_TYPE => "";
|
String get REF_MODEL_TYPE => "";
|
||||||
|
|
||||||
String get attachment => getString("attachment");
|
String get attachment => getString("attachment");
|
||||||
|
|
||||||
|
bool get hasAttachment => attachment.isNotEmpty;
|
||||||
|
|
||||||
// Return the filename of the attachment
|
// Return the filename of the attachment
|
||||||
String get filename {
|
String get filename {
|
||||||
return attachment.split("/").last;
|
return attachment.split("/").last;
|
||||||
@ -1024,6 +1042,10 @@ class InvenTreeAttachment extends InvenTreeModel {
|
|||||||
|
|
||||||
String url = URL;
|
String url = URL;
|
||||||
|
|
||||||
|
if (comment.isNotEmpty) {
|
||||||
|
data["comment"] = comment;
|
||||||
|
}
|
||||||
|
|
||||||
if (InvenTreeAPI().supportsModernAttachments) {
|
if (InvenTreeAPI().supportsModernAttachments) {
|
||||||
|
|
||||||
url = "attachment/";
|
url = "attachment/";
|
||||||
|
@ -338,6 +338,9 @@
|
|||||||
"description": "edit"
|
"description": "edit"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"editAttachment": "Edit Attachment",
|
||||||
|
"@editAttachment": {},
|
||||||
|
|
||||||
"editCategory": "Edit Category",
|
"editCategory": "Edit Category",
|
||||||
"@editCategory": {},
|
"@editCategory": {},
|
||||||
|
|
||||||
|
@ -97,6 +97,14 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
|||||||
refresh(context);
|
refresh(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future<void> editAttachment(BuildContext context, InvenTreeAttachment attachment) async
|
||||||
|
{
|
||||||
|
attachment.editForm(context, L10().editAttachment).then((result) => {
|
||||||
|
refresh(context)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete the specified attachment
|
* Delete the specified attachment
|
||||||
*/
|
*/
|
||||||
@ -117,6 +125,7 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
|||||||
* Display an option context menu for the selected attachment
|
* Display an option context menu for the selected attachment
|
||||||
*/
|
*/
|
||||||
Future<void> showOptionsMenu(BuildContext context, InvenTreeAttachment attachment) async {
|
Future<void> showOptionsMenu(BuildContext context, InvenTreeAttachment attachment) async {
|
||||||
|
|
||||||
OneContext().showDialog(
|
OneContext().showDialog(
|
||||||
builder: (BuildContext ctx) {
|
builder: (BuildContext ctx) {
|
||||||
return SimpleDialog(
|
return SimpleDialog(
|
||||||
@ -125,12 +134,22 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
|||||||
Divider(),
|
Divider(),
|
||||||
SimpleDialogOption(
|
SimpleDialogOption(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Navigator.of(ctx).pop();
|
OneContext().popDialog();
|
||||||
|
editAttachment(context, attachment);
|
||||||
|
},
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(L10().edit),
|
||||||
|
leading: Icon(TablerIcons.edit),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
SimpleDialogOption(
|
||||||
|
onPressed: () async {
|
||||||
|
OneContext().popDialog();
|
||||||
deleteAttachment(context, attachment);
|
deleteAttachment(context, attachment);
|
||||||
},
|
},
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
title: Text(L10().delete),
|
title: Text(L10().delete),
|
||||||
leading: Icon(TablerIcons.trash),
|
leading: Icon(TablerIcons.trash, color: COLOR_DANGER),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
@ -162,6 +181,9 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -43,7 +43,12 @@ mixin BaseWidgetProperties {
|
|||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
physics: AlwaysScrollableScrollPhysics(),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: getTiles(context)
|
children: [
|
||||||
|
ListView(
|
||||||
|
children: getTiles(context),
|
||||||
|
shrinkWrap: true,
|
||||||
|
)
|
||||||
|
],
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user