summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/GroupModuleClientView.vue
diff options
context:
space:
mode:
authorUdo Walter2018-08-02 01:42:30 +0200
committerUdo Walter2018-08-02 01:42:30 +0200
commitb311735e97bedd764f2e6d43afe8d24bb4fb67a1 (patch)
treebcaf99471f341dde57e31a20634341756b45ef0c /webapp/src/components/GroupModuleClientView.vue
parent[groups] add client edit functionality (diff)
downloadbas-b311735e97bedd764f2e6d43afe8d24bb4fb67a1.tar.gz
bas-b311735e97bedd764f2e6d43afe8d24bb4fb67a1.tar.xz
bas-b311735e97bedd764f2e6d43afe8d24bb4fb67a1.zip
[groups] add create functionality
Diffstat (limited to 'webapp/src/components/GroupModuleClientView.vue')
-rw-r--r--webapp/src/components/GroupModuleClientView.vue26
1 files changed, 20 insertions, 6 deletions
diff --git a/webapp/src/components/GroupModuleClientView.vue b/webapp/src/components/GroupModuleClientView.vue
index 9534274..43f09b2 100644
--- a/webapp/src/components/GroupModuleClientView.vue
+++ b/webapp/src/components/GroupModuleClientView.vue
@@ -26,7 +26,7 @@
<v-icon left>create</v-icon>Edit
</v-btn>
<div v-else>
- <v-btn color="primary" flat @click="editMode = false">Cancel</v-btn>
+ <v-btn color="primary" flat @click="cancelEdit">Cancel</v-btn>
<v-btn color="primary" @click="saveInfo">
<v-icon left>save</v-icon>Save
</v-btn>
@@ -62,7 +62,7 @@
</v-autocomplete>
<div v-else class="info-input">
<div class="body-2">Groups</div>
- <template v-if="client.groups.length > 0">
+ <template v-if="client.groups && client.groups.length > 0">
<v-chip v-for="group in client.groups" :key="group.id" small>
{{ group.name || group.id }}
</v-chip>
@@ -113,9 +113,18 @@ export default {
description: '',
ip: '',
mac: '',
- uuid: '',
- groupIds: []
- }
+ uuid: ''
+ },
+ groupIds: []
+ }
+ },
+ created () {
+ if (!this.client.id) this.editInfo()
+ },
+ watch: {
+ client (newValue, oldValue) {
+ if (!newValue.id) this.editInfo()
+ else if (newValue.id !== oldValue.id) this.editMode = false
}
},
methods: {
@@ -126,7 +135,12 @@ export default {
this.editMode = true
this.info.name = this.client.name
this.info.description = this.client.description
- this.groupIds = this.client.groups.map(x => x.id)
+ if (this.client.groups) this.groupIds = this.client.groups.map(x => x.id)
+ },
+ cancelEdit () {
+ this.editMode = false
+ this.$store.commit('groups/deleteFromTabChain', { index: this.tabIndex, count: 1 })
+ this.$store.commit('groups/setActiveTab', this.tabIndex - 1)
},
saveInfo () {
this.$store.dispatch('groups/saveClient', {