aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cypress/cypress/fixtures/highways-ajax.json2
-rw-r--r--web/cobrands/fixmystreet/assets.js11
-rw-r--r--web/cobrands/highways/assets.js35
3 files changed, 21 insertions, 27 deletions
diff --git a/.cypress/cypress/fixtures/highways-ajax.json b/.cypress/cypress/fixtures/highways-ajax.json
index d2234bf4c..fc77ce649 100644
--- a/.cypress/cypress/fixtures/highways-ajax.json
+++ b/.cypress/cypress/fixtures/highways-ajax.json
@@ -33,5 +33,5 @@
"extra_name_info":"",
"titles_list":null,
"councils_text":"<p> These will be sent to <strong>Borsetshire County Council</strong> and also published online for others to see, in accordance with our <a href=\"/privacy\">privacy policy</a>. </p>",
- "category":"<label for='form_category' id=\"form_category_label\">Category</label> <select required class=\"validCategory form-control js-grouped-select\" name=\"category\" id=\"form_category\"> <option value='-- Pick a category --'>-- Pick a category --</option> <option value='Abandoned vehicles'>Abandoned vehicles</option> <option value='Bus stops'>Bus stops</option> <option value='Dog fouling'>Dog fouling</option> <option value='Flyposting'>Flyposting</option> <option value='Flytipping'>Flytipping</option> <option value='Footpath/bridleway away from road'>Footpath/bridleway away from road</option> <option value='Graffiti'>Graffiti</option> <option value='Parks/landscapes'>Parks/landscapes</option> <option value='Pavements'>Pavements</option> <option value='Potholes'>Potholes</option> <option value='Public toilets'>Public toilets</option> <option value='Roads/highways'>Roads/highways</option> <option value='Road traffic signs'>Road traffic signs</option> <option value='Rubbish (refuse and recycling)'>Rubbish (refuse and recycling)</option> <option value='Street cleaning'>Street cleaning</option> <option value='Street lighting'>Street lighting</option> <option value='Street nameplates'>Street nameplates</option> <option value='Traffic lights'>Traffic lights</option> <option value='Trees'>Trees</option> <option value='Other'>Other</option><optgroup label=\"** Highways England **\"><option>Road markings</option><option>Sign issue</option><option>Traffic lights</option></optgroup> <optgroup label=\"Bins\"> <option value='Broken'>Broken</option> <option value='Missing'>Missing</option> <option value='Overflowing'>Overflowing</option></optgroup></select><label id=\"form_subcategory_label\" class=\"hidden\">Subcategory</label>"
+ "category":"<label for='form_category' id=\"form_category_label\">Category</label> <select required class=\"validCategory form-control js-grouped-select\" name=\"category\" id=\"form_category\"> <option value='-- Pick a category --'>-- Pick a category --</option> <option value='Abandoned vehicles'>Abandoned vehicles</option> <option value='Bus stops'>Bus stops</option> <option value='Dog fouling'>Dog fouling</option> <option value='Flyposting'>Flyposting</option> <option value='Flytipping'>Flytipping</option> <option value='Footpath/bridleway away from road'>Footpath/bridleway away from road</option> <option value='Graffiti'>Graffiti</option> <option value='Parks/landscapes'>Parks/landscapes</option> <option value='Pavements'>Pavements</option> <option value='Potholes'>Potholes</option> <option value='Public toilets'>Public toilets</option> <option value='Roads/highways'>Roads/highways</option> <option value='Road traffic signs'>Road traffic signs</option> <option value='Rubbish (refuse and recycling)'>Rubbish (refuse and recycling)</option> <option value='Street cleaning'>Street cleaning</option> <option value='Street lighting'>Street lighting</option> <option value='Street nameplates'>Street nameplates</option> <option value='Traffic lights'>Traffic lights</option> <option value='Trees'>Trees</option> <option value='Other'>Other</option><optgroup label=\"** Highways England **\"><option value='Road markings'>Road markings</option><option value='Sign issue'>Sign issue</option><option value='Traffic lights'>Traffic lights</option></optgroup> <optgroup label=\"Bins\"> <option value='Broken'>Broken</option> <option value='Missing'>Missing</option> <option value='Overflowing'>Overflowing</option></optgroup></select><label id=\"form_subcategory_label\" class=\"hidden\">Subcategory</label>"
}
diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js
index 0a08c0f69..204ceb85d 100644
--- a/web/cobrands/fixmystreet/assets.js
+++ b/web/cobrands/fixmystreet/assets.js
@@ -1198,17 +1198,6 @@ fixmystreet.message_controller = (function() {
disable_report_form(stopper.keep_category_extras);
}
- // make sure we fire the code to check if an asset is selected if
- // we change options in the Highways England message
- $(fixmystreet).on('report_new:highways_change', function() {
- if (fixmystreet.body_overrides.get_only_send() === 'Highways England') {
- $('#' + stopperId).remove(); // Get rid of any stopper message
- responsibility_off(); // Will also reenable form
- } else {
- $(fixmystreet).trigger('report_new:category_change');
- }
- });
-
$(fixmystreet).on('report_new:category_change', check_for_stopper);
return {
diff --git a/web/cobrands/highways/assets.js b/web/cobrands/highways/assets.js
index 1607bc193..666c97e2b 100644
--- a/web/cobrands/highways/assets.js
+++ b/web/cobrands/highways/assets.js
@@ -54,22 +54,27 @@ fixmystreet.assets.add(defaults, {
nearest_radius: 15,
actions: {
found: function(layer, feature) {
- // if we've changed location then we want to reset things otherwise
- // this is probably just being called again by a category change
- var lat = $('#fixmystreet\\.latitude').val(),
- lon = $('#fixmystreet\\.longitude').val();
- if ( fixmystreet.body_overrides.location &&
- lat == fixmystreet.body_overrides.location.latitude &&
- lon == fixmystreet.body_overrides.location.longitude ) {
+ if (fixmystreet.assets.selectedFeature()) {
+ $('#highways').remove();
return;
}
- $('#highways').remove();
- if ( !fixmystreet.assets.selectedFeature() ) {
- add_highways_warning(feature.attributes.ROA_NUMBER);
+ var current_road_name = $('#highways strong').first().text();
+ var new_road_name = feature.attributes.ROA_NUMBER;
+ if (current_road_name === new_road_name) {
+ // this could be because of a category change, or because we've
+ // received new data from the server (but the pin drop had
+ // already shown the HE message)
+ if ($('#js-highways:checked').length) {
+ he_selected();
+ } else {
+ non_he_selected();
+ }
+ } else {
+ $('#highways').remove();
+ add_highways_warning(new_road_name);
}
},
not_found: function(layer) {
- fixmystreet.body_overrides.location = null;
if (fixmystreet.body_overrides.get_only_send() === 'Highways England') {
fixmystreet.body_overrides.remove_only_send();
fixmystreet.body_overrides.do_not_send('Highways England');
@@ -82,10 +87,7 @@ fixmystreet.assets.add(defaults, {
function regenerate_category(he_flag) {
if (!fixmystreet.reporting_data) return;
- fixmystreet.body_overrides.location = {
- latitude: $('#fixmystreet\\.latitude').val(),
- longitude: $('#fixmystreet\\.longitude').val()
- };
+ var old_category = $("#form_category").val();
// Restart the category dropdown from the original data (not all of it as
// we keep subcategories the same)
@@ -99,6 +101,9 @@ function regenerate_category(he_flag) {
select = select.html();
$('#form_category').html(select);
}
+ if ($("#form_category option[value=\"" + old_category + "\"]").length) {
+ $("#form_category").val(old_category);
+ }
// Recalculate the category groups
var old_category_group = $('#category_group').val() || $('#filter_group').val();