From 95a16b2aaff2f3f006603c981e088cf3a968bc16 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 9 Apr 2019 11:47:02 +0200 Subject: [PATCH] Set unique map id per page in map_list This words around the issue where a map is displayed twice while loading more maps in the home page because while loading maps some have been updated --- umap/templates/umap/map_fragment.html | 4 ++-- umap/templates/umap/map_list.html | 2 +- umap/templates/umap/search.html | 2 +- umap/templatetags/umap_tags.py | 6 ++++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/umap/templates/umap/map_fragment.html b/umap/templates/umap/map_fragment.html index 83bed716..ddeb4525 100644 --- a/umap/templates/umap/map_fragment.html +++ b/umap/templates/umap/map_fragment.html @@ -1,5 +1,5 @@ {% load umap_tags %} -
+
diff --git a/umap/templates/umap/map_list.html b/umap/templates/umap/map_list.html index 926bcdd3..672aa6a8 100644 --- a/umap/templates/umap/map_list.html +++ b/umap/templates/umap/map_list.html @@ -3,7 +3,7 @@ {% for map_inst in maps %}
- {% map_fragment map_inst prefix=prefix %} + {% map_fragment map_inst prefix=prefix page=request.GET.p %}
{{ map_inst.name }}{% if map_inst.owner %} {% trans "by" %} {{ map_inst.owner }}{% endif %}
{% endfor %} diff --git a/umap/templates/umap/search.html b/umap/templates/umap/search.html index 51c37a17..074c54c6 100644 --- a/umap/templates/umap/search.html +++ b/umap/templates/umap/search.html @@ -8,7 +8,7 @@
{% if maps %} - {% include "umap/map_list.html" with prefix='search_map_' %} + {% include "umap/map_list.html" with prefix='search_map' %} {% else %} {% trans "Not map found." %} {% endif %} diff --git a/umap/templatetags/umap_tags.py b/umap/templatetags/umap_tags.py index 86a2bbeb..c40691d1 100644 --- a/umap/templatetags/umap_tags.py +++ b/umap/templatetags/umap_tags.py @@ -50,11 +50,13 @@ def map_fragment(map_instance, **kwargs): 'slideshow': {} }) map_settings['properties'].update(kwargs) - prefix = kwargs.pop('prefix', None) or 'map_' + prefix = kwargs.pop('prefix', None) or 'map' + page = kwargs.pop('page', None) or '' + unique_id = prefix + str(page) + "_" + str(map_instance.pk) return { "map_settings": json.dumps(map_settings), "map": map_instance, - "prefix": prefix + "unique_id": unique_id }