[Lada-commits] [PATCH 1 of 2] Fix error handling in ImportResponse window

Wald Commits scm-commit at wald.intevation.org
Mon Oct 31 18:12:17 CET 2016


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1477918440 -3600
# Node ID cfc24d2ae2686cbcd5ef7d3b545f8ced330ce60c
# Parent  d1f43f1e7e84531fd94e8c64eab0e3e732d86419
Fix error handling in ImportResponse window.

diff -r d1f43f1e7e84 -r cfc24d2ae268 app/view/window/ImportResponse.js
--- a/app/view/window/ImportResponse.js	Mon Oct 31 10:05:10 2016 +0100
+++ b/app/view/window/ImportResponse.js	Mon Oct 31 13:54:00 2016 +0100
@@ -19,8 +19,9 @@
         var html;
         var download;
         var i18n = Lada.getApplication().bundle;
-        if (me.data && me.message) {
-            html = me.parseShortResponse(me.message, me.data);
+        var data = Ext.JSON.decode(me.data, true);
+        if (data) {
+            html = me.parseShortResponse(data);
         }
         else {
             html = 'Der Import der Datei ' + this.fileName +
@@ -49,18 +50,16 @@
             }
         }];
         this.callParent(arguments);
-        if (me.data && me.message) {
-            download = me.parseResponse(me.message, me.data);
+        if (data) {
+            download = me.parseResponse(data);
         }
     },
 
     /**
      * Parse the response and create a summary of the result
-     * @param msg
      * @param data
      */
-    parseShortResponse: function(msg, data) {
-        data = Ext.JSON.decode(data, true);
+    parseShortResponse: function(data) {
         var errors = data.data.errors;
         var warnings = data.data.warnings;
         var out = [];
@@ -81,7 +80,7 @@
         else {
             numWarnings = Object.keys(warnings).length;
         }
-        if (msg !== '200') {
+        if (!data.success) {
                 out.push('Der Import der Datei ' + this.fileName +
                     ' war nicht erfolgreich. Der Importvorgang konnte ' +
                     'aufgrund eines Fehlers im Server nicht beendet werden.');
@@ -112,11 +111,9 @@
 
     /**
      * Parse the Response
-     * @param msg the Lada-Erro-Code
      * @param data the payload of the response
      */
-    parseResponse: function(msg, data) {
-        data = Ext.JSON.decode(data, true);
+    parseResponse: function(data) {
         var errors = data.data.errors;
         var warnings = data.data.warnings;
         var out = [];
@@ -137,7 +134,7 @@
         else {
             numWarnings = Object.keys(warnings).length;
         }
-        if (msg !== '200') {
+        if (!data.success) {
                 out.push('Der Import der Datei ' + this.fileName +
                     ' war nicht erfolgreich. Der Importvorgang konnte ' +
                     'aufgrund eines Fehlers im Server nicht beendet werden.');


More information about the Lada-commits mailing list