[IMP] mail: add link to origin channel from message
This commit is contained in:
@@ -32,7 +32,7 @@ function add_message (data, options) {
|
||||
var msg = _.findWhere(messages, { id: data.id });
|
||||
|
||||
if (!msg) {
|
||||
msg = make_message(data, options.channel_id);
|
||||
msg = make_message(data);
|
||||
// Keep the array ordered by date when inserting the new message
|
||||
messages.splice(_.sortedIndex(messages, msg, 'date'), 0, msg);
|
||||
if (options.channel_id) {
|
||||
@@ -59,13 +59,11 @@ function add_message (data, options) {
|
||||
if (!options.silent) {
|
||||
chat_manager.bus.trigger('new_message', msg);
|
||||
}
|
||||
} else if (msg && options.channel_id !== undefined) {
|
||||
add_channel_to_message(msg, options.channel_id);
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
function make_message (data, channel_id) {
|
||||
function make_message (data) {
|
||||
var msg = {
|
||||
id: data.id,
|
||||
author_id: data.author_id,
|
||||
@@ -78,7 +76,7 @@ function make_message (data, channel_id) {
|
||||
email_from: data.email_from,
|
||||
record_name: data.record_name,
|
||||
tracking_value_ids: data.tracking_value_ids,
|
||||
channel_ids: (channel_id !== undefined ? [channel_id] : []),
|
||||
channel_ids: data.channel_ids,
|
||||
model: data.model,
|
||||
res_id: data.res_id,
|
||||
};
|
||||
@@ -116,6 +114,13 @@ function make_message (data, channel_id) {
|
||||
if (_.contains(data.starred_partner_ids, session.partner_id)) {
|
||||
msg.is_starred = true;
|
||||
}
|
||||
var real_channels = _.without(msg.channel_ids, 'channel_inbox', 'channel_starred');
|
||||
var origin = real_channels.length ? real_channels[0] : undefined;
|
||||
var channel;
|
||||
if (origin && (channel = _.findWhere(channels, {id: origin}))) {
|
||||
msg.origin_id = origin;
|
||||
msg.origin_name = channel.name;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,9 @@ var ChatAction = Widget.extend(ControlPanelMixin, {
|
||||
this.$buttons.on('click', '.o_mail_chat_button_detach', this.on_click_button_detach);
|
||||
|
||||
this.thread.on('redirect', this, this.on_redirect);
|
||||
this.thread.on('redirect_to_channel', this, function (channel_id) {
|
||||
this.set_channel(chat_manager.get_channel(channel_id));
|
||||
});
|
||||
this.thread.on('load_more_messages', this, this.load_more_messages);
|
||||
this.thread.on('mark_as_read', this, function (message_id) {
|
||||
chat_manager.mark_as_read(message_id);
|
||||
@@ -340,6 +343,7 @@ var ChatAction = Widget.extend(ControlPanelMixin, {
|
||||
return {
|
||||
display_load_more: !chat_manager.all_history_loaded(this.channel, this.domain),
|
||||
display_needactions: this.channel.display_needactions,
|
||||
channel_id: this.channel.id,
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ var Thread = Widget.extend({
|
||||
|
||||
events: {
|
||||
"click .o_mail_redirect": "on_click_redirect",
|
||||
"click .o_channel_redirect": "on_channel_redirect",
|
||||
"click .o_thread_show_more": "on_click_show_more",
|
||||
"click .o_thread_message_needaction": function (event) {
|
||||
event.stopPropagation();
|
||||
@@ -80,6 +81,12 @@ var Thread = Widget.extend({
|
||||
this.trigger('redirect', res_model, res_id);
|
||||
},
|
||||
|
||||
on_channel_redirect: function (event) {
|
||||
event.preventDefault();
|
||||
var channel_id = $(event.target).data('channel-id');
|
||||
this.trigger('redirect_to_channel', channel_id);
|
||||
},
|
||||
|
||||
on_click_show_more: function () {
|
||||
this.trigger('load_more_messages');
|
||||
},
|
||||
|
||||
@@ -73,6 +73,9 @@
|
||||
.o_mail_mailto, .o_mail_mailto:hover {
|
||||
.text-muted();
|
||||
}
|
||||
.o_channel_redirect {
|
||||
color: gray;
|
||||
}
|
||||
}
|
||||
|
||||
.o_thread_message_star, .o_thread_message_needaction {
|
||||
|
||||
@@ -83,6 +83,9 @@
|
||||
<t t-if="message.model && (message.model != 'mail.channel') && options.display_document_link">
|
||||
on <a class="o_mail_redirect" href="#" t-att-data-oe-model="message.model" t-att-data-oe-id="message.res_id"><t t-esc="message.record_name"/></a>
|
||||
</t>
|
||||
<t t-if="message.origin_id && (message.origin_id !== options.channel_id)">
|
||||
(in channel <a class="o_channel_redirect" t-att-data-channel-id="message.origin_id" href="#"><t t-esc="message.origin_name"/>)</a>
|
||||
</t>
|
||||
</p>
|
||||
<t t-if="message.tracking_value_ids && message.tracking_value_ids.length > 0">
|
||||
<t t-call="mail.ChatThread.MessageTracking"/>
|
||||
|
||||
Reference in New Issue
Block a user