[FIX] portal: no dynamic chatter on edit so no dup

When editing a view on the frontend with a dynamic chatter (chatter
added dynamically to the view), if that part was edited, that
dynamically rendered part would be saved as is. Thus we would get a
duplicated chatter (with the first one statically the rendering at the
edit time).

opw-1813792
closes #23593
This commit is contained in:
Nicolas Lempereur
2018-03-12 13:12:06 +01:00
parent a0b06afcf3
commit 60c920d4a1
+14 -6
View File
@@ -5,6 +5,7 @@ var base = require('web_editor.base');
var ajax = require('web.ajax');
var core = require('web.core');
var Widget = require('web.Widget');
var sAnimation = require('website.content.snippets.animation');
var rpc = require('web.rpc');
var time = require('web.time');
@@ -222,12 +223,19 @@ var PortalChatter = Widget.extend({
},
});
base.ready().then(function () {
$('.o_portal_chatter').each(function (index) {
var $elem = $(this);
var mail_thread = new PortalChatter(null, $elem.data());
mail_thread.appendTo($elem);
});
sAnimation.registry.portal_chatter = sAnimation.Class.extend({
selector: ".o_portal_chatter",
destroy: function () {
this.$target.empty();
return this._super.apply(this, arguments);
},
start: function () {
if (!this.editableMode) {
var mail_thread = new PortalChatter(null, this.$el.data());
mail_thread.appendTo(this.$el);
}
return this._super.apply(this, arguments);
},
});
return {