From 77ec122293c69f6b29adabd963f05e7d34270216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 13 Dec 2015 13:58:57 +0100 Subject: [PATCH] backoffice: disable geolocation for now (#9322) --- wcs/forms/root.py | 2 ++ wcs/qommon/static/js/qommon.geolocation.js | 3 ++- wcs/qommon/static/js/qommon.map.js | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wcs/forms/root.py b/wcs/forms/root.py index c175a20..db95aed 100644 --- a/wcs/forms/root.py +++ b/wcs/forms/root.py @@ -342,6 +342,8 @@ class FormPage(Directory): self.feed_current_data(magictoken) form = self.formdef.create_form(page_no, displayed_fields) + if get_request().is_in_backoffice(): + form.attrs['data-is-backoffice'] = 'true' if editing: form.action = 'wfedit' else: diff --git a/wcs/qommon/static/js/qommon.geolocation.js b/wcs/qommon/static/js/qommon.geolocation.js index a2cf2b3..1e520b9 100644 --- a/wcs/qommon/static/js/qommon.geolocation.js +++ b/wcs/qommon/static/js/qommon.geolocation.js @@ -168,7 +168,8 @@ function geoloc_prefill(element_type, element_value) geoloc_prefill('country', data.address.country); }); }); - if ($('.qommon-map').length == 0) { + if ($('.qommon-map').length == 0 && + $('div[data-geolocation]').parents('form').data('is-backoffice') != true) { /* if there's no map on the page, we do the geolocation without leaflet. */ if (navigator.geolocation) { $('div[data-geolocation] label').addClass('activity'); diff --git a/wcs/qommon/static/js/qommon.map.js b/wcs/qommon/static/js/qommon.map.js index ba70f3c..3999ecf 100644 --- a/wcs/qommon/static/js/qommon.map.js +++ b/wcs/qommon/static/js/qommon.map.js @@ -44,8 +44,9 @@ $(window).on('load', function() { map.marker.setLatLng(coords); hidden.val(coords.lat + ';' + coords.lng); }); + var is_backoffice = ($map_widget.parents('form').data('is-backoffice') == true); position_prefil = $map_widget.parent().parent().data('geolocation') == 'position'; - if (! $map_widget.data('readonly') && ($map_widget.data('init-with-geoloc') || position_prefil)) { + if (! ($map_widget.data('readonly') || is_backoffice) && ($map_widget.data('init-with-geoloc') || position_prefil)) { map.on('locationfound', function(e) { $map_widget.parent().parent().find('label').removeClass('activity'); if (map.marker === null) { -- 2.6.4