[IMP] mail: move hasParentReloadOnFollowersUpdate code to models

Remove code from legacy form in preparation of Owl form.

Part of task-2871070

Part-of: odoo/odoo#93273
This commit is contained in:
Sébastien Theys
2022-06-10 14:58:11 +02:00
parent 910ac4caea
commit 87dc6a035d
5 changed files with 40 additions and 42 deletions
@@ -117,6 +117,10 @@ Object.assign(ChatterContainer, {
type: Boolean,
optional: true,
},
hasParentReloadOnFollowersUpdate: {
type: Boolean,
optional: true,
},
hasTopbarCloseButton: {
type: Boolean,
optional: true,
@@ -47,7 +47,7 @@ export class FollowerListMenu extends Component {
_onClickAddFollowers(ev) {
ev.preventDefault();
this.followerListMenuView.hide();
this.followerListMenuView.chatterOwner.thread.promptAddPartnerFollower();
this.followerListMenuView.chatterOwner.promptAddPartnerFollower();
}
/**
+34
View File
@@ -119,6 +119,37 @@ registerModel({
openAttachmentBoxView() {
this.update({ attachmentBoxView: insertAndReplace() });
},
/**
* Open a dialog to add partners as followers.
*/
promptAddPartnerFollower() {
const action = {
type: 'ir.actions.act_window',
res_model: 'mail.wizard.invite',
view_mode: 'form',
views: [[false, 'form']],
name: this.env._t("Invite Follower"),
target: 'new',
context: {
default_res_model: this.thread.model,
default_res_id: this.thread.id,
},
};
this.env.services.action.doAction(
action,
{
onClose: async () => {
if (!this.exists() && !this.thread) {
return;
}
await this.thread.fetchData(['followers']);
if (this.exists() && this.hasParentReloadOnFollowersUpdate) {
this.reloadParentView();
}
},
}
);
},
async refresh() {
const requestData = ['activities', 'followers', 'suggestedRecipients'];
if (this.hasMessageList) {
@@ -388,6 +419,9 @@ registerModel({
hasParentReloadOnAttachmentsChanged: attr({
default: false,
}),
hasParentReloadOnFollowersUpdate: attr({
default: false,
}),
/**
* Determines whether `this.thread` should be displayed.
*/
-35
View File
@@ -873,12 +873,6 @@ registerModel({
}
await this.notifyPinStateToServer();
},
/**
* Open a dialog to add partners as followers.
*/
promptAddPartnerFollower() {
this._promptAddFollower();
},
/**
* Refresh the typing status of the current partner.
*/
@@ -1687,35 +1681,6 @@ registerModel({
});
}
},
/**
* @private
*/
_promptAddFollower() {
const action = {
type: 'ir.actions.act_window',
res_model: 'mail.wizard.invite',
view_mode: 'form',
views: [[false, 'form']],
name: this.env._t("Invite Follower"),
target: 'new',
context: {
default_res_model: this.model,
default_res_id: this.id,
},
};
this.env.services.action.doAction(
action,
{
onClose: async () => {
if (!this.exists()) {
return;
}
await this.fetchData(['followers']);
owl.Component.env.bus.trigger('Thread:promptAddFollower-closed');
},
}
);
},
/**
* @private
* @returns {Array[]}
@@ -5,8 +5,6 @@ import { ChatterContainer } from '@mail/components/chatter_container/chatter_con
import FormRenderer from 'web.FormRenderer';
import { ComponentWrapper } from 'web.OwlCompatibility';
const { Component } = owl;
class ChatterContainerWrapperComponent extends ComponentWrapper {}
/**
@@ -44,7 +42,6 @@ FormRenderer.include({
this._chatterContainerComponent = undefined;
this.off('o_chatter_rendered', this);
this.off('o_message_posted', this);
Component.env.bus.off('Thread:promptAddFollower-closed', this);
},
//--------------------------------------------------------------------------
@@ -79,9 +76,6 @@ FormRenderer.include({
this.trigger_up('reload', { keepChanges: true });
});
}
if (this.chatterFields.hasRecordReloadOnFollowersUpdate) {
Component.env.bus.on('Thread:promptAddFollower-closed', this, ev => this.trigger_up('reload', { keepChanges: true }));
}
},
/**
* @private
@@ -93,6 +87,7 @@ FormRenderer.include({
hasFollowers: this.chatterFields.hasMessageFollowerIds,
hasMessageList: this.chatterFields.hasMessageIds,
hasParentReloadOnAttachmentsChanged: this.chatterFields.hasRecordReloadOnAttachmentsChanged,
hasParentReloadOnFollowersUpdate: this.chatterFields.hasRecordReloadOnFollowersUpdate,
isAttachmentBoxVisibleInitially: this.chatterFields.isAttachmentBoxVisibleInitially,
threadId: this.state.res_id,
threadModel: this.state.model,