bugfixes in Cache edit

This commit is contained in:
Timo Volkmann 2019-05-15 11:11:12 +02:00
parent eabf972012
commit 7faa9ef327
10 changed files with 64 additions and 20 deletions

View File

@ -93,9 +93,15 @@
console.log(params);
if (!params.cacheID || !params.stationID || !params.durchgefuehrterCacheID || !params.token) {
console.log("Mindestens 1 Parameter konnte nicht erkannt werden!");
let header = "Fehler!";
let message = "Der erkannte QR-Code ist fehlerhaft oder gehört nicht zu BuGa Geocaching.";
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
resolve(false);
} else if (isNaN(params.cacheID) || isNaN(params.stationID) || isNaN(params.durchgefuehrterCacheID)) {
console.log("Mindestens 1 Parameter ist fehlerhaft!");
let header = "Fehler!";
let message = "Der erkannte QR-Code ist fehlerhaft oder gehört nicht zu BuGa Geocaching.";
this.$store.commit('dialog/NEW_MESSAGE_DIALOG', { message: message, title: header, });
resolve(false);
} else {
this.$axios.put('/api/checkStation', null, { params })
@ -162,12 +168,12 @@
},
updateProps() {
console.log("emit result!")
console.log("emit result!");
this.$emit('result', this.params)
},
updateCameraState() {
console.log("Camera State:")
console.log(!this.askForPermission)
console.log("Camera State:");
console.log(!this.askForPermission);
this.$emit('camera', !this.askForPermission)
},

View File

@ -1,5 +1,5 @@
<template>
<q-layout view="hhh Lpr lFf">
<q-layout view="hhh Lpr lFf" @click.native="counter()">
<q-header id="qheader" class="bg-white text-grey-14" elevated>
<q-toolbar class="q-pa-md">
<q-img src="statics/buga_logo.svg" style="max-width: 40px;" class="q-mr-sm"/>
@ -162,6 +162,17 @@
<q-item-label>Login</q-item-label>
</q-item-section>
</q-item>
<!-- <q-item-->
<!-- disable-->
<!-- class="text-grey-5"-->
<!-- >-->
<!-- <q-item-section avatar>-->
<!-- </q-item-section>-->
<!-- <q-item-section>-->
<!-- <q-item-label>dev: {{ clickCounter }} clicks</q-item-label>-->
<!-- </q-item-section>-->
<!-- </q-item>-->
</q-list>
</q-drawer>
@ -196,6 +207,7 @@
data() {
return {
leftDrawerOpen: this.$q.platform.is.desktop,
clickCounter: 0,
};
},
computed: {
@ -238,7 +250,10 @@
//this.evalAuthentication();
},
methods: {
//openURL
counter() {
this.clickCounter++;
//console.log(this.clickCounter);
},
dialogClose() {
console.log("dialogClose(): ")
this.$store.commit('dialog/RESET_MESSAGE_DIALOG');

View File

@ -124,7 +124,7 @@
created: function () {
console.log("isNewCache: " + this.isNewCache);
console.log("Route Params: " + this.$route.params.id);
if (!this.isNewCache) {
if (!this.isNewCache && !this.$store.getters['cacheCollector/GET_LOCK']) {
this.$axios.get('/api/allCaches')
.then((response) => {
console.log("/api/allCaches");
@ -140,8 +140,8 @@
this.$store.commit('cacheCollector/SET_STATIONS', stations);
this.$store.commit('cacheCollector/SET_ENDSTATION', endstation);
})
}
this.$store.commit('cacheCollector/SET_LOCK', false);
},
beforeMount: function () {
},
@ -174,25 +174,22 @@
console.log(this.$store.getters['cacheCollector/GET_STATIONS']);
const station = this.$store.getters['cacheCollector/GET_STATIONS'][index];
console.log(station);
if (station.hasOwnProperty('id')) {
//this.$router.push({ path: '/station/'+station.id});
} else {
// TODO Stationen bearbeitbar machen bevor sie abgeschickt werden. Am besten Station Objekt als Übergabe Parameter bei Router
this.$store.commit('cacheCollector/SET_TEMPSTATION', station);
this.$router.push({path: `/tempstation/${index}`}); // add parameter
}
this.$store.commit('cacheCollector/SET_TEMPSTATION', station);
this.$store.commit('cacheCollector/SET_LOCK', true);
this.$router.push({path: `/tempstation/${index}`}); // add parameter
},
deleteStation(index) {
// TODO wenn Station id hat, mit Backend abgleichen
this.$store.commit('cacheCollector/REMOVE_STATION', index);
},
saveCache() {
// commit to store, send to api, if success -> reset store
console.log("saveCache!");
let cache = JSON.parse(JSON.stringify(this.computedCache));
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);
@ -217,6 +214,7 @@
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);

View File

@ -21,6 +21,7 @@
<q-tab-panels v-model="tab" animated swipeable class="col">
<q-tab-panel name="startedCaches" class=" fit">
<p class="text-grey-4 text-h5 text-center" v-if="startedCaches.filter(cache => cache.cacheAccesDefinition.id === 0).length === 0">keine Einträge</p>
<q-list>
<q-card
class="q-mb-md"
@ -55,6 +56,7 @@
</q-tab-panel>
<q-tab-panel name="finishedCaches" class="fit">
<p class="text-grey-4 text-h5 text-center" v-if="startedCaches.filter(cache => cache.cacheAccesDefinition.id === 1).length === 0">keine Einträge</p>
<q-list>
<q-card class="q-mb-md"
v-for="finishedCache in startedCaches.filter(cache => cache.cacheAccesDefinition.id === 1)"

View File

@ -27,6 +27,7 @@
color="primary"
size="10em"
/>
<p class="text-grey-4 text-h5 text-center" v-if="caches.length === 0">keine Einträge</p>
<q-list v-if="render">
<q-card class="q-mb-md" v-for="cache in caches" :key="cache.id">
<q-expansion-item
@ -229,6 +230,7 @@
},
addCache() {
this.$store.commit('cacheCollector/RESET_NEW_CACHE');
this.$router.push({path: `/cache`})
},
editCache(cacheID) {

View File

@ -134,13 +134,17 @@
})
.catch((error) => {
let message;
let header = "Unbekannter Fehler...";
let header = "Unbekannter Fehler!";
if (error.response) {
console.log(error.response)
console.log(error.response);
if (error.response.status === 409) {
message= "Die E-Mail-Adresse wird bereits verwendet!";
header= "Anmeldedaten überprüfen!";
}
if (error.response.status === 500) {
message= "Der Anmeldeserver konnte die Daten nicht verarbeiten.";
header= "Fehler!";
}
} else if (error.request) {
console.log(error.request);
header = "Anfrage fehlgeschlagen!";

View File

@ -97,13 +97,20 @@
saveStation() {
console.log("saveStation(): ");
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);
}
this.$router.push({path: `/cache`});
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..");
},
dismiss() {

View File

@ -2,6 +2,10 @@ export const GET_CACHE = (state) => {
console.log("GET_CACHE: retrieve cache from store. ");
return state.newCache;
};
export const GET_LOCK = (state) => {
console.log("GET_LOCK: ");
return state.locked;
};
export const GET_TEMPSTATION = (state) => {
console.log("GET_TEMPSTATION: retrieve cache from store. ");
return state.tempStation;

View File

@ -1,7 +1,11 @@
export const SET_CACHE = (state, cache) => {
console.log("SET_CACHE: save cache to store. ")
console.log("SET_CACHE: save cache to store. ");
state.newCache = cache;
};
export const SET_LOCK = (state, bool) => {
console.log("SET_LOCK: ");
state.locked = bool;
};
export const SET_TEMPSTATION = (state, station) => {
console.log("SET_TEMPSTATION: add new station to cache: "+station);
state.tempStation = station;
@ -25,6 +29,7 @@ export const EDIT_STATION = (state, indexStation) => {
console.log("EDIT_STATION: "+index+" "+station);
state.newCache.stationen[index] = station;
console.log("EDIT_STATION: "+JSON.stringify(state.newCache.stationen[index]));
};
export const REMOVE_STATION = (state, index) => {
console.log("REMOVE_STATION: "+index);

View File

@ -1,4 +1,5 @@
export default {
locked: false,
newCache: {
name: "",
description: "",