]> BookStack Code Mirror - bookstack/blobdiff - resources/assets/js/vues/components/dropzone.js
Merge branch 'bug/gif-image-740' of git://github.com/Abijeet/BookStack
[bookstack] / resources / assets / js / vues / components / dropzone.js
index 3e6e6c73028f52a9e1df898e0027c4b888ae41c9..0e40b20ca17685250a2b486690d2a5e9c70b58d2 100644 (file)
@@ -12,7 +12,9 @@ const props = ['placeholder', 'uploadUrl', 'uploadedTo'];
 function mounted() {
    let container = this.$el;
    let _this = this;
-   new DropZone(container, {
+   this._dz = new DropZone(container, {
+       addRemoveLinks: true,
+       dictRemoveFile: trans('components.image_upload_remove'),
         url: function() {
             return _this.uploadUrl;
         },
@@ -35,26 +37,33 @@ function mounted() {
 
             dz.on('error', function (file, errorMessage, xhr) {
                 _this.$emit('error', {file, errorMessage, xhr});
-                console.log(errorMessage);
-                console.log(xhr);
+
                 function setMessage(message) {
                     $(file.previewElement).find('[data-dz-errormessage]').text(message);
                 }
 
-                if (xhr.status === 413) setMessage(trans('errors.server_upload_limit'));
+                if (xhr && xhr.status === 413) setMessage(trans('errors.server_upload_limit'));
                 else if (errorMessage.file) setMessage(errorMessage.file);
+
             });
         }
    });
 }
 
 function data() {
-    return {}
+    return {};
 }
 
+const methods = {
+    onClose: function () {
+        this._dz.removeAllFiles(true);
+    }
+};
+
 module.exports = {
     template,
     props,
     mounted,
     data,
-};
\ No newline at end of file
+    methods
+};