summaryrefslogtreecommitdiffstats
path: root/webapp/src/store/groups.js
diff options
context:
space:
mode:
authorUdo Walter2018-08-02 18:13:05 +0200
committerUdo Walter2018-08-02 18:13:05 +0200
commit028c9aaa8651862b2bd495c527d30845d1fb1f50 (patch)
tree2b6bc68432940ebfe7078a8aefad26f369c09f08 /webapp/src/store/groups.js
parent[groups] small bugfix (diff)
downloadbas-028c9aaa8651862b2bd495c527d30845d1fb1f50.tar.gz
bas-028c9aaa8651862b2bd495c527d30845d1fb1f50.tar.xz
bas-028c9aaa8651862b2bd495c527d30845d1fb1f50.zip
[groups] add dialog to delete, remove and add groups/clients
Diffstat (limited to 'webapp/src/store/groups.js')
-rw-r--r--webapp/src/store/groups.js58
1 files changed, 49 insertions, 9 deletions
diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js
index 58d64b3..a733aac 100644
--- a/webapp/src/store/groups.js
+++ b/webapp/src/store/groups.js
@@ -10,8 +10,7 @@ export default {
showAll: false,
dialog: {
show: false,
- type: '',
- selected: []
+ info: {}
}
},
mutations: {
@@ -26,17 +25,16 @@ export default {
}
state.tabChain.splice(index, 1, item)
},
- setDialog (state, { show, type, selected }) {
- if (show !== undefined) state.dialog.type = type
- if (selected !== undefined) state.dialog.selected = selected
+ setDialog (state, { show, info, selected }) {
+ if (info !== undefined) state.dialog.info = info
if (show !== undefined) state.dialog.show = show
}
},
actions: {
loadLists (context) {
Promise.all([axios.get('/api/groups/getList'), axios.get('/api/clients/getList')]).then(res => {
- context.commit('setGroupList', res[0].data.map(x => ({ value: x.id, text: x.name || x.id })))
- context.commit('setClientList', res[1].data.map(x => ({ value: x.id, text: x.name || x.id })))
+ context.commit('setGroupList', res[0].data)
+ context.commit('setClientList', res[1].data)
})
},
loadHome (context) {
@@ -95,25 +93,67 @@ export default {
context.dispatch('reload')
})
},
- deleteGroups (context, ids) {
+ deleteGroups (context, { selected }) {
+ const ids = selected.map(x => x.id)
axios.post('/api/groups/delete', { ids }).then(() => {
var i = 1
while (i < context.state.tabChain.length) {
if (context.state.tabChain[i].tabType === 'group' && ids.includes(context.state.tabChain[i].id)) {
context.commit('deleteFromTabChain', { index: i, count: context.state.tabChain.length - i })
+ break
}
i++
}
context.dispatch('reload')
})
},
- deleteClients (context, ids) {
+ deleteClients (context, { selected }) {
+ const ids = selected.map(x => x.id)
axios.post('/api/clients/delete', { ids }).then(() => {
const index = context.state.tabChain.length - 1
const item = context.state.tabChain[index]
if (item.tabType === 'client' && ids.includes(item.id)) context.commit('deleteFromTabChain', { index, count: 1 })
context.dispatch('reload')
})
+ },
+ removeSubroups (context, { tabIndex, selected }) {
+ const id = context.state.tabChain[tabIndex].id
+ const ids = selected.map(x => x.id)
+ axios.post('/api/groups/removeSubgroups', { id, ids }).then(() => {
+ if (context.state.tabChain.length > tabIndex + 1
+ && context.state.tabChain[tabIndex + 1].tabType === 'group'
+ && ids.includes(context.state.tabChain[tabIndex + 1].id)) {
+ context.commit('deleteFromTabChain', { index: tabIndex + 1, count: context.state.tabChain.length - (tabIndex + 1) })
+ }
+ context.dispatch('reload')
+ })
+ },
+ removeClients (context, { tabIndex, selected }) {
+ const id = context.state.tabChain[tabIndex].id
+ const ids = selected.map(x => x.id)
+ axios.post('/api/groups/removeClients', { id, ids }).then(() => {
+ if (context.state.tabChain.length > tabIndex + 1
+ && context.state.tabChain[tabIndex + 1].tabType === 'client'
+ && ids.includes(context.state.tabChain[tabIndex + 1].id)) {
+ context.commit('deleteFromTabChain', { index: tabIndex + 1, count: 1 })
+ }
+ context.dispatch('reload')
+ })
+ },
+ addSubgroups (context, { tabIndex, selected }) {
+ const id = context.state.tabChain[tabIndex].id
+ const ids = selected.map(x => x.id)
+ console.log(ids)
+ axios.post('/api/groups/addSubgroups', { id, ids }).then(() => {
+ context.dispatch('reload')
+ })
+ },
+ addClients (context, { tabIndex, selected }) {
+ const id = context.state.tabChain[tabIndex].id
+ const ids = selected.map(x => x.id)
+ axios.post('/api/groups/addClients', { id, ids }).then(() => {
+ context.dispatch('reload')
+ })
}
}
}