Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

details page: add -search by name- for address lines having no osm_id #76

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/components/DetailsOneRow.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<script>
import DetailsLink from '../components/DetailsLink.svelte';
import PageLink from '../components/PageLink.svelte';
import {
formatPlaceType, osmLink, formatAdminLevel, formatDistance
} from '../lib/helpers.js';

export let addressLine;
export let bDistanceInMeters;

$: bAddressLineUsed = addressLine.isaddress;

import {
formatPlaceType, osmLink, formatAdminLevel, formatDistance
} from '../lib/helpers.js';

</script>

<tr class:notused={!bAddressLineUsed}>
<td class="name">
<td class="name font-weight-bold">
{#if addressLine.localname}
{addressLine.localname}
{:else}
Expand All @@ -25,16 +25,21 @@
<td>{addressLine.rank_address}</td>
<td>{formatAdminLevel(addressLine.admin_level)}</td>
<td>{@html formatDistance(addressLine.distance, bDistanceInMeters)}</td>
<td>{#if addressLine.osm_id}<DetailsLink feature={addressLine}>details</DetailsLink>{/if}</td>
<td>
{#if addressLine.osm_id}
<DetailsLink feature={addressLine}>details</DetailsLink>
{:else if addressLine.type.match(/^country/)}
<PageLink page='search', params_hash={{ country: addressLine.localname }}>search by name</PageLink>
{:else if addressLine.type === 'postcode'}
<PageLink page='search', params_hash={{ postalcode: addressLine.localname }}>search by name</PageLink>
{/if}
</td>
</tr>

<style>
.notused {
color:#ddd;
}
.name{
font-weight: bold;
}
.noname{
color:#800;
}
Expand Down
21 changes: 14 additions & 7 deletions src/components/PageLink.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<script>
import { refresh_page } from '../lib/stores.js';
import { refresh_page } from '../lib/stores.js';

export let page;
export let extra_classes = '';
export let page;
export let params_hash = {};
export let extra_classes = '';
let href = page + '.html';

function handleClick() {
refresh_page(page);
}
function handleClick() {
refresh_page(page, new URLSearchParams(params_hash));
}

$: {
let param_str = new URLSearchParams(params_hash).toString();
href = page + '.html' + (param_str ? '?' : '') + param_str;
}
</script>

<a on:click|preventDefault|stopPropagation={handleClick} href="{page}.html" class={extra_classes}><slot></slot></a>
<a on:click|preventDefault|stopPropagation={handleClick} href={href} class={extra_classes}><slot></slot></a>
2 changes: 1 addition & 1 deletion src/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function formatPlaceType(aPlace) {

// Any over 15 are invalid data in OSM anyway
function formatAdminLevel(iLevel) {
return (iLevel < 15 ? iLevel : '');
return (iLevel && iLevel < 15 ? iLevel : '');
}

function formatDistance(fDistance, bInMeters) {
Expand Down