comparison client/src/components/identify/Identify.vue @ 2441:9de710bdb535

client: improved identify box formatter
author Markus Kottlaender <markus@intevation.de>
date Fri, 01 Mar 2019 10:53:52 +0100
parents b6deb03ef13f
children bb5286acfee2
comparison
equal deleted inserted replaced
2440:999bb511ef67 2441:9de710bdb535
133 return formatter[this.featureId(feature)].label; 133 return formatter[this.featureId(feature)].label;
134 } 134 }
135 return this.featureId(feature); 135 return this.featureId(feature);
136 }, 136 },
137 featureProps(feature) { 137 featureProps(feature) {
138 let featureId = this.featureId(feature);
139
138 // create array with {key, val} objects 140 // create array with {key, val} objects
139 let propsArray = []; 141 let propsArray = [];
140 Object.keys(feature.getProperties()).forEach(key => { 142 Object.keys(feature.getProperties()).forEach(key => {
141 // skip geometry (would lead to cyclic object error) 143 // skip geometry (would lead to cyclic object error)
142 if (key !== feature.getGeometryName()) { 144 if (key !== feature.getGeometryName()) {
154 } 156 }
155 } 157 }
156 }); 158 });
157 159
158 // change labels and remove unneeded properties 160 // change labels and remove unneeded properties
159 if (formatter.hasOwnProperty(this.featureId(feature))) { 161 // for all features
160 propsArray = propsArray 162 propsArray = propsArray.map(formatter.all);
161 .map(formatter[this.featureId(feature)].props) 163 // feature specific
162 .filter(p => p); // remove empty entries 164 if (
165 formatter.hasOwnProperty(featureId) &&
166 formatter[featureId].hasOwnProperty("props")
167 ) {
168 propsArray = propsArray.map(formatter[featureId].props);
163 } 169 }
170 // remove empty entries
171 propsArray = propsArray.filter(p => p);
164 172
165 // remove underscores in labels that where not previously changed already 173 // remove underscores in labels that where not previously changed already
166 propsArray = propsArray.map(prop => { 174 propsArray = propsArray.map(prop => {
167 return { key: prop.key.replace(/_/g, " "), val: prop.val }; 175 return { key: prop.key.replace(/_/g, " "), val: prop.val };
168 }); 176 });