aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2019-03-25 14:41:46 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2019-03-27 09:57:01 +0000
commit36ece378eb70da1666671b32ab99d8b0b242d807 (patch)
tree38d80a55974ab7e3bda3d7dab3406f43424b84f2 /web
parent30a6e282fc75d1525ae18b5f4296f98abead83c7 (diff)
Allow things to reset if "Pick a category" picked.
This is most noticeable with category groups, where changing the parent would leave visible any asset/attribute questions.
Diffstat (limited to 'web')
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js13
1 files changed, 4 insertions, 9 deletions
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index b0a373374..23de282f2 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -388,23 +388,18 @@ $.extend(fixmystreet.set_up, {
data = fixmystreet.reporting_data.by_category[category],
$category_meta = $('#category_meta');
- if (!data) {
- // The Pick a category option, or something gone wrong
- return;
- }
-
- fixmystreet.bodies = data.bodies || [];
+ fixmystreet.bodies = data && data.bodies ? data.bodies : [];
if (fixmystreet.body_overrides) {
fixmystreet.body_overrides.clear();
}
- if (data.councils_text) {
+ if (data && data.councils_text) {
fixmystreet.update_councils_text(data);
} else {
// Use the original returned texts
fixmystreet.update_councils_text(fixmystreet.reporting_data);
}
- if ( data.category_extra ) {
+ if (data && data.category_extra) {
if ( $category_meta.length ) {
$category_meta.replaceWith( data.category_extra );
// Preserve any existing values
@@ -428,7 +423,7 @@ $.extend(fixmystreet.set_up, {
});
// apply new validation rules
fixmystreet.set_up.reapply_validation(core_validation_rules);
- $.each(data.bodies, function(index, body) {
+ $.each(fixmystreet.bodies, function(index, body) {
if ( typeof body_validation_rules !== 'undefined' && body_validation_rules[body] ) {
var rules = body_validation_rules[body];
fixmystreet.set_up.reapply_validation(rules);