summaryrefslogtreecommitdiff
path: root/addons/website_livechat/static/src/js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-06-15 18:12:21 +0000
committerSébastien Theys <seb@odoo.com>2020-06-15 18:12:21 +0000
commit3fea5b2136627c1d7e83b2a5e111952fe3eb10a1 (patch)
tree5eefad07972a87ce4689b83260f981bc87aadad4 /addons/website_livechat/static/src/js
parent0a82848606151ef60eb6523e9c4c161171f214e7 (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/src/js')
-rw-r--r--addons/website_livechat/static/src/js/channel.js34
-rw-r--r--addons/website_livechat/static/src/js/im_livechat.js47
-rw-r--r--addons/website_livechat/static/src/js/thread_window.js34
3 files changed, 0 insertions, 115 deletions
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/im_livechat.js b/addons/website_livechat/static/src/js/im_livechat.js
deleted file mode 100644
index 1527057b259..00000000000
--- a/addons/website_livechat/static/src/js/im_livechat.js
+++ /dev/null
@@ -1,47 +0,0 @@
-odoo.define('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;
-
-
-LivechatButton.include({
-
- /**
- * @override
- * Check if a chat request is opened for this visitor
- * if yes, replace the session cookie and start the conversation immediately.
- * Do this before calling super to have everything ready before executing existing start logic.
- * This is used for chat request mechanism, when an operator send a chat request
- * from backend to a website visitor.
- */
- willStart: function () {
- if (this.options.chat_request_session) {
- utils.set_cookie('im_livechat_session', JSON.stringify(this.options.chat_request_session), 60*60);
- }
- return this._super();
- },
-
- /**
- * @override
- * Called when the visitor closes the livechat chatter the first time (first click on X button)
- * this will deactivate the mail_channel, clean the chat request if any
- * and allow the operators to send the visitor a new chat request
- */
- _onCloseChatWindow: function (ev) {
- this._super(ev);
- var cookie = utils.get_cookie('im_livechat_session');
- if (cookie) {
- var channel = JSON.parse(cookie);
- session.rpc('/im_livechat/visitor_leave_session', {uuid: channel.uuid});
- utils.set_cookie('im_livechat_session', "", -1); // remove cookie
- }
- },
-});
-
-return {
- LivechatButton: LivechatButton,
-};
-
-});
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;
-
-});