From 8019c89ea8d019f00b66a3395efb2eb4ce3f32a9 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 5 Oct 2015 11:16:22 +0200 Subject: [PATCH] [IMP] mail: prepare livechat integration - Extract sub-templates for client action's sidebar to ease the livechat integration - Handle livechat's channel_type and messages in chat manager - Make scrollBottom work in the frontend --- addons/mail/static/src/js/chat_manager.js | 13 +- addons/mail/static/src/js/chat_window.js | 2 +- .../mail/static/src/less/client_action.less | 6 +- addons/mail/static/src/xml/chat_window.xml | 3 +- addons/mail/static/src/xml/client_action.xml | 121 ++++++++---------- 5 files changed, 66 insertions(+), 79 deletions(-) diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index b0c5bc5009e..81a5275de94 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -41,11 +41,14 @@ function add_message (data, options) { channel.hidden = false; chat_manager.bus.trigger('new_channel', channel); } - if ((channel.type === "dm") && (options.show_notification)) { + if (!_.contains(["static", "public", "private"], channel.type) && (options.show_notification)) { var query = { is_displayed: false }; chat_manager.bus.trigger('anyone_listening', channel, query); if (!query.is_displayed) { - var title = _t('New message from ') + msg.author_id[1]; + var title = _t('New message'); + if (msg.author_id[1]) { + title += _t(' from ') + msg.author_id[1]; + } var trunc_text = function (t, limit) { return (t.length > limit) ? t.substr(0, limit-1)+'…' : t; }; @@ -177,7 +180,7 @@ function make_channel (data, options) { var channel = { id: data.id, name: data.name, - type: data.type || "public", + type: data.type || data.channel_type, all_history_loaded: false, uuid: data.uuid, is_detached: data.is_minimized, @@ -191,7 +194,9 @@ function make_channel (data, options) { message_ids: [], }}, }; - if (data.public === "private") { + if (channel.type === "channel" && data.public !== "private") { + channel.type = "public"; + } else if (data.public === "private") { channel.type = "private"; } if ('direct_partner' in data) { diff --git a/addons/mail/static/src/js/chat_window.js b/addons/mail/static/src/js/chat_window.js index 73f2ffd7c56..7d7e8ee1f08 100644 --- a/addons/mail/static/src/js/chat_window.js +++ b/addons/mail/static/src/js/chat_window.js @@ -47,7 +47,7 @@ return Widget.extend({ this.thread.render(messages, {display_load_more: false}); }, scrollBottom: function () { - this.$content.scrollTo('max'); + this.$content.scrollTop(this.$content[0].scrollHeight); }, fold: function () { this.$el.animate({ diff --git a/addons/mail/static/src/less/client_action.less b/addons/mail/static/src/less/client_action.less index 53392488146..e76a027bd91 100644 --- a/addons/mail/static/src/less/client_action.less +++ b/addons/mail/static/src/less/client_action.less @@ -48,8 +48,8 @@ width: 100%; .o-webclient-padding(@top: 5px, @bottom: 5px); padding-left: 1.5*@odoo-horizontal-padding; // larger padding than titles - span { - margin-right: 5px; + > input { + padding: 2px 5px; } } } @@ -123,7 +123,7 @@ .o_mail_add_channel { display: none; - input { + > input { color: black; } } diff --git a/addons/mail/static/src/xml/chat_window.xml b/addons/mail/static/src/xml/chat_window.xml index e94c51767c2..01e475a6eb8 100644 --- a/addons/mail/static/src/xml/chat_window.xml +++ b/addons/mail/static/src/xml/chat_window.xml @@ -6,14 +6,13 @@
- +
-
diff --git a/addons/mail/static/src/xml/client_action.xml b/addons/mail/static/src/xml/client_action.xml index e4e80250b92..63c5c7a1c60 100644 --- a/addons/mail/static/src/xml/client_action.xml +++ b/addons/mail/static/src/xml/client_action.xml @@ -1,93 +1,75 @@ - +
+ +
+
+ @ Inbox + +
+
+ Starred +
-
-
- @ Inbox - -
-
- Starred -
- -
-

Channels

- -
- - -
- -
+ public + + Channels -
-
- -
- -
-

Direct Messages

- -
- - -
- - - -
+ + Add a channel -
-
- -
-
-

Private Channels

- -
- - -
- -
+ dm + + Direct Messages + + + true + true + Open chat + + + private + + Private Channels + + + Add a channel -
-
-
- - - - -
- + + +
+

+ +
+
+ + +
+ + + +
+
+
+ +
+
- +
@@ -95,6 +77,7 @@
+