From 3793f54ef56746a2692ecac66b93b065898a0919 Mon Sep 17 00:00:00 2001 From: Klaus Kopec Date: Tue, 15 Mar 2022 21:41:42 +0100 Subject: [PATCH 1/4] Added dynamically requiring address fields. If the Flow component has setting "Detailed Address Fields Required" set to "True", the address fields will be shown as required (i.e., red asterisk). --- .../AddressValidationController.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/aura/AddressValidation/AddressValidationController.js b/src/aura/AddressValidation/AddressValidationController.js index e9cdd8c..cccf330 100644 --- a/src/aura/AddressValidation/AddressValidationController.js +++ b/src/aura/AddressValidation/AddressValidationController.js @@ -27,6 +27,8 @@ - Cleaned up init methods into helper classes 18/10/19 DV - Split 'Required' into 'Search Required' and 'Detailed Address Fields Required' + + 15/03/22 KK - Added dynamically making address details/county fields required (=red asteriks sshows) if option is set in Flow TODO: 1. Input for country restrictions(?) @@ -38,6 +40,25 @@ helper.checkValidFilter(cmp); helper.setValidation(cmp); helper.initialiseMapData(cmp, helper); + + + // set address fields as required if configured as such in Flow + let fieldsRequired = cmp.get("v.fieldsRequired"); // Flow attribute "Detailed Address Fields Required" + + if(fieldsRequired) { + + // if the address fields are shown while all fields are required, they're mandatory as well + if(cmp.get("v.showAddressFields")) { + let divFullAddress = cmp.find('fullAddress'); + divFullAddress.set('v.required', true); + } + + // if county field is shown while all fields are required, it's mandatory as well + if(cmp.get("v.showCountyField")) { + let divCounty = cmp.find('countyInput'); + divCounty.set('v.required', true); + } + } }, /* When typing the search text in input field */ onAddressInput : function(cmp, event, helper) { From ec230829240141b347dbe441db540d81878a26ba Mon Sep 17 00:00:00 2001 From: Klaus Kopec Date: Wed, 16 Mar 2022 11:22:16 +0100 Subject: [PATCH 2/4] Added address label as Flow component attribute. This allows the user to set the address label to be shown as title below the search field, but above the address detail fields. This is especially useful if 'Detailed Address Fields Required' is set to true, as it will add a label where otherwise only a red asteriks is shown, indicating that the whole inputAddress component is set to required. --- src/aura/AddressValidation/AddressValidation.cmp | 3 +++ src/aura/AddressValidation/AddressValidation.design | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/aura/AddressValidation/AddressValidation.cmp b/src/aura/AddressValidation/AddressValidation.cmp index 2f998dc..1e9c97b 100644 --- a/src/aura/AddressValidation/AddressValidation.cmp +++ b/src/aura/AddressValidation/AddressValidation.cmp @@ -29,6 +29,8 @@ + + @@ -126,6 +128,7 @@ + @@ -13,7 +16,9 @@ - + From 831627826cb8a7cfa3a4ee8e495e388455ded77d Mon Sep 17 00:00:00 2001 From: Klaus Kopec Date: Wed, 16 Mar 2022 11:57:02 +0100 Subject: [PATCH 3/4] Added optional showing of read-only geolocation fields. Added flow attribute (boolean) to let users choose whether to display latitude/longitude fields. If true, they are shown below the address details fields. Currently they are read-only. --- src/aura/AddressValidation/AddressValidation.cmp | 5 +++++ .../AddressValidation/AddressValidation.design | 2 ++ .../AddressValidation/AddressValidationHelper.js | 9 +++++++-- src/labels/CustomLabels.labels | 16 ++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/aura/AddressValidation/AddressValidation.cmp b/src/aura/AddressValidation/AddressValidation.cmp index 1e9c97b..42f9929 100644 --- a/src/aura/AddressValidation/AddressValidation.cmp +++ b/src/aura/AddressValidation/AddressValidation.cmp @@ -29,6 +29,7 @@ + @@ -143,6 +144,10 @@ + + + + diff --git a/src/aura/AddressValidation/AddressValidation.design b/src/aura/AddressValidation/AddressValidation.design index 0848d45..c42bac3 100644 --- a/src/aura/AddressValidation/AddressValidation.design +++ b/src/aura/AddressValidation/AddressValidation.design @@ -15,6 +15,8 @@ description="Show the editable county field" /> + Current Location Current Location + + Latitude + Address,Picker,Address Picker + en_US + true + Latitude + Latitude + + + Longitude + Address,Picker,Address Picker + en_US + true + Longitude + Longitude + Default_Address Address,Picker,Address Picker From 08f79fe04b2665c9e829ef9050244861a6c1fc0e Mon Sep 17 00:00:00 2001 From: Klaus Kopec Date: Sat, 19 Mar 2022 14:42:42 +0100 Subject: [PATCH 4/4] Added reloading of map when latitude/longitude is changed manually. The implemented mechanism should also work, once we add the option to change latitude/longitude by moving the pin on the map. --- .../AddressValidation/AddressValidation.cmp | 6 +++-- .../AddressValidationController.js | 14 ++++++++++- .../AddressValidationHelper.js | 24 ++++++++++++++++++- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/aura/AddressValidation/AddressValidation.cmp b/src/aura/AddressValidation/AddressValidation.cmp index 42f9929..ba49175 100644 --- a/src/aura/AddressValidation/AddressValidation.cmp +++ b/src/aura/AddressValidation/AddressValidation.cmp @@ -53,6 +53,8 @@ + + @@ -145,8 +147,8 @@ - - + + diff --git a/src/aura/AddressValidation/AddressValidationController.js b/src/aura/AddressValidation/AddressValidationController.js index cccf330..e727384 100644 --- a/src/aura/AddressValidation/AddressValidationController.js +++ b/src/aura/AddressValidation/AddressValidationController.js @@ -28,7 +28,9 @@ 18/10/19 DV - Split 'Required' into 'Search Required' and 'Detailed Address Fields Required' - 15/03/22 KK - Added dynamically making address details/county fields required (=red asteriks sshows) if option is set in Flow + 15/03/22 KK - Added dynamically making address details/county fields required (=red asteriks shows) if option is set in Flow + + 19/03/22 KK - Added ability to change latitude/longitude by manually entering into these fields. This also triggers a map update TODO: 1. Input for country restrictions(?) @@ -104,4 +106,14 @@ helper.getPlaceDetails(cmp, placeid); }, + + latitudeChange : function(cmp, event, helper) { + /* Manages changes to the latitude.*/ + helper.geolocationChange(cmp); + }, + + longitudeChange : function(cmp, event, helper) { + /* Manages changes to the longitude.*/ + helper.geolocationChange(cmp); + } }) \ No newline at end of file diff --git a/src/aura/AddressValidation/AddressValidationHelper.js b/src/aura/AddressValidation/AddressValidationHelper.js index 796aa09..0566170 100644 --- a/src/aura/AddressValidation/AddressValidationHelper.js +++ b/src/aura/AddressValidation/AddressValidationHelper.js @@ -7,7 +7,9 @@ History: When Who What 15/03/22 KK - Added setting currentLatitude/Longitude when search is successful to display them if showGeolocation is enabled - + + 15/03/22 KK - Added updating the map when geolocation is changed by editing the latitude/longitude fields + TODO: */ @@ -353,5 +355,25 @@ d = Math.floor(d / 16); return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); + }, + + geolocationChange : function(cmp) { + /* Updates the pin on the map after a geolocation change.*/ + let labels = { + SELECTED_ADDRESS : $A.get("$Label.c.Selected_Address"), + DEFAULT_ADDRESS : $A.get("$Label.c.Default_Address") + } + + let lat = cmp.get("v.currentLatitude"); + let lng = cmp.get("v.currentLongitude"); + let formattedAddress = cmp.get("v.formattedAddress"); + + if(formattedAddress) { + this.showMap(cmp, lat, lng, labels.SELECTED_ADDRESS, formattedAddress); + } + else { + this.showMap(cmp, lat, lng, labels.DEFAULT_ADDRESS); + } } + }) \ No newline at end of file