aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mytton <chrismytton@gmail.com>2019-10-18 15:20:08 +0100
committerMatthew Somerville <matthew@mysociety.org>2019-11-13 11:58:51 +0000
commit2428a81a2284db45163f7f4375fcc3c852af06ec (patch)
tree735be9a6e804ef74b6689e9ac9ec2c2cdc698e32
parent6936cdfd98213c337edf8fce78105834b9421267 (diff)
Allow multiple USRN mappings in asset layers
This change modifies the `updateUSRNField` code to accept an array of configuration objects to allow mapping multiple asset attributes to form fields. This will be used in the Bexley Confirm integration (see next commit.)
-rw-r--r--web/cobrands/fixmystreet/assets.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/web/cobrands/fixmystreet/assets.js b/web/cobrands/fixmystreet/assets.js
index 25c1ac08e..c311b0f5f 100644
--- a/web/cobrands/fixmystreet/assets.js
+++ b/web/cobrands/fixmystreet/assets.js
@@ -236,14 +236,19 @@ OpenLayers.Layer.VectorNearest = OpenLayers.Class(OpenLayers.Layer.VectorAsset,
updateUSRNField: function() {
if (this.fixmystreet.usrn) {
- var usrn_field = this.fixmystreet.usrn.field;
- var selected_usrn;
- if ( this.selected_feature ) {
- selected_usrn = this.fixmystreet.getUSRN ?
+ if (!this.fixmystreet.usrn.length) {
+ this.fixmystreet.usrn = [this.fixmystreet.usrn];
+ }
+ for (var i = 0; i < this.fixmystreet.usrn.length; i++) {
+ var usrn = this.fixmystreet.usrn[i];
+ var selected_usrn;
+ if ( this.selected_feature ) {
+ selected_usrn = this.fixmystreet.getUSRN ?
this.fixmystreet.getUSRN(this.selected_feature) :
- this.selected_feature.attributes[this.fixmystreet.usrn.attribute];
+ this.selected_feature.attributes[usrn.attribute];
+ }
+ $("input[name=" + usrn.field + "]").val(selected_usrn);
}
- $("input[name=" + usrn_field + "]").val(selected_usrn);
}
},