diff --git a/src/aura/AddressValidation/AddressValidation.cmp b/src/aura/AddressValidation/AddressValidation.cmp index 2f998dc..ba49175 100644 --- a/src/aura/AddressValidation/AddressValidation.cmp +++ b/src/aura/AddressValidation/AddressValidation.cmp @@ -29,6 +29,9 @@ + + + @@ -50,6 +53,8 @@ + + @@ -126,6 +131,7 @@ + + + + diff --git a/src/aura/AddressValidation/AddressValidation.design b/src/aura/AddressValidation/AddressValidation.design index b2b95ac..c42bac3 100644 --- a/src/aura/AddressValidation/AddressValidation.design +++ b/src/aura/AddressValidation/AddressValidation.design @@ -1,4 +1,7 @@ + @@ -12,8 +15,12 @@ description="Show the editable county field" /> + - + diff --git a/src/aura/AddressValidation/AddressValidationController.js b/src/aura/AddressValidation/AddressValidationController.js index e9cdd8c..e727384 100644 --- a/src/aura/AddressValidation/AddressValidationController.js +++ b/src/aura/AddressValidation/AddressValidationController.js @@ -27,6 +27,10 @@ - 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 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(?) @@ -38,6 +42,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) { @@ -83,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 89c5b7d..0566170 100644 --- a/src/aura/AddressValidation/AddressValidationHelper.js +++ b/src/aura/AddressValidation/AddressValidationHelper.js @@ -5,8 +5,11 @@ Date/Time: 5/21/2019, 1:35:56 PM History: - When Who What - + 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: */ @@ -289,6 +292,10 @@ cmp.set("v.fullStreetAddress", fullStreetAddress); cmp.set("v.latitude", lat); cmp.set("v.longitude", lng); + + //set current values to display the correct Lat/Lng if these fields are shown + cmp.set("v.currentLatitude", lat); + cmp.set("v.currentLongitude", lng); this.showMap(cmp, lat, lng, labels.SELECTED_ADDRESS, formattedAddress); cmp.set("v.locationSelected", true); @@ -348,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 diff --git a/src/labels/CustomLabels.labels b/src/labels/CustomLabels.labels index 1a032b5..f26c027 100644 --- a/src/labels/CustomLabels.labels +++ b/src/labels/CustomLabels.labels @@ -56,6 +56,22 @@ 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