Files
odoo_source/addons/website/views/snippets/s_map.xml
T
Romain Derie 88194dd941 [FIX] website: make s_map work in sanitized fields
Before this commit, the `<iframe/>` element of the `s_map` snippet would
be removed from the field value if the field was sanitized.
The map would then not be displayed, obviously.

The way that `s_map` snippet work is simple:
1. The snippet is defined with a hidden `<iframe/>` element
2. The snippet options are stored as data attributes on the `<section/>`
   element.
3. When those options are changed, the iframe `src` is updated and it is
   shown if needed.

The fix is simple, as we already have all the data attributes available,
we just need to recreate that iframe when the snippet is started without
one. It most likely means it got deleted through the sanitization during
the save.

opw-2844010

closes odoo/odoo#91866

X-original-commit: c2e9bd0e60014b6a42931cf300e0f89f8cf7c225
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2022-05-23 23:31:53 +02:00

69 lines
3.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template name="Map" id="s_map">
<section class="s_map pb56 pt56" data-map-type="m" data-map-zoom="12" t-att-data-map-address="' '.join(filter(None, (user_id.company_id.street, user_id.company_id.city, user_id.company_id.state_id.display_name, user_id.company_id.country_id.display_name)))">
<div class="map_container o_not_editable">
<div class="css_non_editable_mode_hidden">
<div class="missing_option_warning alert alert-info rounded-0 fade show d-none d-print-none">
An address must be specified for a map to be embedded
</div>
</div>
<!-- GMap iframe will be injected in JS -->
<div class="s_map_color_filter"/>
</div>
</section>
</template>
<!-- Snippet's Options -->
<template id="s_map_options" inherit_id="website.snippet_options">
<xpath expr="//div[@data-js='Box']" position="before">
<div data-js="Map" data-selector=".s_map">
<we-input class="o_we_large" string="Address" data-select-data-attribute="" data-no-preview="true" data-attribute-name="mapAddress" placeholder="e.g. De Brouckere, Brussels, Belgium"/>
<we-select string="Type" data-no-preview="true" data-attribute-name="mapType">
<we-button data-select-data-attribute="m">Road</we-button>
<we-button data-select-data-attribute="k">Satellite</we-button>
</we-select>
<we-select string="Zoom" data-select-data-attribute="12" data-no-preview="true" data-attribute-name="mapZoom">
<we-button data-select-data-attribute="21">2.5 m</we-button>
<we-button data-select-data-attribute="20">5 m</we-button>
<we-button data-select-data-attribute="19">10 m</we-button>
<we-button data-select-data-attribute="18">20 m</we-button>
<we-button data-select-data-attribute="17">50 m</we-button>
<we-button data-select-data-attribute="16">100 m</we-button>
<we-button data-select-data-attribute="15">200 m</we-button>
<we-button data-select-data-attribute="14">400 m</we-button>
<we-button data-select-data-attribute="13">1 km</we-button>
<we-button data-select-data-attribute="12">2 km</we-button>
<we-button data-select-data-attribute="11">4 km</we-button>
<we-button data-select-data-attribute="10">8 km</we-button>
<we-button data-select-data-attribute="9">15 km</we-button>
<we-button data-select-data-attribute="8">30 km</we-button>
<we-button data-select-data-attribute="7">50 km</we-button>
<we-button data-select-data-attribute="6">100 km</we-button>
<we-button data-select-data-attribute="5">200 km</we-button>
<we-button data-select-data-attribute="4">400 km</we-button>
<we-button data-select-data-attribute="3">1000 km</we-button>
<we-button data-select-data-attribute="2">2000 km</we-button>
</we-select>
<we-colorpicker string="Color filter" data-select-style="true"
data-css-property="background-color" data-color-prefix="bg-" data-apply-to=".s_map_color_filter"/>
<we-checkbox string="Description" data-no-preview="true" data-show-description="true"/>
</div>
</xpath>
</template>
<record id="website.s_map_000_scss" model="ir.asset">
<field name="name">Map 000 SCSS</field>
<field name="bundle">web.assets_frontend</field>
<field name="path">website/static/src/snippets/s_map/000.scss</field>
</record>
<record id="website.s_map_000_js" model="ir.asset">
<field name="name">Map 000 JS</field>
<field name="bundle">web.assets_frontend</field>
<field name="path">website/static/src/snippets/s_map/000.js</field>
</record>
</odoo>