[MOV] im_livechat: move WebsiteLivechatMessage outside of -

-public_livechat.js

Task-2212347

Part-of: odoo/odoo#87597
This commit is contained in:
Nemael
2022-03-30 19:26:57 +02:00
parent 634aa21019
commit a5f8c8a160
2 changed files with 66 additions and 67 deletions
@@ -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;
});
@@ -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";