diff options
| author | Alexandre Kühn <aku@odoo.com> | 2020-09-07 09:26:38 +0000 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2020-09-11 10:40:22 +0000 |
| commit | 4a693c0233d3fbfdc991e2ccbfcbcd2d360ce788 (patch) | |
| tree | 79d4b3124355f7fdf4cb0cf18578bba24b2aa344 /addons/im_livechat/static/src | |
| parent | 170cd2a0217c8d172115dee32e1e0e5e0451fc7a (diff) | |
[FIX] im_livechat, mail, website_livechat: invite button in livechats
Task-2334724
closes odoo/odoo#57505
X-original-commit: 5316c91c27e48bfaa3ebf3fb97e35220fabc986e
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/im_livechat/static/src')
4 files changed, 86 insertions, 0 deletions
diff --git a/addons/im_livechat/static/src/components/discuss/discuss_tests.js b/addons/im_livechat/static/src/components/discuss/discuss_tests.js index 166e4fd679f..c756f2dff93 100644 --- a/addons/im_livechat/static/src/components/discuss/discuss_tests.js +++ b/addons/im_livechat/static/src/components/discuss/discuss_tests.js @@ -411,6 +411,32 @@ QUnit.test('livechats with no messages are sorted by creation date in the sideba ); }); +QUnit.test('invite button should be present on livechat', async function (assert) { + assert.expect(1); + + this.data['mail.channel'].records.push( + { + anonymous_name: "Visitor 11", + channel_type: 'livechat', + id: 11, + livechat_operator_id: this.data.currentPartnerId, + members: [this.data.currentPartnerId, this.data.publicPartnerId], + }, + ); + await this.start({ + discuss: { + params: { + default_active_id: 'mail.channel_11', + }, + }, + }); + assert.containsOnce( + document.body, + '.o_widget_Discuss_controlPanelButtonInvite', + "Invite button should be visible in control panel when livechat is active thread" + ); +}); + }); }); }); diff --git a/addons/im_livechat/static/src/models/partner/partner.js b/addons/im_livechat/static/src/models/partner/partner.js new file mode 100644 index 00000000000..7392c8d6229 --- /dev/null +++ b/addons/im_livechat/static/src/models/partner/partner.js @@ -0,0 +1,23 @@ +odoo.define('im_livechat/static/src/models/partner/partner.js', function (require) { +'use strict'; + +const { + registerClassPatchModel, +} = require('mail/static/src/model/model_core.js'); + +let nextPublicId = -1; + +registerClassPatchModel('mail.partner', 'im_livechat/static/src/models/partner/partner.js', { + + //---------------------------------------------------------------------- + // Public + //---------------------------------------------------------------------- + + getNextPublicId() { + const id = nextPublicId; + nextPublicId -= 1; + return id; + }, +}); + +}); diff --git a/addons/im_livechat/static/src/models/thread/thread.js b/addons/im_livechat/static/src/models/thread/thread.js index 190a2088066..1ec06246ec7 100644 --- a/addons/im_livechat/static/src/models/thread/thread.js +++ b/addons/im_livechat/static/src/models/thread/thread.js @@ -53,9 +53,11 @@ registerClassPatchModel('mail.thread', 'im_livechat/static/src/models/thread/thr ) ); data2.members.push(['link', partner]); + data2.correspondent = [['link', partner]]; } else { const partnerData = this.env.models['mail.partner'].convertData(data.livechat_visitor); data2.members.push(['insert', partnerData]); + data2.correspondent = [['insert', partnerData]]; } } return data2; @@ -71,6 +73,16 @@ registerInstancePatchModel('mail.thread', 'im_livechat/static/src/models/thread/ /** * @override */ + _computeCorrespondent() { + if (this.channel_type === 'livechat') { + // livechat correspondent never change: always the public member. + return []; + } + return this._super(); + }, + /** + * @override + */ _computeDisplayName() { if (this.channel_type === 'livechat' && this.correspondent) { if (this.correspondent.country) { diff --git a/addons/im_livechat/static/src/widgets/discuss/discuss.js b/addons/im_livechat/static/src/widgets/discuss/discuss.js new file mode 100644 index 00000000000..37673669efa --- /dev/null +++ b/addons/im_livechat/static/src/widgets/discuss/discuss.js @@ -0,0 +1,25 @@ +odoo.define('im_livechat/static/src/widgets/discuss/discuss.js', function (require) { +'use strict'; + +const Discuss = require('mail/static/src/widgets/discuss/discuss.js'); + +Discuss.include({ + //---------------------------------------------------------------------- + // Private + //---------------------------------------------------------------------- + + /** + * @override + */ + _shouldHaveInviteButton() { + if ( + this.discuss.thread && + this.discuss.thread.channel_type === 'livechat' + ) { + return true; + } + return this._super(); + }, +}); + +}); |
