Mercurial > gemma
diff client/src/components/identify/Identify.vue @ 2405:ef928c63388a
client: handle json values in identify box
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Thu, 28 Feb 2019 08:37:41 +0100 |
parents | f185503ef35a |
children | 3423cd4b3136 |
line wrap: on
line diff
--- a/client/src/components/identify/Identify.vue Thu Feb 28 07:45:34 2019 +0100 +++ b/client/src/components/identify/Identify.vue Thu Feb 28 08:37:41 2019 +0100 @@ -138,9 +138,21 @@ // create array with {key, val} objects let propsArray = []; Object.keys(feature.getProperties()).forEach(key => { - // avoid cyclic object value - if (key !== feature.getGeometryName()) - propsArray.push({ key, val: feature.getProperties()[key] }); + let val = feature.getProperties()[key]; + + // if val is a valid json string, parse it and spread its values into + // the array + try { + let json = JSON.parse(val); + Object.keys(json).forEach(key => { + propsArray.push({ key, val: json[key] }); + }); + } catch (e) { + // if val is not json then just put the key value pair into the array + // avoid cyclic object value (I didn't further investigate what's the + // problem here but feature.getGeometryName() needs to be skipped) + if (key !== feature.getGeometryName()) propsArray.push({ key, val }); + } }); // change labels and remove unneeded properties