diff --git a/addons/website/static/src/snippets/s_map/000.scss b/addons/website/static/src/snippets/s_map/000.scss index 54065bae418..3b8c0fb5d34 100644 --- a/addons/website/static/src/snippets/s_map/000.scss +++ b/addons/website/static/src/snippets/s_map/000.scss @@ -39,6 +39,11 @@ $s-map-desc-hover-alpha: 0.55 !default; background: rgba($s-map-desc-hover-bg, $s-map-desc-hover-alpha); color: color-yiq(rgba($s-map-desc-hover-bg, $s-map-desc-hover-alpha)); } + .s_map_color_filter { + @include o-position-absolute(0, 0, 0, 0); + position: absolute !important; + pointer-events: none; + } } .editor_enable .s_map { diff --git a/addons/website/static/src/snippets/s_map/options.js b/addons/website/static/src/snippets/s_map/options.js index 1e6f79cb7e1..1d182e99322 100644 --- a/addons/website/static/src/snippets/s_map/options.js +++ b/addons/website/static/src/snippets/s_map/options.js @@ -1,52 +1,29 @@ -odoo.define('options.s_map_options', function (require) { -'use strict'; +/** @odoo-module **/ -const {_t} = require('web.core'); -const options = require('web_editor.snippets.options'); +import {_t} from 'web.core'; +import options from 'web_editor.snippets.options'; options.registry.Map = options.Class.extend({ /** - * * @override */ - onBuilt: function () { - this.updateUI(); - }, - - /** - * @override - */ - updateUI() { - const dataset = this.$target[0].dataset; - const embedded = this.$target.find('.o_embedded'); - const info = this.$target.find('.missing_option_warning'); - if (dataset.mapAddress) { - const url = 'https://maps.google.com/maps?q=' + encodeURIComponent(dataset.mapAddress) - + '&t=' + encodeURIComponent(dataset.mapType) - + '&z=' + encodeURIComponent(dataset.mapZoom) - + '&ie=UTF8&iwloc=&output=embed'; - if (url !== embedded.attr('src')) { - embedded.attr('src', url); - } - embedded.removeClass('d-none'); - info.addClass('d-none'); - } else { - embedded.attr('src', 'about:blank'); - embedded.addClass('d-none'); - info.removeClass('d-none'); - } - if (! (this.$target.hasClass('o_half_screen_height') || this.$target.hasClass('o_full_screen_height'))) { - this.$target.css('min-height', this.$target[0].dataset.mapMinHeight); - } - return this._super.apply(this, arguments).then(() => { - this.updateUIVisibility(); - }); + onBuilt() { + this._updateSource(); }, //-------------------------------------------------------------------------- // Options //-------------------------------------------------------------------------- + /** + * @see this.selectClass for parameters + */ + async selectDataAttribute(previewMode, widgetValue, params) { + await this._super(...arguments); + if (['mapAddress', 'mapType', 'mapZoom'].includes(params.attributeName)) { + this._updateSource(); + } + }, /** * @see this.selectClass for parameters */ @@ -63,15 +40,6 @@ options.registry.Map = options.Class.extend({ descriptionEl.remove(); } }, - /** - * @see this.selectClass for parameters - */ - async setHeight(previewMode, widgetValue, params) { - if (widgetValue) { - this.$target[0].dataset.mapMinHeight = widgetValue; - this.$target.css('min-height', widgetValue); - } - }, //-------------------------------------------------------------------------- // Private @@ -84,10 +52,33 @@ options.registry.Map = options.Class.extend({ if (methodName === 'showDescription') { return !!this.$target[0].querySelector('.description'); } - if (methodName === 'setHeight') { - return this.$target[0].dataset.mapMinHeight; - } return this._super(...arguments); }, + /** + * @private + */ + _updateSource() { + const dataset = this.$target[0].dataset; + const $embedded = this.$target.find('.s_map_embedded'); + const $info = this.$target.find('.missing_option_warning'); + if (dataset.mapAddress) { + const url = 'https://maps.google.com/maps?q=' + encodeURIComponent(dataset.mapAddress) + + '&t=' + encodeURIComponent(dataset.mapType) + + '&z=' + encodeURIComponent(dataset.mapZoom) + + '&ie=UTF8&iwloc=&output=embed'; + if (url !== $embedded.attr('src')) { + $embedded.attr('src', url); + } + $embedded.removeClass('d-none'); + $info.addClass('d-none'); + } else { + $embedded.attr('src', 'about:blank'); + $embedded.addClass('d-none'); + $info.removeClass('d-none'); + } + }, }); -}); + +export default { + Map: options.registry.Map, +}; diff --git a/addons/website/views/snippets/s_map.xml b/addons/website/views/snippets/s_map.xml index 35c192cbf6e..40dd065e4cb 100644 --- a/addons/website/views/snippets/s_map.xml +++ b/addons/website/views/snippets/s_map.xml @@ -2,17 +2,15 @@ @@ -49,15 +47,10 @@ 2000 km + data-css-property="background-color" data-color-prefix="bg-" data-apply-to=".s_map_color_filter"/> - -
- -
-