Skip to content
Snippets Groups Projects
Commit 975143a1 authored by can-odoo's avatar can-odoo Committed by qsm-odoo
Browse files

[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#130948

X-original-commit: 2a46580e
Signed-off-by: default avatarQuentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: default avatarqsm-odoo <qsm@odoo.com>
parent b23e5647
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ odoo.define('website_mail_group.mail_group', function (require) {
'use strict';
const core = require('web.core');
const publicWidget = require('web.public.widget');
const _t = core._t;
const MailGroup = require('mail_group.mail_group');
......@@ -45,6 +46,42 @@ 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);
},
});
});
......@@ -30,10 +30,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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment