From 475809c40225901bfa363690a1a3ae4740548684 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 23 May 2019 11:46:41 +0100 Subject: Do not focus on title on duplicate list removal. Sometimes this can be a long way down, if e.g. extra Open311 questions above. --- web/js/duplicates.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'web/js/duplicates.js') diff --git a/web/js/duplicates.js b/web/js/duplicates.js index 723c357e9..ff1f0bd47 100644 --- a/web/js/duplicates.js +++ b/web/js/duplicates.js @@ -127,23 +127,14 @@ current_duplicate_markers = markers; } - function remove_duplicate_list(cb) { - var animations = []; - - animations.push( $.Deferred() ); + function remove_duplicate_list() { $('#js-duplicate-reports').slideUp(function(){ $(this).addClass('hidden'); $(this).find('ul').empty(); - animations[0].resolve(); }); if ( $('#problem_form').length ) { - animations.push( $.Deferred() ); - $('.js-hide-if-invalid-category').slideDown(function(){ - animations[1].resolve(); - }); + $('.js-hide-if-invalid-category').slideDown(); } - - $.when.apply(this, animations).then(cb); } function remove_duplicate_pins() { @@ -180,9 +171,7 @@ $('.js-hide-duplicate-suggestions').on('click', function(e){ e.preventDefault(); remove_duplicate_pins(); - remove_duplicate_list(function(){ - $('#form_title').focus(); - }); + remove_duplicate_list(); }); })(); -- cgit v1.2.3 From d6f264c35a4aef78e1c9df75a63aee0eecbd9a7b Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 23 May 2019 12:51:45 +0100 Subject: Have duplicate and asset messages work together. --- web/js/duplicates.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'web/js/duplicates.js') diff --git a/web/js/duplicates.js b/web/js/duplicates.js index ff1f0bd47..0844cb5f3 100644 --- a/web/js/duplicates.js +++ b/web/js/duplicates.js @@ -36,7 +36,7 @@ data: url_params, dataType: 'json' }).done(function(response) { - if ( response.pins.length ){ + if (response.pins.length && take_effect()) { render_duplicate_list(response); render_duplicate_pins(response); } else { @@ -132,7 +132,7 @@ $(this).addClass('hidden'); $(this).find('ul').empty(); }); - if ( $('#problem_form').length ) { + if ($('#problem_form').length && take_effect()) { $('.js-hide-if-invalid-category').slideDown(); } } @@ -158,6 +158,17 @@ refresh_duplicate_list(); } + function take_effect() { + // We do not want to do anything if any other message is being shown + if (document.getElementById('js-category-stopper')) { + return false; + } + if ($('.js-responsibility-message:visible').length) { + return false; + } + return true; + } + // Want to show potential duplicates when a regular user starts a new // report, or changes the category/location of a partial report. $(fixmystreet).on('report_new:category_change', refresh_duplicate_list); -- cgit v1.2.3 From c30ae857af7f2e2bccf974da34cf2f3868e7b7f2 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 4 Jul 2019 21:12:12 +0100 Subject: Improve map JavaScript defensiveness. Add more checking for map things so e.g. on a skipped map page we stop getting JavaScript errors given there is no map present. --- web/js/duplicates.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'web/js/duplicates.js') diff --git a/web/js/duplicates.js b/web/js/duplicates.js index 0844cb5f3..3ed7e6079 100644 --- a/web/js/duplicates.js +++ b/web/js/duplicates.js @@ -121,6 +121,9 @@ } function render_duplicate_pins(api_response) { + if (!fixmystreet.markers) { + return; + } var markers = fixmystreet.maps.markers_list( api_response.pins, true ); fixmystreet.markers.removeFeatures( current_duplicate_markers ); fixmystreet.markers.addFeatures( markers ); @@ -138,6 +141,9 @@ } function remove_duplicate_pins() { + if (!fixmystreet.markers) { + return; + } fixmystreet.markers.removeFeatures( current_duplicate_markers ); } -- cgit v1.2.3 From ea7c5b5ff6657af974bc64e1fa4618cb6a241e7b Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 7 Aug 2019 09:59:51 +0100 Subject: Have duplicate suggestion & assets coexist better. --- web/js/duplicates.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'web/js/duplicates.js') diff --git a/web/js/duplicates.js b/web/js/duplicates.js index 3ed7e6079..023808a14 100644 --- a/web/js/duplicates.js +++ b/web/js/duplicates.js @@ -8,7 +8,11 @@ // but undefined on new report page. var report_id = $("#report_inspect_form .js-report-id").text() || undefined; - function refresh_duplicate_list() { + function refresh_duplicate_list(evt, params) { + if (params && params.skip_duplicates) { + return; + } + var category = $('select[name="category"]').val(); if (category === '-- Pick a category --') { return; @@ -128,6 +132,14 @@ fixmystreet.markers.removeFeatures( current_duplicate_markers ); fixmystreet.markers.addFeatures( markers ); current_duplicate_markers = markers; + + // Hide any asset layer that might be visible and get confused with the duplicates + var layers = fixmystreet.map.getLayersBy('assets', true); + for (var i = 0; i