From: Marc Tobias Date: Mon, 4 Apr 2022 22:50:30 +0000 (+0100) Subject: On Search page the 'deduplication' checkbox needs to be checked by default X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/commitdiff_plain/64e1ec4d0f152bc9a279c2f016a111f9943dc6a4 On Search page the 'deduplication' checkbox needs to be checked by default --- diff --git a/CHANGES.md b/CHANGES.md index 8490af6..ca94529 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # CHANGES +* version 3.2.2 - 2022-04-05 + + * Fix: On Search page the 'deduplication' checkbox needs to be checked by default + * version 3.2.1 - 2021-05-11 * Fix: some npm modules no longer support node version 10 diff --git a/package.json b/package.json index fcc6fe2..a1b3103 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nominatim-ui", "description": "Debug web interface for Nominatim geocoder", - "version": "3.2.1", + "version": "3.2.2", "license": "GPL-2.0", "scripts": { "build": "rollup -c", diff --git a/src/components/SearchSection.svelte b/src/components/SearchSection.svelte index 6bf7bca..e7520ad 100644 --- a/src/components/SearchSection.svelte +++ b/src/components/SearchSection.svelte @@ -69,7 +69,7 @@ } function set_dedupe(e) { - document.querySelector('input[name=dedupe]').value = e.target.checked ? 1 : ''; + document.querySelector('input[name=dedupe]').value = e.target.checked ? 1 : 0; } function set_api_param(e) { @@ -100,7 +100,7 @@
- + - + + id="option_dedupe" checked={api_request_params.dedupe === 0 ? 0 : 1} on:change={set_dedupe}>
diff --git a/src/components/UrlSubmitForm.svelte b/src/components/UrlSubmitForm.svelte index a3dfaa0..01feea1 100644 --- a/src/components/UrlSubmitForm.svelte +++ b/src/components/UrlSubmitForm.svelte @@ -12,6 +12,9 @@ if (['checkbox', 'radio'].indexOf(field.type) > -1 && !field.checked) return; if (typeof field.value === 'undefined' || field.value === '') return; + // Default value for /search endpoint + if (field.name === 'dedupe' && (field.value === 1 || field.value === '1')) return; + params.set(field.name, field.value); }); diff --git a/src/lib/api_utils.js b/src/lib/api_utils.js index 8de3f0f..e6f8158 100644 --- a/src/lib/api_utils.js +++ b/src/lib/api_utils.js @@ -83,6 +83,9 @@ export async function fetch_content_into_element(url, dom_element) { } function generate_nominatim_api_url(endpoint_name, params) { + // default value for /search + if (params.dedupe === 1) delete params.dedupe; + extend_parameters(params, Nominatim_Config.Nominatim_API_Endpoint_Params); return Nominatim_Config.Nominatim_API_Endpoint + endpoint_name + '.php?' + Object.keys(clean_up_parameters(params)).map((k) => { diff --git a/src/pages/SearchPage.svelte b/src/pages/SearchPage.svelte index 134ea8a..e80729f 100644 --- a/src/pages/SearchPage.svelte +++ b/src/pages/SearchPage.svelte @@ -25,7 +25,7 @@ polygon_geojson: Nominatim_Config.Search_AreaPolygons ? 1 : 0, viewbox: search_params.get('viewbox'), bounded: search_params.get('bounded'), - dedupe: search_params.get('dedupe'), + dedupe: (!search_params.has('dedupe') || search_params.get('dedupe') === '1') ? 1 : 0, 'accept-language': search_params.get('accept-language'), countrycodes: search_params.get('countrycodes'), limit: search_params.get('limit'), diff --git a/test/search.js b/test/search.js index e205b0c..628edaa 100644 --- a/test/search.js +++ b/test/search.js @@ -111,6 +111,18 @@ describe('Search Page', function () { assert.equal((await page.$$('#map')).length, 1); }); + it('should default to dedupe=1', async function () { + const checkbox_checked = await page.$eval('#option_dedupe', el => el.checked); + assert.equal(checkbox_checked, true); + + const links_href = await page.$$eval('#api-request a', links => links.map(l => l.href)); + let api_request_url = new URL(links_href[0]); + let debug_url = new URL(links_href[1]); + + assert.deepStrictEqual(api_request_url.searchParams.has('dedupe'), false); + assert.deepStrictEqual(debug_url.searchParams.has('dedupe'), false); + }); + it('should have polygon and marker in map and minimap', async function () { assert.strictEqual((await page.$$('#map .leaflet-overlay-pane path')).length, 4); });