Mercurial > gemma
diff 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 |
line wrap: on
line diff
--- a/client/src/components/identify/Identify.vue Fri Aug 16 17:22:17 2019 +0200 +++ b/client/src/components/identify/Identify.vue Mon Aug 19 12:27:19 2019 +0200 @@ -198,13 +198,19 @@ let featureId = this.featureId(feature); // create array with {key, val} objects + // skip geometry here, because it is slightly more robust + // to get the name of the property to skip and we need a reference + // to `feature` for doing so. + // The geometry is not needed (and previous comments in the code + // mentioned a problem with it becoming cyclic when left in). + let skipList = [feature.getGeometryName()]; let propsArray = []; Object.keys(feature.getProperties()).forEach(key => { - // skip geometry (would lead to cyclic object error) - if (key !== feature.getGeometryName()) { + if (skipList.indexOf(key) === -1) { let val = feature.getProperties()[key]; - // if val is a valid json object string, spread its values into the array + // if val is a valid json object string, + // spread its values into the array let jsonObj = this.getObjectFromString(val); if (jsonObj) { Object.keys(jsonObj).forEach(key => { @@ -217,17 +223,15 @@ } }); - // change labels and remove unneeded properties - // for all features + // run general formatter propsArray = propsArray.map(formatter.all).filter(p => p); - // feature specific + // run feature specific formatter if ( formatter.hasOwnProperty(featureId) && formatter[featureId].hasOwnProperty("props") ) { propsArray = propsArray.map(formatter[featureId].props).filter(p => p); } - // remove underscores in labels that where not previously changed already propsArray = propsArray.map(prop => { return { key: prop.key.replace(/_/g, " "), val: prop.val };