1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
odoo.define('website_livechat.editor', function (require) {
'use strict';
var core = require('web.core');
var wUtils = require('website.utils');
var WebsiteNewMenu = require('website.newMenu');
var _t = core._t;
WebsiteNewMenu.include({
actions: _.extend({}, WebsiteNewMenu.prototype.actions || {}, {
new_channel: '_createNewChannel',
}),
//--------------------------------------------------------------------------
// Actions
//--------------------------------------------------------------------------
/**
* Asks the user information about a new channel to create, then creates it
* and redirects the user to this new channel.
*
* @private
* @returns {Promise} Unresolved if there is a redirection
*/
_createNewChannel: function () {
var self = this;
return wUtils.prompt({
window_title: _t("New Channel"),
input: _t("Name"),
}).then(function (result) {
var name = result.val;
if (!name) {
return;
}
return self._rpc({
model: 'im_livechat.channel',
method: 'create_and_get_website_url',
args: [[]],
kwargs: {
name: name,
},
}).then(function (url) {
window.location.href = url;
return new Promise(function () {});
});
});
},
});
});
|