From 30a6e282fc75d1525ae18b5f4296f98abead83c7 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Mon, 25 Mar 2019 14:39:42 +0000 Subject: Stop filter category overriding chosen category. If you had one filter category selected, clicked the map (category auto pre-selected), changed the category, and clicked the map again, it would re-select the filter category, not the changed category. --- CHANGELOG.md | 1 + web/cobrands/fixmystreet/fixmystreet.js | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3b2e82a5..da8fe219b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - Show all Open311 extra fields in edit admin. - Proper bodies check for sending updates. - Check better if extra question has values. + - Stop filter category overriding chosen category. - Development improvements: - Make front page cache time configurable. - Better working of /fakemapit/ under https. diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index d6d03eac3..b0a373374 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -1170,15 +1170,22 @@ fixmystreet.update_pin = function(lonlat, savePushState) { } $('#side-form, #site-logo').show(); var category_group = $('#category_group').val(), - old_category = $("select#form_category").val(); + old_category = $("#form_category").val(), + filter_category = $("#filter_categories").val(); fixmystreet.reporting_data = data; fixmystreet.update_councils_text(data); $('#js-top-message').html(data.top_message || ''); + $('#form_category_row').html(data.category); - if ($("select#form_category option[value=\""+old_category+"\"]").length) { - $("select#form_category").val(old_category); + if ($("#form_category option[value=\"" + old_category + "\"]").length) { + $("#form_category").val(old_category); + } else if (filter_category !== undefined && $("#form_category option[value='" + filter_category + "']").length) { + // If the category filter appears on the map and the user has selected + // something from it, then pre-fill the category field in the report, + // if it's a value already present in the drop-down. + $("#form_category").val(filter_category); } if ( data.extra_name_info && !$('#form_fms_extra_title').length ) { // there might be a first name field on some cobrands @@ -1192,14 +1199,6 @@ fixmystreet.update_pin = function(lonlat, savePushState) { fixmystreet.body_overrides.clear(); } - // If the category filter appears on the map and the user has selected - // something from it, then pre-fill the category field in the report, - // if it's a value already present in the drop-down. - var category = $("#filter_categories").val(); - if (category !== undefined && $("#form_category option[value='"+category+"']").length) { - $("#form_category").val(category); - } - var category_select = $("select#form_category"); if (category_select.val() != '-- Pick a category --') { category_select.change(); -- cgit v1.2.3