aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-10-16 14:37:38 +0100
committerMatthew Somerville <matthew@mysociety.org>2019-10-16 14:37:39 +0100
commitde94514cd3d66e584d77e60c1869482f4433db77 (patch)
tree413e293bff2879aa99d43744a5ad97737598b989
parentea50c8c1090d1831d0a3a6890a0150469424aa25 (diff)
Stop VectorNearest listening on assets:selected.
An assets:selected event is always accompanied by a maps:update_pin event, which is already being listened on. Reorder the asset selection so the event still occurs before any attribute field setting.
-rw-r--r--web/cobrands/fixmystreet/assets.js12
1 files changed, 4 insertions, 8 deletions
diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js
index 1d13626cd..6a676beaa 100644
--- a/web/cobrands/fixmystreet/assets.js
+++ b/web/cobrands/fixmystreet/assets.js
@@ -187,7 +187,6 @@ OpenLayers.Layer.VectorNearest = OpenLayers.Class(OpenLayers.Layer.VectorAsset,
initialize: function(name, options) {
OpenLayers.Layer.VectorAsset.prototype.initialize.apply(this, arguments);
$(fixmystreet).on('maps:update_pin', this.checkFeature.bind(this));
- $(fixmystreet).on('assets:selected', this.checkFeature.bind(this));
// Update fields/etc from data now available from category change
$(fixmystreet).on('report_new:category_change', this.changeCategory.bind(this));
},
@@ -348,13 +347,6 @@ function asset_selected(e) {
// Keep track of selection in case layer is reloaded or hidden etc.
selected_feature = feature.clone();
- // Pick up the USRN for the location of this asset. NB we do this *before*
- // handling the attributes on the selected feature in case the feature has
- // its own USRN which should take precedence.
- $(fixmystreet).trigger('assets:selected', [ lonlat ]);
-
- this.setAttributeFields(feature);
-
// Hide the normal markers layer to keep things simple, but
// move the green marker to the point of the click to stop
// it jumping around unexpectedly if the user deselects the asset.
@@ -364,6 +356,10 @@ function asset_selected(e) {
// Need to ensure the correct coords are used for the report
fixmystreet.maps.update_pin(lonlat);
+ this.setAttributeFields(feature);
+
+ $(fixmystreet).trigger('assets:selected', [ lonlat ]);
+
// Make sure the marker that was clicked is drawn on top of its neighbours
layer.eraseFeatures([feature]);
layer.drawFeature(feature);