Validation of Coordination Format
This commit is contained in:
parent
f2005aec5a
commit
6e08f4e038
@ -110,23 +110,40 @@
|
||||
console.log(this.station);
|
||||
console.log(this.isNewStation);
|
||||
console.log(this.$route.params.pos);
|
||||
if (this.isNewStation) {
|
||||
this.$store.commit('cacheCollector/ADD_STATION', this.station);
|
||||
} else {
|
||||
this.$store.commit('cacheCollector/EDIT_STATION', {index: this.$route.params.pos, station: this.station});
|
||||
this.$store.commit('cacheCollector/SET_TEMPSTATION', null);
|
||||
console.log("Test Latlang: " + this.validateLatLangFormat());
|
||||
if(!this.validateLatLangFormat()){
|
||||
let title = "Falsche Formatierung";
|
||||
let msg = "Die Koordinaten sind in einer falschen Formatierung eingegeben. Beispiel: 49.98767, 9.87637";
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
||||
}
|
||||
let cache = this.$store.getters['cacheCollector/GET_CACHE'];
|
||||
if (cache.hasOwnProperty('id')) {
|
||||
this.$router.push({path: `/cache/${cache.id}`});
|
||||
} else {
|
||||
this.$router.push({path: `/cache`});
|
||||
if(this.validateEverything()) {
|
||||
if (this.isNewStation) {
|
||||
this.$store.commit('cacheCollector/ADD_STATION', this.station);
|
||||
} else {
|
||||
this.$store.commit('cacheCollector/EDIT_STATION', {index: this.$route.params.pos, station: this.station});
|
||||
this.$store.commit('cacheCollector/SET_TEMPSTATION', null);
|
||||
}
|
||||
|
||||
let cache = this.$store.getters['cacheCollector/GET_CACHE'];
|
||||
if (cache.hasOwnProperty('id')) {
|
||||
this.$router.push({path: `/cache/${cache.id}`});
|
||||
} else {
|
||||
this.$router.push({path: `/cache`});
|
||||
}
|
||||
console.log("Station saved");
|
||||
}
|
||||
console.log("station saved..");
|
||||
|
||||
},
|
||||
dismiss() {
|
||||
this.$store.commit('cacheCollector/SET_TEMPSTATION', null);
|
||||
this.$router.push({path: `/cache`});
|
||||
},
|
||||
validateLatLangFormat(){
|
||||
var re = new RegExp('\\d+(\\.\\d+)?\\,(\\s)?\\d+(\\.\\d+)?');
|
||||
return re.test(this.latlang);
|
||||
},
|
||||
validateEverything(){
|
||||
return this.validateLatLangFormat();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user