diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-04-02 15:27:34 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2020-07-09 11:14:10 +0100 |
commit | f55c261f92ea53d5a36da5d5297394baabd740a4 (patch) | |
tree | ef9387fe4726080061c90f2cec4f6e8a864e3c37 | |
parent | 8ab6e6105a967999dbc766d4a3fd150f5fe2c748 (diff) |
[UK] Show data from StreetManager.
20 files changed, 150 insertions, 109 deletions
diff --git a/.cypress/cypress/fixtures/iow_roadworks.json b/.cypress/cypress/fixtures/iow_roadworks.json index b20dd8514..d6d7bb31b 100644 --- a/.cypress/cypress/fixtures/iow_roadworks.json +++ b/.cypress/cypress/fixtures/iow_roadworks.json @@ -1,97 +1,16 @@ { - "query": { - "recordcount": 38, - "columnlist": "se_id,phase_id,u_se_id,longitude,latitude,gsymbol_id,tooltip,swtype,org_name_disp,promoter,source,promoter_works_ref,originator_ref,swa_org_ref,promoter_org_ref,publisher_orgref,publisher_organisation_id,promoter_organisation_id,organisation_id,lha_id,start_date,end_date,works_state,impact,works_desc,geom_type,geojson_wgs84,tm_cat", - "data": { - "se_id": [ - 114013162 - ], - "phase_id": [ - 1 - ], - "u_se_id": [ - "114013162:1" - ], - "longitude": [ - -1.29574 - ], - "latitude": [ - 50.71086 - ], - "gsymbol_id": [ - "gcln01y" - ], - "tooltip": [ - "B3401 Whitepit Lane, Newport, Isle of Wight\\n18 Jun 2019 - 23 Jul 2019\\ndelays unlikely" - ], - "swtype": [ - "cw" - ], - "org_name_disp": [ - "Island Roads on behalf of the Isle of Wight Council" - ], - "promoter": [ - "Island Roads on behalf of the Isle of Wight Council" - ], - "source": [ - "SW" - ], - "promoter_works_ref": [ - "RF101BT0103000021728" - ], - "originator_ref": [ - "RF101BT0103000021728" - ], - "swa_org_ref": [ - 2114 - ], - "promoter_org_ref": [ - 2114 - ], - "publisher_orgref": [ - 2114 - ], - "publisher_organisation_id": [ - 1062 - ], - "promoter_organisation_id": [ - 1062 - ], - "organisation_id": [ - 1062 - ], - "lha_id": [ - 62 - ], - "start_date": [ - "{ts '2019-06-18 00:00:00'}" - ], - "end_date": [ - "{ts '2030-07-23 23:59:59'}" - ], - "works_state": [ - 4 - ], - "impact": [ - 1 - ], - "works_desc": [ - "Parapet improvement NEWPORT" - ], - "geom_type": [ - 1 - ], - "geojson_wgs84": [ - "{\"type\":\"Point\",\"coordinates\":[-1.295784,50.71086]}" - ], - "tm_cat": [ - "" - ] - } - }, - "reqtoken": "", - "filterimpact": "1,2,3,4", - "filterenddate": "16/10/2019", - "filterstartdate": "16/07/2019", - "timeperiod": "cw" + "type":"FeatureCollection", + "features":[ + { + "type":"Feature", + "geometry":{"type":"Point","coordinates":[449822,90373]}, + "properties":{ + "start_date":"2019-06-18T00:00:00.000Z", + "end_date":"2040-07-23T23:59:59.000Z", + "summary":"B3401 Whitepit Lane, Newport, Isle of Wight", + "description":"Parapet improvement NEWPORT", + "promoter":"Island Roads on behalf of the Isle of Wight Council" + } + } + ] } diff --git a/.cypress/cypress/integration/bathnes.js b/.cypress/cypress/integration/bathnes.js index 1acbd3602..5598409d9 100644 --- a/.cypress/cypress/integration/bathnes.js +++ b/.cypress/cypress/integration/bathnes.js @@ -19,7 +19,7 @@ it('loads the staff layer correctly', function() { cy.window().then(function(win){ var llpg = 0; win.fixmystreet.map.layers.forEach(function(lyr) { - if (lyr.fixmystreet && lyr.fixmystreet.http_options.params.TYPENAME === 'LLPG') { + if (lyr.fixmystreet && lyr.fixmystreet.http_options && lyr.fixmystreet.http_options.params && lyr.fixmystreet.http_options.params.TYPENAME === 'LLPG') { llpg++; } }); diff --git a/.cypress/cypress/integration/isleofwight.js b/.cypress/cypress/integration/isleofwight.js index ab7039a5f..7cfb21c82 100644 --- a/.cypress/cypress/integration/isleofwight.js +++ b/.cypress/cypress/integration/isleofwight.js @@ -20,4 +20,17 @@ describe('When you look at the Island Roads site', function() { cy.get('select:eq(4)').select('Extra'); cy.contains('Help Island Roads'); }); + + it('displays nearby roadworks', function() { + cy.fixture('iow_roadworks.json'); + cy.route('/streetmanager.php**', 'fixture:iow_roadworks.json').as('roadworks'); + cy.visit('http://isleofwight.localhost:3001/'); + cy.get('[name=pc]').type('PO30 5XJ'); + cy.get('[name=pc]').parents('form').submit(); + cy.get('#map_box').click(); + cy.wait('@report-ajax'); + cy.wait('@roadworks'); + cy.contains('Roadworks are scheduled near this location'); + cy.contains('Parapet improvement'); + }); }); diff --git a/templates/web/bathnes/footer_extra_js.html b/templates/web/bathnes/footer_extra_js.html index e46e103e8..fcbbe6eb4 100644 --- a/templates/web/bathnes/footer_extra_js.html +++ b/templates/web/bathnes/footer_extra_js.html @@ -1,4 +1,11 @@ -[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 roadworks=1 %] +[% +IF bodyclass.match('mappage'); + scripts.push( + version('/cobrands/bathnes/js.js') + ); +END +%] [%~ SET council_area_id = c.cobrand.council_area_id; IF c.user_exists AND ((c.user.from_body AND c.user.from_body.areas.$council_area_id) OR c.user.is_superuser); diff --git a/templates/web/bexley/footer_extra_js.html b/templates/web/bexley/footer_extra_js.html index 7369f7147..61a02cdf0 100644 --- a/templates/web/bexley/footer_extra_js.html +++ b/templates/web/bexley/footer_extra_js.html @@ -1 +1 @@ -[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 tfl=1 %] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 tfl=1 roadworks=1 %] diff --git a/templates/web/bristol/footer_extra_js.html b/templates/web/bristol/footer_extra_js.html index 3965c9d1e..60fe6822c 100644 --- a/templates/web/bristol/footer_extra_js.html +++ b/templates/web/bristol/footer_extra_js.html @@ -1 +1 @@ -[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 ~%] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 roadworks=1 ~%] diff --git a/templates/web/bromley/footer_extra_js.html b/templates/web/bromley/footer_extra_js.html index c3bad670c..3a58505ef 100644 --- a/templates/web/bromley/footer_extra_js.html +++ b/templates/web/bromley/footer_extra_js.html @@ -2,7 +2,7 @@ version('/jslib/jquery-1.7.2.min.js'), version('/cobrands/bromley/a-z-nav.js'), ) %] -[% PROCESS 'footer_extra_js_base.html' cobrand_js=1 validation=1 tfl=1 %] +[% PROCESS 'footer_extra_js_base.html' cobrand_js=1 validation=1 tfl=1 roadworks=1 %] [% IF bodyclass.match('mappage'); scripts.push( version('/cobrands/bromley/map.js'), diff --git a/templates/web/buckinghamshire/footer_extra_js.html b/templates/web/buckinghamshire/footer_extra_js.html index 9132ead25..3e2eca135 100644 --- a/templates/web/buckinghamshire/footer_extra_js.html +++ b/templates/web/buckinghamshire/footer_extra_js.html @@ -1 +1 @@ -[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 roadworks=1 %] diff --git a/templates/web/cheshireeast/footer_extra_js.html b/templates/web/cheshireeast/footer_extra_js.html index 9132ead25..3e2eca135 100644 --- a/templates/web/cheshireeast/footer_extra_js.html +++ b/templates/web/cheshireeast/footer_extra_js.html @@ -1 +1 @@ -[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 roadworks=1 %] diff --git a/templates/web/fixmystreet-uk-councils/footer_extra_js_base.html b/templates/web/fixmystreet-uk-councils/footer_extra_js_base.html index 58e2872e3..633d1f14a 100644 --- a/templates/web/fixmystreet-uk-councils/footer_extra_js_base.html +++ b/templates/web/fixmystreet-uk-councils/footer_extra_js_base.html @@ -20,6 +20,11 @@ IF bodyclass.match('mappage'); version('/cobrands/highways/assets.js'), ); END; + IF roadworks; + scripts.push( + version('/cobrands/fixmystreet-uk-councils/roadworks.js'), + ); + END; IF tfl; scripts.push( version('/cobrands/tfl/assets.js'), diff --git a/templates/web/hounslow/footer_extra_js.html b/templates/web/hounslow/footer_extra_js.html index 081ec3a12..84531dee6 100644 --- a/templates/web/hounslow/footer_extra_js.html +++ b/templates/web/hounslow/footer_extra_js.html @@ -1,4 +1,4 @@ -[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 tfl=1 %] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 tfl=1 roadworks=1 %] [% IF bodyclass.match('mappage'); scripts.push( diff --git a/templates/web/isleofwight/footer_extra_js.html b/templates/web/isleofwight/footer_extra_js.html index a7cea7811..379ace871 100644 --- a/templates/web/isleofwight/footer_extra_js.html +++ b/templates/web/isleofwight/footer_extra_js.html @@ -1,4 +1,4 @@ -[% PROCESS 'footer_extra_js_base.html' cobrand_js=1 %] +[% PROCESS 'footer_extra_js_base.html' cobrand_js=1 roadworks=1 %] [% IF bodyclass.match('mappage'); scripts.push( version('/cobrands/isleofwight/js.js'), diff --git a/templates/web/lincolnshire/footer_extra_js.html b/templates/web/lincolnshire/footer_extra_js.html index 9132ead25..3e2eca135 100644 --- a/templates/web/lincolnshire/footer_extra_js.html +++ b/templates/web/lincolnshire/footer_extra_js.html @@ -1 +1 @@ -[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 roadworks=1 %] diff --git a/templates/web/northamptonshire/footer_extra_js.html b/templates/web/northamptonshire/footer_extra_js.html index fbd33dd11..523f441cf 100644 --- a/templates/web/northamptonshire/footer_extra_js.html +++ b/templates/web/northamptonshire/footer_extra_js.html @@ -4,4 +4,4 @@ IF bodyclass.match('mappage'); version('/cobrands/fixmystreet-uk-councils/alloy.js'), ); END %] -[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 roadworks=1 %] diff --git a/templates/web/oxfordshire/footer_extra_js.html b/templates/web/oxfordshire/footer_extra_js.html index 88fc006e7..12a42c0d2 100644 --- a/templates/web/oxfordshire/footer_extra_js.html +++ b/templates/web/oxfordshire/footer_extra_js.html @@ -1 +1 @@ -[% PROCESS 'footer_extra_js_base.html' highways=1 validation=1 %] +[% PROCESS 'footer_extra_js_base.html' highways=1 validation=1 roadworks=1 %] diff --git a/templates/web/peterborough/footer_extra_js.html b/templates/web/peterborough/footer_extra_js.html index 9132ead25..3e2eca135 100644 --- a/templates/web/peterborough/footer_extra_js.html +++ b/templates/web/peterborough/footer_extra_js.html @@ -1 +1 @@ -[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 %] +[% PROCESS 'footer_extra_js_base.html' highways=1 cobrand_js=1 validation=1 roadworks=1 %] diff --git a/templates/web/westminster/footer_extra_js.html b/templates/web/westminster/footer_extra_js.html index f6e8c8bf9..c4896cfbe 100644 --- a/templates/web/westminster/footer_extra_js.html +++ b/templates/web/westminster/footer_extra_js.html @@ -1 +1 @@ -[% PROCESS 'footer_extra_js_base.html' cobrand_js=1 tfl=1 %] +[% PROCESS 'footer_extra_js_base.html' cobrand_js=1 tfl=1 roadworks=1 %] diff --git a/web/cobrands/bathnes/js.js b/web/cobrands/bathnes/js.js new file mode 100644 index 000000000..f76da5cd5 --- /dev/null +++ b/web/cobrands/bathnes/js.js @@ -0,0 +1,11 @@ +fixmystreet.roadworks.config = { + tag_top: 'h3', + colon: true, + text_after: "<p>If you think this issue needs immediate attention you can continue your report below</p>" +}; + +fixmystreet.roadworks.filter = function(feature) { + var category = $('select#form_category').val(), + categories = ['Damage to pavement', 'Damage to road', 'Faded road markings', 'Damaged Railing, manhole, or drain cover']; + return OpenLayers.Util.indexOf(categories, category) != -1; +}; diff --git a/web/cobrands/fixmystreet-uk-councils/roadworks.js b/web/cobrands/fixmystreet-uk-councils/roadworks.js new file mode 100644 index 000000000..a3eec7b1f --- /dev/null +++ b/web/cobrands/fixmystreet-uk-councils/roadworks.js @@ -0,0 +1,82 @@ +/* Using this file, you also need to include the JavaScript file + * OpenLayers.Projection.OrdnanceSurvey.js for the 27700 conversion, and an + * OpenLayers build that includes OpenLayers.Layer.SphericalMercator and + * OpenLayers.Format.GeoJSON. + */ + +(function(){ + +var roadworks_defaults = { + http_options: { + url: "https://tilma.mysociety.org/streetmanager.php" + }, + srsName: "EPSG:27700", + format_class: OpenLayers.Format.GeoJSON, + strategy_class: OpenLayers.Strategy.FixMyStreet, + stylemap: fixmystreet.assets.stylemap_invisible, + non_interactive: true, + always_visible: true, + nearest_radius: 100, + road: true, + all_categories: true, + actions: { + found: function(layer, feature) { + $(".js-roadworks-message-" + layer.id).remove(); + if (!fixmystreet.roadworks.filter || fixmystreet.roadworks.filter(feature)) { + fixmystreet.roadworks.display_message(feature); + return true; + } + }, + not_found: function(layer) { + $(".js-roadworks-message-" + layer.id).remove(); + } + } +}; + +fixmystreet.roadworks = {}; + +// fixmystreet.map.layers[5].getNearestFeature(new OpenLayers.Geometry.Point(-0.835614, 51.816562).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:3857")), 10) + +fixmystreet.roadworks.config = {}; + +fixmystreet.roadworks.display_message = function(feature) { + var attr = feature.attributes, + start = new Date(attr.start_date).toDateString(), + end = new Date(attr.end_date).toDateString(), + summary = attr.summary, + desc = attr.description; + + var config = this.config, + summary_heading_text = config.summary_heading_text || 'Summary', + tag_top = config.tag_top || 'p', + colon = config.colon ? ':' : ''; + + var $msg = $('<div class="js-roadworks-message js-roadworks-message-' + feature.layer.id + ' box-warning"><' + tag_top + '>Roadworks are scheduled near this location, so you may not need to report your issue.</' + tag_top + '></div>'); + var $dl = $("<dl></dl>").appendTo($msg); + $dl.append("<dt>Dates" + colon + "</dt>"); + var $dates = $("<dd></dd>").appendTo($dl); + $dates.text(start + " until " + end); + if (config.extra_dates_text) { + $dates.append('<br>' + config.extra_dates_text); + } + $dl.append("<dt>" + summary_heading_text + colon + "</dt>"); + $dl.append($("<dd></dd>").text(summary)); + if (desc) { + $dl.append("<dt>Description" + colon + "</dt>"); + $dl.append($("<dd></dd>").text(desc)); + } + if (attr.promoter) { + $dl.append("<dt>Responsibility</dt>"); + $dl.append($("<dd></dd>").text(attr.promoter)); + } + + if (config.text_after) { + $dl.append(config.text_after); + } + + $msg.prependTo('#js-post-category-messages'); +}; + +fixmystreet.assets.add(roadworks_defaults); + +})(); diff --git a/web/cobrands/sass/_base.scss b/web/cobrands/sass/_base.scss index f86af2386..07bb2baa1 100644 --- a/web/cobrands/sass/_base.scss +++ b/web/cobrands/sass/_base.scss @@ -2184,6 +2184,10 @@ label .muted { margin-bottom: 0.5em; } + dd:last-child { + margin-bottom: 0; + } + .btn, .btn-primary { margin: 0.5em 0 1em 0; |