Mercurial > gemma
comparison client/src/components/identify/Identify.vue @ 4224:bb66e144dece
client: fix identify for bottlenecks
* Fix identify when clicking on the Data Availability/Accurary layer, by
removing the `gauge_obj` from the list of properties to format for
display. Improved some comments and code structure along the way.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Mon, 19 Aug 2019 12:27:19 +0200 |
parents | 0e91d40af23e |
children | 57c38087fe18 |
comparison
equal
deleted
inserted
replaced
4223:a76a6b26e327 | 4224:bb66e144dece |
---|---|
196 }, | 196 }, |
197 featureProps(feature) { | 197 featureProps(feature) { |
198 let featureId = this.featureId(feature); | 198 let featureId = this.featureId(feature); |
199 | 199 |
200 // create array with {key, val} objects | 200 // create array with {key, val} objects |
201 // skip geometry here, because it is slightly more robust | |
202 // to get the name of the property to skip and we need a reference | |
203 // to `feature` for doing so. | |
204 // The geometry is not needed (and previous comments in the code | |
205 // mentioned a problem with it becoming cyclic when left in). | |
206 let skipList = [feature.getGeometryName()]; | |
201 let propsArray = []; | 207 let propsArray = []; |
202 Object.keys(feature.getProperties()).forEach(key => { | 208 Object.keys(feature.getProperties()).forEach(key => { |
203 // skip geometry (would lead to cyclic object error) | 209 if (skipList.indexOf(key) === -1) { |
204 if (key !== feature.getGeometryName()) { | |
205 let val = feature.getProperties()[key]; | 210 let val = feature.getProperties()[key]; |
206 | 211 |
207 // if val is a valid json object string, spread its values into the array | 212 // if val is a valid json object string, |
213 // spread its values into the array | |
208 let jsonObj = this.getObjectFromString(val); | 214 let jsonObj = this.getObjectFromString(val); |
209 if (jsonObj) { | 215 if (jsonObj) { |
210 Object.keys(jsonObj).forEach(key => { | 216 Object.keys(jsonObj).forEach(key => { |
211 propsArray.push({ key, val: jsonObj[key] }); | 217 propsArray.push({ key, val: jsonObj[key] }); |
212 }); | 218 }); |
215 propsArray.push({ key, val }); | 221 propsArray.push({ key, val }); |
216 } | 222 } |
217 } | 223 } |
218 }); | 224 }); |
219 | 225 |
220 // change labels and remove unneeded properties | 226 // run general formatter |
221 // for all features | |
222 propsArray = propsArray.map(formatter.all).filter(p => p); | 227 propsArray = propsArray.map(formatter.all).filter(p => p); |
223 // feature specific | 228 // run feature specific formatter |
224 if ( | 229 if ( |
225 formatter.hasOwnProperty(featureId) && | 230 formatter.hasOwnProperty(featureId) && |
226 formatter[featureId].hasOwnProperty("props") | 231 formatter[featureId].hasOwnProperty("props") |
227 ) { | 232 ) { |
228 propsArray = propsArray.map(formatter[featureId].props).filter(p => p); | 233 propsArray = propsArray.map(formatter[featureId].props).filter(p => p); |
229 } | 234 } |
230 | |
231 // remove underscores in labels that where not previously changed already | 235 // remove underscores in labels that where not previously changed already |
232 propsArray = propsArray.map(prop => { | 236 propsArray = propsArray.map(prop => { |
233 return { key: prop.key.replace(/_/g, " "), val: prop.val }; | 237 return { key: prop.key.replace(/_/g, " "), val: prop.val }; |
234 }); | 238 }); |
235 | 239 |