From 22deb871dd8f47b6ff9aba286d7cc010d8bb52cc Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Wed, 7 Jan 2026 16:28:53 -0500 Subject: [PATCH 1/2] wip --- index.html | 4 ++- src/components/address-autocomplete/index.ts | 37 ++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 494ccfb..6206346 100644 --- a/index.html +++ b/index.html @@ -79,10 +79,11 @@

-->
@@ -90,6 +91,7 @@

id="example-geocode-autocomplete" arrowStyle="light" labelStyle="static" + osProxyEndpoint="https://api.editor.planx.dev/proxy/ordnance-survey" />

diff --git a/src/components/address-autocomplete/index.ts b/src/components/address-autocomplete/index.ts index 76b16ef..2ed4f94 100644 --- a/src/components/address-autocomplete/index.ts +++ b/src/components/address-autocomplete/index.ts @@ -161,7 +161,41 @@ export class AddressAutocomplete extends LitElement { // filter out "ALTERNATIVE", "HISTORIC", and "PROVISIONAL" records address.LPI.LPI_LOGICAL_STATUS_CODE_DESCRIPTION === "APPROVED", ) + .sort((a: Address, b: Address) => { + // addresses are currently in OS Places default order (API does not support sorting) + // - the default order separates parent properties from flats and orders addresses like 1, 10..., 2 etc + // - we want to first sort street numbers like 1, 2 ... 10, then ensure flats appear beside their parent shells in the list of options + const collator = new Intl.Collator([], { numeric: true }); + if (a.LPI?.PAO_START_NUMBER && b.LPI?.PAO_START_NUMBER) { + collator.compare( + a.LPI.PAO_START_NUMBER, + b.LPI.PAO_START_NUMBER, + ); + } + if (a.LPI?.SAO_TEXT && b.LPI?.SAO_TEXT) { + collator.compare(a.LPI.SAO_TEXT, b.LPI.SAO_TEXT); + } + }) .map((address: Address) => { + // if a "parent" property type (via PlanX BLPU Codes mapping), then prepend to display name to distinguish from flats + if ( + address.LPI?.CLASSIFICATION_CODE.includes( + "RH01", + "RH02", + "RH03", + ) + ) { + address.LPI.ADDRESS = "HMO, " + address.LPI.ADDRESS; + } + + if (address.LPI?.CLASSIFICATION_CODE === "P") { + address.LPI.ADDRESS = "PARENT SHELL, " + address.LPI.ADDRESS; + } + + if (address.LPI?.CLASSIFICATION_CODE === "PP") { + address.LPI.ADDRESS = "PROPERTY SHELL, " + address.LPI.ADDRESS; + } + // omit the council name and postcode from the display name this._options.push( address.LPI.ADDRESS.slice( @@ -172,9 +206,6 @@ export class AddressAutocomplete extends LitElement { ), ); }); - - const collator = new Intl.Collator([], { numeric: true }); - this._options.sort((a, b) => collator.compare(a, b)); } // fetch next page of results if they exist From 73764808a7dbcb48b4a8fd8716de0abaa4513ec5 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Thu, 8 Jan 2026 10:13:25 -0500 Subject: [PATCH 2/2] sort only, don't prepend text --- src/components/address-autocomplete/index.ts | 21 +------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/components/address-autocomplete/index.ts b/src/components/address-autocomplete/index.ts index 2ed4f94..6550ea6 100644 --- a/src/components/address-autocomplete/index.ts +++ b/src/components/address-autocomplete/index.ts @@ -162,7 +162,7 @@ export class AddressAutocomplete extends LitElement { address.LPI.LPI_LOGICAL_STATUS_CODE_DESCRIPTION === "APPROVED", ) .sort((a: Address, b: Address) => { - // addresses are currently in OS Places default order (API does not support sorting) + // addresses are currently in OS Places default order (API does not support sorting directly) // - the default order separates parent properties from flats and orders addresses like 1, 10..., 2 etc // - we want to first sort street numbers like 1, 2 ... 10, then ensure flats appear beside their parent shells in the list of options const collator = new Intl.Collator([], { numeric: true }); @@ -177,25 +177,6 @@ export class AddressAutocomplete extends LitElement { } }) .map((address: Address) => { - // if a "parent" property type (via PlanX BLPU Codes mapping), then prepend to display name to distinguish from flats - if ( - address.LPI?.CLASSIFICATION_CODE.includes( - "RH01", - "RH02", - "RH03", - ) - ) { - address.LPI.ADDRESS = "HMO, " + address.LPI.ADDRESS; - } - - if (address.LPI?.CLASSIFICATION_CODE === "P") { - address.LPI.ADDRESS = "PARENT SHELL, " + address.LPI.ADDRESS; - } - - if (address.LPI?.CLASSIFICATION_CODE === "PP") { - address.LPI.ADDRESS = "PROPERTY SHELL, " + address.LPI.ADDRESS; - } - // omit the council name and postcode from the display name this._options.push( address.LPI.ADDRESS.slice(