view client/src/components/identify/formatter.js @ 3044:c71373594719

client: map: prepared store to hold multiple map objects This will be necessary to sync maps, toggle layers per map, etc. Therefore the methods to move the map (moveToExtent, etc.) became actions instead of mutations.
author Markus Kottlaender <markus@intevation.de>
date Sat, 13 Apr 2019 16:02:06 +0200
parents 4063adda3095
children 9107c959bb3b
line wrap: on
line source

const formatter = {
  all(p) {
    if (p.key === "objnam") p.key = "Name";
    if (p.key === "objname") p.key = "Name";
    if (p.key === "staging_done" || p.key === "fa_critical")
      p.val = p.val ? "yes" : "no";
    if (p.key === "date_info" || p.key === "fa_date_info") {
      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: "Bottleneck",
    props: p => {
      if (p.key === "bottleneck_id") p.key = "ID";
      if (p.key === "responsible_country") p.key = "Responsible Country";
      if (p.key === "fa_date_info") p.key = "Fairway Date";
      if (p.key === "fa_critical") p.key = "Fairway Critical";

      // remove certain props
      let propsToRemove = ["nobjnm", "reference_water_levels"];
      if (propsToRemove.indexOf(p.key) !== -1) return null;

      return p;
    }
  },
  fairway_dimensions: {
    label: "Fairway Dimensions"
  },
  waterway_area: {
    label: "Waterway Area"
  },
  distance_marks_geoserver: {
    label: "Distance Mark"
  },
  waterway_axis: {
    label: "Waterway Axis"
  },
  waterway_profiles: {
    label: "Waterway Profile"
  },
  stretches_geoserver: {
    label: "Stretch"
  },
  gauges_geoserver: {
    label: "Gauge"
  }
};

export { formatter };