diff --git a/addons/website/static/src/components/fields/publish_button.js b/addons/website/static/src/components/fields/publish_button.js new file mode 100644 index 00000000000..cc60352dc23 --- /dev/null +++ b/addons/website/static/src/components/fields/publish_button.js @@ -0,0 +1,10 @@ +/** @odoo-module **/ + +import { registry } from "@web/core/registry"; + +const { Component } = owl; + +class PublishField extends Component {} +PublishField.template = "website.PublishField"; + +registry.category("fields").add("website_publish_button", PublishField); diff --git a/addons/website/static/src/components/fields/publish_button.xml b/addons/website/static/src/components/fields/publish_button.xml new file mode 100644 index 00000000000..79bb3df65d8 --- /dev/null +++ b/addons/website/static/src/components/fields/publish_button.xml @@ -0,0 +1,15 @@ + + + + +
+ + +
+
+ +
diff --git a/addons/website/static/src/components/fields/res_config_settings.js b/addons/website/static/src/components/fields/res_config_settings.js index 20a94ae1589..4b0828097da 100644 --- a/addons/website/static/src/components/fields/res_config_settings.js +++ b/addons/website/static/src/components/fields/res_config_settings.js @@ -1,41 +1,41 @@ -odoo.define('website.settings', function (require) { +/** @odoo-module **/ -const core = require('web.core'); -const Dialog = require('web.Dialog'); -const FieldBoolean = require('web.basic_fields').FieldBoolean; -const fieldRegistry = require('web.field_registry'); +import { BooleanField } from '@web/views/fields/boolean/boolean_field'; +import { Dialog } from '@web/core/dialog/dialog'; +import { registry } from "@web/core/registry"; +import { useService } from "@web/core/utils/hooks"; -const QWeb = core.qweb; -const _t = core._t; +const { Component } = owl; -const WebsiteCookiesbarField = FieldBoolean.extend({ - xmlDependencies: ['/website/static/src/xml/website.res_config_settings.xml'], +class CookieBarDialog extends Component { + accept() { + this.props.accept(); + this.props.close(); + } +} +CookieBarDialog.components = { Dialog }; +CookieBarDialog.template = 'website.res_config_settings.CookieDialog'; - _onChange: function () { - const checked = this.$input[0].checked; - if (!checked) { - return this._setValue(checked); +class WebsiteCookiebarField extends BooleanField { + setup() { + this.dialog = useService('dialog'); + } + + onChange(newValue) { + if (!newValue) { + return this.props.update(newValue); } - - 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, + let value = false; + this.dialog.add(CookieBarDialog, { + title: "Website Cookie Bar", + accept: () => { + value = true; }, - { - text: _t('Activate anyway'), - close: true, - click: () => this._setValue(checked), - }], - cancel_callback: cancelCallback, + }, { + onClose: () => { + this.props.update(value); + } }); - }, -}); - -fieldRegistry.add('website_cookiesbar_field', WebsiteCookiesbarField); -}); + } +} +registry.category("fields").add("website_cookiesbar_field", WebsiteCookiebarField); diff --git a/addons/website/static/src/components/fields/res_config_settings.xml b/addons/website/static/src/components/fields/res_config_settings.xml index eaa1a682e51..f298d232ea5 100644 --- a/addons/website/static/src/components/fields/res_config_settings.xml +++ b/addons/website/static/src/components/fields/res_config_settings.xml @@ -1,18 +1,28 @@ - -
-

- Cookie bars may significantly impair the experience of - your visitors. We recommend you avoid them unless you have - verified with a legal advisor that you absolutely need cookie - consent in your country. -

-

- For session cookies, authentification and analytics, - you do not need to ask for the consent (see e.g. Opinion - 04/2012 on Cookie Consent Exemption by the EU Art.29 WP). -

-
+ + + + +
+

+ Cookie bars may significantly impair the experience of + your visitors. We recommend you avoid them unless you have + verified with a legal advisor that you absolutely need cookie + consent in your country. +

+

+ For session cookies, authentification and analytics, + you do not need to ask for the consent (see e.g. Opinion + 04/2012 on Cookie Consent Exemption by the EU Art.29 WP). +

+
+
+ + + + +
+
diff --git a/addons/website/static/src/js/backend/button.js b/addons/website/static/src/js/backend/button.js index bb3c5bd161e..5a75a304977 100644 --- a/addons/website/static/src/js/backend/button.js +++ b/addons/website/static/src/js/backend/button.js @@ -7,46 +7,7 @@ var field_registry = require('web.field_registry'); var _t = core._t; -var WebsitePublishButton = AbstractField.extend({ - className: 'o_stat_info', - supportedFieldTypes: ['boolean'], - - //-------------------------------------------------------------------------- - // Public - //-------------------------------------------------------------------------- - - /** - * A boolean field is always set since false is a valid value. - * - * @override - */ - isSet: function () { - return true; - }, - - //-------------------------------------------------------------------------- - // Private - //-------------------------------------------------------------------------- - - /** - * This widget is supposed to be used inside a stat button and, as such, is - * rendered the same way in edit and readonly mode. - * - * @override - * @private - */ - _render: function () { - this.$el.empty(); - var text = this.value ? _t("Published") : _t("Unpublished"); - var hover = this.value ? _t("Unpublish") : _t("Publish"); - var valColor = this.value ? 'text-success' : 'text-danger'; - var hoverColor = this.value ? 'text-danger' : 'text-success'; - var $val = $('').addClass('o_stat_text o_not_hover ' + valColor).text(text); - var $hover = $('').addClass('o_stat_text o_hover ' + hoverColor).text(hover); - this.$el.append($val).append($hover); - }, -}); - +// TODO: Remove me when Partner view is adapted to OWL var WidgetWebsiteButtonIcon = AbstractField.extend({ template: 'WidgetWebsiteButtonIcon', events: { @@ -111,6 +72,5 @@ var WidgetWebsiteButtonIcon = AbstractField.extend({ }); field_registry - .add('website_redirect_button', WidgetWebsiteButtonIcon) - .add('website_publish_button', WebsitePublishButton); + .add('website_redirect_button', WidgetWebsiteButtonIcon); }); diff --git a/addons/website/static/src/xml/website.backend.xml b/addons/website/static/src/xml/website.backend.xml index 57a8f7380f1..f5ec944162c 100644 --- a/addons/website/static/src/xml/website.backend.xml +++ b/addons/website/static/src/xml/website.backend.xml @@ -1,10 +1,5 @@ -
- - On Website -
-