summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2015-10-05 11:16:22 +0200
committerAaron Bohy <aab@odoo.com>2015-10-06 16:24:28 +0200
commit8019c89ea8d019f00b66a3395efb2eb4ce3f32a9 (patch)
tree33e8fc703ba7384246bbd02f866644d93f3e016d /addons
parent01caecf1c76691593958a73b7a45650693888830 (diff)
[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
Diffstat (limited to 'addons')
-rw-r--r--addons/mail/static/src/js/chat_manager.js13
-rw-r--r--addons/mail/static/src/js/chat_window.js2
-rw-r--r--addons/mail/static/src/less/client_action.less6
-rw-r--r--addons/mail/static/src/xml/chat_window.xml3
-rw-r--r--addons/mail/static/src/xml/client_action.xml119
5 files changed, 65 insertions, 78 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)+'&hellip;' : 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 @@
<div class="o_chat_window">
<div class="o_chat_header">
<span class="o_chat_title">
- <t t-raw="widget.title"/>
+ <t t-esc="widget.title"/>
</span>
<span>
<a href="#" class="o_chat_window_close fa fa-close"></a>
</span>
</div>
<div class="o_chat_content">
- <!-- <t t-call="mail.chat.im.Conversation.messages"/> -->
</div>
<div class="o_chat_input">
<input t-att-placeholder="widget.placeholder"/>
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 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
- <!--
- ChatMailThread
- Layout of the client action
- param: widget: the widget (ChatMailThread)
- -->
+ <!-- Client Action -->
<t t-name="mail.client_action">
<div class="o_mail_chat">
<div class="o_mail_chat_sidebar"/>
<div class="o_mail_chat_content"/>
</div>
</t>
+ <t t-name="mail.chat.Sidebar">
+ <div class="o_mail_chat_sidebar">
+ <div class="o_mail_chat_channel_item" data-channel-id="channel_inbox">
+ @ Inbox
+ <t t-call="mail.chat.SidebarNeedaction"/>
+ </div>
+ <div class="o_mail_chat_channel_item" data-channel-id="channel_starred">
+ <span class="fa fa-star-o"/> Starred
+ </div>
- <div t-name="mail.chat.Sidebar" class="o_mail_chat_sidebar">
- <div class="o_mail_chat_channel_item" data-channel-id="channel_inbox">
- @ Inbox
- <t t-call="mail.chat.SidebarNeedaction"/>
- </div>
- <div class="o_mail_chat_channel_item" data-channel-id="channel_starred">
- <span class="fa fa-star-o"/> Starred
- </div>
-
- <div class="o_mail_sidebar_title">
- <h4>Channels</h4>
- <span class="fa fa-plus o_add" data-type="public"/>
- </div>
- <t t-foreach="channels" t-as="channel">
- <t t-if="channel.type === 'public'">
- <div class="o_mail_chat_channel_item" t-att-data-channel-id="channel.id">
- <t t-esc="channel.name"/>
- </div>
+ <t t-set="channel_type">public</t>
+ <t t-call="mail.chat.SidebarTitle">
+ <t t-set="channel_title">Channels</t>
+ </t>
+ <t t-call="mail.chat.SidebarItems">
+ <t t-set="input_placeholder">Add a channel</t>
</t>
- </t>
- <div class="o_mail_add_channel" data-type="public">
- <input type="text" placeholder="Add a channel"/>
- </div>
- <div class="o_mail_sidebar_title">
- <h4>Direct Messages</h4>
- <span class="fa fa-plus o_add" data-type="dm"/>
- </div>
- <t t-foreach="channels" t-as="channel">
- <t t-if="channel.type === 'dm'">
- <div class="o_mail_chat_channel_item" t-att-data-channel-id="channel.id">
- <i t-att-class="'fa ' + (channel.status == 'online' ? 'fa-circle' : 'fa-circle-o')"/>
- <t t-esc="channel.name"/>
- <span class="fa fa-times pull-right o_mail_partner_unpin" t-att-title="_t('Close')" t-att-data-channel-id="channel.id"/>
- </div>
+ <t t-set="channel_type">dm</t>
+ <t t-call="mail.chat.SidebarTitle">
+ <t t-set="channel_title">Direct Messages</t>
+ </t>
+ <t t-call="mail.chat.SidebarItems">
+ <t t-set="display_status">true</t>
+ <t t-set="display_close_button">true</t>
+ <t t-set="input_placeholder">Open chat</t>
</t>
- </t>
- <div class="o_mail_add_channel" data-type="dm">
- <input type="text" placeholder="Open chat"/>
- </div>
- <div class="o_mail_sidebar_title">
- <h4>Private Channels</h4>
- <span class="fa fa-plus o_add" data-type="private"/>
- </div>
- <t t-foreach="channels" t-as="channel">
- <t t-if="channel.type === 'private'">
- <div class="o_mail_chat_channel_item" t-att-data-channel-id="channel.id">
- <t t-esc="channel.name"/>
- </div>
+ <t t-set="channel_type">private</t>
+ <t t-call="mail.chat.SidebarTitle">
+ <t t-set="channel_title">Private Channels</t>
+ </t>
+ <t t-call="mail.chat.SidebarItems">
+ <t t-set="input_placeholder">Add a channel</t>
</t>
- </t>
- <div class="o_mail_add_channel" data-type="private">
- <input type="text" placeholder="Add a channel"/>
</div>
-
-
- <!-- <a href="#" class="o_mail_chat_add_more_text"><span class="fa fa-plus"/>Add</a>
- <div class="o_mail_chat_add_more_search_bar" style="display: none;">
- <input type="text"/>
- </div> -->
- <!-- <t t-call="mail.chat.ChatMailThread.channels">
- <t t-set="channel_slot" t-value="'channel_private_group'"/>
- </t> -->
- </div>
-
+ </t>
<t t-name="mail.chat.SidebarNeedaction">
<span t-attf-class="o_mail_sidebar_needaction badge pull-right #{(!needaction_counter ? 'hide' : '')}">
<t t-esc="needaction_counter"/>
</span>
</t>
+ <t t-name="mail.chat.SidebarTitle">
+ <div class="o_mail_sidebar_title">
+ <h4><t t-esc="channel_title"/></h4>
+ <span t-if="!disable_add_channel" class="fa fa-plus o_add" t-att-title="_t('Add')" t-attf-data-type="#{channel_type}"/>
+ </div>
+ </t>
+ <t t-name="mail.chat.SidebarItems">
+ <t t-foreach="channels" t-as="channel">
+ <div t-if="channel.type === channel_type" class="o_mail_chat_channel_item" t-att-data-channel-id="channel.id">
+ <i t-if="display_status" t-att-class="'fa ' + (channel.status == 'online' ? 'fa-circle' : 'fa-circle-o')"/>
+ <t t-esc="channel.name"/>
+ <span t-if="display_close_button" class="fa fa-times pull-right o_mail_partner_unpin" t-att-title="_t('Close')" t-att-data-channel-id="channel.id"/>
+ </div>
+ </t>
+ <div t-if="!disable_add_channel" class="o_mail_add_channel" t-attf-data-type="#{channel_type}">
+ <input type="text" t-attf-placeholder="#{input_placeholder}"/>
+ </div>
+ </t>
- <!--
- Buttons of the Control Panel
- -->
+ <!-- Buttons of the Control Panel -->
<t t-name="mail.chat.ControlButtons">
<div>
<button type="button" class="btn btn-primary btn-sm o_mail_chat_button_invite" t-att-title='_t("Invite people")'>Invite</button>
@@ -95,6 +77,7 @@
</div>
</t>
+ <!-- Invite dialog's content -->
<div t-name="mail.PartnerInviteDialog">
<input type="text" class="o_mail_chat_partner_invite_input" id="mail_search_partners"/>
</div>