From: marc tobias Date: Thu, 4 Apr 2024 21:56:28 +0000 (+0200) Subject: detail page: add country to postcode -search by name- link X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/commitdiff_plain/299cd3166ec51bcfddacf4133f21439b93547bd0 detail page: add country to postcode -search by name- link --- diff --git a/src/components/DetailsOneRow.svelte b/src/components/DetailsOneRow.svelte index 8b77df2..8ba3769 100644 --- a/src/components/DetailsOneRow.svelte +++ b/src/components/DetailsOneRow.svelte @@ -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 {:else if !reverse_only && addressLine.type === 'postcode'} - + search by name {/if} diff --git a/src/pages/DetailsPage.svelte b/src/pages/DetailsPage.svelte index 225d1a0..aa3670f 100644 --- a/src/pages/DetailsPage.svelte +++ b/src/pages/DetailsPage.svelte @@ -63,6 +63,11 @@ ); } + 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') { @@ -155,7 +160,7 @@

Address

- +
@@ -172,7 +177,8 @@ {#each aPlace.address as addressLine} + bDistanceInMeters={false} + sCountryCode={country_code(aPlace)} /> {/each} {/if} diff --git a/test/details.js b/test/details.js index 2d1094d..dc907d0 100644 --- a/test/details.js +++ b/test/details.js @@ -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 () {
Local name