show and disable locked user in barview

This commit is contained in:
Tim Gröger 2019-12-29 17:56:50 +01:00
parent 0dd2122a19
commit da26270a61
3 changed files with 28 additions and 14 deletions

View File

@ -12,17 +12,17 @@
<v-row>
<v-col>
<v-btn class="creditBtn" block @click="addAmount(user.username, 200)"
:color="color">2
:color="color" :disabled="user.locked">2
</v-btn>
</v-col>
<v-col>
<v-btn class="creditBtn" block @click="addAmount(user.username, 100)"
:color="color">1
:color="color" :disabled="user.locked">1
</v-btn>
</v-col>
<v-col>
<v-btn class="creditBtn" block @click="addAmount(user.username, 50)"
:color="color">
:color="color" :disabled="user.locked">
0,50
</v-btn>
</v-col>
@ -30,19 +30,19 @@
<v-row>
<v-col>
<v-btn class="creditBtn" block @click="addAmount(user.username, 40)"
:color="color">
:color="color" :disabled="user.locked">
0,40
</v-btn>
</v-col>
<v-col>
<v-btn class="creditBtn" block @click="addAmount(user.username, 20)"
:color="color">
:color="color" :disabled="user.locked">
0,20
</v-btn>
</v-col>
<v-col>
<v-btn class="creditBtn" block @click="addAmount(user.username, 10)"
:color="color">
:color="color" :disabled="user.locked">
0,10
</v-btn>
</v-col>
@ -58,6 +58,7 @@
</v-row>
</v-col>
</v-row>
<v-alert v-if="user.locked" type="error">Gesperrt</v-alert>
</v-card-text>
</v-card>
</v-container>
@ -77,6 +78,10 @@
color: 'green accent-4'
}
},
created() {
// eslint-disable-next-line no-console
console.log(this.users)
},
methods: {
addAmount(username, amount) {
this.$emit("add:amount", username, amount)

View File

@ -14,6 +14,9 @@ class Service {
getUserBar(token) {
return axios.get(this.url+'bar', {headers: {Token: token}})
}
getOneUserBar(token, data) {
return axios.post(this.url+'barGetUser', {...data}, {headers: {Token: token}})
}
addAmountBar(token, data) {
return axios.post(this.url+'baradd', {...data}, {headers: {Token: token}})
}

View File

@ -67,6 +67,7 @@
return user.username === username ? user : false
})
user.amount = response.data.amount
user.locked = response.data.locked
})
.catch(error => {
if (error.response) {
@ -81,15 +82,20 @@
if (!this.users.find(user1 => {
return user1.username === user.username
})) {
httpClient.getOneUserBar(this.$store.getters.getToken, {userId: user.username})
.then(response => {
const lastId = this.users.length > 0 ? this.users[this.users.length - 1].id : 0
this.users.push({
id: lastId + 1,
username: user.username,
firstname: user.firstname,
lastname: user.lastname,
username: response.data.username,
firstname: response.data.firstname,
lastname: response.data.lastname,
locked: response.data.locked,
amount: 0,
type: null
})
})
}
}
}