From e1a9a56d5ef58ea39c1991e5959a61c5fece1ace Mon Sep 17 00:00:00 2001 From: Peter Grassberger Date: Thu, 3 Dec 2015 15:57:29 +0100 Subject: jingles: fix fetch wrong group after upload diff --git a/www/js/jingles.js b/www/js/jingles.js index 814053a..e5749d2 100644 --- a/www/js/jingles.js +++ b/www/js/jingles.js @@ -317,12 +317,9 @@ JingleCut.prototype.render = function() { var Importer = function() { this.$el = $('#uploadModal'); - this.currentGroup = null; }; Importer.prototype.showUploadModal = function(group) { - this.currentGroup = group; - var uploadModal = $('#uploadModal'); $('div.modal-header h3', uploadModal).text("Datei auswählen..."); var form = $('
'); @@ -340,7 +337,7 @@ Importer.prototype.showUploadModal = function(group) { autoProcessQueue: false, init: function() { this.on("addedfile", function(file) { - self.importFileAdded(this, file); + self.importFileAdded(this, file, group); }); this.on("error", function(file, msg) { self.importFileSelectError(this, file, msg); @@ -351,7 +348,7 @@ Importer.prototype.showUploadModal = function(group) { $('#uploadModal').modal({keyboard: true}); }; -Importer.prototype.importFileAdded = function(dropzone, file) { +Importer.prototype.importFileAdded = function(dropzone, file, group) { $(dropzone.getAcceptedFiles()).each(function(idx, elem) { dropzone.removeFile(elem); }); var uploadModal = $('#uploadModal'); @@ -359,7 +356,7 @@ Importer.prototype.importFileAdded = function(dropzone, file) { $('div.modal-header h3', uploadModal).text(file.name); var self = this; $('#uploadModal-confirm', uploadModal).unbind('click').click(function() { - self.importCartConfirm(dropzone); + self.importCartConfirm(dropzone, group); }).removeAttr('disabled'); }; @@ -371,10 +368,10 @@ Importer.prototype.importFileSelectError = function(dropzone, file, msg) { dropzone.removeFile(file); }; -Importer.prototype.importCartConfirm = function(dz) { +Importer.prototype.importCartConfirm = function(dz, group) { $('#uploadModal').modal('hide'); - var progressBar = this.currentGroup.addUpload(); + var progressBar = group.addUpload(); @@ -391,12 +388,12 @@ Importer.prototype.importCartConfirm = function(dz) { var self = this; dz.on('uploadprogress', function(file) { self.uploadProgress(file, progressBar); }); dz.on('success', function(file) { - self.importFileUploadSuccess(dz, file, progressBar); + self.importFileUploadSuccess(dz, file, group, progressBar); }); dz.on('error', function(file, msg, xhr) { self.importFileUploadError(this, file, msg, xhr); }); - this.importAddCut(dz, files[0]) + this.importAddCut(dz, group, files[0]) }; Importer.prototype.uploadProgress = function(file, progressBar) { @@ -412,13 +409,13 @@ Importer.prototype.uploadProgress = function(file, progressBar) { } }; -Importer.prototype.importFileUploadSuccess = function(dz, file, progressBar) { +Importer.prototype.importFileUploadSuccess = function(dz, file, group, progressBar) { //var command = { LOGIN_NAME: auth_username, PASSWORD: auth_token, DESCRIPTION: file. }; //jingles_updateGroupCartInfo(cart); dz.disable(); progressBar.remove(); - this.currentGroup.fetchCarts(); + group.fetchCarts(); //$(this.currentGroup.mainCart).trigger('add'); }; @@ -432,8 +429,8 @@ Importer.prototype.importFileUploadError = function(dz, file, msg, xhr) { dz.disable(); }; -Importer.prototype.importAddCut = function(dz, file) { - var cart = this.currentGroup.mainCart; +Importer.prototype.importAddCut = function(dz, group, file) { + var cart = group.mainCart; rivendell.addAndEditCut(cart.number, {DESCRIPTION: file.name}, function(cutXml) { var cutNumber = $(cutXml).find('cutNumber').text(); dz.on('sending', function(file, xhr, formData) { -- cgit v0.10.2