From 153291f5440b9f4590a7aa435f45afc92089a9bc Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 20 Feb 2019 16:50:35 +0100 Subject: Map: manage a default limit to items displayed --- ishtar_common/static/js/ishtar.js | 40 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'ishtar_common/static/js') diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index e7ec6850c..e8652720a 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -29,6 +29,17 @@ if (typeof String.prototype.endsWith !== 'function') { }; } +if (typeof String.prototype.format !== 'function') { + String.prototype.format = function() { + var formatted = this; + for (var arg in arguments) { + formatted = formatted.replace("{" + arg + "}", arguments[arg]); + } + return formatted; + }; +} + + function manage_async_link(event){ event.preventDefault(); var url = $(this).attr('href'); @@ -1250,16 +1261,39 @@ var render_map_list_modal = function(map_id){ return html; }; -var render_map = function(map_id){ +var limit_map_msg = "Limit to {0} items"; +var limit_map_help_msg = "Unchecking this limit on a poorly performing device may result in web browser freeze"; +var limit_map_nb = 50000; +var current_map_limit = limit_map_nb; + +var render_map = function(map_id, use_map_limit){ var html = ""; + html += "
"; + html += "
"; + html += "
"; + html += "" + limit_map_msg.format(limit_map_nb); + html += " "; + html += "
"; html += "
"; html += "
"; html += render_map_list_modal(map_id); + current_map_limit = limit_map_nb; return html; }; var register_map = function(map_id, points){ display_map(map_id, points); + $('#ishtar-map-limit-' + map_id).change(function() { + if ($(this).prop('checked')) { + current_map_limit = limit_map_nb; + } else { + current_map_limit = 0; + } + $(".search_button").click(); + }); }; var main_submit_search = function(){ @@ -1295,5 +1329,9 @@ var search_get_query_data = function(query_vars, table_name){ if (data) data += "&"; data += "start=" + ((current_image_page - 1) * $(id_select).val()); } + if (current_tab == "map" && !current_map_limit){ + if (data) data += "&"; + data += "no_limit=true"; + } return data; }; -- cgit v1.2.3