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

View File

@ -14,6 +14,9 @@ class Service {
getUserBar(token) { getUserBar(token) {
return axios.get(this.url+'bar', {headers: {Token: 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) { addAmountBar(token, data) {
return axios.post(this.url+'baradd', {...data}, {headers: {Token: token}}) return axios.post(this.url+'baradd', {...data}, {headers: {Token: token}})
} }

View File

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