aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/cobrands/fixmystreet/assets.js11
-rw-r--r--web/cobrands/highways/assets.js35
2 files changed, 20 insertions, 26 deletions
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();