[FIX] website_mail_channel: stop discussion block disappearing on move

Before this PR, when moving the snippet's position, `d-none` gets added
which should not.

With this PR, removing the `this.$target.addClass('d-none')` from
`cleanForSave` method as it was adding `d-none` unnecessarily while
moving snippets position. The fact is snippet will be hidden if the
current user has no access to the mail group. So that case will be
handled using controllers route `/group/is_member`, if this return email
of the user, snippet is visible else the user has no access to the mail
group so we remove the snippet.

task-3107451

closes odoo/odoo#131131

X-original-commit: 51e92d022d50a7a4adaca872d42849eeaf64f88d
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: qsm-odoo <qsm@odoo.com>
This commit is contained in:
can-odoo
2023-08-09 21:01:12 +02:00
committed by qsm-odoo
co-authored by qsm-odoo
parent 79e05e16ec
commit ef1d17ad2b
2 changed files with 39 additions and 4 deletions
@@ -1,6 +1,7 @@
/** @odoo-module **/
import { _t } from "@web/core/l10n/translation";
import publicWidget from "@web/legacy/js/public/public_widget";
import MailGroup from "@mail_group/js/mail_group";
MailGroup.include({
@@ -43,4 +44,40 @@ MailGroup.include({
this.$el.data('isMember', this.isMember);
},
/**
* @override
*/
destroy: function () {
this.el.classList.add('d-none');
this._super(...arguments);
},
});
// TODO should probably have a better way to handle this, maybe the invisible
// block system could be extended to handle this kind of things. Here we only
// do the same as the non-edit mode public widget: showing and hiding the widget
// but without the rest. Arguably could just enable the whole widget in edit
// mode but not stable-friendly.
publicWidget.registry.MailGroupEditMode = publicWidget.Widget.extend({
selector: MailGroup.prototype.selector,
disabledInEditableMode: false,
/**
* @override
*/
start: function () {
if (this.editableMode) {
this.el.classList.remove('d-none');
}
return this._super(...arguments);
},
/**
* @override
*/
destroy: function () {
if (this.editableMode) {
this.el.classList.add('d-none');
}
this._super(...arguments);
},
});
@@ -28,10 +28,8 @@ options.registry.Group = options.Class.extend({
},
cleanForSave: function () {
// Hide the element by default, this class will be removed
// if the current user has access to the group
this.$target.addClass('d-none');
// TODO: this should probably be done by the public widget, not the
// option code, not important enough to try and fix in stable though.
const emailInput = this.$target.find('.o_mg_subscribe_email');
emailInput.val('');
emailInput.removeAttr('readonly');