Attachment rename now without filename extension

This commit is contained in:
Martin Filser 2022-04-26 19:27:22 +02:00
parent 26e1c1dc4a
commit 11f8b17a05
2 changed files with 7 additions and 3 deletions

View file

@ -90,6 +90,6 @@ template(name="attachmentActionsPopup")
| {{_ 'attachment-move-storage-gridfs'}}
template(name="attachmentRenamePopup")
input.js-edit-attachment-name(type='text' autofocus value=name dir="auto")
input.js-edit-attachment-name(type='text' autofocus value="{{getNameWithoutExtension}}" dir="auto")
.edit-controls.clearfix
button.primary.confirm.js-submit-edit-attachment-name(type="submit") {{_ 'save'}}

View file

@ -161,6 +161,10 @@ BlazeComponent.extendComponent({
}).register('attachmentActionsPopup');
BlazeComponent.extendComponent({
getNameWithoutExtension() {
const ret = this.data().name.replace(new RegExp("\." + this.data().extension + "$"), "");
return ret;
},
events() {
return [
{
@ -175,9 +179,9 @@ BlazeComponent.extendComponent({
event.preventDefault();
const name = this.$('.js-edit-attachment-name')[0]
.value
.trim();
.trim() + this.data().extensionWithDot;
Meteor.call('renameAttachment', this.data()._id, name);
Popup.back();
Popup.back(2);
},
}
]