diff options
-rw-r--r-- | web/cobrands/eastsussex/assets.js | 41 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/assets.js | 24 |
2 files changed, 30 insertions, 35 deletions
diff --git a/web/cobrands/eastsussex/assets.js b/web/cobrands/eastsussex/assets.js index 296c8ede4..6f5304cd0 100644 --- a/web/cobrands/eastsussex/assets.js +++ b/web/cobrands/eastsussex/assets.js @@ -72,18 +72,10 @@ fixmystreet.assets.add(defaults, { asset_item: 'street light', asset_category: ["Burning By Day", "Intermittent", "Lamp Dim", "Lamp Flashing", "Lamp Obscured", "Lamp Out", "Missing Number", "Noisy Column", "Vandalism" ], select_action: true, + feature_code: 'Name', actions: { - asset_found: function(asset) { - var id = asset.attributes.Name || ''; - if (id !== '') { - $('.category_meta_message').html('You have selected <b>' + id + '</b>'); - } else { - $('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map »'); - } - }, - asset_not_found: function() { - $('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map »'); - } + asset_found: fixmystreet.assets.named_select_action_found, + asset_not_found: fixmystreet.assets.named_select_action_not_found } }); @@ -106,22 +98,19 @@ fixmystreet.assets.add(defaults, { asset_item: 'drain', asset_category: ["Blocked Drain", "Culvert", "Broken Drain Cover", "Smell", "Sunken Drain", "Missing Drain Cover"], select_action: true, + construct_selected_asset_message: function(asset) { + var last_clean = asset.attributes.Gully_Last_Clean_Date__c || ''; + var next_clean = asset.attributes.Gully_Next_Clean_Date__c || ''; + if (last_clean !== '' || next_clean !== '') { + var message = ''; + if (last_clean) { message += '<b>Last Cleaned</b>: ' + last_clean; } + if (next_clean) { message += ' <b>Next Clean</b>: ' + next_clean; } + return message; + } + }, actions: { - asset_found: function(asset) { - var last_clean = asset.attributes.Gully_Last_Clean_Date__c || ''; - var next_clean = asset.attributes.Gully_Next_Clean_Date__c || ''; - if (last_clean !== '' || next_clean !== '') { - var message = ''; - if (last_clean) { message += '<b>Last Cleaned</b>: ' + last_clean; } - if (next_clean) { message += ' <b>Next Clean</b>: ' + next_clean; } - $('.category_meta_message').html(message); - } else { - $('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map »'); - } - }, - asset_not_found: function() { - $('.category_meta_message').html('You can pick a <b class="asset-spot">' + this.fixmystreet.asset_item + '</b> from the map »'); - } + asset_found: fixmystreet.assets.named_select_action_found, + asset_not_found: fixmystreet.assets.named_select_action_not_found } }); diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js index eda9bb276..ffa342e5f 100644 --- a/web/cobrands/fixmystreet/assets.js +++ b/web/cobrands/fixmystreet/assets.js @@ -179,6 +179,18 @@ OpenLayers.Layer.VectorAsset = OpenLayers.Class(OpenLayers.Layer.Vector, { return (f1.attributes[asset_id_field] == f2.attributes[asset_id_field]); }, + construct_selected_asset_message: function(asset) { + var id = asset.attributes[this.fixmystreet.feature_code] || ''; + if (id === '') { + return; + } + var data = { id: id, name: this.fixmystreet.asset_item }; + if (this.fixmystreet.construct_asset_name) { + data = this.fixmystreet.construct_asset_name(id) || data; + } + return 'You have selected ' + data.name + ' <b>' + data.id + '</b>'; + }, + find_matching_feature: function(feature, layer) { if (!layer) { return false; @@ -836,15 +848,9 @@ fixmystreet.assets = { return new OpenLayers.Style(f); }, named_select_action_found: function(asset) { - var id = asset.attributes[this.fixmystreet.feature_code] || ''; - var message; - if (id !== '') { - var data = { id: id, name: this.fixmystreet.asset_item }; - if (this.fixmystreet.construct_asset_name) { - data = this.fixmystreet.construct_asset_name(id) || data; - } - message = 'You have selected ' + data.name + ' <b>' + data.id + '</b>'; - } else { + var fn = this.fixmystreet.construct_selected_asset_message || this.construct_selected_asset_message; + var message = fn.call(this, asset); + if (!message) { message = get_asset_pick_message.call(this); } $('.category_meta_message').html(message); |