summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/GroupModule.vue
blob: b690628bc3ba2d3af6f30f8b0d8b5f202b58801e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<i18n>
{
  "en": {
  },
  "de": {
  }
}
</i18n>

<template>
  <v-container fill-height>
    <v-layout>
      <v-flex class="tabs-wrapper" xl10 offset-xl1 lg12>
          <v-card>
            <v-tabs :value="activeTab" @input="setActiveTab" :dark="tabsDark" :color="tabsColor" :slider-color="tabsSliderColor">
              <template v-for="(item, index) in tabChain">
                <v-icon v-if="item.id > 0" :key="2*index">keyboard_arrow_right</v-icon>
                <v-tab :key="2*index+1" ripple>
                  <v-icon v-if="item.id === 0">home</v-icon>
                  <template v-else>
                    <v-icon v-if="item.isClient" style="margin-right: 10px">computer</v-icon>
                    {{ item.name ? item.name : item.id }}
                  </template>
                </v-tab>
              </template>
            </v-tabs>
          </v-card>
          <v-tabs-items :value="activeTab" @input="setActiveTab" touchless style="padding-bottom: 20px">
            <template v-for="(item, index) in tabChain">
              <v-tab-item :key="index">
                <group-module-group-view :tabIndex="index" v-if="!item.isClient" />
                <group-module-client-view v-else />
              </v-tab-item>
            </template>
          </v-tabs-items>
      </v-flex>
    </v-layout>
  </v-container>
</template>

<script>
import GroupModuleGroupView from '@/components/GroupModuleGroupView'
import GroupModuleClientView from '@/components/GroupModuleClientView'
import { mapState, mapGetters, mapMutations } from 'vuex'

export default {
  name: 'GroupModule',
  components: {
    GroupModuleGroupView,
    GroupModuleClientView
  },
  data () {
    return {
    }
  },
  computed: {
    ...mapGetters(['tabsDark', 'tabsColor', 'tabsSliderColor']),
    ...mapState('groups', ['groupChain', 'client', 'activeTab']),
    tabChain () {
      if (this.client) return this.groupChain.concat({ isClient: true, ...this.client })
      else return this.groupChain
    }
  },
  methods: {
    ...mapMutations('groups', ['setActiveTab'])
  },
  created () {
    this.$store.dispatch('groups/loadLists')
    this.$store.dispatch('groups/loadRoot')
  },
  destroyed () {
    this.$store.commit('groups/resetStore')
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
</style>