finished ##210

This commit is contained in:
Tim Gröger 2020-03-03 22:50:47 +01:00
parent 7ab0af4119
commit 11b8df2251
2 changed files with 36 additions and 11 deletions

View File

@ -116,18 +116,26 @@
append-icon
>
<template v-slot:selection="data">
<v-icon>{{
<v-icon class="ma-2">{{
data.item === 'user'
? person
: data.item === 'bar'
? bar
: data.item === 'moneymaster'
? finanzer
: false
: data.item === 'gastro'
? gastro
: ''
}}</v-icon>
</template>
</v-combobox>
</v-col>
<v-col>
<v-text-field outlined :value="computeStatus" readonly label="Mitgliedsstatus"/>
</v-col>
<v-col>
<v-text-field outlined :value="user.voting ? 'ja' : 'nein'" readonly label="Stimmrecht" />
</v-col>
</v-row>
</v-card-text>
<v-card-actions>
@ -135,14 +143,19 @@
<v-btn @click="save">Save</v-btn>
</v-card-actions>
<v-expand-transition>
<v-alert type="error" v-if="error">{{error}}</v-alert>
<v-alert type="error" v-if="error">{{ error }}</v-alert>
</v-expand-transition>
</v-card>
</div>
</template>
<script>
import { mdiAccount, mdiGlassCocktail, mdiCurrencyEur } from '@mdi/js'
import {
mdiAccount,
mdiGlassCocktail,
mdiCurrencyEur,
mdiFoodForkDrink
} from '@mdi/js'
import { mapGetters, mapActions } from 'vuex'
export default {
name: 'Config',
@ -151,6 +164,7 @@ export default {
person: mdiAccount,
bar: mdiGlassCocktail,
finanzer: mdiCurrencyEur,
gastro: mdiFoodForkDrink,
username: null,
mail: null,
firstname: null,
@ -159,9 +173,9 @@ export default {
equal_password: value =>
this.password === value || 'Passwörter sind nicht identisch.',
email: value => {
if(value.length > 0) {
const pattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return pattern.test(value) || 'keine gültige E-Mail';
if (value.length > 0) {
const pattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return pattern.test(value) || 'keine gültige E-Mail'
}
return true
}
@ -169,7 +183,8 @@ export default {
},
methods: {
...mapActions({
saveConfig: 'user/saveConfig'
saveConfig: 'user/saveConfig',
getStatus: 'user/getStatus'
}),
save() {
let user = {}
@ -182,14 +197,15 @@ export default {
if (this.$refs.password.validate()) {
if (this.password) user.password = this.password
}
this.saveConfig({oldUsername: user.username, ...user})
this.saveConfig({ oldUsername: user.username, ...user })
}
},
computed: {
...mapGetters({
user: 'user/user',
error: 'user/error',
loading: 'user/loading'
loading: 'user/loading',
status: 'user/status'
}),
lock() {
return this.user.locked ? 'gesperrt' : 'nicht gesperrt'
@ -202,7 +218,13 @@ export default {
},
autoLockColor() {
return this.user.autoLock ? 'green' : 'red'
},
computeStatus() {
return this.status.find(a => a.id == this.user.statusgroup).name
}
},
created() {
this.getStatus()
}
}
</script>

View File

@ -318,7 +318,7 @@ const actions = {
},
async getStatus({commit, rootState, dispatch }) {
try {
const response = await axios.post(url.user.getAllStatus, {
const response = await axios.get(url.user.getAllStatus, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setStatus', response.data)
@ -355,6 +355,9 @@ const getters = {
},
messages: state => {
return state.message
},
status: state => {
return state.status
}
}