diff options
author | Struan Donald <struan@exo.org.uk> | 2018-12-18 09:55:33 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2018-12-19 10:57:45 +0000 |
commit | 4fb4902468756ae7793312e413e7350cc02fcdb5 (patch) | |
tree | 868cf59431d65c9d6bd7b1d23d34e45313b17db7 | |
parent | 8680b7f42145332a28de2150ff4d650d56746036 (diff) |
[Buckinghamshire] change sidebar label depending on asset type
use the asset code to determine what sort of type the asset is for
displaying the 'you have selected $type $code' message. Also, pull this
out into a new set of defaults so we can apply it across multiple asset
types.
-rw-r--r-- | web/cobrands/buckinghamshire/assets.js | 50 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/assets.js | 4 |
2 files changed, 38 insertions, 16 deletions
diff --git a/web/cobrands/buckinghamshire/assets.js b/web/cobrands/buckinghamshire/assets.js index cf08f6b1f..318555494 100644 --- a/web/cobrands/buckinghamshire/assets.js +++ b/web/cobrands/buckinghamshire/assets.js @@ -77,32 +77,54 @@ var streetlight_stylemap = new OpenLayers.StyleMap({ }) }); -fixmystreet.assets.add($.extend(true, {}, defaults, { +var streetlight_code_to_type = { + 'LC': 'street light', + 'S': 'sign', + 'BB': 'belisha beacon', + 'B': 'bollard', + 'BS': 'traffic signal', + 'VMS': 'sign', + 'RB': 'bollard', + 'CPS': 'sign', + 'SF': 'sign' +}; + +var labeled_defaults = $.extend(true, {}, defaults, { select_action: true, stylemap: streetlight_stylemap, + attributes: { + central_asset_id: 'central_as', + site_code: 'site_code' + }, + actions: { + asset_found: function(asset, config) { + var id = asset.attributes.feature_id || ''; + if (id !== '') { + var code = id.replace(/[0-9]/g, ''); + var asset_name = streetlight_code_to_type[code] || config.asset_item; + $('.category_meta_message').html('You have selected ' + asset_name + ' <b>' + id + '</b>'); + } else { + $('.category_meta_message').html('You can pick a <b class="asset-spot">' + config.asset_item + '</b> from the map »'); + } + }, + asset_not_found: function(config) { + $('.category_meta_message').html('You can pick a <b class="asset-spot">' + config.asset_item + '</b> from the map »'); + } + } +}); + +fixmystreet.assets.add($.extend(true, {}, labeled_defaults, { http_options: { params: { TYPENAME: "StreetLights_Merged" } }, - attributes: { - central_asset_id: 'central_as', - site_code: 'Site_code' - }, asset_category: [ 'Light on during the day', 'Street light dim', 'Street light intermittent', 'Street light not working' ], - asset_item: 'street light', - actions: { - asset_found: function(asset) { - $('.category_meta_message').html('You have selected street light <b>' + asset.attributes.Feature_id + '</b>'); - }, - asset_not_found: function() { - $('.category_meta_message').html('You can pick a <b class="asset-spot">street light</b> from the map »'); - } - } + asset_item: 'street light' })); diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js index 65b507467..fbf40c690 100644 --- a/web/cobrands/fixmystreet/assets.js +++ b/web/cobrands/fixmystreet/assets.js @@ -112,13 +112,13 @@ OpenLayers.Layer.VectorAsset = OpenLayers.Class(OpenLayers.Layer.Vector, { asset_found: function() { if (this.fixmystreet.actions) { - this.fixmystreet.actions.asset_found(fixmystreet.assets.selectedFeature()); + this.fixmystreet.actions.asset_found(fixmystreet.assets.selectedFeature(), this.fixmystreet); } }, asset_not_found: function() { if (this.fixmystreet.actions) { - this.fixmystreet.actions.asset_not_found(); + this.fixmystreet.actions.asset_not_found(this.fixmystreet); } }, |