From da26270a61148c8149cf36cadeda6c5e510673e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 29 Dec 2019 17:56:50 +0100 Subject: [PATCH] show and disable locked user in barview --- src/components/baruser/CreditLists.vue | 17 +++++++++++------ src/plugins/restService.js | 3 +++ src/views/BarView.vue | 22 ++++++++++++++-------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/components/baruser/CreditLists.vue b/src/components/baruser/CreditLists.vue index 4ddf330..ff69bab 100644 --- a/src/components/baruser/CreditLists.vue +++ b/src/components/baruser/CreditLists.vue @@ -12,17 +12,17 @@ 2 € + :color="color" :disabled="user.locked">2 € 1 € + :color="color" :disabled="user.locked">1 € + :color="color" :disabled="user.locked"> 0,50 € @@ -30,19 +30,19 @@ + :color="color" :disabled="user.locked"> 0,40 € + :color="color" :disabled="user.locked"> 0,20 € + :color="color" :disabled="user.locked"> 0,10 € @@ -58,6 +58,7 @@ + Gesperrt @@ -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) diff --git a/src/plugins/restService.js b/src/plugins/restService.js index ddcb951..8116027 100644 --- a/src/plugins/restService.js +++ b/src/plugins/restService.js @@ -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}}) } diff --git a/src/views/BarView.vue b/src/views/BarView.vue index f01e384..4ade2f8 100644 --- a/src/views/BarView.vue +++ b/src/views/BarView.vue @@ -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 })) { - 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, - amount: 0, - type: null + 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: response.data.username, + firstname: response.data.firstname, + lastname: response.data.lastname, + locked: response.data.locked, + amount: 0, + type: null + }) }) + } } }