From 13fc3657a2668d83f70636ac4d1156d38a1b1007 Mon Sep 17 00:00:00 2001
From: Peter Grassberger <petertheone@gmail.com>
Date: Mon, 22 Feb 2016 18:48:35 +0100
Subject: destroy dropzone on cancel, success and modal hide


diff --git a/www/js/importer.js b/www/js/importer.js
index 06caa1c..c5b48df 100644
--- a/www/js/importer.js
+++ b/www/js/importer.js
@@ -55,6 +55,12 @@ Rivendell.Importer.prototype.openModal = function(group, groupView, createCart,
     autoProcessQueue: false
   });
 
+  this.$el.off('hide.bs.modal').on('hide.bs.modal', function() {
+    dropzone.removeAllFiles(true);
+    dropzone.disable();
+    dropzone.destroy();
+  });
+
   var self = this;
   dropzone.on('addedfile', function(file) {
     if (!Dropzone.isValidFile(file, dropzone.options.acceptedFiles)) {
@@ -71,10 +77,12 @@ Rivendell.Importer.prototype.openModal = function(group, groupView, createCart,
       var upload = new Rivendell.Upload(group, groupView, createCart, newCartNumber, useMetadata, dropzone);
       self.uploads.push(upload);
 
+      self.$el.off('hide.bs.modal');
       self.$el.modal('hide');
     })
         .removeAttr('disabled').focus();
   });
+
   this.$el.modal({keyboard: true});
 };
 
@@ -113,6 +121,7 @@ Rivendell.Upload.prototype.cancel = function() {
   this.dropzone.off(Dropzone.ERROR);
   this.dropzone.removeAllFiles(true);
   this.dropzone.disable();
+  this.dropzone.destroy();
 
   var self = this;
   if (this.createCart && this.cart !== null) {
@@ -172,10 +181,10 @@ Rivendell.Upload.prototype.importFileUploadSuccess = function() {
   this.dropzone.off(Dropzone.ERROR);
   this.dropzone.removeAllFiles(true);
   this.dropzone.disable();
+  this.dropzone.destroy();
+  importer.removeUpload(this);
 
   this.group.fetchCarts();
-
-  importer.removeUpload(this);
 };
 
 Rivendell.Upload.prototype.importFileUploadError = function(file, msg, xhr) {
-- 
cgit v0.10.2