aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-04-24 20:10:40 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-04-24 20:10:40 +0100
commita9f5ff1d3d0c045d1ef4aae01295a0d8daab5f9f (patch)
tree4d4a778d6f2af02eca4633b7ee136911e852a5e0
parentf70ef9f6a612d3387db24519e163e6b326a9fb64 (diff)
Maintain category group on pin move.
If the same category is in multiple groups, upon moving the pin and fetching new categories from the server it would then pick the last instance of that category in the list. Instead of using val(), pick the correct entry in the previously selected optgroup.
-rw-r--r--CHANGELOG.md1
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js5
2 files changed, 5 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 71fef3855..80b74a669 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
- Application user in Docker container can't install packages. #2914
- Look at all categories when sending reports.
- Provide access to staff-only categories in admin.
+ - Maintain group on pin move with same category in multiple groups. #2962
- Development improvements:
- Refactor Script::Report into an object.
- Move summary failures to a separate script.
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index 15ba18df4..f0b4cbb84 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -1362,7 +1362,10 @@ fixmystreet.fetch_reporting_data = function() {
}
$('#form_category_row').html(data.category);
- if ($("#form_category option[value=\"" + old_category + "\"]").length) {
+ var cat_in_group = $("#form_category optgroup[label=\"" + old_category_group + "\"] option[value=\"" + old_category + "\"]");
+ if (cat_in_group.length) {
+ cat_in_group.prop({selected:true});
+ } else 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