From c8a6ab7d351228746a55a5507a5988b27f91f617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Mon, 24 Aug 2020 15:18:21 +0200 Subject: [PATCH] =?UTF-8?q?Gr=C3=BCnde=20f=C3=BCr=20Freigetr=C3=A4nke=20k?= =?UTF-8?q?=C3=B6nnen=20erstellt=20und=20gel=C3=B6scht=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Außerdem wurd überall ein Loading balken hinzugefügt. --- src/components/vorstand/FreeDrinkList.vue | 17 +++- .../FreeDrinkList/FreeDrinkListConfig.vue | 88 ++++++++++++++++++- .../FreeDrinkListConfigReasonItem.vue | 70 +++++++++++++++ .../FreeDrinkList/FreeDrinkListWorkgroup.vue | 2 +- src/plugins/routes.js | 1 + src/store/modules/freeDrinkList.js | 65 ++++++++++++++ 6 files changed, 236 insertions(+), 7 deletions(-) create mode 100644 src/components/vorstand/FreeDrinkList/FreeDrinkListConfigComponents/FreeDrinkListConfigReasonItem.vue diff --git a/src/components/vorstand/FreeDrinkList.vue b/src/components/vorstand/FreeDrinkList.vue index 546be23..d4189a7 100644 --- a/src/components/vorstand/FreeDrinkList.vue +++ b/src/components/vorstand/FreeDrinkList.vue @@ -35,6 +35,7 @@ +
@@ -42,7 +43,7 @@ + + \ No newline at end of file diff --git a/src/components/vorstand/FreeDrinkList/FreeDrinkListWorkgroup.vue b/src/components/vorstand/FreeDrinkList/FreeDrinkListWorkgroup.vue index 71e2d94..84b6f77 100644 --- a/src/components/vorstand/FreeDrinkList/FreeDrinkListWorkgroup.vue +++ b/src/components/vorstand/FreeDrinkList/FreeDrinkListWorkgroup.vue @@ -94,7 +94,7 @@ name: "FreeDrinkListWorkgroup", label: drink_config.label, name: drink_config.drink.name, user: `${history_config.user.firstname} ${history_config.user.lastname}`, - reason: history_config.free_drink_list_reason.name, + reason: history_config.free_drink_list_reason ? history_config.free_drink_list_reason.name : null, description: history_config.description, pricepro: (drink_config.price / 100).toFixed(2) }) diff --git a/src/plugins/routes.js b/src/plugins/routes.js index e974d25..cfa1742 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -33,6 +33,7 @@ const url = { freeDrinkListHistoryFromTo: main + 'freeDrinkListHistoryFromTo', deleteDrinkListHistory: main + 'deleteDrinkListHistory', freeDrinkListReasons: main + 'freeDrinkListReasons', + deleteFreeDrinkListReason: main + 'deleteFreeDrinkListReason', freeDrinkTypes: main + 'freeDrinkTypes', deleteFreeDrinkListConfig: main + 'deleteFreeDrinkListConfig', vorstand: { diff --git a/src/store/modules/freeDrinkList.js b/src/store/modules/freeDrinkList.js index c46d651..f95451b 100644 --- a/src/store/modules/freeDrinkList.js +++ b/src/store/modules/freeDrinkList.js @@ -266,7 +266,66 @@ const actions = { } finally { commit('set_free_drink_list_config_loading', false) } + }, + async set_free_drink_list_reason({ commit, dispatch, rootState }, data) { + try { + commit('set_free_drink_list_reasons_loading', true) + const response = await axios.post(url.freeDrinkListReasons, {...data},{ + headers: { Token: rootState.login.user.accessToken }, + timeout + }) + commit('set_free_drink_list_reasons', response.data) + } catch (e) { + dispatch('connectionError/addError', null, { root: true }) + if (e.message == 'Network Error') { + dispatch('connectionError/addError', null, { root: true }) + } + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } finally { + commit('set_free_drink_list_reasons_loading', false) + } } + , + async update_free_drink_list_reason({ commit, dispatch, rootState }, data) { + try { + commit('set_free_drink_list_reasons_loading', true) + const response = await axios.put(url.freeDrinkListReasons, {...data},{ + headers: { Token: rootState.login.user.accessToken }, + timeout + }) + commit('set_free_drink_list_reasons', response.data) + } catch (e) { + dispatch('connectionError/addError', null, { root: true }) + if (e.message == 'Network Error') { + dispatch('connectionError/addError', null, { root: true }) + } + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } finally { + commit('set_free_drink_list_reasons_loading', false) + } + }, + async delete_free_drink_list_reason({ commit, dispatch, rootState }, data) { + try { + commit('set_free_drink_list_reasons_loading', true) + const response = await axios.post(url.deleteFreeDrinkListReason, {...data},{ + headers: { Token: rootState.login.user.accessToken }, + timeout + }) + commit('set_free_drink_list_reasons', response.data) + } catch (e) { + dispatch('connectionError/addError', null, { root: true }) + if (e.message == 'Network Error') { + dispatch('connectionError/addError', null, { root: true }) + } + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } finally { + commit('set_free_drink_list_reasons_loading', false) + } + } + } const getters = { @@ -356,6 +415,12 @@ const getters = { free_drink_types(state) { return state.free_drink_types }, + free_drink_list_history_loading(state) { + return state.free_drink_list_history_loading + }, + free_drink_list_config_loading(state) { + return state.free_drink_list_config_loading + }, free_drink_types_loading(state) { return state.free_drink_types_loading },