Validation of Rankinglist points
This commit is contained in:
parent
6e08f4e038
commit
42a912701b
@ -103,7 +103,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {mapGetters} from 'vuex';
|
||||
|
||||
export default {
|
||||
name: "Cache",
|
||||
@ -189,58 +188,76 @@
|
||||
console.log(cache);
|
||||
cache.stationen.push(this.computedEndstation);
|
||||
console.log("isnewcache "+this.isNewCache)
|
||||
if (this.isNewCache) {
|
||||
console.log("CREATECACHE")
|
||||
this.$axios.post('/api/createCache', cache)
|
||||
.then((response) => {
|
||||
console.log("POST api/createCache: " + response.statusText);
|
||||
this.$store.commit('cacheCollector/RESET_NEW_CACHE');
|
||||
this.$router.push({path: '/overview'});
|
||||
}).catch((error) => {
|
||||
let msg;
|
||||
let title;
|
||||
if (error.response) {
|
||||
title = "Bitte Eingaben überprüfen!";
|
||||
msg = error.response.data;
|
||||
} else if (error.request) {
|
||||
title = "Verbindungsfehler!";
|
||||
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
|
||||
console.log(error.request);
|
||||
} else {
|
||||
title = "Error";
|
||||
msg = error.message;
|
||||
console.log('Error', error.message);
|
||||
}
|
||||
console.log(error.config);
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
||||
})
|
||||
} else {
|
||||
console.log("EDITCACHE")
|
||||
this.$axios.put('/api/editCache', cache)
|
||||
.then((response) => {
|
||||
console.log("POST api/editCache: " + response.statusText);
|
||||
this.$store.commit('cacheCollector/RESET_NEW_CACHE');
|
||||
this.$router.push({path: '/overview'});
|
||||
}).catch((error) => {
|
||||
let msg;
|
||||
let title;
|
||||
if (error.response) {
|
||||
title = "Bitte Eingaben überprüfen!";
|
||||
msg = error.response.data;
|
||||
} else if (error.request) {
|
||||
title = "Verbindungsfehler!";
|
||||
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
|
||||
console.log(error.request);
|
||||
} else {
|
||||
title = "Error";
|
||||
msg = error.message;
|
||||
console.log('Error', error.message);
|
||||
}
|
||||
console.log(error.config);
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
||||
})
|
||||
|
||||
//Error messages
|
||||
if(!this.validateRankingPoints()){
|
||||
let title = "Falsche Formatierung";
|
||||
let msg = "Die Ranglistenpunkte müssen eine ganze Zahl sein";
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
||||
}
|
||||
|
||||
if(this.validateEverything()) {
|
||||
if (this.isNewCache) {
|
||||
console.log("CREATECACHE")
|
||||
this.$axios.post('/api/createCache', cache)
|
||||
.then((response) => {
|
||||
console.log("POST api/createCache: " + response.statusText);
|
||||
this.$store.commit('cacheCollector/RESET_NEW_CACHE');
|
||||
this.$router.push({path: '/overview'});
|
||||
}).catch((error) => {
|
||||
let msg;
|
||||
let title;
|
||||
if (error.response) {
|
||||
title = "Bitte Eingaben überprüfen!";
|
||||
msg = error.response.data;
|
||||
} else if (error.request) {
|
||||
title = "Verbindungsfehler!";
|
||||
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
|
||||
console.log(error.request);
|
||||
} else {
|
||||
title = "Error";
|
||||
msg = error.message;
|
||||
console.log('Error', error.message);
|
||||
}
|
||||
console.log(error.config);
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
||||
})
|
||||
} else {
|
||||
console.log("EDITCACHE")
|
||||
this.$axios.put('/api/editCache', cache)
|
||||
.then((response) => {
|
||||
console.log("POST api/editCache: " + response.statusText);
|
||||
this.$store.commit('cacheCollector/RESET_NEW_CACHE');
|
||||
this.$router.push({path: '/overview'});
|
||||
}).catch((error) => {
|
||||
let msg;
|
||||
let title;
|
||||
if (error.response) {
|
||||
title = "Bitte Eingaben überprüfen!";
|
||||
msg = error.response.data;
|
||||
} else if (error.request) {
|
||||
title = "Verbindungsfehler!";
|
||||
msg = "Es konnte keine Verbindung zum Server aufgebaut werden. Versuchen Sie es später noch einmal!"
|
||||
console.log(error.request);
|
||||
} else {
|
||||
title = "Error";
|
||||
msg = error.message;
|
||||
console.log('Error', error.message);
|
||||
}
|
||||
console.log(error.config);
|
||||
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', {message: msg, title: title,});
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
validateRankingPoints: function () {
|
||||
var re = new RegExp('^[0-9]+$');
|
||||
var rps = String.valueOf(this.computedCache.rankingPoints);
|
||||
return re.test(rps);
|
||||
},
|
||||
validateEverything(){
|
||||
return this.validateRankingPoints();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
computedCache: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user