From 10eccba914154b5aebd43f4766d5e87340778868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 1 Sep 2020 09:16:24 +0200 Subject: [PATCH 1/4] Entfernen der User aus den FreeDrinkLists --- .../FreeDrinkList/FreeDrinkListBand.vue | 23 +++---------------- .../FreeDrinkList/FreeDrinkListJob.vue | 23 +++---------------- 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/src/components/vorstand/FreeDrinkList/FreeDrinkListBand.vue b/src/components/vorstand/FreeDrinkList/FreeDrinkListBand.vue index 98848c1..c8548eb 100644 --- a/src/components/vorstand/FreeDrinkList/FreeDrinkListBand.vue +++ b/src/components/vorstand/FreeDrinkList/FreeDrinkListBand.vue @@ -46,10 +46,6 @@ name: "FreeDrinkListBand", text: 'Anzahl', value: 'count' }, - { - text: 'User', - value: 'user' - }, { text: 'Preis pro Getränk', value: 'pricepro' @@ -87,29 +83,16 @@ name: "FreeDrinkListBand", let history_of_config = history_of_date.filter(item => { return item.free_drink_config_id == drink_config.id }) - // eslint-disable-next-line no-unused-vars - let users = [] - history_of_config.forEach(history_config => { - if (!users.find(user_id => { return user_id == history_config.user_id})) { - users.push(history_config.user_id) - } - }) - users.forEach(user_id => { - let history_of_user = history_of_config.filter(item => { - return item.user_id == user_id - }) - if (history_of_user.length > 0) { + if (history_of_config.length > 0) { retVal.push({ date: `${from.getDate()}.${from.getMonth() + 1}.${from.getFullYear()}`, label: drink_config.label, name: drink_config.drink.name, - user: `${history_of_user[0].user.firstname} ${history_of_user[0].user.lastname}`, - count: history_of_user.length, + count: history_of_config.length, pricepro: (drink_config.price / 100).toFixed(2), - sum: (drink_config.price / 100 * history_of_user.length).toFixed(2) + sum: (drink_config.price / 100 * history_of_config.length).toFixed(2) }) } - }) }) } return retVal diff --git a/src/components/vorstand/FreeDrinkList/FreeDrinkListJob.vue b/src/components/vorstand/FreeDrinkList/FreeDrinkListJob.vue index 7d35878..f0fd708 100644 --- a/src/components/vorstand/FreeDrinkList/FreeDrinkListJob.vue +++ b/src/components/vorstand/FreeDrinkList/FreeDrinkListJob.vue @@ -46,10 +46,6 @@ data() { text: 'Anzahl', value: 'count' }, - { - text: 'User', - value: 'user' - }, { text: 'Preis pro Getränk', value: 'pricepro' @@ -87,29 +83,16 @@ computed: { let history_of_config = history_of_date.filter(item => { return item.free_drink_config_id == drink_config.id }) - // eslint-disable-next-line no-unused-vars - let users = [] - history_of_config.forEach(history_config => { - if (!users.find(user_id => { return user_id == history_config.user_id})) { - users.push(history_config.user_id) - } - }) - users.forEach(user_id => { - let history_of_user = history_of_config.filter(item => { - return item.user_id == user_id - }) - if (history_of_user.length > 0) { + if (history_of_config.length > 0) { retVal.push({ date: `${from.getDate()}.${from.getMonth() + 1}.${from.getFullYear()}`, label: drink_config.label, name: drink_config.drink.name, - user: `${history_of_user[0].user.firstname} ${history_of_user[0].user.lastname}`, - count: history_of_user.length, + count: history_of_config.length, pricepro: (drink_config.price / 100).toFixed(2), - sum: (drink_config.price / 100 * history_of_user.length).toFixed(2) + sum: (drink_config.price / 100 * history_of_config.length).toFixed(2) }) } - }) }) } return retVal From 3d311d3677c0b868a0a54188363478b6779448e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 1 Sep 2020 09:31:03 +0200 Subject: [PATCH 2/4] =?UTF-8?q?BarUser=20FreeDrinkList=20zeigt=20Summe=20v?= =?UTF-8?q?on=20Bandgetr=C3=A4nken=20an.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/baruser/BarFreedrinks.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/baruser/BarFreedrinks.vue b/src/components/baruser/BarFreedrinks.vue index bc47eba..e3ba181 100644 --- a/src/components/baruser/BarFreedrinks.vue +++ b/src/components/baruser/BarFreedrinks.vue @@ -90,9 +90,8 @@ {{ - free_drink_list_history_band_without_canceled.length - }} - Getränke + (free_drink_list_history_band_without_canceled_price/100).toFixed(2) + }} € @@ -398,6 +397,13 @@ export default { this.free_drink_list_config_band.length == 0 && this.free_drink_list_config_job.length == 0 ) + }, + free_drink_list_history_band_without_canceled_price() { + let sum = 0 + this.free_drink_list_history_band_without_canceled.forEach(item => { + sum += item.free_drink_config.price + }) + return sum } }, beforeDestroy() { From f212c5962c9628e06e821c5ea97c5f0f358bc9b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 1 Sep 2020 10:04:21 +0200 Subject: [PATCH 3/4] Bugfix: Beim updaten der FreeDrinkListHistory kommt kein Networkfehler --- src/components/baruser/BarFreedrinks.vue | 2 ++ src/components/user/freedrink/freedrinkUserView.vue | 4 +++- src/store/modules/freeDrinkList.js | 12 ++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/baruser/BarFreedrinks.vue b/src/components/baruser/BarFreedrinks.vue index e3ba181..82ccf53 100644 --- a/src/components/baruser/BarFreedrinks.vue +++ b/src/components/baruser/BarFreedrinks.vue @@ -285,6 +285,8 @@ export default { 'ERROR: ' + message.free_drink_type.name +': Konnte ' + message.label + ' für ' + (message.price / 100).toFixed(2) + '€ nicht hinzufügen.' + } else if (message.canceled) { + text = `${message.free_drink_type.name}: ${message.label} wurde für ${(message.price/100).toFixed(2)}€ storniert.` } else { text = message.free_drink_type.name + ': ' + message.label + ' wurde für ' + (message.price / 100).toFixed(2) + '€ hinzugefügt.' } diff --git a/src/components/user/freedrink/freedrinkUserView.vue b/src/components/user/freedrink/freedrinkUserView.vue index 1a94a5a..487a35e 100644 --- a/src/components/user/freedrink/freedrinkUserView.vue +++ b/src/components/user/freedrink/freedrinkUserView.vue @@ -296,7 +296,7 @@ export default { this.amount = null this.selectedReason = null this.reasonDescription = null - this.drinkCount = 0 + this.drinkCount = 1 this.free_drink_type_id = null this.free_drink = null }, @@ -321,6 +321,8 @@ export default { ' für ' + (message.price / 100).toFixed(2) + '€ nicht hinzufügen.' + } else if (message.canceled) { + text = `${message.free_drink_type.name}: ${message.label} wurde für ${(message.price/100).toFixed(2)}€ storniert.` } else { text = message.free_drink_type.name + diff --git a/src/store/modules/freeDrinkList.js b/src/store/modules/freeDrinkList.js index f95451b..acf03d6 100644 --- a/src/store/modules/freeDrinkList.js +++ b/src/store/modules/freeDrinkList.js @@ -44,9 +44,11 @@ const mutations = { add_snackbar_message(state, { data, error }) { data.error = error data.visible = true - data.free_drink_type = data.free_drink_types.find(item => { + data.label = data.free_drink_config != null && data.label == null ? data.free_drink_config.label : data.label + data.price = data.free_drink_config != null && data.price == null ? data.free_drink_config.price : data.price + data.free_drink_type = data.free_drink_type == null ? data.free_drink_types.find(item => { return item.id == data.free_drink_type_id - }) + }) : data.free_drink_type data.timer = setTimeout(() => { if (!data.error) { data.visible = false @@ -98,8 +100,10 @@ const actions = { headers: { Token: rootState.login.user.accessToken }, timeout }) + console.log(response.data) commit('set_free_drink_list_history', response.data) } catch (e) { + console.log(e) if (e.message == 'Network Error') { dispatch('connectionError/addError', null, { root: true }) } @@ -138,6 +142,7 @@ const actions = { timeout } ) + console.log(data) commit('set_free_drink_list_history', response.data) commit('add_snackbar_message', { data, error: false }) } catch (e) { @@ -153,15 +158,18 @@ const actions = { }, async update_free_drink_list_history({ commit, dispatch, rootState }, data) { try { + console.log(data) commit('set_free_drink_list_history_loading', true) const response = await axios.put( url.freeDrinkListHistory, { ...data }, { headers: { Token: rootState.login.user.accessToken }, timeout } ) + console.log(response.data) commit('set_free_drink_list_history', response.data) commit('add_snackbar_message', { data, error: false }) } catch (e) { + console.log(e) dispatch('connectionError/addError', null, { root: true }) if (e.message == 'Network Error') { dispatch('connectionError/addError', null, { root: true }) From 0563740e9ced56fee20e55eb7e87fc188aec8f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 1 Sep 2020 10:18:09 +0200 Subject: [PATCH 4/4] Fehler im Verlauf der FreeDrinkList in der baransicht wurde behoben --- src/components/baruser/BarFreedrinks.vue | 7 ++++++- src/plugins/routes.js | 4 ++-- src/store/modules/freeDrinkList.js | 8 -------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/components/baruser/BarFreedrinks.vue b/src/components/baruser/BarFreedrinks.vue index 82ccf53..eec219f 100644 --- a/src/components/baruser/BarFreedrinks.vue +++ b/src/components/baruser/BarFreedrinks.vue @@ -110,7 +110,7 @@
{ + return item.free_drink_type.id == 1 || item.free_drink_type.id == 3 + }) } }, beforeDestroy() { diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 6282c3d..d25a4da 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -1,8 +1,8 @@ //const main = 'https://192.168.5.128:5000/' -//const main = 'http://localhost:5000/' +const main = 'http://localhost:5000/' //const main = 'http://192.168.5.118:5000/' //const main = 'https://groeger-clan.duckdns.org:5000/' -const main = 'https://flaschengeist.wu5.de:5000/' +//const main = 'https://flaschengeist.wu5.de:5000/' const url = { login: main + 'login', diff --git a/src/store/modules/freeDrinkList.js b/src/store/modules/freeDrinkList.js index acf03d6..e9fc998 100644 --- a/src/store/modules/freeDrinkList.js +++ b/src/store/modules/freeDrinkList.js @@ -54,7 +54,6 @@ const mutations = { data.visible = false } }, 5000) - console.log(data) state.snackbar_messages.unshift(data) }, set_free_drink_list_reasons(state, data) { @@ -100,10 +99,8 @@ const actions = { headers: { Token: rootState.login.user.accessToken }, timeout }) - console.log(response.data) commit('set_free_drink_list_history', response.data) } catch (e) { - console.log(e) if (e.message == 'Network Error') { dispatch('connectionError/addError', null, { root: true }) } @@ -142,7 +139,6 @@ const actions = { timeout } ) - console.log(data) commit('set_free_drink_list_history', response.data) commit('add_snackbar_message', { data, error: false }) } catch (e) { @@ -158,18 +154,15 @@ const actions = { }, async update_free_drink_list_history({ commit, dispatch, rootState }, data) { try { - console.log(data) commit('set_free_drink_list_history_loading', true) const response = await axios.put( url.freeDrinkListHistory, { ...data }, { headers: { Token: rootState.login.user.accessToken }, timeout } ) - console.log(response.data) commit('set_free_drink_list_history', response.data) commit('add_snackbar_message', { data, error: false }) } catch (e) { - console.log(e) dispatch('connectionError/addError', null, { root: true }) if (e.message == 'Network Error') { dispatch('connectionError/addError', null, { root: true }) @@ -342,7 +335,6 @@ const getters = { }, free_drink_list_config_job(state) { return state.free_drink_list_config.filter(item => { - console.log(item) return item.free_drink_types.find(drink_type => { return drink_type.id == 1 })