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 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

(limited to 'webapp/src/components/GroupModuleGroupView.vue')

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 @@
       ></v-switch>
 
       <v-tabs-items touchless>
-        <v-tab-item v-if="group.id !== 0" :transition="false" :reverse-transition="false">
+        <v-tab-item v-if="group.id !== 0" lazy :transition="false" :reverse-transition="false">
           <v-divider></v-divider>
           <v-card-text>
             <v-layout wrap>
@@ -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 })
     },
-- 
cgit v1.2.3-55-g7522

