From 8a442d029b5cc54ed38bf4bbe9aed4411cb9492e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 23 Aug 2020 21:16:56 +0200 Subject: [PATCH] =?UTF-8?q?L=C3=B6schen,=20Modifizieren=20und=20Hinzuf?= =?UTF-8?q?=C3=BCgen=20von=20Freigetr=C3=A4nken?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Der Vorstand kann nun Freigetränke löschen, modifizieren und hinzufügen. --- .../FreeDrinkList/FreeDrinkListConfig.vue | 132 +++++++++++------- .../FreeDrinkListConfigConfigItem.vue | 116 +++++++++++++++ src/plugins/routes.js | 1 + src/store/modules/freeDrinkList.js | 66 +++++++++ 4 files changed, 268 insertions(+), 47 deletions(-) create mode 100644 src/components/vorstand/FreeDrinkList/FreeDrinkListConfigComponents/FreeDrinkListConfigConfigItem.vue diff --git a/src/components/vorstand/FreeDrinkList/FreeDrinkListConfig.vue b/src/components/vorstand/FreeDrinkList/FreeDrinkListConfig.vue index 2c3b77c..326e95a 100644 --- a/src/components/vorstand/FreeDrinkList/FreeDrinkListConfig.vue +++ b/src/components/vorstand/FreeDrinkList/FreeDrinkListConfig.vue @@ -9,83 +9,121 @@ + + + + + - - LOG + + + mdi-plus Gründe für Freigetränke + + + + + Wirklich löschen? + + + Willst du wirklich {{check_model.label}} mit dem Getränk {{check_model.drink.name}} löschen? + Wenn du dies löscht, wird auch der ganze Verlauf gelöscht. Dh. es ist nicht mehr vollständig nachvollziehbar, was getrunken wurde. + + + + Abbrechen + Löschen + + + diff --git a/src/components/vorstand/FreeDrinkList/FreeDrinkListConfigComponents/FreeDrinkListConfigConfigItem.vue b/src/components/vorstand/FreeDrinkList/FreeDrinkListConfigComponents/FreeDrinkListConfigConfigItem.vue new file mode 100644 index 0000000..8f8bd70 --- /dev/null +++ b/src/components/vorstand/FreeDrinkList/FreeDrinkListConfigComponents/FreeDrinkListConfigConfigItem.vue @@ -0,0 +1,116 @@ + + + + + \ No newline at end of file diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 953a34a..cef3e5a 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -33,6 +33,7 @@ const url = { deleteDrinkListHistory: main + 'deleteDrinkListHistory', freeDrinkListReasons: main + 'freeDrinkListReasons', freeDrinkTypes: main + 'freeDrinkTypes', + deleteFreeDrinkListConfig: main + 'deleteFreeDrinkListConfig', vorstand: { sm: { addUser: main + 'sm/addUser', diff --git a/src/store/modules/freeDrinkList.js b/src/store/modules/freeDrinkList.js index 7d434d5..44f9434 100644 --- a/src/store/modules/freeDrinkList.js +++ b/src/store/modules/freeDrinkList.js @@ -63,6 +63,12 @@ const mutations = { }, set_free_drink_types_loading(state, loading) { state.free_drink_types_loading = loading + }, + set_free_drink_config(state, data) { + let config = state.free_drink_list_config.find(item => { + return item.id == data.id + }) + Object.assign(config, data) } } @@ -185,6 +191,63 @@ const actions = { } finally { commit('set_free_drink_types_loading', false) } + }, + async set_free_drink_list_config({commit, dispatch, rootState}, data) { + try { + commit('set_free_drink_list_config_loading', true) + const response = await axios.post(url.freeDrinkListConfig, {...data},{ + headers: { Token: rootState.login.user.accessToken }, + timeout + }) + commit('set_free_drink_list_config', 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_config_loading', false) + } + }, + async update_free_drink_list_config({commit, dispatch, rootState}, data) { + try { + commit('set_free_drink_list_config_loading', true) + const response = await axios.put(url.freeDrinkListConfig, {...data},{ + headers: { Token: rootState.login.user.accessToken }, + timeout + }) + commit('set_free_drink_list_config', 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_config_loading', false) + } + }, + async delete_free_drink_list_config({commit, dispatch, rootState}, data) { + try { + commit('set_free_drink_list_config_loading', true) + const response = await axios.post(url.deleteFreeDrinkListConfig, {...data},{ + headers: { Token: rootState.login.user.accessToken }, + timeout + }) + commit('set_free_drink_list_config', 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_config_loading', false) + } } } @@ -267,6 +330,9 @@ const getters = { }, free_drink_types_loading(state) { return state.free_drink_types_loading + }, + free_drink_list_config_by_id: (state) => (id) => { + return state.free_drink_list_config.find(item => { return item.id == id}) } }