annotate client/src/components/identify/formatter.js @ 4775:391cc6291ea4

identify: use same date formater as in bottleneck selection
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 21 Oct 2019 12:41:05 +0200
parents 65a67b3492fd
children 544e5a2eacb6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4230
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
1 import Feature from "ol/Feature";
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
2 import app from "@/main";
4691
65a67b3492fd client: formatter: unify date formatting
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4690
diff changeset
3 import filters from "@/lib/filters";
4230
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
4
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
5 const formatter = {
2441
9de710bdb535 client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents: 2439
diff changeset
6 all(p) {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
7 if (p.key === "objnam") p.key = app.$gettext("Name");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
8 if (p.key === "objname") p.key = app.$gettext("Name");
2509
3dc7c0f60a62 client: identify box: formatted fa_date_info and fa_critical
Markus Kottlaender <markus@intevation.de>
parents: 2458
diff changeset
9 if (p.key === "staging_done" || p.key === "fa_critical")
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
10 p.val = p.val ? app.$gettext("yes") : app.$gettext("no");
3485
ef4803f87631 Add 'translation' and bottleneck attributes for measurement availability
Tom Gottfried <tom@intevation.de>
parents: 3362
diff changeset
11 if (
3635
6d6577a87963 Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents: 3505
diff changeset
12 (p.key === "date_info" ||
6d6577a87963 Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents: 3505
diff changeset
13 p.key === "fa_date_info" ||
6d6577a87963 Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents: 3505
diff changeset
14 p.key === "gm_measuredate") &&
6d6577a87963 Do not show missing date as Unix epoch
Tom Gottfried <tom@intevation.de>
parents: 3505
diff changeset
15 p.val !== null
3485
ef4803f87631 Add 'translation' and bottleneck attributes for measurement availability
Tom Gottfried <tom@intevation.de>
parents: 3362
diff changeset
16 ) {
4775
391cc6291ea4 identify: use same date formater as in bottleneck selection
Thomas Junk <thomas.junk@intevation.de>
parents: 4691
diff changeset
17 p.val = filters.surveyDate(p.val);
2441
9de710bdb535 client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents: 2439
diff changeset
18 }
2743
4063adda3095 client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents: 2573
diff changeset
19
4063adda3095 client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents: 2573
diff changeset
20 // remove certain props
4063adda3095 client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents: 2573
diff changeset
21 let propsToRemove = ["bbox"];
4063adda3095 client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents: 2573
diff changeset
22 if (propsToRemove.indexOf(p.key) !== -1) return null;
4063adda3095 client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents: 2573
diff changeset
23
2441
9de710bdb535 client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents: 2439
diff changeset
24 return p;
9de710bdb535 client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents: 2439
diff changeset
25 },
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
26 bottlenecks_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
27 label: app.$gettext("Bottleneck"),
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
28 props: p => {
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
29 if (p.key === "bottleneck_id") p.key = "ID";
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
30 if (p.key === "responsible_country")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
31 p.key = app.$gettext("Responsible Country");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
32 if (p.key === "fa_date_info") p.key = app.$gettext("Fairway Date");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
33 if (p.key === "fa_critical") p.key = app.$gettext("Fairway Critical");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
34 if (p.key === "gauge_objname") p.key = app.$gettext("Reference Gauge");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
35 if (p.key === "source_organization")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
36 p.key = app.$gettext("Source Organization");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
37 if (p.key === "gm_measuredate")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
38 p.key = app.$gettext("Gauge Waterlevel Date");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
39 if (p.key === "gm_waterlevel") p.key = app.$gettext("Gauge Waterlevel");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
40 if (p.key === "gm_n_14d")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
41 p.key = app.$gettext("G.W. Count in Last 14 Days");
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
42 // remove certain props
4224
bb66e144dece client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents: 3636
diff changeset
43 // * gauge_obj is another feature object and we want to stay flat
bb66e144dece client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents: 3636
diff changeset
44 // for display (if left in causes a
bb66e144dece client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents: 3636
diff changeset
45 // TypeError: Converting circular structure to JSON
bb66e144dece client: fix identify for bottlenecks
Bernhard Reiter <bernhard@intevation.de>
parents: 3636
diff changeset
46 // somewhere later)
4230
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
47 if (p.val instanceof Feature) {
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
48 return null;
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
49 }
f3b733fd119a Identify: Improve formatter for Identify tool
Thomas Junk <thomas.junk@intevation.de>
parents: 4224
diff changeset
50 let propsToRemove = ["nobjnm", "reference_water_levels", "fa_data"];
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
51 if (propsToRemove.indexOf(p.key) !== -1) return null;
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
52
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
53 return p;
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
54 }
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
55 },
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
56 fairway_dimensions: {
4286
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
57 label: app.$gettext("Fairway Dimensions"),
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
58 props: p => {
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
59 let propsToRemove = ["id"];
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
60 if (propsToRemove.indexOf(p.key) !== -1) return null;
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
61
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
62 return p;
1604284d2597 Client: Avoid output of primary key for fd in feature info.
Raimund Renkert <raimund@renkert.org>
parents: 4258
diff changeset
63 }
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
64 },
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
65 waterway_area: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
66 label: app.$gettext("Waterway Area")
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
67 },
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
68 distance_marks_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
69 label: app.$gettext("Distance Mark")
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
70 },
3081
9107c959bb3b client: Changed distance marks ashore to WMS layer.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2743
diff changeset
71 distance_marks_ashore_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
72 label: app.$gettext("Distance Mark ashore")
3081
9107c959bb3b client: Changed distance marks ashore to WMS layer.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2743
diff changeset
73 },
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
74 waterway_axis: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
75 label: app.$gettext("Waterway Axis")
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
76 },
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
77 waterway_profiles: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
78 label: app.$gettext("Waterway Profile")
2439
c3c014435e88 client: identify box: formatted streches
Markus Kottlaender <markus@intevation.de>
parents: 2405
diff changeset
79 },
c3c014435e88 client: identify box: formatted streches
Markus Kottlaender <markus@intevation.de>
parents: 2405
diff changeset
80 stretches_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
81 label: app.$gettext("Stretch"),
3636
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
82 props: p => {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
83 if (p.key === "gm_measuredate")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
84 p.key = app.$gettext("Min. Gauge Waterlevel Date");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
85 if (p.key === "gm_n_14d")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
86 p.key = app.$gettext("Min. G.W. Count in Last 14 Days");
3636
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
87
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
88 return p;
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
89 }
2458
204b0baac93c client: identified box: added gauges to formatter
Markus Kottlaender <markus@intevation.de>
parents: 2441
diff changeset
90 },
3309
80037790032d client: fully implemented sections
Markus Kottlaender <markus@intevation.de>
parents: 3081
diff changeset
91 sections_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
92 label: app.$gettext("Section"),
3636
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
93 props: p => {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
94 if (p.key === "gm_measuredate")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
95 p.key = app.$gettext("Min. Gauge Waterlevel Date");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
96 if (p.key === "gm_n_14d")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
97 p.key = app.$gettext("Min. G.W. Count in Last 14 Days");
3636
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
98
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
99 return p;
89a39783c20a Add forecast and measurement quality parameters to sections and stretches
Tom Gottfried <tom@intevation.de>
parents: 3635
diff changeset
100 }
3309
80037790032d client: fully implemented sections
Markus Kottlaender <markus@intevation.de>
parents: 3081
diff changeset
101 },
2458
204b0baac93c client: identified box: added gauges to formatter
Markus Kottlaender <markus@intevation.de>
parents: 2441
diff changeset
102 gauges_geoserver: {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
103 label: app.$gettext("Gauge"),
3362
bda4034304b1 client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3359
diff changeset
104 props: p => {
4258
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
105 if (p.key === "gm_measuredate")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
106 p.key = app.$gettext("Latest Waterlevel Date");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
107 if (p.key === "gm_waterlevel") p.key = app.$gettext("Latest Waterlevel");
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
108 if (p.key === "gm_n_14d")
57c38087fe18 client: correct strings-marking for translations (identify box)
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4230
diff changeset
109 p.key = app.$gettext("Measurement Count in Last 14 Days");
3362
bda4034304b1 client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3359
diff changeset
110
3505
d136ceed5d41 client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents: 3485
diff changeset
111 // remove certain props
d136ceed5d41 client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents: 3485
diff changeset
112 let propsToRemove = ["nsc_data"];
d136ceed5d41 client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents: 3485
diff changeset
113 if (propsToRemove.indexOf(p.key) !== -1) return null;
d136ceed5d41 client: identify: remove unwanted attributes from bottlenecks and gauges
Markus Kottlaender <markus@intevation.de>
parents: 3485
diff changeset
114
3362
bda4034304b1 client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3359
diff changeset
115 return p;
bda4034304b1 client: identify: added formatting for latest gauge waterlevel
Markus Kottlaender <markus@intevation.de>
parents: 3359
diff changeset
116 }
4688
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
117 },
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
118 sounding_results_areas_geoserver: {
4690
b263d9ae0057 client: mark sounding results strings for translation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4688
diff changeset
119 label: app.$gettext("Sounding results"),
4688
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
120 props: p => {
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
121 let propsToRemove = ["height"];
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
122 if (propsToRemove.indexOf(p.key) !== -1) return null;
4690
b263d9ae0057 client: mark sounding results strings for translation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4688
diff changeset
123 if (p.key === "surtyp") p.key = app.$gettext("Survey type");
b263d9ae0057 client: mark sounding results strings for translation
Fadi Abbud <fadi.abbud@intevation.de>
parents: 4688
diff changeset
124 if (p.key === "bottleneck_id") p.key = app.$gettext("Bottleneck");
4688
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
125 return p;
ad271887fd8d Added FeatureInfo for sounding results including surtyp attribute.
Raimund Renkert <raimund@renkert.org>
parents: 4286
diff changeset
126 }
2371
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
127 }
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
128 };
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
129
045bac575294 client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
130 export { formatter };