diff options
| author | qsm-odoo <qsm@odoo.com> | 2019-12-16 17:17:43 +0000 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2019-12-19 15:30:06 +0000 |
| commit | 2a0a0e52dd1d97941b118c4ae9112b6a890e19de (patch) | |
| tree | cbfe0de1f0344e0ef24ed59f8a6921b94af8f3e2 /addons/website_mass_mailing/static/src | |
| parent | 32e294e7dae298edb4d421d78a309f583b2c4fed (diff) | |
[REF] web_editor, *: review invisible element click action
* website, website_mass_mailing
Instead of triggering an event on the invisible element when its related
button in the left panel is clicked, the invisible element's options are
now toggled (shown if were hidden and hidden if were shown). To do that
the new 'onTargetShow' and 'onTargetHide' methods are called, and the
appropriate action can be done there.
Those two new methods are also automatically called in other cases:
- When dropped in the page, after onBuild, 'onTargetShow' is called
for any snippet.
- Before cleanForSave: 'onTargetHide' is called for snippets with the
'o_snippet_invisible' and 'onTargetShow' is called for the others.
In case the element visibility should be toggled another way (like the
close button of a modal), the option can trigger_up an event named
'snippet_option_visibility_update' with a 'show' parameter so that the
the UI is updated accordingly (and so that the options are hidden if
necessary).
Part of https://github.com/odoo/odoo/pull/41789
Diffstat (limited to 'addons/website_mass_mailing/static/src')
| -rw-r--r-- | addons/website_mass_mailing/static/src/js/website_mass_mailing.editor.js | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/addons/website_mass_mailing/static/src/js/website_mass_mailing.editor.js b/addons/website_mass_mailing/static/src/js/website_mass_mailing.editor.js index 83957980e8a..76de1c4b674 100644 --- a/addons/website_mass_mailing/static/src/js/website_mass_mailing.editor.js +++ b/addons/website_mass_mailing/static/src/js/website_mass_mailing.editor.js @@ -65,18 +65,28 @@ options.registry.newsletter_popup = options.registry.mailing_list_subscribe.exte * @override */ start: function () { - var self = this; - this.$target.on('invisible_snippet_activation', function (ev, options) { - // So that the snippet is not enabled again by the editor - ev.stopPropagation(); - self.$target.data('quick-open', true); - options.onSuccess(self._refreshPublicWidgets()); - }); - this.$target.on('shown.bs.modal.newsletter_popup_option hide.bs.modal.newsletter_popup_option', function () { - self.$target.closest('.o_editable').trigger('content_changed'); - self.trigger_up('deactivate_snippet'); + this.$target.on('hidden.bs.modal.newsletter_popup_option', () => { + this.trigger_up('snippet_option_visibility_update', {show: false}); }); - return this._super.apply(this, arguments); + return this._super(...arguments); + }, + /** + * @override + */ + onTargetShow: function () { + // Open the modal + this.$target.data('quick-open', true); + return this._refreshPublicWidgets(); + }, + /** + * @override + */ + onTargetHide: function () { + // Close the modal + const $modal = this.$('.modal'); + if ($modal.length && $modal.is('.modal_shown')) { + $modal.modal('hide'); + } }, /** * @override |
