From 0aa28e47e87fc78e152de7f1750e97ccf260c595 Mon Sep 17 00:00:00 2001 From: mtmail Date: Wed, 27 Oct 2021 18:33:10 +0200 Subject: [PATCH] new config option -Reverse_Only- (#166) --- .github/workflows/ci.yml | 10 ++++-- dist/config.defaults.js | 3 ++ dist/search.html | 6 ++++ src/components/DetailsOneRow.svelte | 6 ++-- src/components/Error.svelte | 2 +- src/components/Header.svelte | 11 ++++--- src/lib/stores.js | 15 +++++++-- src/pages/DetailsPage.svelte | 51 +++++++++++++++-------------- test/_bootstrap.js | 3 +- test/config_reverse_only.js | 31 ++++++++++++++++++ test/details.js | 37 ++++++++++++--------- test/search.js | 3 ++ 12 files changed, 125 insertions(+), 53 deletions(-) create mode 100644 test/config_reverse_only.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5833130..a8c25ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,10 @@ jobs: run: yarn build - name: Testing - run: | - yarn test - API_ON_SAME_PORT=1 yarn test + run: yarn test + + - name: Testing API_ON_SAME_PORT + run: API_ON_SAME_PORT=1 yarn test + + - name: Testing REVERSE_ONLY + run: REVERSE_ONLY=1 yarn test diff --git a/dist/config.defaults.js b/dist/config.defaults.js index ccbddfc..1ab8bd9 100644 --- a/dist/config.defaults.js +++ b/dist/config.defaults.js @@ -12,6 +12,9 @@ let Nominatim_Config = { // Additional query parameters for Nominatim API. Nominatim_API_Endpoint_Params: {}, + // If database has no search index, then hide search page + Reverse_Only: false, + // relative path or full URL Images_Base_Url: 'mapicons/', diff --git a/dist/search.html b/dist/search.html index 99aa904..5e19ab7 100644 --- a/dist/search.html +++ b/dist/search.html @@ -14,6 +14,12 @@ + + diff --git a/src/components/DetailsOneRow.svelte b/src/components/DetailsOneRow.svelte index 1d63d75..ccc38cf 100644 --- a/src/components/DetailsOneRow.svelte +++ b/src/components/DetailsOneRow.svelte @@ -10,7 +10,7 @@ export let bMarkUnusedLines = false; $: bAddressLineUsed = addressLine.isaddress; - + $: reverse_only = Nominatim_Config.Reverse_Only; @@ -29,9 +29,9 @@ {#if addressLine.osm_id} details - {:else if addressLine.type.match(/^country/)} + {:else if !reverse_only && addressLine.type.match(/^country/)} search by name - {:else if addressLine.type === 'postcode'} + {:else if !reverse_only && addressLine.type === 'postcode'} search by name {/if} diff --git a/src/components/Error.svelte b/src/components/Error.svelte index 9267963..e8702b9 100644 --- a/src/components/Error.svelte +++ b/src/components/Error.svelte @@ -14,6 +14,6 @@
{error_message} - +
{/if} diff --git a/src/components/Header.svelte b/src/components/Header.svelte index a93d6c5..0fbead9 100644 --- a/src/components/Header.svelte +++ b/src/components/Header.svelte @@ -8,6 +8,7 @@ $: view = $page.tab; $: page_title = Nominatim_Config.Page_Title; + $: reverse_only = Nominatim_Config.Reverse_Only; let map_lat; let map_lon; @@ -67,7 +68,7 @@