Validation of Coordination Format
This commit is contained in:
parent
f2005aec5a
commit
6e08f4e038
@ -110,23 +110,40 @@
|
|||||||
console.log(this.station);
|
console.log(this.station);
|
||||||
console.log(this.isNewStation);
|
console.log(this.isNewStation);
|
||||||
console.log(this.$route.params.pos);
|
console.log(this.$route.params.pos);
|
||||||
if (this.isNewStation) {
|
console.log("Test Latlang: " + this.validateLatLangFormat());
|
||||||
this.$store.commit('cacheCollector/ADD_STATION', this.station);
|
if(!this.validateLatLangFormat()){
|
||||||
} else {
|
let title = "Falsche Formatierung";
|
||||||
this.$store.commit('cacheCollector/EDIT_STATION', {index: this.$route.params.pos, station: this.station});
|
let msg = "Die Koordinaten sind in einer falschen Formatierung eingegeben. Beispiel: 49.98767, 9.87637";
|
||||||
this.$store.commit('cacheCollector/SET_TEMPSTATION', null);
|
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
||||||
}
|
}
|
||||||
let cache = this.$store.getters['cacheCollector/GET_CACHE'];
|
if(this.validateEverything()) {
|
||||||
if (cache.hasOwnProperty('id')) {
|
if (this.isNewStation) {
|
||||||
this.$router.push({path: `/cache/${cache.id}`});
|
this.$store.commit('cacheCollector/ADD_STATION', this.station);
|
||||||
} else {
|
} else {
|
||||||
this.$router.push({path: `/cache`});
|
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() {
|
dismiss() {
|
||||||
this.$store.commit('cacheCollector/SET_TEMPSTATION', null);
|
this.$store.commit('cacheCollector/SET_TEMPSTATION', null);
|
||||||
this.$router.push({path: `/cache`});
|
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