From d49200feca07afd595281c70c6aeb9d8c47f61be Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 18 Aug 2022 16:42:37 +0000 Subject: [PATCH] [REF] website, *: remove (deprecated) $target uses in public widgets *: auth_totp_portal, mail_group, portal, survey, web, website_event, website_event_track, website_mail, website_mail_group, website_mass_mailing, website_payment, website_sale Although this is deprecated since 5 years with [1], new occurrences of `this.$target` in widgets kept being introduced. `this.$el` can be used just like in any other widget, or even better: `this.el` to not rely on jQuery. For now, this still keeps the definition. This just removes the bad uses to prevent more copy/paste... let's delay the decision to remove the definition entirely to another day. [1]: https://github.com/odoo/odoo/commit/2972976962617d4b8a0113bae58c640ab41cdff8 closes odoo/odoo#106437 Related: odoo/design-themes#618 Related: odoo/enterprise#34343 Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/totp_frontend.js | 2 +- addons/mail_group/static/src/js/mail_group.js | 24 +++---- addons/portal/static/src/js/portal.js | 2 +- addons/survey/static/src/js/survey_form.js | 6 +- .../src/legacy/js/public/public_widget.js | 6 +- .../src/js/content/snippets.animation.js | 58 ++++++++-------- .../src/snippets/s_dynamic_snippet/000.js | 2 +- .../s_dynamic_snippet_carousel/000.js | 6 +- .../src/snippets/s_image_gallery/000.js | 2 +- .../static/src/snippets/s_popup/000.js | 10 +-- .../src/snippets/s_table_of_content/000.js | 14 ++-- .../static/src/snippets/s_website_form/000.js | 68 +++++++++---------- .../static/src/js/display_timer_widget.js | 2 +- .../js/website_event_track_proposal_form.js | 4 +- addons/website_mail/static/src/js/follow.js | 2 +- .../static/src/snippets/s_group/000.js | 2 +- .../static/src/js/website_mass_mailing.js | 18 ++--- .../static/src/js/website_payment_donation.js | 4 +- .../static/src/snippets/s_donation/000.js | 8 +-- .../static/src/js/website_sale.js | 30 ++++---- 20 files changed, 135 insertions(+), 135 deletions(-) diff --git a/addons/auth_totp_portal/static/src/js/totp_frontend.js b/addons/auth_totp_portal/static/src/js/totp_frontend.js index c456d5dcf70..f14eb55f21c 100644 --- a/addons/auth_totp_portal/static/src/js/totp_frontend.js +++ b/addons/auth_totp_portal/static/src/js/totp_frontend.js @@ -278,7 +278,7 @@ publicWidget.registry.RevokeTrustedDeviceButton = publicWidget.Widget.extend({ this._rpc({ model: 'auth_totp.device', method: 'remove', - args: [parseInt(this.target.id)] + args: [parseInt(this.el.id)] }) ); window.location = window.location; diff --git a/addons/mail_group/static/src/js/mail_group.js b/addons/mail_group/static/src/js/mail_group.js index e1774c0ea34..fce6175cc6d 100644 --- a/addons/mail_group/static/src/js/mail_group.js +++ b/addons/mail_group/static/src/js/mail_group.js @@ -15,8 +15,8 @@ publicWidget.registry.MailGroup = publicWidget.Widget.extend({ * @override */ start: function () { - this.mailgroupId = this.$target.data('id'); - this.isMember = this.$target.data('isMember') || false; + this.mailgroupId = this.$el.data('id'); + this.isMember = this.$el.data('isMember') || false; const searchParams = (new URL(document.location.href)).searchParams; this.token = searchParams.get('token'); this.forceUnsubscribe = searchParams.has('unsubscribe'); @@ -32,15 +32,15 @@ publicWidget.registry.MailGroup = publicWidget.Widget.extend({ */ _onSubscribeBtnClick: async function (ev) { ev.preventDefault(); - const $email = this.$target.find(".o_mg_subscribe_email"); + const $email = this.$el.find(".o_mg_subscribe_email"); const email = $email.val(); if (!email.match(/.+@.+/)) { - this.$target.addClass('o_has_error').find('.form-control, .form-select').addClass('is-invalid'); + this.$el.addClass('o_has_error').find('.form-control, .form-select').addClass('is-invalid'); return false; } - this.$target.removeClass('o_has_error').find('.form-control, .form-select').removeClass('is-invalid'); + this.$el.removeClass('o_has_error').find('.form-control, .form-select').removeClass('is-invalid'); const action = (this.isMember || this.forceUnsubscribe) ? 'unsubscribe' : 'subscribe'; @@ -57,29 +57,29 @@ publicWidget.registry.MailGroup = publicWidget.Widget.extend({ if (response === 'added') { this.isMember = true; - this.$target.find('.o_mg_subscribe_btn').text(_t('Unsubscribe')).removeClass('btn-primary').addClass('btn-outline-primary'); + this.$el.find('.o_mg_subscribe_btn').text(_t('Unsubscribe')).removeClass('btn-primary').addClass('btn-outline-primary'); } else if (response === 'removed') { this.isMember = false; - this.$target.find('.o_mg_subscribe_btn').text(_t('Subscribe')).removeClass('btn-outline-primary').addClass('btn-primary'); + this.$el.find('.o_mg_subscribe_btn').text(_t('Subscribe')).removeClass('btn-outline-primary').addClass('btn-primary'); } else if (response === 'email_sent') { // The confirmation email has been sent - this.$target.html( + this.$el.html( $('