[FIX] web_editor: disable button when html field loading

Backporting bed33e1 and 472c5a4f9f from v10.0

OPW 1853150
closes #25043
This commit is contained in:
Lucas Perais (lpe)
2018-06-05 09:52:09 +02:00
parent b837bbdd8b
commit 0046bf7292
+25 -2
View File
@@ -289,12 +289,32 @@ var FieldTextHtml = widget.extend({
src += "&datarecord="+ encodeURIComponent(JSON.stringify(datarecord));
return src;
},
_toggleFormButtons: function(enable) {
if (this.$formButtons) {
if (enable) {
this.$formButtons.find('button').removeClass('o_disabled').attr('disabled', false);
} else {
this.$formButtons.find('button').addClass('o_disabled').attr('disabled', true);
}
}
},
initialize_content: function() {
var self = this;
// Do not Forward port in >= 10.0
function getModalButtons() {
var $modal = self.getParent().getParent();
if ($modal && $modal.$footer) {
return $modal.$footer;
}
}
this.$formButtons = this.getParent().$buttons || getModalButtons();
this.$el.closest('.modal-body').css('max-height', 'none');
this.$iframe = this.$el.find('iframe');
// deactivate any button to avoid saving a not ready iframe
$('.o_cp_buttons, .o_statusbar_buttons').find('button').addClass('o_disabled').attr('disabled', true);
// Do not Forward port in >= 10.0
this._toggleFormButtons(false);
this.document = null;
this.$body = $();
this.$content = $();
@@ -321,7 +341,8 @@ var FieldTextHtml = widget.extend({
this._dirty_flag = false;
this.render_value();
// reactivate all the buttons when the field's content (the iframe) is loaded
$('.o_cp_buttons, .o_statusbar_buttons').find('button').removeClass('o_disabled').attr('disabled', false);
// Do not Forward port in >= 10.0
this._toggleFormButtons(true);
setTimeout(function () {
self.add_button();
setTimeout(self.resize,0);
@@ -424,6 +445,8 @@ var FieldTextHtml = widget.extend({
}
},
destroy: function () {
// Do not Forward port in >= 10.0
this._toggleFormButtons(true);
$(window).off('resize', this.resize);
delete window.odoo[this.callback+"_editor"];
delete window.odoo[this.callback+"_content"];