[IMP] display wait throbber/blockUI for network operations taking more than ~3s (aggregated)
lp bug: https://launchpad.net/bugs/854017 fixed bzr revid: xmo@openerp.com-20111027135828-y1q85e8pq2uh3frz
This commit is contained in:
@@ -195,10 +195,20 @@ openerp.web.Loading = openerp.web.Widget.extend(/** @lends openerp.web.Loading#
|
||||
init: function(parent, element_id) {
|
||||
this._super(parent, element_id);
|
||||
this.count = 0;
|
||||
this.blocked_ui = false;
|
||||
this.session.on_rpc_request.add_first(this.on_rpc_event, 1);
|
||||
this.session.on_rpc_response.add_last(this.on_rpc_event, -1);
|
||||
},
|
||||
on_rpc_event : function(increment) {
|
||||
var self = this;
|
||||
if (!this.count && increment === 1) {
|
||||
// Block UI after 3s
|
||||
this.long_running_timer = setTimeout(function () {
|
||||
self.blocked_ui = true;
|
||||
$.blockUI();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
this.count += increment;
|
||||
if (this.count) {
|
||||
//this.$element.html(QWeb.render("Loading", {}));
|
||||
@@ -206,6 +216,12 @@ openerp.web.Loading = openerp.web.Widget.extend(/** @lends openerp.web.Loading#
|
||||
this.$element.show();
|
||||
this.widget_parent.$element.addClass('loading');
|
||||
} else {
|
||||
clearTimeout(this.long_running_timer);
|
||||
// Don't unblock if blocked by somebody else
|
||||
if (self.blocked_ui) {
|
||||
this.blocked_ui = false;
|
||||
$.unblockUI();
|
||||
}
|
||||
this.$element.fadeOut();
|
||||
this.widget_parent.$element.removeClass('loading');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user