From 843946b27642f5acdeb1d5dc0d46eada379dbd0c Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Thu, 18 Apr 2019 13:21:08 +0000 Subject: [webapp/groups] automatically switch to subgroups or clients on load --- webapp/src/components/GroupModuleGroupView.vue | 18 ++++++++++-------- webapp/src/store/groups.js | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'webapp') diff --git a/webapp/src/components/GroupModuleGroupView.vue b/webapp/src/components/GroupModuleGroupView.vue index a793d8a..04b0be0 100644 --- a/webapp/src/components/GroupModuleGroupView.vue +++ b/webapp/src/components/GroupModuleGroupView.vue @@ -64,7 +64,7 @@ > - + @@ -217,6 +217,7 @@ export default { return { activeTab: 0, editMode: false, + showAllClicked: false, info: { name: '', description: '', @@ -239,18 +240,19 @@ export default { }, watch: { group (newValue, oldValue) { - if (newValue.id === 'create') { - this.editInfo() - this.activeTab = 0 - } else if (newValue.id !== oldValue.id) { - this.editMode = false - this.activeTab = 0 - } + if (newValue.id === 'create') this.editInfo() + else if (newValue.id !== oldValue.id) this.editMode = false + else if (!oldValue.isPlaceholder) return + + if (newValue.subgroups.length) this.activeTab = (this.group.id === 0 ? 0 : 1) + else if (newValue.clients.length) this.activeTab = (this.group.id === 0 ? 1 : 2) + else this.activeTab = 0 } }, methods: { ...mapMutations('groups', ['setDialog', 'setActiveTab', 'adjustTabSlider', 'deleteFromTabChain']), setShowAll (value) { + this.showAllClicked = true this.$store.commit('groups/setShowAll', { index: this.tabIndex, value }) this.$store.dispatch('groups/loadGroup', { id: this.group.id, tabIndex: this.tabIndex }) }, diff --git a/webapp/src/store/groups.js b/webapp/src/store/groups.js index c5df70a..24f58d3 100644 --- a/webapp/src/store/groups.js +++ b/webapp/src/store/groups.js @@ -78,7 +78,7 @@ export default { if (insert) context.commit('setActiveTab', 2) context.commit(insert ? 'insertTab' : 'setTab', { index: tabIndex, - item: { id, name, tabType: 'group', tabShowAll: showAll, subgroups: [], clients: [] } + item: { id, name, tabType: 'group', tabShowAll: showAll, subgroups: [], clients: [], isPlaceholder: true } }) } if (insert) tabIndex = 1 -- cgit v1.2.3-55-g7522