summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-08-31 18:24:38 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-10-25 12:06:03 +0200
commit3057285ffd5cffedccbb1dbd1361c857137d6bca (patch)
treef80dd740fb78ca5e638fa98c853ea8344d70036b
parent2b60ed096578912270e393c1c4e8d7516dea70a7 (diff)
downloadIshtar-3057285ffd5cffedccbb1dbd1361c857137d6bca.tar.bz2
Ishtar-3057285ffd5cffedccbb1dbd1361c857137d6bca.zip
Put geo map detail in experimental features
-rw-r--r--archaeological_context_records/templates/ishtar/sheet_contextrecord.html2
-rw-r--r--archaeological_operations/templates/ishtar/sheet_operation.html2
-rw-r--r--ishtar_common/templates/ishtar/blocks/sheet_map.html62
-rw-r--r--ishtar_common/templates/ishtar/blocks/sheet_simple_map.html69
-rw-r--r--ishtar_common/tests.py1
5 files changed, 77 insertions, 59 deletions
diff --git a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
index 05a6962b3..c98bcef98 100644
--- a/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
+++ b/archaeological_context_records/templates/ishtar/sheet_contextrecord.html
@@ -156,7 +156,9 @@
<div class="col-12 col-lg-6 flex-wrap">
{% field_flex_multiple_full "Towns" item.operation.towns %}
{% include "ishtar/blocks/sheet_coordinates.html"%}
+ {% if PROFILE.experimental_feature %}
{% include "ishtar/blocks/sheet_geo_items.html"%}
+ {% endif %}
</div>
{% endwith %}
</div>
diff --git a/archaeological_operations/templates/ishtar/sheet_operation.html b/archaeological_operations/templates/ishtar/sheet_operation.html
index f597c9598..bd75bbb99 100644
--- a/archaeological_operations/templates/ishtar/sheet_operation.html
+++ b/archaeological_operations/templates/ishtar/sheet_operation.html
@@ -290,7 +290,9 @@
{% field_flex "Complement" item.associated_file.address_complement %}
{% field_flex "Postal code" item.associated_file.postal_code %}
{% endif %}
+ {% if PROFILE.experimental_feature %}
{% include "ishtar/blocks/sheet_geo_items.html"%}
+ {% endif %}
</div>
{% endwith %}
</div>
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_map.html b/ishtar_common/templates/ishtar/blocks/sheet_map.html
new file mode 100644
index 000000000..296516e86
--- /dev/null
+++ b/ishtar_common/templates/ishtar/blocks/sheet_map.html
@@ -0,0 +1,62 @@
+const disp_map = function() {
+ const 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' %}
+ const {{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 %}
+ const {{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 == "operation" or geo_item.SLUG == "contextrecord" %}
+const disp_geo_items = function(disp_cr, disp_bf, get_polygons) {
+ if (disp_cr || disp_bf) {
+ const get_poly = (get_polygons === "polygons");
+ let url = null;
+ if (get_poly) {
+ url = "{% url 'api-get-geo-polygons' %}";
+ }
+ else {
+ url = "{% url 'api-get-geo-points' %}";
+ }
+ display_geo_items("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", url, "{{geo_item.SLUG}}",
+ "{{geo_item.pk}}", disp_cr, disp_bf, get_poly);
+ }
+}
+let geo_items_displayed_once = false;
+const disp_bf = $("#disp-bf-for-{{geo_item.SLUG}}-{{geo_item.pk}}");
+const get_polygons = $("#get-poly-for-{{geo_item.SLUG}}-{{geo_item.pk}}");
+
+{% if geo_item.SLUG == "operation" %}
+const disp_cr = $("#disp-cr-for-{{geo_item.SLUG}}-{{geo_item.pk}}");
+const event_func_disp_geo_items = function () {
+ if (geo_items_displayed_once) {
+ disp_map();
+ }
+ else { geo_items_displayed_once = true; }
+ disp_geo_items(disp_cr.prop('checked'), disp_bf.prop('checked'), get_polygons.val());
+}
+disp_cr.change( event_func_disp_geo_items );
+disp_bf.change( event_func_disp_geo_items );
+get_polygons.change( function () {
+ disp_map();
+ disp_geo_items(disp_cr.prop('checked'), disp_bf.prop('checked'), get_polygons.val());
+})
+{% else %}
+const event_func_disp_geo_items = function () {
+ if (geo_items_displayed_once) {
+ disp_map();
+ }
+ else { geo_items_displayed_once = true; }
+ disp_geo_items(false, disp_bf.prop('checked'), get_polygons.val());
+}
+disp_bf.change( event_func_disp_geo_items );
+get_polygons.change( function () {
+ disp_map();
+ disp_geo_items(false, disp_bf.prop('checked'), get_polygons.val());
+})
+{% endif %}
+{% endif %}
diff --git a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
index b77922302..93035862f 100644
--- a/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
+++ b/ishtar_common/templates/ishtar/blocks/sheet_simple_map.html
@@ -6,66 +6,17 @@
<div id="map-content-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}"></div>
</div>
<script type="text/javascript">
-const disp_map = function() {
- const 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' %}
- const {{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 %}
- const {{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 == "operation" or geo_item.SLUG == "contextrecord" %}
-const disp_geo_items = function(disp_cr, disp_bf, get_polygons) {
- if (disp_cr || disp_bf) {
- const get_poly = (get_polygons === "polygons");
- let url = null;
- if (get_poly) {
- url = "{% url 'api-get-geo-polygons' %}";
- }
- else {
- url = "{% url 'api-get-geo-points' %}";
- }
- display_geo_items("map-{{window_id}}-{{geo_item.SLUG}}-{{geo_item.pk}}", url, "{{geo_item.SLUG}}",
- "{{geo_item.pk}}", disp_cr, disp_bf, get_poly);
- }
-}
-let geo_items_displayed_once = false;
-const disp_bf = $("#disp-bf-for-{{geo_item.SLUG}}-{{geo_item.pk}}");
-const get_polygons = $("#get-poly-for-{{geo_item.SLUG}}-{{geo_item.pk}}");
-
-{% if geo_item.SLUG == "operation" %}
-const disp_cr = $("#disp-cr-for-{{geo_item.SLUG}}-{{geo_item.pk}}");
-const event_func_disp_geo_items = function () {
- if (geo_items_displayed_once) {
- disp_map();
- }
- else { geo_items_displayed_once = true; }
- disp_geo_items(disp_cr.prop('checked'), disp_bf.prop('checked'), get_polygons.val());
-}
-disp_cr.change( event_func_disp_geo_items );
-disp_bf.change( event_func_disp_geo_items );
-get_polygons.change( function () {
- disp_map();
- disp_geo_items(disp_cr.prop('checked'), disp_bf.prop('checked'), get_polygons.val());
-})
+{% if PROFILE.experimental_feature %}
+{% include "ishtar/blocks/sheet_map.html" %}
{% else %}
-const event_func_disp_geo_items = function () {
- if (geo_items_displayed_once) {
- disp_map();
- }
- else { geo_items_displayed_once = true; }
- disp_geo_items(false, disp_bf.prop('checked'), get_polygons.val());
-}
-disp_bf.change( event_func_disp_geo_items );
-get_polygons.change( function () {
- disp_map();
- disp_geo_items(false, disp_bf.prop('checked'), get_polygons.val());
-})
+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 %}
{% endif %}
</script>
diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py
index 50ccf1738..52f4190de 100644
--- a/ishtar_common/tests.py
+++ b/ishtar_common/tests.py
@@ -3619,6 +3619,7 @@ class SeleniumTests(StaticLiveServerTestCase):
profile.context_record = True
profile.find = True
profile.warehouse = True
+ profile.experimental_feature = True
profile.save()
# login