From b04539a98ddf785cdb8ffd21eb2263a9efdc382a Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 16 May 2018 17:59:34 +0100 Subject: Tweak asset message text, allow override. --- web/cobrands/fixmystreet/assets.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js index 9a72590fd..7928b6941 100644 --- a/web/cobrands/fixmystreet/assets.js +++ b/web/cobrands/fixmystreet/assets.js @@ -312,9 +312,13 @@ function check_zoom_message_visibility() { } if (this.getVisibility() && this.inRange) { - $p.html('Or pick a ' + this.fixmystreet.asset_item + ' from the map »'); + if (this.fixmystreet.asset_item_message) { + $p.html(this.fixmystreet.asset_item_message); + } else { + $p.html('You can pick a ' + this.fixmystreet.asset_item + ' 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 { -- cgit v1.2.3 From 2e9ec23409e1c17223678dd11a3b6c49eccaa810 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 17 May 2018 10:33:46 +0100 Subject: Ignore non-interactive layers for asset message. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise a non-interactive layer applying to the same category as an asset layer can cause an ‘undefined’ message to appear. --- CHANGELOG.md | 1 + web/cobrands/fixmystreet/assets.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aea940ce0..fbc50442e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,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/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js index 7928b6941..321f09284 100644 --- a/web/cobrands/fixmystreet/assets.js +++ b/web/cobrands/fixmystreet/assets.js @@ -301,6 +301,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, -- cgit v1.2.3 From 5b66cc7fc8f48a09cb6ca6ab6988f8a1d8e5c8ba Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 17 May 2018 18:01:31 +0100 Subject: Allow lookup of whether asset selected. --- web/cobrands/fixmystreet/assets.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js index 321f09284..a4e0b3f6a 100644 --- a/web/cobrands/fixmystreet/assets.js +++ b/web/cobrands/fixmystreet/assets.js @@ -238,6 +238,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 +270,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) { @@ -462,6 +463,10 @@ fixmystreet.assets = { layers: [], controls: [], + selectedFeature: function() { + return selected_feature; + }, + add: function(options) { var asset_fault_layer = null; -- cgit v1.2.3 From e26b6d32a8b15ea617343996a509c16f1eefd811 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 17 May 2018 13:04:50 +0100 Subject: [Open311] Factor cobrand overrides to functions. [Stevenage] Make sure Other included, like East Herts. --- perllib/Open311/PopulateServiceList.pm | 42 ++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index ac9f156ae..d283beb0f 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -237,6 +237,14 @@ sub _add_meta_to_contact { # Some Open311 endpoints, such as Bromley and Warwickshire send # 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'); @@ -264,11 +272,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 +301,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 +326,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 +337,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; -- cgit v1.2.3 From 636938bd3509a395647e00c926229f75471c8c72 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 17 May 2018 21:47:11 +0100 Subject: Refactor USRN/road code into a Layer class. --- web/cobrands/fixmystreet/assets.js | 173 ++++++++++++++----------------------- 1 file changed, 64 insertions(+), 109 deletions(-) diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js index a4e0b3f6a..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()); - }, - - select: function(evt, lonlat) { - fixmystreet.roads.check_for_road(lonlat); + this.checkFeature(null, fixmystreet.get_lonlat_from_dom()); }, - 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) { @@ -545,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) { -- cgit v1.2.3 From 1131880eb9a412410321c869a0aba85f3b343fde Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Fri, 16 Mar 2018 16:57:39 +0000 Subject: [Bromley] extra asset layers Adds street lights, park bins, trees, rights of way, and TfL red route asset layers. --- perllib/FixMyStreet/Map/Bromley.pm | 3 +- web/cobrands/bromley/map.js | 103 +++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) 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/web/cobrands/bromley/map.js b/web/cobrands/bromley/map.js index 0753907cc..622fbeed6 100644 --- a/web/cobrands/bromley/map.js +++ b/web/cobrands/bromley/map.js @@ -1 +1,104 @@ 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 bin 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 +})); + +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 +})); + +})(); -- cgit v1.2.3 From 07be4da57ab98fc955b0c88bb0049fd886a16b92 Mon Sep 17 00:00:00 2001 From: Struan Donald Date: Tue, 27 Mar 2018 17:34:12 +0100 Subject: [Bromley] Handle clicks on TfL road layer. If a TfL road is clicked, but no asset selected, show a message that it might not be a Bromley road and set single_body_only to TfL. Otherwise hide message and set single_body_only to Bromley. --- web/cobrands/bromley/map.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/web/cobrands/bromley/map.js b/web/cobrands/bromley/map.js index 622fbeed6..35c339f69 100644 --- a/web/cobrands/bromley/map.js +++ b/web/cobrands/bromley/map.js @@ -77,7 +77,32 @@ fixmystreet.assets.add($.extend(true, {}, defaults, { 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 + 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: Street issues'; + if ( $('#road-warning').length ) { + $('#road-warning').html(msg); + } else { + $('.change_location').after('
' + msg + '
'); + } + $('#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({ -- cgit v1.2.3 From 46655c327dc3a3d1d16b685f11c58dad1f632db4 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 17 May 2018 21:46:41 +0100 Subject: [Bromley] Store PROW id in a field if present. --- web/cobrands/bromley/map.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web/cobrands/bromley/map.js b/web/cobrands/bromley/map.js index 35c339f69..e2e8e0073 100644 --- a/web/cobrands/bromley/map.js +++ b/web/cobrands/bromley/map.js @@ -123,7 +123,17 @@ fixmystreet.assets.add($.extend(true, {}, defaults, { }, stylemap: prow_stylemap, always_visible: true, - non_interactive: 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(''); + } + } })); })(); -- cgit v1.2.3 From 360539076792ddaea6cb1ffb5cd48d694fc75be6 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 17 May 2018 17:55:05 +0100 Subject: [Bromley] Add asset/PROW ID meta to attributes. --- perllib/Open311/PopulateServiceList.pm | 19 +++++++++ t/open311/populate-service-list.t | 72 +++++----------------------------- 2 files changed, 28 insertions(+), 63 deletions(-) diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm index d283beb0f..4ffd8c143 100644 --- a/perllib/Open311/PopulateServiceList.pm +++ b/perllib/Open311/PopulateServiceList.pm @@ -248,6 +248,25 @@ sub _add_meta_to_contact_cobrand_overrides { 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'); } 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 = ' - - 100 - - - true - type - string - true - Type of bin - 1 - Type of bin - - - - '; - - 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 = ' @@ -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; -- cgit v1.2.3 From 4fd8fce72cf9adae08e1827fda984049a10580a5 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 17 May 2018 17:59:35 +0100 Subject: [Bromley] Include asset ID in title if given. --- perllib/FixMyStreet/Cobrand/Bromley.pm | 10 +++++++++- t/cobrand/bromley.t | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm index 2f47225a7..95ed5dc12 100644 --- a/perllib/FixMyStreet/Cobrand/Bromley.pm +++ b/perllib/FixMyStreet/Cobrand/Bromley.pm @@ -112,11 +112,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/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; -- cgit v1.2.3 From 7e15d7dfda2e9fb10138aa63c990dd551994cc7a Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 31 May 2018 15:19:50 +0100 Subject: For duplicate, make sure update will be included. It was checking update text was present, but not whether the update would be included. --- perllib/FixMyStreet/App/Controller/Report.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.'); } -- cgit v1.2.3