changeset 4230:f3b733fd119a

Identify: Improve formatter for Identify tool The main usecase of the formatter is providing a key-value structure for displaying information in the identify box. Therefore the assumption seems justified, that a value displayed in the identify tool should be human readable. This isn't the case for values, which are javascript objects like "Feature". That said, it seems valid to exclude such values, which are instances of "Feature". This improves the solution of ommiting one specific "feature" to a more general solution of omitting every "feature".
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 20 Aug 2019 17:15:06 +0200
parents 912b8aa42c31
children 6f31a99cd92d
files client/src/components/identify/formatter.js
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/identify/formatter.js	Tue Aug 20 11:02:43 2019 +0200
+++ b/client/src/components/identify/formatter.js	Tue Aug 20 17:15:06 2019 +0200
@@ -1,3 +1,5 @@
+import Feature from "ol/Feature";
+
 const formatter = {
   all(p) {
     if (p.key === "objnam") p.key = "Name";
@@ -31,18 +33,15 @@
       if (p.key === "gm_measuredate") p.key = "Gauge Waterlevel Date";
       if (p.key === "gm_waterlevel") p.key = "Gauge Waterlevel";
       if (p.key === "gm_n_14d") p.key = "G.W. Count in Last 14 Days";
-
       // remove certain props
       //    * 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 (p.val instanceof Feature) {
+        return null;
+      }
+      let propsToRemove = ["nobjnm", "reference_water_levels", "fa_data"];
       if (propsToRemove.indexOf(p.key) !== -1) return null;
 
       return p;