Mercurial > gemma
changeset 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 | a76a6b26e327 |
children | 92c2f93fef3c |
files | client/src/components/identify/Identify.vue client/src/components/identify/formatter.js |
diffstat | 2 files changed, 21 insertions(+), 8 deletions(-) [+] |
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 };
--- a/client/src/components/identify/formatter.js Fri Aug 16 17:22:17 2019 +0200 +++ b/client/src/components/identify/formatter.js Mon Aug 19 12:27:19 2019 +0200 @@ -33,7 +33,16 @@ if (p.key === "gm_n_14d") p.key = "G.W. Count in Last 14 Days"; // remove certain props - let propsToRemove = ["nobjnm", "reference_water_levels", "fa_data"]; + // * gauge_obj is another feature object and we want to stay flat + // for display (if left in causes a + // TypeError: Converting circular structure to JSON + // somewhere later) + let propsToRemove = [ + "nobjnm", + "reference_water_levels", + "fa_data", + "gauge_obj" + ]; if (propsToRemove.indexOf(p.key) !== -1) return null; return p;