summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2019-07-24 07:36:59 +0000
committerMartin Trigaux <mat@odoo.com>2019-07-24 10:32:23 +0000
commita98427834e00380e2e63e08668f5c2b069e3c2ea (patch)
treefbefd4a26124efbaf5e6b4bdbf58ec570014c896 /addons/mail/static/src/js
parent4e6ee3ac97041653ff15a77abd77084dc0c9f525 (diff)
parent860ab5a1c28ba85d7a193d68cfbbb1063bbf0651 (diff)
[MERGE] Forward port of saas-12.2 to saas-12.3 up to 860ab5a1c28ba
closes odoo/odoo#35119 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/mail/static/src/js')
-rw-r--r--addons/mail/static/src/js/models/threads/dm_chat.js13
-rw-r--r--addons/mail/static/src/js/models/threads/document_thread.js4
-rw-r--r--addons/mail/static/src/js/models/threads/mixins/thread_typing_mixin.js13
-rw-r--r--addons/mail/static/src/js/services/mail_document_thread_manager.js17
-rw-r--r--addons/mail/static/src/js/services/mail_notification_manager.js3
-rw-r--r--addons/mail/static/src/js/services/mail_status_manager.js32
-rw-r--r--addons/mail/static/src/js/services/mail_window_manager.js13
-rw-r--r--addons/mail/static/src/js/thread_windows/thread_window.js18
8 files changed, 97 insertions, 16 deletions
diff --git a/addons/mail/static/src/js/models/threads/dm_chat.js b/addons/mail/static/src/js/models/threads/dm_chat.js
index c0ba9c527b0..78cc01a7044 100644
--- a/addons/mail/static/src/js/models/threads/dm_chat.js
+++ b/addons/mail/static/src/js/models/threads/dm_chat.js
@@ -101,6 +101,19 @@ var DMChat = TwoUserChannel.extend(ChannelSeenMixin, {
getStatus: function () {
return this.call('mail_service', 'getImStatus', { partnerID: this._directPartnerID });
},
+
+ /**
+ * @param {Object} data
+ * @param {string} data.outOfOfficeMessage
+ * @param {string} data.outOfOfficeDateEnd
+ */
+ updateOutOfOfficeInfo: function (data) {
+ this._outOfOfficeMessage = data.outOfOfficeMessage;
+ this._outOfOfficeDateEnd = data.outOfOfficeDateEnd;
+ this.call('mail_service', 'getMailBus').trigger('updated_out_of_office', {
+ threadID: this.getID(),
+ });
+ }
});
return DMChat;
diff --git a/addons/mail/static/src/js/models/threads/document_thread.js b/addons/mail/static/src/js/models/threads/document_thread.js
index 08e441610ee..b4f1df097cf 100644
--- a/addons/mail/static/src/js/models/threads/document_thread.js
+++ b/addons/mail/static/src/js/models/threads/document_thread.js
@@ -329,7 +329,9 @@ var DocumentThread = Thread.extend({
.then(function (messages) {
messages[0].model = resModel;
messages[0].res_id = resID;
- self.call('mail_service', 'addMessage', messages[0]);
+ self.call('mail_service', 'addMessage', messages[0], {
+ postedFromDocumentThread: true,
+ });
return messages[0];
});
});
diff --git a/addons/mail/static/src/js/models/threads/mixins/thread_typing_mixin.js b/addons/mail/static/src/js/models/threads/mixins/thread_typing_mixin.js
index 7d97538dbb9..3c98836dc70 100644
--- a/addons/mail/static/src/js/models/threads/mixins/thread_typing_mixin.js
+++ b/addons/mail/static/src/js/models/threads/mixins/thread_typing_mixin.js
@@ -171,11 +171,15 @@ var ThreadTypingMixin = {
if (this._isTypingMyselfInfo(params)) {
return;
}
+ var partnerID = params.partnerID;
this._othersTypingTimers.registerTimer({
- timeoutCallbackArguments: [params.partnerID],
- timerID: params.partnerID,
+ timeoutCallbackArguments: [partnerID],
+ timerID: partnerID,
});
- this._typingPartnerIDs.push(params.partnerID);
+ if (_.contains(this._typingPartnerIDs, partnerID)) {
+ return;
+ }
+ this._typingPartnerIDs.push(partnerID);
this._warnUpdatedTypingPartners();
},
/**
@@ -209,6 +213,9 @@ var ThreadTypingMixin = {
unregisterTyping: function (params) {
var partnerID = params.partnerID;
this._othersTypingTimers.unregisterTimer({ timerID: partnerID });
+ if (!_.contains(this._typingPartnerIDs, partnerID)) {
+ return;
+ }
this._typingPartnerIDs = _.reject(this._typingPartnerIDs, function (id) {
return id === partnerID;
});
diff --git a/addons/mail/static/src/js/services/mail_document_thread_manager.js b/addons/mail/static/src/js/services/mail_document_thread_manager.js
index f1d9eefb44a..acf06461a04 100644
--- a/addons/mail/static/src/js/services/mail_document_thread_manager.js
+++ b/addons/mail/static/src/js/services/mail_document_thread_manager.js
@@ -48,23 +48,16 @@ MailManager.include({
*
* @override
* @param {Object} data
- * @param {Array} [data.author_id] [int, string] where int is server ID of
- * the author, and string is the name of the author.
* @param {integer} data.id server ID of the message
- * @param {string} [data.model] the model name of the document that this
- * message is related to.
- * @param {integer} [data.res_id] the ID of the document that this message
- * is related to.
- *
+ * @param {Object} [options]
+ * @param {boolean} [options.postedFromDocumentThread=false]
*/
- addMessage: function (data) {
+ addMessage: function (data, options) {
var message = this.getMessage(data.id);
if (
!message &&
- data.res_id &&
- data.model &&
- data.author_id &&
- data.author_id[0] === session.partner_id
+ options &&
+ options.postedFromDocumentThread
) {
var key = this.DOCUMENT_THREAD_MESSAGE_KEY;
this.call('local_storage', 'setItem', key, data);
diff --git a/addons/mail/static/src/js/services/mail_notification_manager.js b/addons/mail/static/src/js/services/mail_notification_manager.js
index caf0c3c4e12..c22276867b1 100644
--- a/addons/mail/static/src/js/services/mail_notification_manager.js
+++ b/addons/mail/static/src/js/services/mail_notification_manager.js
@@ -417,6 +417,9 @@ MailManager.include({
this._handlePartnerUserConnectionNotification(data);
} else if (data.info === 'channel_seen') {
this._handlePartnerChannnelSeenNotification(data);
+ } else if (data.type === 'simple_notification') {
+ var title = _.escape(data.title), message = _.escape(data.message);
+ data.warning ? this.do_warn(title, message, data.sticky) : this.do_notify(title, message, data.sticky);
} else {
this._handlePartnerChannelNotification(data);
}
diff --git a/addons/mail/static/src/js/services/mail_status_manager.js b/addons/mail/static/src/js/services/mail_status_manager.js
index 7891461c9af..a40299a02d5 100644
--- a/addons/mail/static/src/js/services/mail_status_manager.js
+++ b/addons/mail/static/src/js/services/mail_status_manager.js
@@ -54,13 +54,45 @@ MailManager.include({
updateImStatus: function (statusList) {
var updatedIDs = [];
var self = this;
+ var dmChat;
+ var toUpdateOutOfOfficeChatIDs = [];
_.each(statusList, function (status) {
if (self._imStatus[status.id] === status.im_status) {
return;
}
+ if (
+ status.im_status.indexOf('leave') !== -1 ||
+ (
+ self._imStatus[status.id] &&
+ self._imStatus[status.id].indexOf('leave') !== -1
+ )
+ ) {
+ dmChat = self.getDMChatFromPartnerID(status.id);
+ if (dmChat) {
+ toUpdateOutOfOfficeChatIDs.push(dmChat.getID());
+ }
+ }
updatedIDs.push(status.id);
self._imStatus[status.id] = status.im_status;
});
+ if (!_.isEmpty(toUpdateOutOfOfficeChatIDs)) {
+ this._rpc({
+ model: 'mail.channel',
+ method: 'channel_info',
+ args: [toUpdateOutOfOfficeChatIDs],
+ }).then(function (channelsInfo) {
+ _.each(channelsInfo, function (channelInfo) {
+ dmChat = self.getChannel(channelInfo.id);
+ if (!dmChat) {
+ return;
+ }
+ dmChat.updateOutOfOfficeInfo({
+ outOfOfficeMessage: channelInfo.direct_partner[0].out_of_office_message,
+ outOfOfficeDateEnd: channelInfo.direct_partner[0].out_of_office_date_end,
+ });
+ });
+ });
+ }
if (! _.isEmpty(updatedIDs)) {
this._mailBus.trigger('updated_im_status', updatedIDs); // useful for thread window header
this._renderImStatus(updatedIDs);
diff --git a/addons/mail/static/src/js/services/mail_window_manager.js b/addons/mail/static/src/js/services/mail_window_manager.js
index 6214fc8b5b7..81f0ef7e97c 100644
--- a/addons/mail/static/src/js/services/mail_window_manager.js
+++ b/addons/mail/static/src/js/services/mail_window_manager.js
@@ -344,6 +344,7 @@ MailManager.include({
.on('is_thread_bottom_visible', this, this._onIsThreadBottomVisible)
.on('unsubscribe_from_channel', this, this._onUnsubscribeFromChannel)
.on('updated_im_status', this, this._onUpdatedImStatus)
+ .on('updated_out_of_office', this, this._onUpdatedOutOfOffice)
.on('update_thread_unread_counter', this, this._onUpdateThreadUnreadCounter);
core.bus.on('resize', this, _.debounce(this._repositionThreadWindows.bind(this), 100));
@@ -701,6 +702,18 @@ MailManager.include({
});
},
/**
+ * @private
+ * @param {Object} data
+ * @param {integer} data.threadID
+ */
+ _onUpdatedOutOfOffice: function (data) {
+ var threadWindow = this._getThreadWindow(data.threadID);
+ if (!threadWindow) {
+ return;
+ }
+ threadWindow.renderOutOfOffice();
+ },
+ /**
* Called when a thread has its unread counter that has changed.
* The unread counter on the thread windows should be updated.
*
diff --git a/addons/mail/static/src/js/thread_windows/thread_window.js b/addons/mail/static/src/js/thread_windows/thread_window.js
index 9999014a08d..16d5cd31c86 100644
--- a/addons/mail/static/src/js/thread_windows/thread_window.js
+++ b/addons/mail/static/src/js/thread_windows/thread_window.js
@@ -6,6 +6,7 @@ var BasicComposer = require('mail.composer.Basic');
var core = require('web.core');
+var QWeb = core.qweb;
var _t = core._t;
/**
@@ -153,6 +154,23 @@ var ThreadWindow = AbstractThreadWindow.extend({
removePassive: function () {
this._passive = false;
},
+ renderOutOfOffice: function () {
+ var $outOfOffice = this.$('.o_out_of_office');
+ if (!this.getOutOfOfficeInfo() && !this.getOutOfOfficeMessage()) {
+ if ($outOfOffice.length) {
+ $outOfOffice.remove();
+ }
+ return;
+ }
+ var $newOutOfOffice = $(QWeb.render('mail.thread_window.OutOfOffice', {
+ widget: this,
+ }));
+ if ($outOfOffice.length) {
+ $outOfOffice.replaceWith($newOutOfOffice);
+ } else {
+ $newOutOfOffice.insertAfter(this.$('.o_thread_window_header'));
+ }
+ },
/**
* Update this thread window
*