]> git.openstreetmap.org Git - nominatim-ui.git/commitdiff
detail page: add country to postcode -search by name- link
authormarc tobias <mtmail@gmx.net>
Thu, 4 Apr 2024 21:56:28 +0000 (23:56 +0200)
committermtmail <mtmail@gmx.net>
Fri, 5 Apr 2024 09:06:44 +0000 (11:06 +0200)
src/components/DetailsOneRow.svelte
src/pages/DetailsPage.svelte
test/details.js

index 8b77df236c1d25a0f2f1457b0b5266fa9bf8fcc1..8ba3769b7b76188b1176485704be2e9dcd0c9a7b 100644 (file)
@@ -8,6 +8,7 @@
   export let addressLine;
   export let bDistanceInMeters;
   export let bMarkUnusedLines = false;
+  export let sCountryCode;
 
   $: bAddressLineUsed = addressLine.isaddress;
   $: reverse_only = Nominatim_Config.Reverse_Only;
@@ -38,7 +39,8 @@
         search by name
       </PageLink>
     {:else if !reverse_only && addressLine.type === 'postcode'}
-      <PageLink page='search' params_hash={{ postalcode: addressLine.localname }}>
+      <PageLink page='search'
+                params_hash={{ postalcode: addressLine.localname, country: sCountryCode }}>
         search by name
       </PageLink>
     {/if}
index 225d1a0662ff81353acd063e5ee50ba337c493af..aa3670f072f02c74ed61583bf689cb7f356048fd 100644 (file)
     );
   }
 
+  function country_code(aThisPlace) {
+    let aLine = aThisPlace.address.find((address_line) => address_line.type === 'country_code');
+    return aLine ? aLine.localname : null;
+  }
+
   $: {
     let pageinfo = $page;
     if (pageinfo.tab === 'details') {
     <div class="row">
       <div class="col-md-12">
         <h2>Address</h2>
-         <table id="address" class="table table-striped table-small">
+        <table id="address" class="table table-striped table-small">
           <thead>
             <tr>
               <th>Local name</th>
               {#each aPlace.address as addressLine}
                 <DetailsOneRow addressLine={addressLine}
                                bMarkUnusedLines={true}
-                               bDistanceInMeters={false} />
+                               bDistanceInMeters={false}
+                               sCountryCode={country_code(aPlace)} />
               {/each}
             {/if}
 
index 2d1094d78f3cf59372c4287434de0c238a6b6910..dc907d0b01cca27ad360583531a34d19722f60ee 100644 (file)
@@ -66,6 +66,12 @@ describe('Details Page', function () {
       assert.strictEqual((await page.$$eval(`a[href="${url}"]`, (links) => links.length)), 2);
     });
 
+    it('should have a link to postcode which includes country code', async function () {
+      const url = 'search.html?postalcode=9490&country=li';
+
+      assert.strictEqual((await page.$$eval(`a[href="${url}"]`, (links) => links.length)), 1);
+    });
+
     // Reverse-only installation have no search index, therefore no keywords
     if (!reverse_only) {
       it('should change url and add new header on clicking display keywords', async function () {