From ed79f533a6d3373a90db2e1bf6e1095dbb086722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Mon, 18 Jun 2018 00:23:47 +0200 Subject: [IMP] mail: open document threads in thread windows Also roughly called "open chatter in chat windows". With this commit, document threads can now be detached in a small thread window. It uses client-side cross-tab window synchronization by means of the local storage. To detach a document thread in a thread window, click on the document thread preview in the systray messaging menu when receving a new (needaction) document thread message. ------------------------- Technical Limitations ------------------------- 1. In order to use this feature, the user must select the Notification Management 'Handle with Odoo' in the Preferences of the User settings (top-right menu). 2. For the moment, only needaction messages automatically updates the thread window. Manual refresh is still needed for other kinds of messages (e.g. reload document record to fetch new messages in the document thread). Server-side code changes are required to receive new document thread message notifications on the longpoll bus, which would fix the limitations above. ------------------------- Future Works ------------------------- 1. Receive any new message from the document thread window when it is detached. 2. Log a note from the document thread window. Task-33118 --- .../mail/static/src/js/models/document_thread.js | 43 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'addons/mail/static/src/js/models/document_thread.js') diff --git a/addons/mail/static/src/js/models/document_thread.js b/addons/mail/static/src/js/models/document_thread.js index b9671107d9d..92cc26e845b 100644 --- a/addons/mail/static/src/js/models/document_thread.js +++ b/addons/mail/static/src/js/models/document_thread.js @@ -71,6 +71,47 @@ var DocumentThread = Thread.extend({ this._messageIDs.push(message.getID()); } }, + /** + * Overrides to store the thread's state in the LocalStorage, so that it is + * shared between tabs, and restored on F5. + * + * @override + */ + close: function () { + this._super.apply(this, arguments); + this.call('mail_service', 'updateDocumentThreadState', this._id, { + name: this.getName(), + windowState: 'closed', + }); + }, + /** + * Overrides to store the thread's state in the LocalStorage, so that it is + * shared between tabs, and restored on F5. + * + * @override + */ + detach: function () { + this._super.apply(this, arguments); + var windowState = this._folded ? 'folded' : 'open'; + this.call('mail_service', 'updateDocumentThreadState', this._id, { + name: this.getName(), + windowState: windowState, + }); + }, + /** + * Overrides to store the thread's state in the LocalStorage, so that it is + * shared between tabs, and restored on F5. + * + * @override + */ + fold: function () { + this._super.apply(this, arguments); + var windowState = this._folded ? 'folded' : 'open'; + this.call('mail_service', 'updateDocumentThreadState', this._id, { + name: this.getName(), + windowState: windowState, + }); + }, /** * Get the model name of the document that is linked to this document thread * @@ -151,7 +192,7 @@ var DocumentThread = Thread.extend({ _.extend(messageData, { context: data.context, message_type: data.message_type, - subtype: data.subtype, + subtype: data.subtype || "mail.mt_comment", subtype_id: data.subtype_id, }); return self._rpc({ -- cgit v1.2.3