Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

Commit

Permalink
disable save until location is found
Browse files Browse the repository at this point in the history
  • Loading branch information
ssylvia committed Nov 8, 2016
1 parent 7714076 commit 6d982da
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 0 additions & 1 deletion .tern-project
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"plugins": {
"complete_strings": {},
"node": {},
"lint": {},
"requirejs": {
"baseURL": "./src",
"paths": {
Expand Down
21 changes: 20 additions & 1 deletion src/app/components/forms/location/Location.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 6d982da

Please sign in to comment.