summaryrefslogtreecommitdiffstats
path: root/webapp/src/store
diff options
context:
space:
mode:
authorUdo Walter2018-08-02 06:38:41 +0200
committerUdo Walter2018-08-02 06:38:41 +0200
commit6d7ca39adac324246b6862ed1299384ef998b8ec (patch)
tree82de9db2ece4396a9fdf4d98d9e55b5c32c2391c /webapp/src/store
parent[groups] add ability to show all groups and clients (diff)
downloadbas-6d7ca39adac324246b6862ed1299384ef998b8ec.tar.gz
bas-6d7ca39adac324246b6862ed1299384ef998b8ec.tar.xz
bas-6d7ca39adac324246b6862ed1299384ef998b8ec.zip
[groups] add delete client/group functionality
Diffstat (limited to 'webapp/src/store')
-rw-r--r--webapp/src/store/groups.js36
1 files changed, 33 insertions, 3 deletions
diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js
index 137ae6a..58d64b3 100644
--- a/webapp/src/store/groups.js
+++ b/webapp/src/store/groups.js
@@ -7,7 +7,12 @@ export default {
clientList: [],
tabChain: [],
activeTab: 0,
- showAll: false
+ showAll: false,
+ dialog: {
+ show: false,
+ type: '',
+ selected: []
+ }
},
mutations: {
setGroupList: (state, list) => { state.groupList = list },
@@ -20,6 +25,11 @@ export default {
state.tabChain = state.tabChain.slice(0, index + 1)
}
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
+ if (show !== undefined) state.dialog.show = show
}
},
actions: {
@@ -66,7 +76,7 @@ export default {
})
},
saveGroup (context, { id, info, parentIds, tabIndex }) {
- axios.post('/api/groups/updateOrCreate', { id, info, parentIds }).then(res => {
+ axios.post('/api/groups/save', { id, info, parentIds }).then(res => {
if (!id) context.commit('setTab', { index: tabIndex, item: { id: res.data.id, name: info.name, tabType: 'group' } })
if (parentIds && tabIndex > 1 && !parentIds.includes(context.state.tabChain[tabIndex - 1].id)) {
context.commit('deleteFromTabChain', { index: 1, count: tabIndex - 1 })
@@ -76,7 +86,7 @@ export default {
})
},
saveClient (context, { id, info, groupIds, tabIndex }) {
- axios.post('/api/clients/updateOrCreate', { id, info, groupIds }).then(res => {
+ axios.post('/api/clients/save', { id, info, groupIds }).then(res => {
if (!id) context.commit('setTab', { index: tabIndex, item: { id: res.data.id, name: info.name, tabType: 'client' } })
if (groupIds && tabIndex > 1 && !groupIds.includes(context.state.tabChain[tabIndex - 1].id)) {
context.commit('deleteFromTabChain', { index: 1, count: tabIndex - 1 })
@@ -84,6 +94,26 @@ export default {
}
context.dispatch('reload')
})
+ },
+ deleteGroups (context, ids) {
+ 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 })
+ }
+ i++
+ }
+ context.dispatch('reload')
+ })
+ },
+ deleteClients (context, ids) {
+ 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')
+ })
}
}
}