summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/models/threads/dm_chat.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/mail/static/src/js/models/threads/dm_chat.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/mail/static/src/js/models/threads/dm_chat.js')
-rw-r--r--addons/mail/static/src/js/models/threads/dm_chat.js109
1 files changed, 0 insertions, 109 deletions
diff --git a/addons/mail/static/src/js/models/threads/dm_chat.js b/addons/mail/static/src/js/models/threads/dm_chat.js
deleted file mode 100644
index 177c5224ea4..00000000000
--- a/addons/mail/static/src/js/models/threads/dm_chat.js
+++ /dev/null
@@ -1,109 +0,0 @@
-odoo.define('mail.model.DMChat', function (require) {
-"use strict";
-
-var ChannelSeenMixin = require('mail.model.ChannelSeenMixin');
-var TwoUserChannel = require('mail.model.TwoUserChannel');
-
-var core = require('web.core');
-const { str_to_datetime } = require('web.time');
-
-var _t = core._t;
-
-/**
- * Any piece of code in JS that make use of DMs must ideally interact with
- * such objects, instead of direct data from the server.
- */
-var DMChat = TwoUserChannel.extend(ChannelSeenMixin, {
- /**
- * @override
- * @param {Object} params
- * @param {Object} params.data
- * @param {string|undefined} [params.custom_channel_name] if set, use this
- * custom name for this DM
- * @param {Object[]} params.data.direct_partner
- * @param {integer} params.data.direct_partner[0].id
- * @param {string} params.data.direct_partner[0].im_status
- * @param {string} params.data.direct_partner[0].name
- * @param {string} [params.data.direct_partner[0].out_of_office_date_end]
- */
- init: function (params) {
- this._super.apply(this, arguments);
- ChannelSeenMixin.init.apply(this, arguments);
-
- var data = params.data;
-
- this._directPartnerID = data.direct_partner[0].id;
- this._name = data.custom_channel_name || data.direct_partner[0].name;
- this._outOfOfficeDateEnd = data.direct_partner[0].out_of_office_date_end;
- this._type = 'dm_chat';
-
- this.call('mail_service', 'updateImStatus', [{
- id: this._directPartnerID,
- im_status: data.direct_partner[0].im_status
- }]);
- },
-
- //--------------------------------------------------------------------------
- // Public
- //--------------------------------------------------------------------------
-
- /**
- * Get the direct partner ID linked to the DM, i.e. the partner ID of the
- * user at the other end of the DM conversation. All DM chats do have a
- * direct partner iD.
- *
- * @returns {integer}
- */
- getDirectPartnerID: function () {
- return this._directPartnerID;
- },
- /**
- * Get the out of office info
- *
- * @override {mail.model.AbstractThread}
- * @returns {string|undefined}
- */
- getOutOfOfficeInfo: function () {
- if (!this._outOfOfficeDateEnd) {
- return undefined;
- }
- var currentDate = new Date();
- var date = str_to_datetime(this._outOfOfficeDateEnd);
- var options = { day: 'numeric', month: 'short' };
- if (currentDate.getFullYear() !== date.getFullYear()) {
- options.year = 'numeric';
- }
- var formattedDate = date.toLocaleDateString(window.navigator.language, options);
- return _.str.sprintf(_t("Out of office until %s"), formattedDate);
- },
- /**
- * @override
- */
- getPreview: function () {
- var result = this._super.apply(this, arguments);
- result.imageSRC = '/web/image/res.partner/' + this.getDirectPartnerID() + '/image_128';
- return result;
- },
- /**
- * @override
- * @return {string}
- */
- getStatus: function () {
- return this.call('mail_service', 'getImStatus', { partnerID: this._directPartnerID });
- },
-
- /**
- * @param {Object} data
- * @param {string} data.outOfOfficeDateEnd
- */
- updateOutOfOfficeInfo: function (data) {
- this._outOfOfficeDateEnd = data.outOfOfficeDateEnd;
- this.call('mail_service', 'getMailBus').trigger('updated_out_of_office', {
- threadID: this.getID(),
- });
- }
-});
-
-return DMChat;
-
-});