summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/backend/res_config_settings.js
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/website/static/src/js/backend/res_config_settings.js
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/website/static/src/js/backend/res_config_settings.js')
-rw-r--r--addons/website/static/src/js/backend/res_config_settings.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/addons/website/static/src/js/backend/res_config_settings.js b/addons/website/static/src/js/backend/res_config_settings.js
new file mode 100644
index 00000000..6dd014c0
--- /dev/null
+++ b/addons/website/static/src/js/backend/res_config_settings.js
@@ -0,0 +1,81 @@
+odoo.define('website.settings', function (require) {
+
+const BaseSettingController = require('base.settings').Controller;
+const core = require('web.core');
+const Dialog = require('web.Dialog');
+const FieldBoolean = require('web.basic_fields').FieldBoolean;
+const fieldRegistry = require('web.field_registry');
+const FormController = require('web.FormController');
+
+const QWeb = core.qweb;
+const _t = core._t;
+
+BaseSettingController.include({
+
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+
+ /**
+ * Bypasses the discard confirmation dialog when going to a website because
+ * the target website will be the one selected and when selecting a theme
+ * because the theme will be installed on the selected website.
+ *
+ * Without this override, it is impossible to go to a website other than the
+ * first because discarding will revert it back to the default value.
+ *
+ * Without this override, it is impossible to edit robots.txt website other than the
+ * first because discarding will revert it back to the default value.
+ *
+ * Without this override, it is impossible to submit sitemap to google other than for the
+ * first website because discarding will revert it back to the default value.
+ *
+ * Without this override, it is impossible to install a theme on a website
+ * other than the first because discarding will revert it back to the
+ * default value.
+ *
+ * @override
+ */
+ _onButtonClicked: function (ev) {
+ if (ev.data.attrs.name === 'website_go_to'
+ || ev.data.attrs.name === 'action_open_robots'
+ || ev.data.attrs.name === 'action_ping_sitemap'
+ || ev.data.attrs.name === 'install_theme_on_current_website') {
+ FormController.prototype._onButtonClicked.apply(this, arguments);
+ } else {
+ this._super.apply(this, arguments);
+ }
+ },
+});
+
+const WebsiteCookiesbarField = FieldBoolean.extend({
+ xmlDependencies: ['/website/static/src/xml/website.res_config_settings.xml'],
+
+ _onChange: function () {
+ const checked = this.$input[0].checked;
+ if (!checked) {
+ return this._setValue(checked);
+ }
+
+ const cancelCallback = () => this.$input[0].checked = !checked;
+ Dialog.confirm(this, null, {
+ title: _t("Please confirm"),
+ $content: QWeb.render('website.res_config_settings.cookies_modal_main'),
+ buttons: [{
+ text: _t('Do not activate'),
+ classes: 'btn-primary',
+ close: true,
+ click: cancelCallback,
+ },
+ {
+ text: _t('Activate anyway'),
+ close: true,
+ click: () => this._setValue(checked),
+ }],
+ cancel_callback: cancelCallback,
+ });
+ },
+});
+
+fieldRegistry.add('website_cookiesbar_field', WebsiteCookiesbarField);
+});