hide popup message if failure is handled - not sure what knock on effect this may...
[Pman.Core] / Pman.Request.js
index 5cf0aae..a2b5fc6 100644 (file)
@@ -25,6 +25,7 @@ var t = new Pman.Request({
 *       request, a url encoded string or a function to call to get either.
 * @cfg  {Function} success  called with ( JSON decoded data of the data.. )
 * @cfg  {Function} success  called with ( JSON decoded data of the data.. )
+* @cfg {Boolean} showFailureDialog (true|false) default true
 */
 
 Pman.Request = function(config){
@@ -33,8 +34,6 @@ Pman.Request = function(config){
     
     if (this.mask) {
         this.maskEl = this.maskEl || Roo.get(document.body);
-        Roo.log('mask EL !!!!!!!!!!!!!!!!!!!!!!!!!!11');
-        Roo.log(this.maskEl);
         Roo.get(this.maskEl).mask(this.mask);
         
     }
@@ -44,6 +43,8 @@ Pman.Request = function(config){
 
 Roo.extend(Pman.Request, Roo.data.Connection, {
     // private
+    showFailureDialog : true,
+    
     processResponse : function(response) {
         // convert the Roo Connection response into JSON data.
         
@@ -76,11 +77,11 @@ Roo.extend(Pman.Request, Roo.data.Connection, {
         this.fireEvent("requestcomplete", this, response, options);
         
         if (this.mask && this.maskEl) {
-            Roo.get(this.maskEl).unmask(false);
+            Roo.get(this.maskEl).unmask(true);
         }
         var res = this.processResponse(response);
                 
-        if (!res.success) { // error!
+        if (!res.success && !res.done) { // error!
             if (options.failure) {
                 // failure is handled... - do not show error..
                 Roo.callback(options.failure, options.scope, [res, options]);
@@ -93,6 +94,7 @@ Roo.extend(Pman.Request, Roo.data.Connection, {
         Roo.callback(options.success, options.scope, [res, options]);
         
     },
+    
     handleFailure : function(response, e){
         this.transId = false;
         var options = response.argument.options;
@@ -102,14 +104,23 @@ Roo.extend(Pman.Request, Roo.data.Connection, {
         if (this.mask && this.maskEl) {
             Roo.get(this.maskEl).unmask(true);
         }
+        if(!this.showFailureDialog){
+            return;
+        }
         if (res !== true) {
             var decode = this.processResponse(response);
             Roo.log(decode);
-            if (Roo.MessageBox.isVisible()) {
-                alert(decode && decode.errorMsg ?  decode.errorMsg : "Error Sending data - return true from failure to remove message");
+            // this pops up even if we have a method to handle failure..
+            if (Roo.MessageBox.isVisible() ) {
+                if (!options.failure) {
+                    alert(decode && decode.errorMsg ?  decode.errorMsg : "Error Sending data - return true from failure to remove message");
+                }
+                
                 return;
-            }            
+            }
+            
             Roo.MessageBox.alert("Error", decode && decode.errorMsg ?  decode.errorMsg : "Error Sending data");
+            
         }
     }
-});
\ No newline at end of file
+});