diff options
| author | Sébastien Theys <seb@odoo.com> | 2020-06-15 18:12:21 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-06-15 18:12:21 +0000 |
| commit | 3fea5b2136627c1d7e83b2a5e111952fe3eb10a1 (patch) | |
| tree | 5eefad07972a87ce4689b83260f981bc87aadad4 /addons/website_livechat/static | |
| parent | 0a82848606151ef60eb6523e9c4c161171f214e7 (diff) | |
[REF] mail, *: refactor messaging with OWL
This commit is a significant rewriting of client-side discuss, chatter,
chat window, and messaging menu using OWL. The behavior should be broadly
the same, with some slight functional changes here and there.
From a technical standpoint, the code of messaging is mainly organized in 2
main groups of modules:
- models, which are logical entities that depict the client-side state of
messaging as a whole.
- components, which are in charge of displaying information from models.
This refactoring also introduces new JS guidelines regarding folder structure
(/static) and naming rules for JS modules.
Community PR: https://github.com/odoo/odoo/pull/39023
Enterprise PR: https://github.com/odoo/enterprise/pull/6249
Task-1914207
This PR is a collaborative work by Alexandre, Julien, Sébastien and Xavier,
with the precious help of Lucas to speed it up towards the end.
closes odoo/odoo#39023
Related: odoo/enterprise#6249
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Co-authored-by: Alexandre Kühn <aku@odoo.com>
Co-authored-by: Julien Giannone <jgi@odoo.com>
Co-authored-by: Lucas Perais <lpe@odoo.com>
Co-authored-by: Sébastien Theys <seb@odoo.com>
Co-authored-by: Xavier Dubuc <xdu@odoo.com>
Diffstat (limited to 'addons/website_livechat/static')
| -rw-r--r-- | addons/website_livechat/static/src/bugfix/bugfix.js | 10 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/bugfix/bugfix.scss | 6 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/bugfix/bugfix.xml | 11 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/bugfix/bugfix_tests.js | 18 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/bugfix/public_bugfix.js | 10 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/bugfix/public_bugfix.scss | 6 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/bugfix/public_bugfix.xml | 11 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/js/channel.js | 34 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/js/thread_window.js | 34 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/legacy/public_livechat.js (renamed from addons/website_livechat/static/src/js/im_livechat.js) | 4 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/scss/mail_thread_visitor_info.scss | 34 | ||||
| -rw-r--r-- | addons/website_livechat/static/src/xml/thread.xml | 60 | ||||
| -rw-r--r-- | addons/website_livechat/static/tests/tours/website_livechat_common.js | 2 |
13 files changed, 75 insertions, 165 deletions
diff --git a/addons/website_livechat/static/src/bugfix/bugfix.js b/addons/website_livechat/static/src/bugfix/bugfix.js new file mode 100644 index 00000000000..b2f0f5e8231 --- /dev/null +++ b/addons/website_livechat/static/src/bugfix/bugfix.js @@ -0,0 +1,10 @@ +/** + * This file allows introducing new JS modules without contaminating other files. + * This is useful when bug fixing requires adding such JS modules in stable + * versions of Odoo. Any module that is defined in this file should be isolated + * in its own file in master. + */ +odoo.define('website_livechat/static/src/bugfix/bugfix.js', function (require) { +'use strict'; + +}); diff --git a/addons/website_livechat/static/src/bugfix/bugfix.scss b/addons/website_livechat/static/src/bugfix/bugfix.scss new file mode 100644 index 00000000000..c4272e527b4 --- /dev/null +++ b/addons/website_livechat/static/src/bugfix/bugfix.scss @@ -0,0 +1,6 @@ +/** +* This file allows introducing new styles without contaminating other files. +* This is useful when bug fixing requires adding new components for instance in +* stable versions of Odoo. Any style that is defined in this file should be isolated +* in its own file in master. +*/ diff --git a/addons/website_livechat/static/src/bugfix/bugfix.xml b/addons/website_livechat/static/src/bugfix/bugfix.xml new file mode 100644 index 00000000000..c17906f75bb --- /dev/null +++ b/addons/website_livechat/static/src/bugfix/bugfix.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<templates xml:space="preserve"> + +<!-- + This file allows introducing new static templates without contaminating other files. + This is useful when bug fixing requires adding new components for instance in stable + versions of Odoo. Any template that is defined in this file should be isolated + in its own file in master. +--> + +</templates> diff --git a/addons/website_livechat/static/src/bugfix/bugfix_tests.js b/addons/website_livechat/static/src/bugfix/bugfix_tests.js new file mode 100644 index 00000000000..24179c314ed --- /dev/null +++ b/addons/website_livechat/static/src/bugfix/bugfix_tests.js @@ -0,0 +1,18 @@ +odoo.define('website_livechat/static/src/bugfix/bugfix_tests.js', function (require) { +'use strict'; + +/** + * This file allows introducing new QUnit test modules without contaminating + * other test files. This is useful when bug fixing requires adding new + * components for instance in stable versions of Odoo. Any test that is defined + * in this file should be isolated in its own file in master. + */ +QUnit.module('website_livechat', {}, function () { +QUnit.module('bugfix', {}, function () { +QUnit.module('bugfix_tests.js', { + +}); +}); +}); + +}); diff --git a/addons/website_livechat/static/src/bugfix/public_bugfix.js b/addons/website_livechat/static/src/bugfix/public_bugfix.js new file mode 100644 index 00000000000..b2f0f5e8231 --- /dev/null +++ b/addons/website_livechat/static/src/bugfix/public_bugfix.js @@ -0,0 +1,10 @@ +/** + * This file allows introducing new JS modules without contaminating other files. + * This is useful when bug fixing requires adding such JS modules in stable + * versions of Odoo. Any module that is defined in this file should be isolated + * in its own file in master. + */ +odoo.define('website_livechat/static/src/bugfix/bugfix.js', function (require) { +'use strict'; + +}); diff --git a/addons/website_livechat/static/src/bugfix/public_bugfix.scss b/addons/website_livechat/static/src/bugfix/public_bugfix.scss new file mode 100644 index 00000000000..c4272e527b4 --- /dev/null +++ b/addons/website_livechat/static/src/bugfix/public_bugfix.scss @@ -0,0 +1,6 @@ +/** +* This file allows introducing new styles without contaminating other files. +* This is useful when bug fixing requires adding new components for instance in +* stable versions of Odoo. Any style that is defined in this file should be isolated +* in its own file in master. +*/ diff --git a/addons/website_livechat/static/src/bugfix/public_bugfix.xml b/addons/website_livechat/static/src/bugfix/public_bugfix.xml new file mode 100644 index 00000000000..c17906f75bb --- /dev/null +++ b/addons/website_livechat/static/src/bugfix/public_bugfix.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<templates xml:space="preserve"> + +<!-- + This file allows introducing new static templates without contaminating other files. + This is useful when bug fixing requires adding new components for instance in stable + versions of Odoo. Any template that is defined in this file should be isolated + in its own file in master. +--> + +</templates> diff --git a/addons/website_livechat/static/src/js/channel.js b/addons/website_livechat/static/src/js/channel.js deleted file mode 100644 index 24d679e8593..00000000000 --- a/addons/website_livechat/static/src/js/channel.js +++ /dev/null @@ -1,34 +0,0 @@ -odoo.define('website.livechat.mail.model.Channel', function (require) { -"use strict"; - -var Channel = require('mail.model.Channel'); -var session = require('web.session'); - -/** - * This class represent channels in JS. In this context, the word channel - * has the same meaning of channel on the server, meaning that direct messages - * (DM) and livechats are also channels. - * - * Any piece of code in JS that make use of channels must ideally interact with - * such objects, instead of direct data from the server. - */ -Channel.include({ - /** - * @override - * Add the visitor if is set on the channel - * @param {Object} params - * @param {Object} params.data - * @param {string} params.data.visitor - */ - init: function (params) { - var self = this; - var data = params.data; - this._visitor = data.visitor; - this._super.apply(this, arguments); - }, - -}); - -return Channel; - -}); diff --git a/addons/website_livechat/static/src/js/thread_window.js b/addons/website_livechat/static/src/js/thread_window.js deleted file mode 100644 index a53d2bcddd5..00000000000 --- a/addons/website_livechat/static/src/js/thread_window.js +++ /dev/null @@ -1,34 +0,0 @@ -odoo.define('website_livechat.ThreadWindow', function (require) { -"use strict"; - -var ThreadWindow = require('mail.ThreadWindow'); -var session = require('web.session'); - -/** - * This is the main widget for rendering small windows for mail.model.Thread. - * Almost all instances of this class are linked to a thread. The sole - * exception is the "blank" thread window. This window let us open another - * thread window, using this "blank" thread window. - */ -ThreadWindow.include({ - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - /** - * @override - */ - close: function () { - var self = this; - if (this.hasThread() && this._thread._type === "livechat" && this._threadWidget._messages.length == 0) { - session.rpc('/im_livechat/close_empty_livechat', {uuid: this._thread._uuid}); - } - else { - this._super(); - } - }, -}); - -return ThreadWindow; - -}); diff --git a/addons/website_livechat/static/src/js/im_livechat.js b/addons/website_livechat/static/src/legacy/public_livechat.js index 1527057b259..6bb1573564d 100644 --- a/addons/website_livechat/static/src/js/im_livechat.js +++ b/addons/website_livechat/static/src/legacy/public_livechat.js @@ -1,9 +1,9 @@ -odoo.define('website_livechat.livechat_request', function (require) { +odoo.define('website_livechat.legacy.website_livechat.livechat_request', function (require) { "use strict"; var utils = require('web.utils'); var session = require('web.session'); -var LivechatButton = require('im_livechat.im_livechat').LivechatButton; +var LivechatButton = require('im_livechat.legacy.im_livechat.im_livechat').LivechatButton; LivechatButton.include({ diff --git a/addons/website_livechat/static/src/scss/mail_thread_visitor_info.scss b/addons/website_livechat/static/src/scss/mail_thread_visitor_info.scss deleted file mode 100644 index df8ed2040f7..00000000000 --- a/addons/website_livechat/static/src/scss/mail_thread_visitor_info.scss +++ /dev/null @@ -1,34 +0,0 @@ -.o_web_client { - &:not(.o_no_thread_window) { - .o_w_visitor_info { - display:none !important; - } - } - &.o_no_thread_window { - .o_mail_thread { - position: sticky; - } - .o_w_visitor_info { - height: 87px; - border-bottom: 1px solid #ced4da; - position: fixed; - background: white; - width: 100%; - z-index: 1; - .o_w_visitor_status { - position: absolute; - bottom: 0; - right: 0; - &.o_w_visitor_disconnected { - color: red; - } - &.o_w_visitor_connected { - color: #00A09D; - } - } - } - .o_w_visitor_info + .o_sub_w_visitor_info { - padding-top: 80px; - } - } -} diff --git a/addons/website_livechat/static/src/xml/thread.xml b/addons/website_livechat/static/src/xml/thread.xml deleted file mode 100644 index aaab8703a52..00000000000 --- a/addons/website_livechat/static/src/xml/thread.xml +++ /dev/null @@ -1,60 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<templates xml:space="preserve"> - <t t-extend="mail.widget.Thread.Content.ASC"> - <t t-jquery=".o_mail_thread_content" t-operation="replace"> - <t t-call="mail.widget.Thread.website.visitor.banner"/> - <div class="o_mail_thread_content o_sub_w_visitor_info"> - <t t-if="options.displayLoadMore" t-call="mail.widget.Thread.LoadMore"/> - <t t-call="mail.widget.Thread.Messages"/> - <t t-if="options.displayBottomThreadFreeSpace"> - <div class="o_thread_bottom_free_space"/> - </t> - </div> - </t> - </t> - - <t t-extend="mail.widget.Thread.Content.DESC"> - <t t-jquery=".o_mail_thread_content" t-operation="replace"> - <t t-call="mail.widget.Thread.website.visitor.banner"/> - <div class="o_mail_thread_content"> - <t t-if="options.messagesSeparatorPosition == 'top'" t-call="mail.MessagesSeparator"/> - <t t-set="messages" t-value="messages.slice().reverse()"/> - <t t-call="mail.widget.Thread.Messages"/> - <t t-if="options.displayLoadMore" t-call="mail.widget.Thread.LoadMore"/> - </div> - </t> - </t> - - <t t-name="mail.widget.Thread.website.visitor.banner"> - <t t-set="visitor" t-value="thread._visitor"/> - <t t-if="visitor"> - <div class="o_w_visitor_info o_thread_message o_mail_discussion d-flex"> - <div class="o_thread_message_sidebar align-self-center"> - <div class="o_thread_message_sidebar_image"> - <img alt="" - t-att-src="visitor.partner_id ? '/web/image/res.partner/' + visitor.partner_id + '/image_128' : '/mail/static/src/img/smiley/avatar.jpg'" - class="o_thread_message_avatar rounded-circle"/> - <span> - <i t-if="visitor.is_connected" aria-label="Visitor is connected" class="o_w_visitor_status o_w_visitor_connected fa fa-circle" role="img" title="Online"></i> - <i t-else="" aria-label="Visitor is offline" class="o_w_visitor_status o_w_visitor_disconnected fa fa-circle" role="img" title="Offline"></i> - </span> - </div> - </div> - <div class="o_thread_message_core pt-2 align-self-center"> - <div class="d-flex"> - <img t-if="visitor.country_code" t-attf-src='base/static/img/country_flags/#{visitor.country_code}.png' class="o_country_flag mr-2 mb-1"/> - <strong class="o_thread_author" t-esc="visitor.name"/> - <span><i class="fa fa-comment-o ml-4 mr-2" aria-label="Lang"/><t t-esc="visitor.lang"/></span> - <span t-if="visitor.website"><i class="fa fa-globe ml-4 mr-2" aria-label="Website"/><span t-esc="visitor.website"/></span> - </div> - <div class="o_thread_message_content"> - <div class="d-flex"> - <span><i class="fa fa-history mr-2" aria-label="History"/></span> - <p t-esc="visitor.history"/> - </div> - </div> - </div> - </div> - </t> - </t> -</templates> diff --git a/addons/website_livechat/static/tests/tours/website_livechat_common.js b/addons/website_livechat/static/tests/tours/website_livechat_common.js index 1ec61f700ec..6568a82f1b4 100644 --- a/addons/website_livechat/static/tests/tours/website_livechat_common.js +++ b/addons/website_livechat/static/tests/tours/website_livechat_common.js @@ -2,7 +2,7 @@ odoo.define('website_livechat.tour_common', function(require) { 'use strict'; var session = require('web.session'); -var LivechatButton = require('im_livechat.im_livechat').LivechatButton; +var LivechatButton = require('im_livechat.legacy.im_livechat.im_livechat').LivechatButton; /** * Alter this method for test purposes. |
