diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/im_livechat/static/src/js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/im_livechat/static/src/js')
3 files changed, 87 insertions, 0 deletions
diff --git a/addons/im_livechat/static/src/js/ajax_external.js b/addons/im_livechat/static/src/js/ajax_external.js new file mode 100644 index 00000000..9c6bd4cd --- /dev/null +++ b/addons/im_livechat/static/src/js/ajax_external.js @@ -0,0 +1,14 @@ +odoo.define('web.ajax_external', function (require) { +"use strict"; + +var ajax = require('web.ajax'); + +/** + * This file should be used in the context of an external widget loading (e.g: live chat in a non-Odoo website) + * It overrides the 'loadJS' method that is supposed to load additional scripts, based on a relative URL (e.g: '/web/webclient/locale/en_US') + * As we're not in an Odoo website context, the calls will not work, and we avoid a 404 request. + */ +ajax.loadJS = function (url) { + console.warn('Tried to load the following script on an external website: ' + url); +}; +}); diff --git a/addons/im_livechat/static/src/js/im_livechat_channel_form_controller.js b/addons/im_livechat/static/src/js/im_livechat_channel_form_controller.js new file mode 100644 index 00000000..9819e8cb --- /dev/null +++ b/addons/im_livechat/static/src/js/im_livechat_channel_form_controller.js @@ -0,0 +1,54 @@ +odoo.define('im_livechat.ImLivechatChannelFormController', function (require) { +'use strict'; + +const FormController = require('web.FormController'); + +const ImLivechatChannelFormController = FormController.extend({ + events: Object.assign({}, FormController.prototype.events, { + 'click .o_im_livechat_channel_form_button_colors_reset_button': '_onClickLivechatButtonColorsResetButton', + 'click .o_im_livechat_channel_form_chat_window_colors_reset_button': '_onClickLivechatChatWindowColorsResetButton', + }), + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * @private + * @param {Object} colorValues + */ + async _updateColors(colorValues) { + for (const name in colorValues) { + this.$(`[name="${name}"] .o_field_color`).css('background-color', colorValues[name]); + } + const result = await this.model.notifyChanges(this.handle, colorValues); + this._updateRendererState(this.model.get(this.handle), { fieldNames: result }); + }, + + //-------------------------------------------------------------------------- + // Handlers + //-------------------------------------------------------------------------- + + /** + * @private + */ + async _onClickLivechatButtonColorsResetButton() { + await this._updateColors({ + button_background_color: "#878787", + button_text_color: "#FFFFFF", + }); + }, + /** + * @private + */ + async _onClickLivechatChatWindowColorsResetButton() { + await this._updateColors({ + header_background_color: "#875A7B", + title_color: "#FFFFFF", + }); + }, +}); + +return ImLivechatChannelFormController; + +}); diff --git a/addons/im_livechat/static/src/js/im_livechat_channel_form_view.js b/addons/im_livechat/static/src/js/im_livechat_channel_form_view.js new file mode 100644 index 00000000..af5f42d7 --- /dev/null +++ b/addons/im_livechat/static/src/js/im_livechat_channel_form_view.js @@ -0,0 +1,19 @@ +odoo.define('im_livechat.ImLivechatChannelFormView', function (require) { +"use strict"; + +const ImLivechatChannelFormController = require('im_livechat.ImLivechatChannelFormController'); + +const FormView = require('web.FormView'); +const viewRegistry = require('web.view_registry'); + +const ImLivechatChannelFormView = FormView.extend({ + config: Object.assign({}, FormView.prototype.config, { + Controller: ImLivechatChannelFormController, + }), +}); + +viewRegistry.add('im_livechat_channel_form_view_js', ImLivechatChannelFormView); + +return ImLivechatChannelFormView; + +}); |
