[FIX] website_mass_mailing: restore newsletter inputs post-upgrade
Commit [1] renamed the "js_subscribe_email" class into "js_subscribe_value" as the same subscription feature layout is now available for sms (not only email). The problem was that no upgrade script was made to convert the old class in old databases... so newly migrated users have a traceback on all pages which contain a newsletter. For now, this patches the JS to support both class names. In the future, we'll probably have to remove the compatibility and make an upgrade script about the old class. [1]: https://github.com/odoo/odoo/commit/bd6ef64f4c79b9c04dc8b85dc2daccb61d55cad0 opw-3243399 opw-3244080 opw-3246089 opw-3246194 opw-3246435 opw-3248473 X-original-commit: 2b16b4d7b2041b20c0537d78d78f447164fef5fe Part-of: odoo/odoo#117416
This commit is contained in:
@@ -70,7 +70,7 @@ publicWidget.registry.subscribe = publicWidget.Widget.extend({
|
||||
const isSubscriber = data.is_subscriber;
|
||||
const subscribeBtnEl = this.el.querySelector('.js_subscribe_btn');
|
||||
const thanksBtnEl = this.el.querySelector('.js_subscribed_btn');
|
||||
const valueInputEl = this.el.querySelector('input.js_subscribe_value');
|
||||
const valueInputEl = this.el.querySelector('input.js_subscribe_value, input.js_subscribe_email'); // js_subscribe_email is kept by compatibility (it was the old name of js_subscribe_value)
|
||||
|
||||
subscribeBtnEl.disabled = isSubscriber;
|
||||
valueInputEl.value = data.value || '';
|
||||
@@ -96,7 +96,7 @@ publicWidget.registry.subscribe = publicWidget.Widget.extend({
|
||||
_onSubscribeClick: async function () {
|
||||
var self = this;
|
||||
const inputName = this.$('input').attr('name');
|
||||
const $input = this.$(".js_subscribe_value:visible");
|
||||
const $input = this.$(".js_subscribe_value:visible, .js_subscribe_email:visible"); // js_subscribe_email is kept by compatibility (it was the old name of js_subscribe_value)
|
||||
if (inputName === 'email' && $input.length && !$input.val().match(/.+@.+/)) {
|
||||
this.$el.addClass('o_has_error').find('.form-control').addClass('is-invalid');
|
||||
return false;
|
||||
@@ -125,7 +125,7 @@ publicWidget.registry.subscribe = publicWidget.Widget.extend({
|
||||
if (toastType === 'success') {
|
||||
self.$(".js_subscribe_btn").addClass('d-none');
|
||||
self.$(".js_subscribed_btn").removeClass('d-none');
|
||||
self.$('input.js_subscribe_value').prop('disabled', !!result);
|
||||
self.$('input.js_subscribe_value, input.js_subscribe_email').prop('disabled', !!result); // js_subscribe_email is kept by compatibility (it was the old name of js_subscribe_value)
|
||||
const $popup = self.$el.closest('.o_newsletter_modal');
|
||||
if ($popup.length) {
|
||||
$popup.modal('hide');
|
||||
|
||||
@@ -16,7 +16,7 @@ PopupWidget.include({
|
||||
_canShowPopup() {
|
||||
if (
|
||||
this.$el.is('.o_newsletter_popup') &&
|
||||
this.$el.find('input.js_subscribe_value').prop('disabled')
|
||||
this.$el.find('input.js_subscribe_value, input.js_subscribe_email').prop('disabled') // js_subscribe_email is kept by compatibility (it was the old name of js_subscribe_value)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user