diff options
| author | Romain Derie <rde@odoo.com> | 2019-12-31 13:18:42 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2020-01-29 14:52:23 +0000 |
| commit | 506d29371437f4411a8dedbf86a4ec724892151a (patch) | |
| tree | 6710abc25def8761493479c0494a823dc7712b3f /addons/website | |
| parent | 1f6f76e7ef088ccbcdcf9a01f4a546db7bd83d07 (diff) | |
[FIX] web_editor, *: correctly find `o_snippet_invisible`
*: website
This commit is a safety nest to ensure `o_snippet_invisible` will be
found, even if somehow they appear as one of the editable area elements.
It might be the case with some refactoring, as it was the case between
404fa8164 and 83d99941c, in which case, the step to reproduce were:
- Add s_popup snippet into the page
- In the options, select 'Show On All pages' -> It moves to footer
- Now save and enter Edit mode again
- The invisible element (popup in this case) is in the DOM, the widget
is working fine but it is not retrieved as an invisible element,
thus not possible to edit it
+ lint/dead code
Part of https://github.com/odoo/odoo/pull/41294
task-2087003
Diffstat (limited to 'addons/website')
| -rw-r--r-- | addons/website/static/src/snippets/s_popup/000.js | 6 | ||||
| -rw-r--r-- | addons/website/static/src/snippets/s_popup/options.js | 9 | ||||
| -rw-r--r-- | addons/website/views/snippets/s_popup.xml | 2 |
3 files changed, 5 insertions, 12 deletions
diff --git a/addons/website/static/src/snippets/s_popup/000.js b/addons/website/static/src/snippets/s_popup/000.js index 561388be3af..437626639f6 100644 --- a/addons/website/static/src/snippets/s_popup/000.js +++ b/addons/website/static/src/snippets/s_popup/000.js @@ -2,12 +2,8 @@ odoo.define('website.s_popup', function (require) { 'use strict'; const config = require('web.config'); -const core = require('web.core'); const publicWidget = require('web.public.widget'); -const qweb = core.qweb; -const _t = core._t; - const PopupWidget = publicWidget.Widget.extend({ selector: '.s_popup', events: { @@ -54,7 +50,7 @@ const PopupWidget = publicWidget.Widget.extend({ if (display === 'afterDelay') { this.timeout = setTimeout(() => this._showPopup(), delay); } else { - $(document).on('mouseleave.open_popup', () => this._showPopup()); + $(document).on('mouseleave.open_popup', () => this._showPopup()); } }, /** diff --git a/addons/website/static/src/snippets/s_popup/options.js b/addons/website/static/src/snippets/s_popup/options.js index 1b0a989b991..b6decdec8e9 100644 --- a/addons/website/static/src/snippets/s_popup/options.js +++ b/addons/website/static/src/snippets/s_popup/options.js @@ -1,11 +1,8 @@ odoo.define('website.s_popup_options', function (require) { 'use strict'; -const core = require('web.core'); const options = require('web_editor.snippets.options'); -const qweb = core.qweb; - options.registry.SnippetPopup = options.Class.extend({ /** * @override @@ -41,7 +38,7 @@ options.registry.SnippetPopup = options.Class.extend({ */ moveBlock: function (previewMode, widgetValue, params) { const $container = $(widgetValue === 'moveToFooter' ? 'footer' : 'main'); - this.$target.closest('.s_popup').prependTo($container.find(':o_editable').first()); + this.$target.closest('.s_popup').prependTo($container.find('.oe_structure:o_editable').first()); }, /** * Switch layout from modal <--> a sticky div @@ -66,9 +63,9 @@ options.registry.SnippetPopup = options.Class.extend({ _computeWidgetState: function (methodName, params) { switch (methodName) { case 'moveBlock': - return this.$target.closest('footer').length ? 'moveToFooter': 'moveToBody'; + return this.$target.closest('footer').length ? 'moveToFooter' : 'moveToBody'; case 'setLayout': - return this.$target.hasClass('s_popup_center') ? 'modal': 'fixed'; + return this.$target.hasClass('s_popup_center') ? 'modal' : 'fixed'; } return this._super(...arguments); }, diff --git a/addons/website/views/snippets/s_popup.xml b/addons/website/views/snippets/s_popup.xml index 4bec477b28c..8150aa983ce 100644 --- a/addons/website/views/snippets/s_popup.xml +++ b/addons/website/views/snippets/s_popup.xml @@ -2,7 +2,7 @@ <odoo> <template id="s_popup" name="Popup"> - <div class="s_popup o_snippet_invisible" string="Popup"> + <div class="s_popup o_snippet_invisible"> <div class='modal s_popup_main popup_backdrop s_popup_center o_one_page bg-black-25 ' data-show-after="5000" data-display="afterDelay"> <div class='modal-dialog modal-dialog-centered s_popup_frame modal-md'> <div class='oe_structure modal-content s_popup_content oe_img_bg oe_custom_bg' style="background-color: #FFFFFF"> |
