Mercurial > gemma
comparison client/src/components/identify/formatter.js @ 2441:9de710bdb535
client: improved identify box formatter
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Fri, 01 Mar 2019 10:53:52 +0100 |
parents | c3c014435e88 |
children | 204b0baac93c |
comparison
equal
deleted
inserted
replaced
2440:999bb511ef67 | 2441:9de710bdb535 |
---|---|
1 const formatter = { | 1 const formatter = { |
2 all(p) { | |
3 if (p.key === "objnam") p.key = "Name"; | |
4 if (p.key === "staging_done") p.val = p.val ? "yes" : "no"; | |
5 if (p.key === "date_info") { | |
6 p.val = new Date(p.val).toLocaleString(); | |
7 } | |
8 return p; | |
9 }, | |
2 bottlenecks_geoserver: { | 10 bottlenecks_geoserver: { |
3 label: "Bottleneck", | 11 label: "Bottleneck", |
4 props: p => { | 12 props: p => { |
5 if (p.key === "bottleneck_id") p.key = "ID"; | 13 if (p.key === "bottleneck_id") p.key = "ID"; |
6 if (p.key === "objnam") p.key = "Name"; | |
7 if (p.key === "responsible_country") p.key = "Responsible Country"; | 14 if (p.key === "responsible_country") p.key = "Responsible Country"; |
8 if (p.key === "date_info") { | |
9 p.val = new Date(p.val).toLocaleString(); | |
10 } | |
11 | 15 |
12 // remove certain props | 16 // remove certain props |
13 let propsToRemove = ["nobjnm", "reference_water_levels"]; | 17 let propsToRemove = ["nobjnm", "reference_water_levels"]; |
14 if (propsToRemove.indexOf(p.key) !== -1) return null; | 18 if (propsToRemove.indexOf(p.key) !== -1) return null; |
15 | 19 |
16 return p; | 20 return p; |
17 } | 21 } |
18 }, | 22 }, |
19 fairway_dimensions: { | 23 fairway_dimensions: { |
20 label: "Fairway Dimensions", | 24 label: "Fairway Dimensions" |
21 props: p => { | |
22 if (p.key === "staging_done") p.val = p.val ? "yes" : "no"; | |
23 if (p.key === "date_info") { | |
24 p.val = new Date(p.val).toLocaleString(); | |
25 } | |
26 | |
27 // remove certain props | |
28 let propsToRemove = []; | |
29 if (propsToRemove.indexOf(p.key) !== -1) return null; | |
30 | |
31 return p; | |
32 } | |
33 }, | 25 }, |
34 waterway_area: { | 26 waterway_area: { |
35 label: "Waterway Area", | 27 label: "Waterway Area" |
36 props: p => p | |
37 }, | 28 }, |
38 distance_marks_geoserver: { | 29 distance_marks_geoserver: { |
39 label: "Distance Mark", | 30 label: "Distance Mark" |
40 props: p => p | |
41 }, | 31 }, |
42 waterway_axis: { | 32 waterway_axis: { |
43 label: "Waterway Axis", | 33 label: "Waterway Axis" |
44 props: p => { | |
45 if (p.key === "objnam") p.key = "Name"; | |
46 return p; | |
47 } | |
48 }, | 34 }, |
49 waterway_profiles: { | 35 waterway_profiles: { |
50 label: "Waterway Profile", | 36 label: "Waterway Profile" |
51 props: p => { | |
52 if (p.key === "staging_done") p.val = p.val ? "yes" : "no"; | |
53 if (p.key === "date_info") { | |
54 p.key = "Date info"; | |
55 p.val = new Date(p.val).toLocaleString(); | |
56 } | |
57 | |
58 // remove certain props | |
59 let propsToRemove = []; | |
60 if (propsToRemove.indexOf(p.key) !== -1) return null; | |
61 | |
62 return p; | |
63 } | |
64 }, | 37 }, |
65 stretches_geoserver: { | 38 stretches_geoserver: { |
66 label: "Stretch", | 39 label: "Stretch" |
67 props: p => { | |
68 if (p.key === "date_info") { | |
69 p.key = "Date info"; | |
70 p.val = new Date(p.val).toLocaleString(); | |
71 } | |
72 return p; | |
73 } | |
74 } | 40 } |
75 }; | 41 }; |
76 | 42 |
77 export { formatter }; | 43 export { formatter }; |