X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=Pman.Request.js;h=b4db0f0783dd2c3c096a2fea9cc96d53ec154817;hp=57f6dd6e6fb71e4b2723299d2cd854711836817d;hb=refs%2Fheads%2Fwip_edward_T5851_download_old_offer_sheet;hpb=ace9c1ce97946a97d80e48ff519ad316642ce4db diff --git a/Pman.Request.js b/Pman.Request.js index 57f6dd6e..b4db0f07 100644 --- a/Pman.Request.js +++ b/Pman.Request.js @@ -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){ @@ -42,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. @@ -74,17 +77,15 @@ Roo.extend(Pman.Request, Roo.data.Connection, { this.fireEvent("requestcomplete", this, response, options); if (this.mask && this.maskEl) { - Roo.get(this.maskEl).unmask(); + Roo.get(this.maskEl).unmask(true); } - var res = this.processResponse(response); if (!res.success) { // error! if (options.failure) { // failure is handled... - do not show error.. - if (true === Roo.callback(options.failure, options.scope, [res, options])) { - return; - } + Roo.callback(options.failure, options.scope, [res, options]); + return; } Roo.MessageBox.hide(); // hide any existing messages.. Roo.MessageBox.alert("Error", res && res.errorMsg ? res.errorMsg : "Error Sending data"); @@ -100,16 +101,22 @@ Roo.extend(Pman.Request, Roo.data.Connection, { this.fireEvent("requestexception", this, response, options, e); var res = Roo.callback(options.failure, options.scope, [response, options]); if (this.mask && this.maskEl) { - Roo.get(this.maskEl).unmask(); + Roo.get(this.maskEl).unmask(true); + } + if(!this.showFailureDialog){ + return; } if (res !== true) { var decode = this.processResponse(response); Roo.log(decode); - if (Roo.MessageBox.isVisable()) { - alert(decode && decode.errorMsg ? decode.errorMsg : "Error Sending data"); + + if (Roo.MessageBox.isVisible()) { + 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 +});