|
@ -1,4 +1,6 @@ |
|
|
odoo.define("mail_sent.sent", function(require) { |
|
|
|
|
|
|
|
|
/* Copyright 2020 Denis Mudarisov <https://github.com/trojikman> |
|
|
|
|
|
License MIT (https://opensource.org/licenses/MIT). */
|
|
|
|
|
|
odoo.define("mail_sent.sent", function (require) { |
|
|
"use strict"; |
|
|
"use strict"; |
|
|
|
|
|
|
|
|
var core = require("web.core"); |
|
|
var core = require("web.core"); |
|
@ -9,7 +11,7 @@ odoo.define("mail_sent.sent", function(require) { |
|
|
|
|
|
|
|
|
var ChatAction = core.action_registry.get("mail.chat.instant_messaging"); |
|
|
var ChatAction = core.action_registry.get("mail.chat.instant_messaging"); |
|
|
ChatAction.include({ |
|
|
ChatAction.include({ |
|
|
init: function(parent, action, options) { |
|
|
|
|
|
|
|
|
init: function (parent, action, options) { |
|
|
this._super.apply(this, arguments); |
|
|
this._super.apply(this, arguments); |
|
|
var channel_name = "channel_sent"; |
|
|
var channel_name = "channel_sent"; |
|
|
// Add channel Sent for show "Send message" button
|
|
|
// Add channel Sent for show "Send message" button
|
|
@ -18,44 +20,44 @@ odoo.define("mail_sent.sent", function(require) { |
|
|
this.channels_display_subject.push(channel_name); |
|
|
this.channels_display_subject.push(channel_name); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
update_message_on_current_channel: function(current_channel_id, message) { |
|
|
|
|
|
|
|
|
update_message_on_current_channel: function (current_channel_id, message) { |
|
|
var result = this._super.apply(this, arguments); |
|
|
var result = this._super.apply(this, arguments); |
|
|
var sent = current_channel_id === "channel_sent" && !message.is_sent; |
|
|
var sent = current_channel_id === "channel_sent" && !message.is_sent; |
|
|
return sent || result; |
|
|
return sent || result; |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Inherit class and override methods
|
|
|
|
|
|
var chat_manager_super = _.clone(chat_manager); |
|
|
|
|
|
chat_manager.get_properties = function(msg) { |
|
|
|
|
|
var properties = chat_manager_super.get_properties.apply(this, arguments); |
|
|
|
|
|
properties.is_sent = this.property_descr("channel_sent", msg, this); |
|
|
|
|
|
return properties; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
chat_manager.is_ready.then(function () { |
|
|
|
|
|
// Inherit class and override methods
|
|
|
|
|
|
var chat_manager_super = _.clone(chat_manager); |
|
|
|
|
|
chat_manager.get_properties = function (msg) { |
|
|
|
|
|
var properties = chat_manager_super.get_properties.apply(this, arguments); |
|
|
|
|
|
properties.is_sent = this.property_descr("channel_sent", msg, this); |
|
|
|
|
|
return properties; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
chat_manager.set_channel_flags = function(data, msg) { |
|
|
|
|
|
chat_manager_super.set_channel_flags.apply(this, arguments); |
|
|
|
|
|
if (data.sent && data.author_id[0] === session.partner_id) { |
|
|
|
|
|
msg.is_sent = true; |
|
|
|
|
|
} |
|
|
|
|
|
return msg; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
chat_manager.set_channel_flags = function (data, msg) { |
|
|
|
|
|
chat_manager_super.set_channel_flags.apply(this, arguments); |
|
|
|
|
|
if (data.sent && data.author_id[0] === session.partner_id) { |
|
|
|
|
|
msg.is_sent = true; |
|
|
|
|
|
} |
|
|
|
|
|
return msg; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
chat_manager.get_channel_array = function(msg) { |
|
|
|
|
|
var arr = chat_manager_super.get_channel_array.apply(this, arguments); |
|
|
|
|
|
return arr.concat("channel_sent"); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
chat_manager.get_channel_array = function (msg) { |
|
|
|
|
|
var arr = chat_manager_super.get_channel_array.apply(this, arguments); |
|
|
|
|
|
return arr.concat("channel_sent"); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
chat_manager.get_domain = function(channel) { |
|
|
|
|
|
return channel.id === "channel_sent" |
|
|
|
|
|
? [ |
|
|
|
|
|
["sent", "=", true], |
|
|
|
|
|
["author_id.user_ids", "in", [session.uid]], |
|
|
|
|
|
] |
|
|
|
|
|
: chat_manager_super.get_domain.apply(this, arguments); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
chat_manager.get_domain = function (channel) { |
|
|
|
|
|
return channel.id === "channel_sent" |
|
|
|
|
|
? [ |
|
|
|
|
|
["sent", "=", true], |
|
|
|
|
|
["author_id.user_ids", "in", [session.uid]], |
|
|
|
|
|
] |
|
|
|
|
|
: chat_manager_super.get_domain.apply(this, arguments); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
chat_manager.is_ready.then(function() { |
|
|
|
|
|
// Add sent channel
|
|
|
// Add sent channel
|
|
|
chat_manager.add_channel({ |
|
|
chat_manager.add_channel({ |
|
|
id: "channel_sent", |
|
|
id: "channel_sent", |
|
|