[FIX] prevent rpc defaults from unblocking db-creation UI in case e.g. db.create() takes more than 3s
bzr revid: xmo@openerp.com-20111205132425-6jr9lv8i4zviwrso
This commit is contained in:
parent
758260b6bb
commit
53603c3365
|
@ -240,6 +240,7 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database
|
|||
init: function(parent, element_id, option_id) {
|
||||
this._super(parent, element_id);
|
||||
this.$option_id = $('#' + option_id);
|
||||
this.unblockUIFunction = $.unblockUI;
|
||||
},
|
||||
start: function() {
|
||||
this._super();
|
||||
|
@ -335,10 +336,26 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database
|
|||
self.widget_parent.do_login(
|
||||
info.db, admin.login, admin.password);
|
||||
self.stop();
|
||||
$.unblockUI();
|
||||
self.unblockUI();
|
||||
});
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Blocks UI and replaces $.unblockUI by a noop to prevent third parties
|
||||
* from unblocking the UI
|
||||
*/
|
||||
blockUI: function () {
|
||||
$.blockUI();
|
||||
$.unblockUI = function () {};
|
||||
},
|
||||
/**
|
||||
* Reinstates $.unblockUI so third parties can play with blockUI, and
|
||||
* unblocks the UI
|
||||
*/
|
||||
unblockUI: function () {
|
||||
$.unblockUI = this.unblockUIFunction;
|
||||
$.unblockUI();
|
||||
},
|
||||
/**
|
||||
* Displays an error dialog resulting from the various RPC communications
|
||||
* failing over themselves
|
||||
|
@ -364,10 +381,10 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database
|
|||
self.$option_id.find("form[name=create_db_form]").validate({
|
||||
submitHandler: function (form) {
|
||||
var fields = $(form).serializeArray();
|
||||
$.blockUI();
|
||||
self.blockUI();
|
||||
self.rpc("/web/database/create", {'fields': fields}, function(result) {
|
||||
if (result.error) {
|
||||
$.unblockUI();
|
||||
self.unblockUI();
|
||||
self.display_error(result);
|
||||
return;
|
||||
}
|
||||
|
@ -415,7 +432,7 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database
|
|||
.html(QWeb.render("BackupDB", self))
|
||||
.find("form[name=backup_db_form]").validate({
|
||||
submitHandler: function (form) {
|
||||
$.blockUI();
|
||||
self.blockUI();
|
||||
self.session.get_file({
|
||||
form: form,
|
||||
error: function (body) {
|
||||
|
@ -425,7 +442,7 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database
|
|||
error: error[1]
|
||||
});
|
||||
},
|
||||
complete: $.unblockUI
|
||||
complete: $.proxy(self, 'unblockUI')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -436,7 +453,7 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database
|
|||
|
||||
self.$option_id.find("form[name=restore_db_form]").validate({
|
||||
submitHandler: function (form) {
|
||||
$.blockUI();
|
||||
self.blockUI();
|
||||
$(form).ajaxSubmit({
|
||||
url: '/web/database/restore',
|
||||
type: 'POST',
|
||||
|
@ -461,9 +478,7 @@ openerp.web.Database = openerp.web.Widget.extend(/** @lends openerp.web.Database
|
|||
})
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
$.unblockUI();
|
||||
}
|
||||
complete: $.proxy(self, 'unblockUI')
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue