diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2018-04-30 14:44:32 +0200 |
|---|---|---|
| committer | Lucas Perais (lpe) <lpe@odoo.com> | 2018-05-02 09:58:04 +0200 |
| commit | 472c5a4f9fa262f2ec2e10f4ad3e97c8c1bf4083 (patch) | |
| tree | 41d9f375f965e6ba8b42183d6d963680804d2d86 /addons/web_editor | |
| parent | 5ff3c03410127477dc1b9563f2fd48e754510b52 (diff) | |
[FIX] web_editor: disable button when html field loading
Commit bed33e1ca241c9cb0ff22897dbe60af476d59590 forgot to include the case
where the html field is in a modal
This commit accounts for that case
closes #24500
Diffstat (limited to 'addons/web_editor')
| -rw-r--r-- | addons/web_editor/static/src/js/backend.js | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js index b160e6a7e97..964ececa06b 100644 --- a/addons/web_editor/static/src/js/backend.js +++ b/addons/web_editor/static/src/js/backend.js @@ -194,8 +194,6 @@ 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 () { @@ -293,13 +291,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 >= 11.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 // Do not Forward port in >= 11.0 - this.$formButtons.find('button').addClass('o_disabled').attr('disabled', true); + this._toggleFormButtons(false); this.document = null; this.$body = $(); this.$content = $(); @@ -327,7 +344,7 @@ var FieldTextHtml = widget.extend({ this.render_value(); // reactivate all the buttons when the field's content (the iframe) is loaded // Do not Forward port in >= 11.0 - this.$formButtons.find('button').removeClass('o_disabled').attr('disabled', false); + this._toggleFormButtons(true); setTimeout(function () { self.add_button(); setTimeout(self.resize,0); @@ -426,7 +443,7 @@ var FieldTextHtml = widget.extend({ }, destroy: function () { // Do not Forward port in >= 11.0 - this.$formButtons.find('button').removeClass('o_disabled').attr('disabled', false); + this._toggleFormButtons(true); $(window).off('resize', this.resize); delete window.odoo[this.callback+"_editor"]; delete window.odoo[this.callback+"_content"]; |
