changeset 1222:4e62bc6e7250

Fixed parsing of empty data and require the import response window.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 27 Oct 2016 16:26:07 +0200
parents 4b456449029c
children 4c443efd5587
files app/view/window/FileUpload.js app/view/window/ImportResponse.js
diffstat 2 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/app/view/window/FileUpload.js	Wed Oct 26 16:50:07 2016 +0200
+++ b/app/view/window/FileUpload.js	Thu Oct 27 16:26:07 2016 +0200
@@ -11,6 +11,7 @@
  */
 Ext.define('Lada.view.window.FileUpload', {
     extend: 'Ext.window.Window',
+    requires: ['Lada.view.window.ImportResponse'],
 
     layout: 'hbox',
 
--- a/app/view/window/ImportResponse.js	Wed Oct 26 16:50:07 2016 +0200
+++ b/app/view/window/ImportResponse.js	Thu Oct 27 16:26:07 2016 +0200
@@ -22,6 +22,10 @@
         if (me.data && me.message) {
             html = me.parseShortResponse(me.message, me.data);
         }
+        else {
+            html = 'Der Import der Datei ' + this.fileName +
+                    ' war nicht erfolgreich.';
+        }
         this.bodyStyle = {background: '#fff'};
         me.items = [{
             xtype: 'panel',
@@ -45,7 +49,9 @@
             }
         }];
         this.callParent(arguments);
-        download = me.parseResponse(me.message, me.data);
+        if (me.data && me.message) {
+            download = me.parseResponse(me.message, me.data);
+        }
     },
 
     /**
@@ -54,7 +60,7 @@
      * @param data
      */
     parseShortResponse: function(msg, data) {
-        data = Ext.JSON.decode(data);
+        data = Ext.JSON.decode(data, true);
         var errors = data.data.errors;
         var warnings = data.data.warnings;
         var out = [];
@@ -110,8 +116,7 @@
      * @param data the payload of the response
      */
     parseResponse: function(msg, data) {
-        console.log(Ext.JSON.decode(data));
-        data = Ext.JSON.decode(data);
+        data = Ext.JSON.decode(data, true);
         var errors = data.data.errors;
         var warnings = data.data.warnings;
         var out = [];
@@ -207,7 +212,6 @@
                 this.down('button[name=download]').enable();
             }
         }
-        console.log(out.join(''));
         return out.join('');
     }
 });

http://lada.wald.intevation.org