X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/f9ae81bddd61b9749df987e6c8ee9263ae464705..0aa28e47e87fc78e152de7f1750e97ccf260c595:/src/pages/DetailsPage.svelte

diff --git a/src/pages/DetailsPage.svelte b/src/pages/DetailsPage.svelte
index baac180..33fb94d 100644
--- a/src/pages/DetailsPage.svelte
+++ b/src/pages/DetailsPage.svelte
@@ -54,6 +54,14 @@
     }
   }
 
+  function place_has_keywords(aThisPlace) {
+    // Return false if Nominatim API sends 'keywords: { name: [], address: [] }'
+    return (
+      aThisPlace.keywords && aThisPlace.keywords.name && aThisPlace.keywords.address
+      && (aThisPlace.keywords.name.length > 0 || aThisPlace.keywords.address.length > 0)
+    );
+  }
+
   $: {
     let pageinfo = $page;
     if (pageinfo.tab === 'details') {
@@ -61,6 +69,7 @@
       base_url = window.location.search;
     }
   }
+  $: reverse_only = Nominatim_Config.Reverse_Only;
 </script>
 
 <Header>
@@ -162,23 +171,13 @@
               {/each}
             {/if}
 
-            <tr class="all-columns"><td colspan="6"><h2>Keywords</h2></td></tr>
-            {#if api_request_params.keywords}
-
-              {#if aPlace.keywords && (aPlace.keywords.name || aPlace.keywords.address) }
-                <tr class="all-columns"><td colspan="6"><h3>Name Keywords</h3></td></tr>
-                {#each aPlace.keywords.name as keyword}
-                  <tr>
-                    <td>{formatKeywordToken(keyword.token)}</td>
-                    {#if keyword.id}
-                      <td>word id: {keyword.id}</td>
-                    {/if}
-                  </tr>
-                {/each}
+            {#if !reverse_only}
+              <tr class="all-columns"><td colspan="6"><h2>Keywords</h2></td></tr>
+              {#if api_request_params.keywords}
 
-                {#if aPlace.keywords.address}
-                  <tr class="all-columns"><td colspan="6"><h3>Address Keywords</h3></td></tr>
-                  {#each aPlace.keywords.address as keyword}
+                {#if place_has_keywords(aPlace)}
+                  <tr class="all-columns"><td colspan="6"><h3>Name Keywords</h3></td></tr>
+                  {#each aPlace.keywords.name as keyword}
                     <tr>
                       <td>{formatKeywordToken(keyword.token)}</td>
                       {#if keyword.id}
@@ -186,17 +185,29 @@
                       {/if}
                     </tr>
                   {/each}
+
+                  {#if aPlace.keywords.address}
+                    <tr class="all-columns"><td colspan="6"><h3>Address Keywords</h3></td></tr>
+                    {#each aPlace.keywords.address as keyword}
+                      <tr>
+                        <td>{formatKeywordToken(keyword.token)}</td>
+                        {#if keyword.id}
+                          <td>word id: {keyword.id}</td>
+                        {/if}
+                      </tr>
+                    {/each}
+                  {/if}
+                {:else}
+                  <tr><td>Place has no keywords</td></tr>
                 {/if}
               {:else}
-                <tr><td>Place has no keywords</td></tr>
+                <tr>
+                  <td>
+                     <a class="btn btn-outline-secondary btn-sm"
+                      href="{base_url}&keywords=1">display keywords</a>
+                  </td>
+                </tr>
               {/if}
-            {:else}
-              <tr>
-                <td>
-                   <a class="btn btn-outline-secondary btn-sm"
-                    href="{base_url}&keywords=1">display keywords</a>
-                </td>
-              </tr>
             {/if}
 
             <tr class="all-columns"><td colspan="6"><h2>Parent Of</h2></td></tr>
