[FIX] pad: render_value binded on change effective_readonly event, so render value calls wait for each others
Proper fix than 9968 revid:dle@openerp.com-20140409160214-1anxi8z07xj49vsp bzr revid: dle@openerp.com-20140409162932-y5fxd5wbojing2t2
This commit is contained in:
parent
83996269ca
commit
c28a5a1021
|
@ -13,6 +13,7 @@ openerp.pad = function(instance) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
self.set("configured", true);
|
self.set("configured", true);
|
||||||
});
|
});
|
||||||
|
this.pad_loading_request = null;
|
||||||
},
|
},
|
||||||
initialize_content: function() {
|
initialize_content: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -25,23 +26,20 @@ openerp.pad = function(instance) {
|
||||||
self.$(".oe_unconfigured").toggle(!configured);
|
self.$(".oe_unconfigured").toggle(!configured);
|
||||||
self.$(".oe_configured").toggle(configured);
|
self.$(".oe_configured").toggle(configured);
|
||||||
});
|
});
|
||||||
this.on("change:effective_readonly", this, this.render_value);
|
this.render_value();
|
||||||
},
|
},
|
||||||
render_value: function() {
|
render_value: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
this._configured_deferred.always(function() {
|
$.when(this._configured_deferred, this.pad_loading_request).always(function() {
|
||||||
if (! self.get('configured')) {
|
if (! self.get('configured')) {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
var value = self.get('value');
|
var value = self.get('value');
|
||||||
if (self.get('effective_readonly')) {
|
if (self.get('effective_readonly')) {
|
||||||
if (_.str.startsWith(value, 'http')) {
|
if (_.str.startsWith(value, 'http')) {
|
||||||
self.$('.oe_pad_content').addClass('oe_pad_loading')
|
self.pad_loading_request = self.view.dataset.call('pad_get_content', {url: value}).done(function(data) {
|
||||||
this.pad_loading_request = self.view.dataset.call('pad_get_content', {url: value}).done(function(data) {
|
self.$('.oe_pad_content').removeClass('oe_pad_loading').html('<div class="oe_pad_readonly"><div>');
|
||||||
if (self.$('.oe_pad_loading').length) {
|
self.$('.oe_pad_readonly').html(data);
|
||||||
self.$('.oe_pad_content').removeClass('oe_pad_loading').html('<div class="oe_pad_readonly"><div>');
|
|
||||||
self.$('.oe_pad_readonly').html(data);
|
|
||||||
}
|
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
self.$('.oe_pad_content').text(_t('Unable to load pad'));
|
self.$('.oe_pad_content').text(_t('Unable to load pad'));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue