summaryrefslogtreecommitdiffstats
path: root/webapp/src/store/groups.js
diff options
context:
space:
mode:
authorUdo Walter2018-07-20 05:49:54 +0200
committerUdo Walter2018-07-20 05:49:54 +0200
commitbe1394e50b38f229260e267828cd880299b99393 (patch)
tree6deb141088fdf46d41cf48443a1b5e2478494326 /webapp/src/store/groups.js
parent[webapp/devserver] api port for the webpack dev server proxy must now be set ... (diff)
downloadbas-be1394e50b38f229260e267828cd880299b99393.tar.gz
bas-be1394e50b38f229260e267828cd880299b99393.tar.xz
bas-be1394e50b38f229260e267828cd880299b99393.zip
[webapp/settings] added switch to enable colored tab panels
Diffstat (limited to 'webapp/src/store/groups.js')
-rw-r--r--webapp/src/store/groups.js44
1 files changed, 31 insertions, 13 deletions
diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js
index fca5358..c5ecce4 100644
--- a/webapp/src/store/groups.js
+++ b/webapp/src/store/groups.js
@@ -4,30 +4,48 @@ export default {
namespaced: true,
state: {
groupChain: [],
- activeTab: 0
+ activeTab: 0,
+ editGroupDialog: false,
+ editGroup: null,
},
mutations: {
updateActiveTab (state, tabIndex) {
state.activeTab = tabIndex
},
- addGroup (state, data) {
- if (state.groupChain.length <= data.tabIndex || state.groupChain[data.tabIndex].id !== data.group.id) {
- state.groupChain = state.groupChain.slice(0, data.tabIndex)
- state.groupChain.push(data.group)
+ setGroupInChain (state, { tabIndex, group }) {
+ if (state.groupChain.length <= tabIndex || state.groupChain[tabIndex].id !== group.id) {
+ state.groupChain = state.groupChain.slice(0, tabIndex)
+ state.groupChain.push(group)
}
- state.activeTab = data.tabIndex
+ },
+ openEditGroupDialog (state, group) {
+ state.editGroupDialog = true
+ state.editGroup = group
+ },
+ closeEditGroupDialog (state) {
+ state.editGroupDialog = false
+ state.editGroup = null
}
},
actions: {
- loadGroup (context, data) {
- var getSubGroups = axios('/api/groups?action=getSubGroups&id=' + data.id)
- var getClients = axios('/api/groups?action=getClients&id=' + data.id)
+ loadGroupInChain (context, { id, name, tabIndex, switchTab }) {
+ var getSubGroups = axios.get('/api/groups?action=getSubGroups&id=' + id)
+ var getClients = axios.get('/api/groups?action=getClients&id=' + id)
axios.all([getSubGroups, getClients]).then(axios.spread((groupRespsonse, clientResponse) => {
- var group = { id: data.id, name: data.name }
- group.subGroups = groupRespsonse.data
- group.clients = clientResponse.data
- context.commit('addGroup', { group: group, tabIndex: data.tabIndex })
+ var group = { id: id, name: name, subGroups: groupRespsonse.data, clients: clientResponse.data }
+ context.commit('setGroupInChain', { group: group, tabIndex: tabIndex })
+ if (switchTab) context.commit('updateActiveTab', tabIndex)
}))
+ },
+ editGroup (context, { id, name }) {
+ axios.get('/api/groups?action=getParents&id=' + id).then(res => {
+ context.commit('openEditGroupDialog', { id: id, name: name, parents: res.data })
+ })
+ },
+ saveGroup (context) {
+ axios.post('/api/groups?action=update&id=' + context.state.editGroup.id).then(res => {
+ context.commit('closeEditGroupDialog')
+ })
}
}
}