[FIX] website_mass_mailing: add missing s_newsletter_list class
Commit [1], combined with commit [2], added a s_newsletter_list class on two newsletter snippets to move the related newsletter option to the root node that contains the newsletter subscription input. The problem is that no migration script was made thus making it impossible to customize old snippets anymore. We could mark them as outdated... but it happens that marking a snippet as outdated (by incrementing the vxml counter for example) is not straightforward (users that already migrated would not get that XML update). This creates a widget that tries to fix snippets that were malformed, on page load. An upgrade script should be made to fix databases and get rid of this in the future. opw-3243399 opw-3244080 opw-3246089 opw-3246194 opw-3246435 opw-3248473 closes odoo/odoo#117416 X-original-commit: 8d7eaaf916250086cd2f628bd2f3b07cc825959a Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
@@ -140,4 +140,25 @@ publicWidget.registry.subscribe = publicWidget.Widget.extend({
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* This widget tries to fix snippets that were malformed because of a missing
|
||||
* upgrade script. Without this, some newsletter snippets coming from users
|
||||
* upgraded from a version lower than 16.0 may not be able to update their
|
||||
* newsletter block.
|
||||
*
|
||||
* TODO an upgrade script should be made to fix databases and get rid of this.
|
||||
*/
|
||||
publicWidget.registry.fixNewsletterListClass = publicWidget.Widget.extend({
|
||||
selector: '.s_newsletter_subscribe_form:not(.s_subscription_list), .s_newsletter_block',
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
start() {
|
||||
this.$target[0].classList.add('s_newsletter_list');
|
||||
return this._super(...arguments);
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!--
|
||||
Users upgraded from a version lower than 16.0 may have those blocks in their
|
||||
database, without the s_newsletter_list class. See fixNewsletterListClass.
|
||||
-->
|
||||
<template id="s_newsletter_subscribe_form" name="Newsletter">
|
||||
<div class="s_newsletter_subscribe_form s_newsletter_list js_subscribe" data-vxml="001" data-list-id="0" data-name="Newsletter Form">
|
||||
<div class="input-group">
|
||||
@@ -33,6 +37,10 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!--
|
||||
Users upgraded from a version lower than 16.0 may have those blocks in their
|
||||
database, without the s_newsletter_list class. See fixNewsletterListClass.
|
||||
-->
|
||||
<template id="s_newsletter_block" name="Newsletter block">
|
||||
<section class="s_newsletter_block s_newsletter_list pt32 pb32" data-list-id="0">
|
||||
<div class="container">
|
||||
|
||||
Reference in New Issue
Block a user