From 4af0d77584515c24ec258951c29c68ecc84efc65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 17 May 2020 20:22:03 +0200 Subject: [PATCH 01/12] vorstand can create, edit and delete jobkinds --- src/components/vorstand/JobKindManager.vue | 119 ++++++++++++++++++ .../vorstand/ManagementNavigation.vue | 8 ++ src/plugins/routes.js | 6 +- src/router/index.js | 5 + src/store/index.js | 4 +- src/store/modules/jobkindManager.js | 118 +++++++++++++++++ 6 files changed, 258 insertions(+), 2 deletions(-) create mode 100644 src/components/vorstand/JobKindManager.vue create mode 100644 src/store/modules/jobkindManager.js diff --git a/src/components/vorstand/JobKindManager.vue b/src/components/vorstand/JobKindManager.vue new file mode 100644 index 0000000..036674f --- /dev/null +++ b/src/components/vorstand/JobKindManager.vue @@ -0,0 +1,119 @@ + + + + + diff --git a/src/components/vorstand/ManagementNavigation.vue b/src/components/vorstand/ManagementNavigation.vue index f2ec3ac..46ffe61 100644 --- a/src/components/vorstand/ManagementNavigation.vue +++ b/src/components/vorstand/ManagementNavigation.vue @@ -24,6 +24,14 @@ Arbeitsgruppen + + + ??? + + + Dienstarten + + diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 118a35e..66b4282 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -33,7 +33,11 @@ const url = { getUser: main + 'sm/getUser', getUsers: main + 'sm/getUsers', lockDay: main + 'sm/lockDay', - searchUser: main + 'sm/searchWithExtern' + searchUser: main + 'sm/searchWithExtern', + jobkind: main + 'sm/JobKind', + getAllJobKindsbKinds: main + 'sm/getAllJobKinds', + getJobKind: main + 'sm/getJobKind', + deleteJobKind: main + 'sm/deleteJobKind' }, um: { setStatus: main + 'um/setStatus', diff --git a/src/router/index.js b/src/router/index.js index fecd282..c7a8f16 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -24,6 +24,7 @@ import GastroNavigation from '@/components/gastro/GastroNavigation' import PriceListView from '@/views/contents/PriceListView' import UserManager from '@/components/vorstand/UserManager' import WorkgroupManagement from "@/components/vorstand/WorkgroupManagement"; +import JobKindManager from "@/components/vorstand/JobKindManager"; Vue.use(VueRouter) @@ -63,6 +64,10 @@ const routes = [ { path: 'workgroupmanagement', component: WorkgroupManagement + }, + { + path: 'jobkindmanagement', + component: JobKindManager } ] }, diff --git a/src/store/index.js b/src/store/index.js index 5fc6616..eb63086 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -10,6 +10,7 @@ import requestJobs from '@/store/modules/jobRequests' import priceList from '@/store/modules/pricelist' import usermanager from '@/store/modules/userManager' import wm from '@/store/modules/workgroupManagement' +import jkm from '@/store/modules/jobkindManager' Vue.use(Vuex) @@ -24,6 +25,7 @@ export default new Vuex.Store({ requestJobs, priceList, usermanager, - wm + wm, + jkm } }) diff --git a/src/store/modules/jobkindManager.js b/src/store/modules/jobkindManager.js new file mode 100644 index 0000000..09b36a9 --- /dev/null +++ b/src/store/modules/jobkindManager.js @@ -0,0 +1,118 @@ +import url from '@/plugins/routes' +import axios from 'axios' + +const state = { + jobkinds: [], + jobkindLoading: false +} + +const mutations = { + setJobkinds: (state, jobkinds) => { + state.jobkinds = jobkinds + }, + updateJobKind: (state, jobkind) => { + console.log(jobkind) + const exists = state.jobkinds.find(a => { + return a.id === jobkind.id + }) + console.log(exists) + if (exists) { + exists.name = jobkind.name + } else { + state.jobkinds.push(jobkind) + } + }, + deleteJobKind: (state, jobkind) => { + const exists = state.jobkinds.indexOf( + state.jobkinds.find(a => { + return a.id === jobkind.id + }) + ) + state.jobkinds.splice(exists, 1) + }, + setJobkindsLoading: (state, value) => { + state.jobkindLoading = value + } +} + +const actions = { + async getAllJobKinds({ commit, rootState, dispatch }) { + try { + commit('setJobkindsLoading', true) + const response = await axios.get(url.vorstand.sm.getAllJobKindsbKinds, { + headers: { Token: rootState.login.user.accessToken } + }) + commit('setJobkinds', response.data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async addJobKind({ commit, rootState, dispatch }, data) { + try { + commit('setJobkindsLoading', true) + const response = await axios.put( + url.vorstand.sm.jobkind, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateJobKind', response.data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async updateJobKind({ commit, rootState, dispatch }, data) { + try { + commit('setJobkindsLoading', true) + const response = await axios.post( + url.vorstand.sm.jobkind, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateJobKind', response.data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + }, + async deleteJobKind({ commit, rootState, dispatch }, data) { + try { + commit('setJobkindsLoading', true) + await axios.post( + url.vorstand.sm.deleteJobKind, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('deleteJobKind', data) + commit('setJobkindsLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } + } +} + +const getters = { + jobkinds: state => { + return state.jobkinds + }, + jobkindsLoading: state => { + return state.jobkindLoading + } +} + +export default { + namespaced: true, + state, + mutations, + actions, + getters +} From 9bd854209e74a96e36cb855267f73880b7d9adb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 17 May 2020 21:19:19 +0200 Subject: [PATCH 02/12] vorstand can change group for jobkind --- src/components/vorstand/JobKindManager.vue | 130 ++++++++++++++------- src/components/vorstand/UserManager.vue | 61 ++++++---- src/store/modules/jobkindManager.js | 1 + 3 files changed, 130 insertions(+), 62 deletions(-) diff --git a/src/components/vorstand/JobKindManager.vue b/src/components/vorstand/JobKindManager.vue index 036674f..ca4a63d 100644 --- a/src/components/vorstand/JobKindManager.vue +++ b/src/components/vorstand/JobKindManager.vue @@ -1,43 +1,62 @@