summaryrefslogblamecommitdiffstats
path: root/webapp/src/components/GroupModuleGroupList.vue
blob: 88add11a1cbac0a0ba7c3269e9d5c25244717cf8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


         


                                 



                                                                    

         


                                  



                                                                               




          

            
                                                                                             

                                                     



                                                                                                               

                                      



                                                                                                                               

          


           
                                              
                                   
 

                               
                                           
               
             
    

            
                  


             

                


                                                            
       


                                                                     
     

          

                        


            
                                                                       

                                                                                                                              

                 
                                                                         


                          






                                                                                                                                 
     





                                                                   



              




                      
<i18n>
{
  "en": {
    "id": "ID",
    "name": "Name",
    "description": "Description",
    "removeSubgroups": "Remove one subgroup | Remove {0} subgroups",
    "addSubgroups": "Add subgroups",
    "deleteGroups": "Delete one group | Delete {0} groups",
    "createGroup": "Create group"
  },
  "de": {
    "id": "ID",
    "name": "Name",
    "description": "Beschreibung",
    "removeSubgroups": "Entferne eine Untergruppe | Entferne {0} Untergruppen",
    "addSubgroups": "Füge Untergruppen hinzu",
    "deleteGroups": "Lösche eine Gruppe | Lösche {0} Gruppen",
    "createGroup": "Gruppe erstellen"
  }
}
</i18n>

<template>
  <div>
    <v-card>
      <data-table v-model="selected" :headers="headers" :items="groups" :loading="loading" />
    </v-card>
    <div v-if="tabIndex === 0" class="text-xs-right">
      <v-btn flat color="error" @click="deleteSelected" :disabled="selected.length === 0">
        <v-icon left>delete</v-icon>{{ $tc('deleteGroups', selected.length, [selected.length]) }}
      </v-btn>
      <v-btn flat color="success" @click="newGroup"><v-icon left>create</v-icon>{{ $t('createGroup') }}</v-btn>
    </div>
    <div v-else class="text-xs-right">
      <v-btn flat color="error" @click="removeSelected" :disabled="selected.length === 0">
        <v-icon left>remove_circle_outline</v-icon>{{ $tc('removeSubgroups', selected.length, [selected.length]) }}
      </v-btn>
      <v-btn flat color="success" @click="addExisting"><v-icon left>add_circle_outline</v-icon>{{ $t('addSubgroups') }}</v-btn>
    </div>
  </div>
</template>

<script>
import DataTable from '@/components/DataTable'
import { mapMutations } from 'vuex'

export default {
  name: 'GroupModuleGroupList',
  props: ['tabIndex', 'groupId', 'groups'],
  components: {
    DataTable
  },
  data () {
    return {
      selected: []
    }
  },
  computed: {
    headers () {
      return [
        { text: this.$t('id'), key: 'id', width: '100px' },
        { text: this.$t('name'), key: 'name' },
        { text: this.$t('description'), key: 'description' }
      ]
    },
    loading () {
      return this.$store.state.groups.tabChain[this.tabIndex].loading
    }
  },
  watch: {
    groups () {
      this.selected = []
    }
  },
  methods: {
    ...mapMutations('groups', ['setActiveTab', 'setTab', 'setDialog']),
    loadGroup (item) {
      this.$store.dispatch('groups/loadGroup', { id: item.id, name: item.name, tabIndex: this.tabIndex + 1, switchTab: true })
    },
    newGroup () {
      this.setTab({ index: 1, item: { id: 'create', tabType: 'group' } })
      this.setActiveTab(1)
    },
    deleteSelected () {
      this.setDialog({ show: true, info: { action: 'delete', type: 'group', selected: this.selected } })
    },
    removeSelected () {
      this.setDialog({ show: true, info: { action: 'remove', type: 'group', selected: this.selected, tabIndex: this.tabIndex } })
    },
    addExisting () {
      this.setDialog({ show: true, info: { action: 'add', type: 'group', selected: this.selected, tabIndex: this.tabIndex } })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.narrow-td {
  width: 10px;
}

.next-arrow {
  margin-left: 20px;
  margin-right: -10px;
}
</style>