Mercurial > gemma
view client/src/components/identify/formatter.js @ 4434:0ca5e6c4f195
Added tag v4-preview20190918 for changeset b5619087e3e9
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Wed, 18 Sep 2019 18:04:39 +0200 |
parents | 1604284d2597 |
children | ad271887fd8d |
line wrap: on
line source
import Feature from "ol/Feature"; import app from "@/main"; const formatter = { all(p) { if (p.key === "objnam") p.key = app.$gettext("Name"); if (p.key === "objname") p.key = app.$gettext("Name"); if (p.key === "staging_done" || p.key === "fa_critical") p.val = p.val ? app.$gettext("yes") : app.$gettext("no"); if ( (p.key === "date_info" || p.key === "fa_date_info" || p.key === "gm_measuredate") && p.val !== null ) { p.val = new Date(p.val).toLocaleString(); } // remove certain props let propsToRemove = ["bbox"]; if (propsToRemove.indexOf(p.key) !== -1) return null; return p; }, bottlenecks_geoserver: { label: app.$gettext("Bottleneck"), props: p => { if (p.key === "bottleneck_id") p.key = "ID"; if (p.key === "responsible_country") p.key = app.$gettext("Responsible Country"); if (p.key === "fa_date_info") p.key = app.$gettext("Fairway Date"); if (p.key === "fa_critical") p.key = app.$gettext("Fairway Critical"); if (p.key === "gauge_objname") p.key = app.$gettext("Reference Gauge"); if (p.key === "source_organization") p.key = app.$gettext("Source Organization"); if (p.key === "gm_measuredate") p.key = app.$gettext("Gauge Waterlevel Date"); if (p.key === "gm_waterlevel") p.key = app.$gettext("Gauge Waterlevel"); if (p.key === "gm_n_14d") p.key = app.$gettext("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) 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; } }, fairway_dimensions: { label: app.$gettext("Fairway Dimensions"), props: p => { let propsToRemove = ["id"]; if (propsToRemove.indexOf(p.key) !== -1) return null; return p; } }, waterway_area: { label: app.$gettext("Waterway Area") }, distance_marks_geoserver: { label: app.$gettext("Distance Mark") }, distance_marks_ashore_geoserver: { label: app.$gettext("Distance Mark ashore") }, waterway_axis: { label: app.$gettext("Waterway Axis") }, waterway_profiles: { label: app.$gettext("Waterway Profile") }, stretches_geoserver: { label: app.$gettext("Stretch"), props: p => { if (p.key === "gm_measuredate") p.key = app.$gettext("Min. Gauge Waterlevel Date"); if (p.key === "gm_n_14d") p.key = app.$gettext("Min. G.W. Count in Last 14 Days"); return p; } }, sections_geoserver: { label: app.$gettext("Section"), props: p => { if (p.key === "gm_measuredate") p.key = app.$gettext("Min. Gauge Waterlevel Date"); if (p.key === "gm_n_14d") p.key = app.$gettext("Min. G.W. Count in Last 14 Days"); return p; } }, gauges_geoserver: { label: app.$gettext("Gauge"), props: p => { if (p.key === "gm_measuredate") p.key = app.$gettext("Latest Waterlevel Date"); if (p.key === "gm_waterlevel") p.key = app.$gettext("Latest Waterlevel"); if (p.key === "gm_n_14d") p.key = app.$gettext("Measurement Count in Last 14 Days"); // remove certain props let propsToRemove = ["nsc_data"]; if (propsToRemove.indexOf(p.key) !== -1) return null; return p; } } }; export { formatter };