details:   https://code.openbravo.com/erp/devel/pi/rev/0b908a2c7f99
changeset: 33344:0b908a2c7f99
user:      Javier Armendáriz <javier.armendariz <at> openbravo.com>
date:      Fri Feb 02 15:00:04 2018 +0100
summary:   Fixed bug 35268: No message displayed on request timeout responses.

The RPC response handler does not show any message when the request fails. Now 
it shows an error in the messageBar if its a server timeout.

diffstat:

 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
 |  32 ++++++++-
 1 files changed, 28 insertions(+), 4 deletions(-)

diffs (50 lines):

diff -r 1cb95f1f4e4d -r 0b908a2c7f99 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- 
a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
  Fri Feb 02 11:38:24 2018 +0100
+++ 
b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
  Fri Feb 02 15:00:04 2018 +0100
@@ -774,18 +774,42 @@
       delete target.view.isRefreshing;
       target.view.toolBar.updateButtonState();
     }
+
+    // in case of response timeout, show the error in the view if possible
+    if (this.isServerTimeoutResponse(response) && 
this.canShowErrorMessage(target)) {
+      target.view.setErrorMessageFromResponse(response, response.data, 
request);
+    }
+
     if (!request.willHandleError) {
       this._originalhandleError(response, request);
     }
   },
 
+  isServerTimeoutResponse: function (response) {
+    return response.status === isc.RPCResponse.STATUS_SERVER_TIMEOUT;
+  },
+
+  canShowErrorMessage: function (target) {
+    return target && target.view && 
isc.isA.Function(target.view.setErrorMessageFromResponse);
+  },
+
   _originalEvalResult: isc.RPCManager.evalResult,
   evalResult: function (request, response, results) {
-    // if the response contains an error status, call the errorCallback
-    if (response.status !== isc.RPCResponse.STATUS_SUCCESS && 
isc.isA.Function(request.errorCallback)) {
-      request.errorCallback(request, response);
+    if (response.status !== isc.RPCResponse.STATUS_SUCCESS) {
+      if (isc.isA.Function(request.errorCallback)) {
+        // if the response contains an error status, call the errorCallback
+        request.errorCallback(request, response);
+      } else {
+        // try to handle the error in the standard way
+        this.handleError(response, request);
+      }
     }
-    return this._originalEvalResult(request, response, results);
+
+    return this._originalEvalResult(request, response, 
this.sanitizeResults(results));
+  },
+
+  sanitizeResults: function (results) {
+    return isc.isA.Object(results) ? JSON.stringify(results) : results;
   },
 
   // Escape characters that are not properly handled in JavaScript's eval. See 
issue #36788.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to