diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Bromley.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/Map/Bromley.pm | 3 | ||||
-rw-r--r-- | perllib/Open311/PopulateServiceList.pm | 61 | ||||
-rw-r--r-- | t/cobrand/bromley.t | 12 | ||||
-rw-r--r-- | t/open311/populate-service-list.t | 72 | ||||
-rw-r--r-- | web/cobrands/bromley/map.js | 138 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/assets.js | 199 |
9 files changed, 301 insertions, 197 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ea1e9fff..fff0c21a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ - Response template containing double quote now works. - A few small display issues with RTL text display. - Improve handling of loading spinner display. #2059 + - Ignore non-interactive layers for asset message. - Admin improvements: - Inspectors can set non_public status of reports. #1992 - Default start date is shown on the dashboard. diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 3f79a99f7..799985f8e 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -402,7 +402,7 @@ sub inspect : Private { if ( $problem->state eq 'duplicate') { if (my $duplicate_of = $c->get_param('duplicate_of')) { $problem->set_duplicate_of($duplicate_of); - } elsif (not $c->get_param('public_update')) { + } elsif (not $c->get_param('include_update')) { $valid = 0; push @{ $c->stash->{errors} }, _('Please provide a duplicate ID or public update for this report.'); } diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index c52e871e3..5d14d0b01 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -114,11 +114,19 @@ sub open311_config { my ($self, $row, $h, $params) = @_; my $extra = $row->get_extra_fields; + my $title = $row->title; + + foreach (@$extra) { + $title .= ' | ID: ' . $_->{value} if $_->{name} eq 'feature_id'; + $title .= ' | PROW ID: ' . $_->{value} if $_->{name} eq 'prow_reference'; + } + @$extra = grep { $_->{name} !~ /feature_id|prow_reference/ } @$extra; + push @$extra, { name => 'report_url', value => $h->{url} }, { name => 'report_title', - value => $row->title }, + value => $title }, { name => 'public_anonymity_required', value => $row->anonymous ? 'TRUE' : 'FALSE' }, { name => 'email_alerts_requested', diff --git a/perllib/FixMyStreet/Map/Bromley.pm b/perllib/FixMyStreet/Map/Bromley.pm index 1310c2a5a..22e4147f6 100644 --- a/perllib/FixMyStreet/Map/Bromley.pm +++ b/perllib/FixMyStreet/Map/Bromley.pm @@ -10,10 +10,11 @@ use base 'FixMyStreet::Map::FMS'; use strict; sub map_javascript { [ - '/vendor/OpenLayers/OpenLayers.fixmystreet.js', + '/vendor/OpenLayers/OpenLayers.buckinghamshire.js', '/js/map-OpenLayers.js', '/js/map-bing-ol.js', '/js/map-fms.js', + '/cobrands/fixmystreet/assets.js', '/cobrands/bromley/map.js', ] } diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index ac9f156ae..4ffd8c143 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -237,9 +237,36 @@ sub _add_meta_to_contact { # Some Open311 endpoints, such as Bromley and Warwickshire send <metadata> # for attributes which we *don't* want to display to the user (e.g. as # fields in "category_extras" + $self->_add_meta_to_contact_cobrand_overrides($contact, \@meta); + + $contact->set_extra_fields(@meta); + $contact->update; +} + +sub _add_meta_to_contact_cobrand_overrides { + my ( $self, $contact, $meta ) = @_; if ($self->_current_body->name eq 'Bromley Council') { $contact->set_extra_metadata( id_field => 'service_request_id_ext'); + # Lights we want to store feature ID, PROW on all categories. + push @$meta, { + code => 'prow_reference', + datatype => 'string', + description => 'Right of way reference', + order => 101, + required => 'false', + variable => 'true', + automated => 'hidden_field', + }; + push @$meta, { + code => 'feature_id', + datatype => 'string', + description => 'Feature ID', + order => 100, + required => 'false', + variable => 'true', + automated => 'hidden_field', + } if $self->_current_service->{service_code} eq 'LIGHTS'; } elsif ($self->_current_body->name eq 'Warwickshire County Council') { $contact->set_extra_metadata( id_field => 'external_id'); } @@ -264,11 +291,8 @@ sub _add_meta_to_contact { if (my $override = $override{ $self->_current_body->name }) { my %ignore = map { $_ => 1 } @{ $override }; - @meta = grep { ! $ignore{ $_->{ code } } } @meta; + @$meta = grep { ! $ignore{ $_->{ code } } } @$meta; } - - $contact->set_extra_fields(@meta); - $contact->update; } sub _normalize_service_name { @@ -296,6 +320,21 @@ sub _delete_contacts_not_in_service_list { } ); + $found_contacts = $self->_delete_contacts_not_in_service_list_cobrand_overrides($found_contacts); + + $found_contacts->update( + { + state => 'deleted', + editor => $0, + whenedited => \'current_timestamp', + note => 'automatically marked as deleted by script' + } + ); +} + +sub _delete_contacts_not_in_service_list_cobrand_overrides { + my ( $self, $found_contacts ) = @_; + # for Warwickshire/Bristol/BANES, which are mixed Open311 and email, don't delete # the email addresses if ($self->_current_body->name eq 'Warwickshire County Council' || @@ -306,8 +345,9 @@ sub _delete_contacts_not_in_service_list { email => { -not_like => '%@%' } } ); - } elsif ($self->_current_body->name eq 'East Hertfordshire District Council') { - # For EHDC we need to leave the 'Other' category alone or reports made + } elsif ($self->_current_body->name eq 'East Hertfordshire District Council' || + $self->_current_body->name eq 'Stevenage Borough Council') { + # For EHDC/Stevenage we need to leave the 'Other' category alone or reports made # in this category will be sent only to Hertfordshire County Council. $found_contacts = $found_contacts->search( { @@ -316,14 +356,7 @@ sub _delete_contacts_not_in_service_list { ); } - $found_contacts->update( - { - state => 'deleted', - editor => $0, - whenedited => \'current_timestamp', - note => 'automatically marked as deleted by script' - } - ); + return $found_contacts; } 1; diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index e42ab5be2..b3fb3564b 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -54,6 +54,7 @@ for my $test ( 'attribute[easting]' => 529025, 'attribute[northing]' => 179716, 'attribute[service_request_id_ext]' => $report->id, + 'attribute[report_title]' => 'Test Test 1 for ' . $body->id, 'jurisdiction_id' => 'FMS', address_id => undef, }, @@ -72,11 +73,20 @@ for my $test ( 'address_id' => '#NOTPINPOINTED#', }, }, + { + desc => 'asset ID', + feature_id => '1234', + expected => { + 'attribute[service_request_id_ext]' => $report->id, + 'attribute[report_title]' => 'Test Test 1 for ' . $body->id . ' | ID: 1234', + }, + }, ) { subtest $test->{desc}, sub { - $report->set_extra_fields(); $report->$_($test->{updates}->{$_}) for keys %{$test->{updates}}; $report->$_(undef) for qw/ whensent send_method_used external_id /; + $report->set_extra_fields({ name => 'feature_id', value => $test->{feature_id} }) + if $test->{feature_id}; $report->update; $body->update( { send_method => 'Open311', endpoint => 'http://bromley.endpoint.example.com', jurisdiction => 'FMS', api_key => 'test', send_comments => 1 } ); my $test_data; diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t index 7d4f491c6..b54b1c242 100644 --- a/t/open311/populate-service-list.t +++ b/t/open311/populate-service-list.t @@ -192,67 +192,6 @@ subtest 'check conflicting contacts not changed' => sub { is $contact_count, 4, 'correct number of contacts'; }; -subtest 'check meta data population' => sub { - my $processor = Open311::PopulateServiceList->new(); - - my $meta_xml = '<?xml version="1.0" encoding="utf-8"?> -<service_definition> - <service_code>100</service_code> - <attributes> - <attribute> - <variable>true</variable> - <code>type</code> - <datatype>string</datatype> - <required>true</required> - <datatype_description>Type of bin</datatype_description> - <order>1</order> - <description>Type of bin</description> - </attribute> - </attributes> -</service_definition> - '; - - my $contact = FixMyStreet::DB->resultset('Contact')->find_or_create( - { - body_id => 1, - email => '001', - category => 'Bins left out 24x7', - state => 'confirmed', - editor => $0, - whenedited => \'current_timestamp', - note => 'test contact', - } - ); - - my $o = Open311->new( - jurisdiction => 'mysociety', - endpoint => 'http://example.com', - test_mode => 1, - test_get_returns => { 'services/100.xml' => $meta_xml } - ); - - $processor->_current_open311( $o ); - $processor->_current_body( $bromley ); - $processor->_current_service( { service_code => 100 } ); - - $processor->_add_meta_to_contact( $contact ); - - my $extra = [ { - variable => 'true', - code => 'type', - datatype => 'string', - required => 'true', - datatype_description => 'Type of bin', - order => 1, - description => 'Type of bin' - - } ]; - - $contact->discard_changes; - - is_deeply $contact->get_extra_fields, $extra, 'meta data saved'; -}; - for my $test ( { desc => 'check meta data added to existing contact', @@ -527,7 +466,7 @@ subtest 'check attribute ordering' => sub { is_deeply $contact->get_extra_fields, $extra, 'meta data re-ordered correctly'; }; -subtest 'check bromely skip code' => sub { +subtest 'check Bromley skip code' => sub { my $processor = Open311::PopulateServiceList->new(); my $meta_xml = '<?xml version="1.0" encoding="utf-8"?> @@ -598,7 +537,14 @@ subtest 'check bromely skip code' => sub { datatype_description => 'Type of bin', order => 1, description => 'Type of bin' - + }, { + automated => 'hidden_field', + variable => 'true', + code => 'prow_reference', + datatype => 'string', + required => 'false', + order => 101, + description => 'Right of way reference' } ]; $contact->discard_changes; diff --git a/web/cobrands/bromley/map.js b/web/cobrands/bromley/map.js index 0753907cc..e2e8e0073 100644 --- a/web/cobrands/bromley/map.js +++ b/web/cobrands/bromley/map.js @@ -1 +1,139 @@ fixmystreet.maps.tile_base = [ [ "", "a-" ], "https://{S}fix.bromley.gov.uk/tilma" ]; + +(function(){ + +if (!fixmystreet.maps) { + return; +} + +var defaults = { + http_options: { + url: "https://tilma.staging.mysociety.org/mapserver/bromley_wfs", + params: { + SERVICE: "WFS", + VERSION: "1.1.0", + REQUEST: "GetFeature", + SRSNAME: "urn:ogc:def:crs:EPSG::3857" + } + }, + format_class: OpenLayers.Format.GML.v3.MultiCurveFix, + asset_type: 'spot', + max_resolution: 2.388657133579254, + min_resolution: 0.5971642833948135, + asset_id_field: 'CENTRAL_AS', + geometryName: 'msGeometry', + srsName: "EPSG:3857", + strategy_class: OpenLayers.Strategy.FixMyStreet +}; + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "Streetlights" + } + }, + asset_id_field: 'FEATURE_ID', + attributes: { + feature_id: 'FEATURE_ID' + }, + asset_category: ["Faulty street light"], + asset_item: 'street light' +})); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "Bins" + } + }, + asset_category: ["Overflowing litter bin"], + asset_item: 'park bin', + asset_item_message: 'For our parks, pick a <b class="asset-spot">bin</b> from the map »' +})); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "Street_Trees" + } + }, + asset_category: ["Public Tree related issue"], + asset_item: 'tree' +})); + +var highways_stylemap = new OpenLayers.StyleMap({ + 'default': new OpenLayers.Style({ + fill: false, + stroke: false + }) +}); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "TFL_Red_Route" + } + }, + stylemap: highways_stylemap, + always_visible: true, + asset_category: ["Blocked drains", "Faulty street light", 'Faulty street sign', 'Floral displays', 'Grass needs cutting', 'Obstructions (skips, A boards)', 'Overhanging vegetation from private land', 'Pavement defect', 'Public Tree related issue', "Road defect"], + non_interactive: true, + road: true, + actions: { + found: function(layer) { + if (fixmystreet.assets.selectedFeature()) { + $('#road-warning').remove(); + return; + } + var msg = 'The location selected is a Transport for London Red Route. TfL are responsible for the reported category and can be alerted to issues via: <a href="https://tfl.gov.uk/help-and-contact/contact-us-about-streets-and-other-road-issues">Street issues</a>'; + if ( $('#road-warning').length ) { + $('#road-warning').html(msg); + } else { + $('.change_location').after('<div class="box-warning" id="road-warning">' + msg + '</div>'); + } + $('#single_body_only').val(layer.fixmystreet.body_found); + }, + + not_found: function(layer) { + if ( $('#road-warning').length ) { + $('#road-warning').remove(); + } + $('#single_body_only').val(layer.fixmystreet.body_council); + } + }, + body_found: 'TfL', + body_council: 'Bromley Council' +})); + +var prow_stylemap = new OpenLayers.StyleMap({ + 'default': new OpenLayers.Style({ + fill: false, + fillOpacity: 0, + strokeColor: "#660099", + strokeOpacity: 0.5, + strokeWidth: 6 + }) +}); + +fixmystreet.assets.add($.extend(true, {}, defaults, { + http_options: { + params: { + TYPENAME: "PROW" + } + }, + stylemap: prow_stylemap, + always_visible: true, + non_interactive: true, + road: true, + all_categories: true, + actions: { + found: function(layer, feature) { + $('#form_prow_reference').val(feature.attributes.PROW_REFER); + }, + not_found: function(layer) { + $('#form_prow_reference').val(''); + } + } +})); + +})(); diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js index 9a72590fd..5af8ef1cd 100644 --- a/web/cobrands/fixmystreet/assets.js +++ b/web/cobrands/fixmystreet/assets.js @@ -16,139 +16,90 @@ var fixmystreet = fixmystreet || {}; }; })(); -/* Special USRN handling */ - -(function(){ - -var selected_usrn = null; -var usrn_field = null; +// Handles layers such as USRN, TfL roads, and the like +OpenLayers.Layer.VectorNearest = OpenLayers.Class(OpenLayers.Layer.Vector, { + selected_feature: null, + + initialize: function(name, options) { + OpenLayers.Layer.Vector.prototype.initialize.apply(this, arguments); + $(fixmystreet).on('maps:update_pin', this.checkFeature.bind(this)); + $(fixmystreet).on('assets:selected', this.checkFeature.bind(this)); + // Might only be able to fill in fields once they've been returned from the server + $(fixmystreet).on('report_new:category_change:extras_received', this.changeCategory.bind(this)); + // But also want to do it immediately in case it's hiding the form or something + $(fixmystreet).on('report_new:category_change', this.changeCategory.bind(this)); + }, -fixmystreet.usrn = { - select: function(evt, lonlat) { - var usrn_providers = fixmystreet.map.getLayersBy('fixmystreet', { - test: function(options) { - return options && options.usrn; - } - }); - if (usrn_providers.length) { - var usrn_layer = usrn_providers[0]; - usrn_field = usrn_layer.fixmystreet.usrn.field; - var point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat); - var feature = usrn_layer.getFeatureAtPoint(point); - if (feature == null) { - // The click wasn't directly over a road, try and find one - // nearby - feature = usrn_layer.getNearestFeature(point, 10); - } - if (feature !== null) { - selected_usrn = feature.attributes[usrn_layer.fixmystreet.usrn.attribute]; + checkFeature: function(evt, lonlat) { + this.getNearest(lonlat); + this.updateUSRNField(); + if (this.fixmystreet.road) { + var valid_category = this.fixmystreet.all_categories || (this.fixmystreet.asset_category && this.fixmystreet.asset_category.indexOf($('select#form_category').val()) != -1); + if (!valid_category || !this.selected_feature) { + this.road_not_found(); } else { - selected_usrn = null; + this.road_found(); } - fixmystreet.usrn.update_field(); } }, - update_field: function() { - $("input[name="+usrn_field+"]").val(selected_usrn); + getNearest: function(lonlat) { + var point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat); + var feature = this.getFeatureAtPoint(point); + if (feature == null) { + // The click wasn't directly over a road, try and find one nearby + feature = this.getNearestFeature(point, 10); + } + this.selected_feature = feature; }, - one_time_select: function() { - // This function takes the current report lat/lon from hidden input - // fields and uses that to look up a USRN from the USRN layer. - // It's registered as an event handler by init_asset_layer below, - // and is only intended to run the once (because if the user drags the - // pin the usual USRN lookup event handler is run) so unregisters itself - // immediately. - this.events.unregister( 'loadend', this, fixmystreet.usrn.one_time_select ); - fixmystreet.usrn.select(null, fixmystreet.get_lonlat_from_dom()); - } -}; - -$(fixmystreet).on('maps:update_pin', fixmystreet.usrn.select); -$(fixmystreet).on('assets:selected', fixmystreet.usrn.select); -$(fixmystreet).on('report_new:category_change:extras_received', fixmystreet.usrn.update_field); - -})(); - -(function(){ - -var selected_road = null; - -fixmystreet.roads = { - last_road: null, + updateUSRNField: function() { + if (this.fixmystreet.usrn) { + var usrn_field = this.fixmystreet.usrn.field; + var selected_usrn = this.selected_feature ? this.selected_feature.attributes[this.fixmystreet.usrn.attribute] : ''; + $("input[name=" + usrn_field + "]").val(selected_usrn); + } + }, - change_category: function() { + changeCategory: function() { if (!fixmystreet.map) { // Sometimes the category change event is fired before the map has // initialised, for example when visiting /report/new directly // on a cobrand with category groups enabled. return; } - fixmystreet.roads.check_for_road(fixmystreet.get_lonlat_from_dom()); + this.checkFeature(null, fixmystreet.get_lonlat_from_dom()); }, - select: function(evt, lonlat) { - fixmystreet.roads.check_for_road(lonlat); - }, - - check_for_road: function(lonlat) { - var road_providers = fixmystreet.map.getLayersBy('fixmystreet', { - test: function(options) { - return options && options.road && (options.all_categories || options.asset_category.indexOf($('select#form_category').val()) != -1); - } - }); - if (road_providers.length) { - var road_layer = road_providers[0]; - fixmystreet.roads.last_road = road_layer; - var point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat); - var feature = road_layer.getFeatureAtPoint(point); - if (feature == null) { - // The click wasn't directly over a road, try and find one - // nearby - feature = road_layer.getNearestFeature(point, 10); - } - if (feature !== null) { - selected_road = feature; //.attributes[road_layer.fixmystreet.road.attribute]; - } else { - selected_road = null; - } - if (selected_road) { - fixmystreet.roads.found(road_layer, selected_road); - } else { - fixmystreet.roads.not_found(road_layer); - } - } else { - fixmystreet.roads.not_found(); - } + one_time_select: function() { + // This function takes the current report lat/lon from hidden input + // fields and uses that to look up a USRN from the USRN layer. + // It's registered as an event handler by init_asset_layer below, + // and is only intended to run the once (because if the user drags the + // pin the usual USRN lookup event handler is run) so unregisters itself + // immediately. + this.events.unregister( 'loadend', this, this.one_time_select ); + this.checkFeature(null, fixmystreet.get_lonlat_from_dom()); }, - found: function(layer, feature) { - if (layer.fixmystreet.actions) { - layer.fixmystreet.actions.found(layer, feature); + road_found: function() { + if (this.fixmystreet.actions) { + this.fixmystreet.actions.found(this, this.selected_feature); } else { - $('#single_body_only').val(layer.fixmystreet.body); + $('#single_body_only').val(this.fixmystreet.body); } }, - not_found: function(layer) { - if (layer && layer.fixmystreet.actions) { - layer.fixmystreet.actions.not_found(layer); + road_not_found: function() { + if (this.fixmystreet.actions) { + this.fixmystreet.actions.not_found(this); } else { - if ( fixmystreet.roads.last_road && fixmystreet.roads.last_road.fixmystreet.actions.unselected ) { - fixmystreet.roads.last_road.fixmystreet.actions.unselected(); - fixmystreet.roads.last_road = null; - } $('#single_body_only').val(''); } }, -}; - -$(fixmystreet).on('maps:update_pin', fixmystreet.roads.select); -$(fixmystreet).on('assets:selected', fixmystreet.roads.select); -$(fixmystreet).on('report_new:category_change', fixmystreet.roads.change_category); -})(); + CLASS_NAME: 'OpenLayers.Layer.VectorNearest' +}); (function(){ @@ -176,17 +127,17 @@ function init_asset_layer(layer, pins_layer) { layer.fixmystreet.fault_layer.setZIndex(layer.getZIndex()-1); } - if (fixmystreet.page == 'new' && layer.fixmystreet.usrn) { + if (fixmystreet.page == 'new' && (layer.fixmystreet.usrn || layer.fixmystreet.road)) { // If the user visits /report/new directly and doesn't change the pin // location, then the assets:selected/maps:update_pin events are never - // fired and fixmystreet.usrn.select is never called. This results in a + // fired and USRN's checkFeature is never called. This results in a // report whose location was never looked up against the USRN layer, // which can cause issues for Open311 endpoints that require a USRN // value. // To prevent this situation we register an event handler that looks up // the new report's lat/lon against the USRN layer, calls usrn.select // and then unregisters itself. - layer.events.register( 'loadend', layer, fixmystreet.usrn.one_time_select ); + layer.events.register( 'loadend', layer, layer.one_time_select ); } if (!layer.fixmystreet.always_visible) { @@ -238,6 +189,12 @@ function asset_selected(e) { return; } + var layer = e.feature.layer; + var feature = e.feature; + + // 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. @@ -264,13 +221,8 @@ function asset_selected(e) { fixmystreet.maps.update_pin(lonlat); // Make sure the marker that was clicked is drawn on top of its neighbours - var layer = e.feature.layer; - var feature = e.feature; layer.eraseFeatures([feature]); layer.drawFeature(feature); - - // Keep track of selection in case layer is reloaded or hidden etc. - selected_feature = feature.clone(); } function asset_unselected(e) { @@ -301,6 +253,9 @@ function find_matching_feature(feature, layer, asset_id_field) { } function check_zoom_message_visibility() { + if (this.fixmystreet.non_interactive) { + return; + } var category = $("#problem_form select#form_category").val(), prefix = category.replace(/[^a-z]/gi, ''), id = "category_meta_message_" + prefix, @@ -312,9 +267,13 @@ function check_zoom_message_visibility() { } if (this.getVisibility() && this.inRange) { - $p.html('Or pick a <b class="asset-' + this.fixmystreet.asset_type + '">' + this.fixmystreet.asset_item + '</b> from the map »'); + if (this.fixmystreet.asset_item_message) { + $p.html(this.fixmystreet.asset_item_message); + } else { + $p.html('You can pick a <b class="asset-' + this.fixmystreet.asset_type + '">' + this.fixmystreet.asset_item + '</b> from the map »'); + } } else { - $p.html('Or zoom in and pick a ' + this.fixmystreet.asset_item + ' from the map'); + $p.html('Zoom in to pick a ' + this.fixmystreet.asset_item + ' from the map'); } } else { @@ -455,6 +414,10 @@ fixmystreet.assets = { layers: [], controls: [], + selectedFeature: function() { + return selected_feature; + }, + add: function(options) { var asset_fault_layer = null; @@ -533,7 +496,11 @@ fixmystreet.assets = { } } - var asset_layer = new OpenLayers.Layer.Vector(options.name || "WFS", layer_options); + var layer_class = OpenLayers.Layer.Vector; + if (options.usrn || options.road) { + layer_class = OpenLayers.Layer.VectorNearest; + } + var asset_layer = new layer_class(options.name || "WFS", layer_options); // A non-interactive layer to display existing asset faults if (options.wfs_fault_feature) { |