From a5f8c8a16096d34d5ec451e91543f9725b35b6a2 Mon Sep 17 00:00:00 2001 From: Nemael Date: Fri, 18 Mar 2022 15:03:02 +0000 Subject: [PATCH] [MOV] im_livechat: move WebsiteLivechatMessage outside of - -public_livechat.js Task-2212347 Part-of: odoo/odoo#87597 --- .../legacy/models/website_livechat_message.js | 66 ++++++++++++++++++ .../static/src/legacy/public_livechat.js | 67 ------------------- 2 files changed, 66 insertions(+), 67 deletions(-) create mode 100644 addons/im_livechat/static/src/legacy/models/website_livechat_message.js diff --git a/addons/im_livechat/static/src/legacy/models/website_livechat_message.js b/addons/im_livechat/static/src/legacy/models/website_livechat_message.js new file mode 100644 index 00000000000..0edfadcf1a6 --- /dev/null +++ b/addons/im_livechat/static/src/legacy/models/website_livechat_message.js @@ -0,0 +1,66 @@ +odoo.define('im_livechat.legacy.im_livechat.model.WebsiteLivechatMessage', function (require) { +"use strict"; + +var AbstractMessage = require('im_livechat.legacy.mail.model.AbstractMessage'); + +/** + * This is a message that is handled by im_livechat, without making use of the + * mail.Manager. The purpose of this is to make im_livechat compatible with + * mail.widget.Thread. + * + * @see im_livechat.legacy.mail.model.AbstractMessage for more information. + */ +var WebsiteLivechatMessage = AbstractMessage.extend({ + + /** + * @param {im_livechat.legacy.im_livechat.im_livechat.LivechatButton} parent + * @param {Object} data + * @param {Object} options + * @param {string} options.default_username + * @param {string} options.serverURL + */ + init: function (parent, data, options) { + this._super.apply(this, arguments); + + this._defaultUsername = options.default_username; + this._serverURL = options.serverURL; + }, + + //-------------------------------------------------------------------------- + // Public + //-------------------------------------------------------------------------- + + /** + * Get the relative url of the avatar to display next to the message + * + * @override + * @return {string} + */ + getAvatarSource: function () { + var source = this._serverURL; + if (this.hasAuthor()) { + source += '/web/image/res.partner/' + this.getAuthorID() + '/avatar_128'; + } else { + source += '/mail/static/src/img/smiley/avatar.jpg'; + } + return source; + }, + /** + * Get the text to display for the author of the message + * + * Rule of precedence for the displayed author:: + * + * author name > default usernane + * + * @override + * @return {string} + */ + getDisplayedAuthor: function () { + return this._super.apply(this, arguments) || this._defaultUsername; + }, + +}); + +return WebsiteLivechatMessage; + +}); diff --git a/addons/im_livechat/static/src/legacy/public_livechat.js b/addons/im_livechat/static/src/legacy/public_livechat.js index 3b9ded6f5ae..7ca3d234460 100644 --- a/addons/im_livechat/static/src/legacy/public_livechat.js +++ b/addons/im_livechat/static/src/legacy/public_livechat.js @@ -634,73 +634,6 @@ return { }); -odoo.define('im_livechat.legacy.im_livechat.model.WebsiteLivechatMessage', function (require) { -"use strict"; - -var AbstractMessage = require('im_livechat.legacy.mail.model.AbstractMessage'); - -/** - * This is a message that is handled by im_livechat, without making use of the - * mail.Manager. The purpose of this is to make im_livechat compatible with - * mail.widget.Thread. - * - * @see im_livechat.legacy.mail.model.AbstractMessage for more information. - */ -var WebsiteLivechatMessage = AbstractMessage.extend({ - - /** - * @param {im_livechat.legacy.im_livechat.im_livechat.LivechatButton} parent - * @param {Object} data - * @param {Object} options - * @param {string} options.default_username - * @param {string} options.serverURL - */ - init: function (parent, data, options) { - this._super.apply(this, arguments); - - this._defaultUsername = options.default_username; - this._serverURL = options.serverURL; - }, - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - /** - * Get the relative url of the avatar to display next to the message - * - * @override - * @return {string} - */ - getAvatarSource: function () { - var source = this._serverURL; - if (this.hasAuthor()) { - source += '/web/image/res.partner/' + this.getAuthorID() + '/avatar_128'; - } else { - source += '/mail/static/src/img/smiley/avatar.jpg'; - } - return source; - }, - /** - * Get the text to display for the author of the message - * - * Rule of precedence for the displayed author:: - * - * author name > default usernane - * - * @override - * @return {string} - */ - getDisplayedAuthor: function () { - return this._super.apply(this, arguments) || this._defaultUsername; - }, - -}); - -return WebsiteLivechatMessage; - -}); - odoo.define('im_livechat.legacy.im_livechat.WebsiteLivechatWindow', function (require) { "use strict";