From 6d982daeca206e36b58e21fb8c865a421e10f0c0 Mon Sep 17 00:00:00 2001 From: Stephen Sylvia Date: Tue, 8 Nov 2016 09:42:10 -0500 Subject: [PATCH] disable save until location is found --- .tern-project | 1 - .../forms/location/Location.babel.js | 21 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.tern-project b/.tern-project index c5c0f42..fec0e22 100644 --- a/.tern-project +++ b/.tern-project @@ -13,7 +13,6 @@ "plugins": { "complete_strings": {}, "node": {}, - "lint": {}, "requirejs": { "baseURL": "./src", "paths": { diff --git a/src/app/components/forms/location/Location.babel.js b/src/app/components/forms/location/Location.babel.js index b260150..d217eac 100644 --- a/src/app/components/forms/location/Location.babel.js +++ b/src/app/components/forms/location/Location.babel.js @@ -87,8 +87,18 @@ export default class Location extends FormGroup { this.geocoderAutocomplete.addClass('form-control'); this.locateButton.on('locate',this.reverseGeocode); + this.locatorContainer.on('click',(e) => { + if (e.which === 13) { + this.value = undefined; + this.valid = false; + this.handleChange(); + } + }); this.locatorContainer.on('keypress',(e) => { if (e.which === 13) { + this.value = undefined; + this.valid = false; + this.handleChange(); this.locateButton.locate(); } }); @@ -258,8 +268,11 @@ export default class Location extends FormGroup { } onBlur() { + this.value = undefined; + this.valid = false; + this.handleChange(); + setTimeout(() => { - this.validateForm(); const latLong = this.parseResultForGeoPoint(this.geocoderInput.val()); if (latLong) { @@ -279,6 +292,8 @@ export default class Location extends FormGroup { } else if (this.geocoder.results.length > 0) { this.geocoder.select(this.geocoder.results[0]); } + } else { + this.validateForm(); } },0); } @@ -294,6 +309,10 @@ export default class Location extends FormGroup { reverseGeocode(response,setReverseCoords,ignoreShowingMapOnMobile) { let point; + this.value = undefined; + this.valid = false; + this.handleChange(); + if (ignoreShowingMapOnMobile && ignoreShowingMapOnMobile !== true) { ignoreShowingMapOnMobile = false; }