2
0
Эх сурвалжийг харах

Attachment rename now without filename extension

Martin Filser 3 жил өмнө
parent
commit
11f8b17a05

+ 1 - 1
client/components/cards/attachments.jade

@@ -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'}}

+ 6 - 2
client/components/cards/attachments.js

@@ -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);
         },
       }
     ]