[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
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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>
|
||||
<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-call="mail.chat.SidebarItems">
|
||||
<t t-set="input_placeholder">Add a channel</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">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 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>
|
||||
|
||||
Reference in New Issue
Block a user