changeset 3779:33180c25bd87

Added extra information to search results (wwname, ISRS code) I used the opportunity to unify the design of extra information on search results: the back end can provide optional additional information in dedicated keys (currently 'location' and 'location code'), formatting and rendering is done by the front end.
author Sascha Wilde <wilde@intevation.de>
date Thu, 04 Jul 2019 17:21:21 +0200
parents 1b11ff97c1d1
children aa7bede70b96 d5d4a38866bd 49052775f57f
files client/src/components/Search.vue schema/search_functions.sql schema/updates_3.0.1/02.search_functions.sql
diffstat 3 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Search.vue	Thu Jul 04 16:30:19 2019 +0200
+++ b/client/src/components/Search.vue	Thu Jul 04 17:21:21 2019 +0200
@@ -70,7 +70,12 @@
             class="mr-1"
             fixed-width
           />
-          {{ entry.name }} {{ entry.locationcode }}
+          {{ entry.name }}
+          <span v-if="entry.location || entry.locationcode"
+            >({{ entry.location
+            }}<span v-if="entry.location && entry.locationcode">, </span
+            >{{ entry.locationcode }})</span
+          >
         </a>
       </div>
     </div>
--- a/schema/search_functions.sql	Thu Jul 04 16:30:19 2019 +0200
+++ b/schema/search_functions.sql	Thu Jul 04 17:21:21 2019 +0200
@@ -22,6 +22,7 @@
       INTO _result
       FROM (SELECT (location_code).hectometre || ' rhm' AS name,
                         isrs_asText(location_code) AS locationcode,
+                        wwname AS location,
                ST_AsGeoJSON(geom)::json AS geom, 'rhm' AS type
         FROM waterway.distance_marks_virtual
         WHERE (location_code).hectometre = search_string::int) r;
@@ -30,6 +31,7 @@
       INTO _result
       FROM (SELECT (location_code).hectometre || ' rhm' AS name,
                         isrs_asText(location_code) AS locationcode,
+                        wwname AS location,
                ST_AsGeoJSON(geom)::json AS geom, 'rhm' AS type
         FROM waterway.distance_marks_virtual
         WHERE location_code = isrs_fromText(search_string)) r;
@@ -66,7 +68,8 @@
 BEGIN
   SELECT COALESCE(json_agg(r),'[]')
     INTO _result
-    FROM (SELECT name || ' (' || country_code || ')' AS name,
+    FROM (SELECT name,
+                 country_code AS location,
                  ST_AsGeoJSON(location)::json AS geom,
                  'city' AS type
             FROM waterway.geonames
@@ -92,7 +95,8 @@
       FROM (
          SELECT objname AS name,
                    ST_AsGeoJSON(geom)::json AS geom,
-                   'gauge' AS type
+                   'gauge' AS type,
+                   isrs_asText(location) AS locationcode
               FROM waterway.gauges
               WHERE NOT erased AND location = isrs_fromText(search_string)
             ORDER BY name) r;
@@ -102,7 +106,8 @@
       FROM (
          SELECT objname AS name,
                    ST_AsGeoJSON(geom)::json AS geom,
-                   'gauge' AS type
+                   'gauge' AS type,
+                   isrs_asText(location) AS locationcode
               FROM waterway.gauges
               WHERE NOT erased AND objname ILIKE '%' || search_string || '%'
             ORDER BY name) r;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/schema/updates_3.0.1/02.search_functions.sql	Thu Jul 04 17:21:21 2019 +0200
@@ -0,0 +1,1 @@
+../search_functions.sql
\ No newline at end of file