diff options
author | QuentinAndre <quentin.andre@imt-atlantique.net> | 2021-07-26 14:43:05 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-07-08 09:58:48 +0200 |
commit | 2a8d2108f9d87f62db245895cc716e90f2225af6 (patch) | |
tree | 941848bc1ef3914c21e5606bc62b422b10b85c5b /ishtar_common/templates | |
parent | 92bd9026e0b6397103da83bffe64f3a53ee06742 (diff) | |
download | Ishtar-2a8d2108f9d87f62db245895cc716e90f2225af6.tar.bz2 Ishtar-2a8d2108f9d87f62db245895cc716e90f2225af6.zip |
url with get and display geo items
Diffstat (limited to 'ishtar_common/templates')
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_geo_items.html | 48 | ||||
-rw-r--r-- | ishtar_common/templates/ishtar/blocks/sheet_simple_map.html | 56 |
2 files changed, 95 insertions, 9 deletions
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html b/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html new file mode 100644 index 000000000..451453d59 --- /dev/null +++ b/ishtar_common/templates/ishtar/blocks/sheet_geo_items.html @@ -0,0 +1,48 @@ +{% load i18n window_field %}{% if PROFILE.mapping %} +{% if geo_item.point_2d or geo_item.multi_polygon %} +<dl class="col-12"> + <dt>{% trans "Display geo items" %}</dt> + <dd> + <label for="display-geo-items">{% trans "Display associated features: " %}</label> + <select name="display-geo-items" id="display-geo-items"> + <option value="" selected="selected">{% trans "None" %}</option> + <option id="disp-context-records" value="contextrecords">{% trans "Context records" %}</option> + <option value="basefinds">{% trans "Base finds" %}</option> + </select> + </dd> + <dd> + <label for="get-polygons" id="label-get-polygons">{% trans "Geometry: " %}</label> + <select name="get-polygons" id="get-polygons"> + <option value="polygons" selected="selected">{% trans "Display polygons" %}</option> + <option value="points">{% trans "Display points" %}</option> + </select> + </dd> +</dl> +<script> +var hide_context_records = function() { + if ("{{geo_item.SLUG}}" === "contextrecord") { + const disp_cr = $("#disp-context-records")[0]; + disp_cr.hidden = true; + } +} +hide_context_records(); + +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;} + }) +} +hide_get_polygons(); +</script> +{% endif %} +{% endif %}
\ No newline at end of file diff --git a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html index d755fe531..b475e7343 100644 --- a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html +++ b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html @@ -6,15 +6,53 @@ <div id="map-content-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}"></div> </div> <script type="text/javascript"> -var html = render_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", false, true); -$("#map-content-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}").html(html); -{% if geo_item.most_precise_geo == 'point' %} -var {{geo_item.SLUG}}{{geo_item.pk}} = {{geo_item.point_2d_geojson|safe}}; -display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", {{geo_item.SLUG}}{{geo_item.pk}}); -{% else %} -var {{geo_item.SLUG}}{{geo_item.pk}} = {{geo_item.multi_polygon_geojson|safe}}; -display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", null, {{geo_item.SLUG}}{{geo_item.pk}}); -{% endif %} +var disp_map = function() { + var html = render_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", false, true); + $("#map-content-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}").html(html); + {% if geo_item.most_precise_geo == 'point' %} + var {{geo_item.SLUG}}{{geo_item.pk}} = {{geo_item.point_2d_geojson|safe}}; + display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", {{geo_item.SLUG}}{{geo_item.pk}}); + {% else %} + var {{geo_item.SLUG}}{{geo_item.pk}} = {{geo_item.multi_polygon_geojson|safe}}; + display_map("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", null, {{geo_item.SLUG}}{{geo_item.pk}}); + {% endif %} +} +disp_map(); + +if ("{{geo_item.SLUG}}" === 'contextrecord' || "{{geo_item.SLUG}}" === 'operation') { + var display_geo_items = function(disp, get_polygons) { + var display_both = false; + if ((disp === "basefinds") && ("{{geo_item.SLUG}}" === "operation")) { + display_both = true; + } + var url = null; + if (get_polygons === "Points") { + url = "{% url 'archaeological_finds:api-get-geo-points' %}"; + } + else { + url = "{% url 'archaeological_finds:api-get-geo-polygons' %}"; + } + disp_geo_items("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", url, "{{geo_item.SLUG}}", "{{geo_item.pk}}", display_both); + } + + var geo_items_displayed_once = false; + var disp = $("#display-geo-items")[0]; + var get_polygons = $("#get-polygons")[0]; + disp.addEventListener('change', (event) => { + if (geo_items_displayed_once) { + disp_map(); + } + if (disp.value !== "") { + console.log("geo items"); + display_geo_items(disp.value, get_polygons.value); + geo_items_displayed_once = true; + } + }) + get_polygons.addEventListener('change', (event) => { + disp_map(); + display_geo_items(disp.value, get_polygons.value); + }) +} </script> {% endif %} {% endif %} |