diff options
author | Dave Arter <davea@mysociety.org> | 2018-03-29 13:10:09 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2018-04-03 12:44:25 +0100 |
commit | ef6d1938b0db5441ace6d86dbb0857e99b57354f (patch) | |
tree | a0b805e5e20a68723492a760cc649c2c798dc8a3 /web/cobrands/buckinghamshire/js.js | |
parent | 0c80982326dba6e9fcf6c71cdcf18ccab17f68a1 (diff) |
[Buckinghamshire] Show error message when trying to create a road defect outside of Bucks roads
Diffstat (limited to 'web/cobrands/buckinghamshire/js.js')
-rw-r--r-- | web/cobrands/buckinghamshire/js.js | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/web/cobrands/buckinghamshire/js.js b/web/cobrands/buckinghamshire/js.js index e6df526e7..ff634d825 100644 --- a/web/cobrands/buckinghamshire/js.js +++ b/web/cobrands/buckinghamshire/js.js @@ -71,6 +71,53 @@ var highways_stylemap = new OpenLayers.StyleMap({ }) }); + +// The "whole street asset" layer indicates who is responsible for maintaining +// a road via the 'feature_ty' attribute on features. +// These are roads that Bucks maintain. +var bucks_types = [ + "2", // HW: STRATEGIC ROUTE + "3A", // HW: MAIN DISTRIBUTOR + "3B", // HW: SECONDARY DISTRIBUTOR + "4A", // HW: LINK ROAD + "4B", // HW: LOCAL ACCESS ROAD +]; +// And these are roads they don't maintain. +var non_bucks_types = [ + "HE", // HW: HIGHWAYS ENGLAND + "HWOA", // OTHER AUTHORITY + "HWSA", // HW: Whole Street Asset + "P", // HW: PRIVATE +]; + +// We show roads that Bucks are and aren't responsible for, and display a +// message to the user if they click something Bucks don't maintain. +var types_to_show = bucks_types.concat(non_bucks_types); + +// Some road types we don't want to display at all. +var types_to_hide = [ + "11", // HW: BYWAY OPEN TO TRAFFIC + "12", // HW: FOOTPATH PROW + "13", // HW: BYWAY RESTRICTED + "14", // HW: BRIDLEWAY + "9", // HW: NO CARRIAGEWAY +]; + + +function show_responsibility_error(id) { + hide_responsibility_errors(); + $("#js-bucks-responsibility").removeClass("hidden"); + $("#js-bucks-responsibility .js-responsibility-message").addClass("hidden"); + $(id).removeClass("hidden"); + + // TODO: Disable report creation at this point? +} + +function hide_responsibility_errors() { + $("#js-bucks-responsibility").addClass("hidden"); + $("#js-bucks-responsibility .js-responsibility-message").addClass("hidden"); +} + fixmystreet.assets.add($.extend(true, {}, defaults, { http_options: { params: { @@ -80,10 +127,34 @@ fixmystreet.assets.add($.extend(true, {}, defaults, { stylemap: highways_stylemap, always_visible: true, non_interactive: true, + road: true, + asset_item: 'road', + asset_category: [ + "Pothole", + "Road surface" + ], + actions: { + found: function(layer, feature) { + if (bucks_types.indexOf(feature.attributes.feature_ty) != -1) { + hide_responsibility_errors(); + } else { + // User has clicked a road that Bucks don't maintain. + show_responsibility_error("#js-not-bucks-road"); + } + }, + + not_found: function(layer) { + // If a feature wasn't found at the location they've clicked, it's + // probably a field or something. Show an error to that effect. + show_responsibility_error("#js-not-a-road"); + } + }, usrn: { attribute: 'site_code', field: 'site_code' - } + }, + filter_key: 'feature_ty', + filter_value: types_to_show, })); fixmystreet.assets.add(fixmystreet.roadworks.layer_future); |