Skip to content

Commit

Permalink
detail page: add country to postcode -search by name- link
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmail committed Apr 4, 2024
1 parent c2a3d9e commit a1350b5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/DetailsOneRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}
Expand Down
10 changes: 8 additions & 2 deletions src/pages/DetailsPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -155,7 +160,7 @@
<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>
Expand All @@ -172,7 +177,8 @@
{#each aPlace.address as addressLine}
<DetailsOneRow addressLine={addressLine}
bMarkUnusedLines={true}
bDistanceInMeters={false} />
bDistanceInMeters={false}
sCountryCode={country_code(aPlace)} />
{/each}
{/if}

Expand Down
6 changes: 6 additions & 0 deletions test/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit a1350b5

Please sign in to comment.