[Lada-commits] [PATCH] Fixed parsing of empty data and require the import response window

Wald Commits scm-commit at wald.intevation.org
Thu Oct 27 16:26:10 CEST 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1477578367 -7200
# Node ID 4e62bc6e7250238b6dc12707a5458212907bfa2f
# Parent  4b456449029c9348167b1deeb699af8fc0f5e75e
Fixed parsing of empty data and require the import response window.

diff -r 4b456449029c -r 4e62bc6e7250 app/view/window/FileUpload.js
--- 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',
 
diff -r 4b456449029c -r 4e62bc6e7250 app/view/window/ImportResponse.js
--- 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('');
     }
 });


More information about the Lada-commits mailing list