2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-06-12 03:28:37 +00:00

[feature] Rename attachments (#11920)

* Implementation

* Update API and CHANGELOG

* Annotate response type

* Simplify attachment renaming

- Use the existing API endpoint

* Capture the actual saved path

* Tweak attachment table fields

* Use built-in validation

* Update docs

* Unit testing

* Ignore some lines from coverage

* Check if file exists before deleting
This commit is contained in:
Oliver
2026-05-18 20:02:46 +10:00
committed by GitHub
parent 73c7820ac0
commit acc2786e44
9 changed files with 257 additions and 5 deletions
@@ -232,12 +232,16 @@ export function AttachmentTable({
hidden: true
},
attachment: {},
filename: {},
link: {},
comment: {}
};
if (attachmentType != 'link') {
delete fields['link'];
} else {
delete fields['attachment'];
delete fields['filename'];
}
// Remove the 'attachment' field if we are editing an existing attachment, or uploading a link
@@ -245,6 +249,11 @@ export function AttachmentTable({
delete fields['attachment'];
}
if (!selectedAttachment) {
// Cannot edit the filename during creation
delete fields['filename'];
}
return fields;
}, [model_type, model_id, attachmentType, selectedAttachment]);
@@ -329,6 +338,11 @@ export function AttachmentTable({
RowEditAction({
hidden: !user.hasChangePermission(model_type),
onClick: () => {
if (record.attachment) {
setAttachmentType('attachment');
} else {
setAttachmentType('link');
}
setSelectedAttachment(record.pk);
editAttachment.open();
}