diff options
author | QuentinAndre <quentin.andre@imt-atlantique.net> | 2021-07-26 20:30:30 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-10-25 12:06:02 +0200 |
commit | 8eeb37c0648690e4ffca7234b710e44be4359b20 (patch) | |
tree | 338ffc42a3ec9f6a48d6289649804438380a83e8 /ishtar_common | |
parent | f74c43040a9ad2f7fac9cd16dc76f1bcdc533962 (diff) | |
download | Ishtar-8eeb37c0648690e4ffca7234b710e44be4359b20.tar.bz2 Ishtar-8eeb37c0648690e4ffca7234b710e44be4359b20.zip |
all in jquery and get_geo_items fixes
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/models_common.py | 10 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_geo_items.html | 23 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_simple_map.html | 14 |
3 files changed, 23 insertions, 24 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 5d1cd5d90..9b4dabf19 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2871,16 +2871,16 @@ class GeoItem(models.Model): dict["geometry"]["coordinates"] = list_coords else: dict["geometry"]["type"] = "Point" - if self.multi_polygon: - dict["geometry"]["coordinates"] = self.convert_coordinates( - self.multi_polygon.centroid, rounded - ) - else: + if self.point_2d: try: x, y = self.display_coordinates dict["geometry"]["coordinates"] = [x, y] except ValueError: dict["geometry"]["coordinates"] = [] + else: + dict["geometry"]["coordinates"] = self.convert_coordinates( + self.multi_polygon.centroid, rounded + ) return dict def convert_coordinates(self, point_2d, rounded): diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html b/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html index 9b485de15..36fbabfcf 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html @@ -24,18 +24,17 @@ </dl> <script> var hide_get_polygons = function() { - const disp = $("#display-geo-items")[0]; - const get_poly = $("#get-polygons")[0]; - const label = $("#label-get-polygons")[0]; - get_poly.hidden = true; - label.hidden = true; - disp.addEventListener('change', (event) => { - if (event.target.value === "") { - get_poly.hidden = true; - label.hidden = true; - get_poly.value = ""; - } else { get_poly.hidden = false; - label.hidden = false;} + const disp = $("#display-geo-items"); + const get_poly = $("#get-polygons"); + const label = $("#label-get-polygons"); + get_poly.hide(); + label.hide(); + disp.change( function () { + if (disp.val() === "") { + get_poly.hide(); + label.hide(); + } else { get_poly.show(); + label.show();} }) } hide_get_polygons(); diff --git a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html index 2c9d49be2..b4e669a70 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html @@ -38,20 +38,20 @@ var display_geo_items = function(disp, get_polygons) { } var geo_items_displayed_once = false; -var disp = $("#display-geo-items")[0]; -var get_polygons = $("#get-polygons")[0]; -disp.addEventListener('change', (event) => { +var disp = $("#display-geo-items"); +var get_polygons = $("#get-polygons"); +disp.change( function () { if (geo_items_displayed_once) { disp_map(); } - if (disp.value !== "") { - display_geo_items(disp.value, get_polygons.value); + if (disp.val() !== "") { + display_geo_items(disp.val(), get_polygons.val()); geo_items_displayed_once = true; } }) -get_polygons.addEventListener('change', (event) => { +get_polygons.change( function () { disp_map(); - display_geo_items(disp.value, get_polygons.value); + display_geo_items(disp.val(), get_polygons.val()); }) {% endif %} </script> |