[FIX] web_editor: block only the form's buttons

Commit cae188514f was largely incomplete
and inaccurate in fixing the issue at hand

The aim of this commit is to deactivate the form buttons when the Html field is not completely loaded
thus preventing the temporary value of the iframe to be saved

OPW 1824545
closes #23905
This commit is contained in:
Lucas Perais (lpe)
2018-03-28 09:36:33 +02:00
parent 32421c4daa
commit bed33e1ca2
+8 -3
View File
@@ -194,7 +194,8 @@ var FieldTextHtml = widget.extend({
},
start: function () {
var self = this;
// Do not Forward port in >= 11.0
this.$formButtons = this.getParent().$buttons;
this.callback = _.uniqueId('FieldTextHtml_');
window.odoo[this.callback+"_editor"] = function (EditorBar) {
setTimeout(function () {
@@ -297,7 +298,8 @@ var FieldTextHtml = widget.extend({
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 >= 11.0
this.$formButtons.find('button').addClass('o_disabled').attr('disabled', true);
this.document = null;
this.$body = $();
this.$content = $();
@@ -324,7 +326,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 >= 11.0
this.$formButtons.find('button').removeClass('o_disabled').attr('disabled', false);
setTimeout(function () {
self.add_button();
setTimeout(self.resize,0);
@@ -422,6 +425,8 @@ var FieldTextHtml = widget.extend({
}
},
destroy: function () {
// Do not Forward port in >= 11.0
this.$formButtons.find('button').removeClass('o_disabled').attr('disabled', false);
$(window).off('resize', this.resize);
delete window.odoo[this.callback+"_editor"];
delete window.odoo[this.callback+"_content"];