summaryrefslogtreecommitdiff
path: root/addons/website/static/src/snippets/s_google_map/options.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/snippets/s_google_map/options.js
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/website/static/src/snippets/s_google_map/options.js')
-rw-r--r--addons/website/static/src/snippets/s_google_map/options.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/addons/website/static/src/snippets/s_google_map/options.js b/addons/website/static/src/snippets/s_google_map/options.js
new file mode 100644
index 00000000..6aad46f1
--- /dev/null
+++ b/addons/website/static/src/snippets/s_google_map/options.js
@@ -0,0 +1,56 @@
+odoo.define('options.s_google_map_options', function (require) {
+'use strict';
+
+const {_t} = require('web.core');
+const options = require('web_editor.snippets.options');
+
+options.registry.GoogleMap = options.Class.extend({
+
+ //--------------------------------------------------------------------------
+ // Options
+ //--------------------------------------------------------------------------
+
+ /**
+ * @see this.selectClass for parameters
+ */
+ resetMapColor(previewMode, widgetValue, params) {
+ this.$target[0].dataset.mapColor = '';
+ },
+ /**
+ * @see this.selectClass for parameters
+ */
+ setFormattedAddress(previewMode, widgetValue, params) {
+ this.$target[0].dataset.pinAddress = params.gmapPlace.formatted_address;
+ },
+ /**
+ * @see this.selectClass for parameters
+ */
+ async showDescription(previewMode, widgetValue, params) {
+ const descriptionEl = this.$target[0].querySelector('.description');
+ if (widgetValue && !descriptionEl) {
+ this.$target.append($(`
+ <div class="description">
+ <font>${_t('Visit us:')}</font>
+ <span>${_t('Our office is located in the northeast of Brussels. TEL (555) 432 2365')}</span>
+ </div>`)
+ );
+ } else if (!widgetValue && descriptionEl) {
+ descriptionEl.remove();
+ }
+ },
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * @override
+ */
+ _computeWidgetState(methodName, params) {
+ if (methodName === 'showDescription') {
+ return this.$target[0].querySelector('.description') ? 'true' : '';
+ }
+ return this._super(...arguments);
+ },
+});
+});