summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUdo Walter2018-08-04 10:18:59 +0200
committerUdo Walter2018-08-04 10:18:59 +0200
commit132e04e3f71a101f69309b4c9c8b8ed5618b111b (patch)
tree933679f9cdba76fdfccb9c4b5d441fcd29200ea0
parentsmall changes (diff)
downloadbas-132e04e3f71a101f69309b4c9c8b8ed5618b111b.tar.gz
bas-132e04e3f71a101f69309b4c9c8b8ed5618b111b.tar.xz
bas-132e04e3f71a101f69309b4c9c8b8ed5618b111b.zip
[groups] small bug fixes
-rw-r--r--server/api/clients.js2
-rw-r--r--server/api/groups.js2
-rw-r--r--webapp/src/components/GroupModule.vue12
-rw-r--r--webapp/src/components/GroupModuleClientView.vue31
-rw-r--r--webapp/src/components/GroupModuleGroupView.vue31
-rw-r--r--webapp/src/store/groups.js10
6 files changed, 37 insertions, 51 deletions
diff --git a/server/api/clients.js b/server/api/clients.js
index 06fa780..046bced 100644
--- a/server/api/clients.js
+++ b/server/api/clients.js
@@ -56,6 +56,6 @@ module.exports.post = {
// delete clients
delete: function (req, res) {
- db.client.destroy({ where: { id: req.body.ids } }).then(count => { res.end(count) })
+ db.client.destroy({ where: { id: req.body.ids } }).then(count => { res.send({ count }) })
}
}
diff --git a/server/api/groups.js b/server/api/groups.js
index 526f3ee..02bfa25 100644
--- a/server/api/groups.js
+++ b/server/api/groups.js
@@ -57,7 +57,7 @@ module.exports.post = {
// delete groups
delete: function (req, res) {
- db.group.destroy({ where: { id: req.body.ids } }).then(count => { res.end(count) })
+ db.group.destroy({ where: { id: req.body.ids } }).then(count => { res.send({ count }) })
},
// remove subgroups from a group
diff --git a/webapp/src/components/GroupModule.vue b/webapp/src/components/GroupModule.vue
index c163b5a..08bd6c6 100644
--- a/webapp/src/components/GroupModule.vue
+++ b/webapp/src/components/GroupModule.vue
@@ -47,7 +47,7 @@ export default {
name: 'GroupModule',
routes () {
return [
- { name: 'home', path: '' },
+ { name: 'home', path: 'home' },
{ name: 'group', path: ':id' },
{ name: 'client', path: 'client/:id' }
]
@@ -91,12 +91,10 @@ export default {
if (this.groupList.length === 0 || this.clientList.length === 0) this.$store.dispatch('groups/loadLists')
if (this.tabChain.length === 0) this.$store.dispatch('groups/loadHome')
this.loadItem(this.$route.name, this.$route.params.id)
- if (this.tabChain[this.activeTab].tabType !== 'home') {
- this.$router.replace({
- name: 'GroupModule.' + this.tabChain[this.activeTab].tabType,
- params: { id: this.tabChain[this.activeTab].id, noReload: true }
- })
- }
+ this.$router.replace({
+ name: 'GroupModule.' + this.tabChain[this.activeTab].tabType,
+ params: { id: this.tabChain[this.activeTab].id, noReload: true }
+ })
},
beforeRouteUpdate (to, from, next) {
if (!to.params.noReload) this.loadItem(to.name, to.params.id)
diff --git a/webapp/src/components/GroupModuleClientView.vue b/webapp/src/components/GroupModuleClientView.vue
index 7a7a4a8..ab12ed0 100644
--- a/webapp/src/components/GroupModuleClientView.vue
+++ b/webapp/src/components/GroupModuleClientView.vue
@@ -46,18 +46,10 @@
color="primary"
multiple
item-value="id"
+ item-text="name"
+ small-chips
+ deletable-chips
>
- <template slot="selection" slot-scope="data">
- <v-chip small :selected="data.selected" @input="removeGroup(data.item.id)" close>
- {{ data.item.name || data.item.id }}
- </v-chip>
- </template>
- <template slot="item" slot-scope="data">
- <div class="select-item">
- <v-checkbox class="select-item-checkbox" color="primary" :value="groupIds.includes(data.item.id)" hide-details></v-checkbox>
- {{ data.item.name || data.item.id }}
- </div>
- </template>
</v-autocomplete>
<div v-else class="info-input">
<div class="body-2 info-heading"><v-icon>device_hub</v-icon><span>{{ $t('groups') }}</span></div>
@@ -169,9 +161,17 @@ export default {
id: this.client.id,
info: this.info,
groupIds: this.groupIds,
- tabIndex: this.tabIndex
+ tabIndex: this.tabIndex,
+ callback: this.updateUrl
})
this.editMode = false
+ },
+ updateUrl (id) {
+ console.log(id)
+ this.$router.replace({
+ name: 'GroupModule.client',
+ params: { id, noReload: true }
+ })
}
}
}
@@ -185,13 +185,6 @@ export default {
.info-input {
margin: 20px;
}
-.select-item {
- display: flex;
- align-items: center;
-}
-.select-item-checkbox {
- margin-right: 20px;
-}
.info-heading {
display: flex;
align-items: center;
diff --git a/webapp/src/components/GroupModuleGroupView.vue b/webapp/src/components/GroupModuleGroupView.vue
index 21a5851..bda2922 100644
--- a/webapp/src/components/GroupModuleGroupView.vue
+++ b/webapp/src/components/GroupModuleGroupView.vue
@@ -46,18 +46,10 @@
color="primary"
multiple
item-value="id"
+ item-text="name"
+ small-chips
+ deletable-chips
>
- <template slot="selection" slot-scope="data">
- <v-chip small :selected="data.selected" @input="removeParent(data.item.id)" close>
- {{ data.item.name || data.item.id }}
- </v-chip>
- </template>
- <template slot="item" slot-scope="data">
- <div class="select-item">
- <v-checkbox class="select-item-checkbox" color="primary" :value="parentIds.includes(data.item.id)" hide-details></v-checkbox>
- {{ data.item.name || data.item.id }}
- </div>
- </template>
</v-autocomplete>
<div v-else class="info-input">
<div class="body-2 info-heading"><v-icon>device_hub</v-icon><span>{{ $t('parents') }}</span></div>
@@ -156,9 +148,17 @@ export default {
id: this.group.id,
info: this.info,
parentIds: this.parentIds,
- tabIndex: this.tabIndex
+ tabIndex: this.tabIndex,
+ callback: this.updateUrl
})
this.editMode = false
+ },
+ updateUrl (id) {
+ console.log(id)
+ this.$router.replace({
+ name: 'GroupModule.group',
+ params: { id, noReload: true }
+ })
}
}
}
@@ -172,13 +172,6 @@ export default {
.info-input {
margin: 20px;
}
-.select-item {
- display: flex;
- align-items: center;
-}
-.select-item-checkbox {
- margin-right: 20px;
-}
.info-heading {
display: flex;
align-items: center;
diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js
index e595232..ddb1df8 100644
--- a/webapp/src/store/groups.js
+++ b/webapp/src/store/groups.js
@@ -33,8 +33,8 @@ export default {
actions: {
loadLists (context) {
Promise.all([axios.get('/api/groups/getList'), axios.get('/api/clients/getList')]).then(res => {
- context.commit('setGroupList', res[0].data)
- context.commit('setClientList', res[1].data)
+ context.commit('setGroupList', res[0].data.map(x => ({ id: x.id, name: x.name || x.id })))
+ context.commit('setClientList', res[1].data.map(x => ({ id: x.id, name: x.name || x.id })))
})
},
loadHome (context) {
@@ -74,8 +74,9 @@ export default {
else if (item.tabType === 'client') context.dispatch('loadClient', { id: item.id, tabIndex: index, reload: true })
})
},
- saveGroup (context, { id, info, parentIds, tabIndex }) {
+ saveGroup (context, { id, info, parentIds, tabIndex, callback }) {
axios.post('/api/groups/save', { id, info, parentIds }).then(res => {
+ if (callback) callback(res.data.id)
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 })
@@ -84,8 +85,9 @@ export default {
context.dispatch('reload')
})
},
- saveClient (context, { id, info, groupIds, tabIndex }) {
+ saveClient (context, { id, info, groupIds, tabIndex, callback }) {
axios.post('/api/clients/save', { id, info, groupIds }).then(res => {
+ if (callback) callback(res.data.id)
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 })