summaryrefslogtreecommitdiff
path: root/addons/website_livechat/static/src/js/website_livechat.editor.js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2018-09-21 12:25:22 +0200
committerSébastien Theys <seb@odoo.com>2018-09-25 16:23:08 +0200
commite4aa8ec6d18a47e46a6b4c4cca70156ce7916d15 (patch)
tree52000239592c67ed68703959fd00f245a3249014 /addons/website_livechat/static/src/js/website_livechat.editor.js
parent2ab6ce80d6224df5f6a4b113762e1698910ba8db (diff)
[IMP] website,website_livechat,website_slides: add "new content" buttons
Those allow the user to quickly create a new channel or new slides. PR: #27110 task-1885419
Diffstat (limited to 'addons/website_livechat/static/src/js/website_livechat.editor.js')
-rw-r--r--addons/website_livechat/static/src/js/website_livechat.editor.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/addons/website_livechat/static/src/js/website_livechat.editor.js b/addons/website_livechat/static/src/js/website_livechat.editor.js
new file mode 100644
index 00000000000..32ad9f8d268
--- /dev/null
+++ b/addons/website_livechat/static/src/js/website_livechat.editor.js
@@ -0,0 +1,52 @@
+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 weContext = require('web_editor.context');
+
+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 {Deferred} Unresolved if there is a redirection
+ */
+ _createNewChannel: function () {
+ var self = this;
+ return wUtils.prompt({
+ window_title: _t("New Channel"),
+ input: _t("Name"),
+ }).then(function (name) {
+ if (!name) {
+ return;
+ }
+ return self._rpc({
+ model: 'im_livechat.channel',
+ method: 'create_and_get_website_url',
+ context: weContext.get(),
+ args: [[]],
+ kwargs: {
+ name: name,
+ },
+ }).then(function (url) {
+ window.location.href = url;
+ return $.Deferred();
+ });
+ });
+ },
+});
+
+});