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

View File

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