summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/PermissionModuleRoleList.vue
blob: 3eade73a1f80fe809202ef7c3b27ccfd750cfc0b (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
80
81
82
83
84
85
86
87
88
89
90
91
<i18n>
{
  "en": {
    "create-role": "Create Role",
    "delete-role": "Delete {0} Role | Delete {0} Roles",
    "id": "ID",
    "name": "Name",
    "description": "Description"
  },
  "de": {
    "create-role": "Rolle erstellen",
    "delete-role": "Lösche {0} Rolle | Lösche {0} Rollen",
    "id": "ID",
    "name": "Name",
    "description": "Beschreibung"
  }
}
</i18n>

<template>
  <div>
    <v-card>
      <component-search-table :value="selectedRoles"  @input="$store.commit('permissions/setSelectedRoles', $event)" :headers="headers" :items="roles" select-all>
        <template slot="items" slot-scope="props">
          <tr :style="props.color" @click="props.data.selected = !props.data.selected">
            <td>
              <v-checkbox
                color="primary"
                v-model="props.data.selected"
                hide-details
              ></v-checkbox>
            </td>
            <td>{{ props.data.item.id }}</td>
            <td>{{ props.data.item.name }}</td>
            <td>{{ props.data.item.descr }}</td>
            <td>
              <v-layout>
                <v-btn flat icon color="primary" @click.stop="$store.commit('permissions/editRole', props.data.item.id)">
                  <v-icon>edit</v-icon>
                </v-btn>
              </v-layout>
            </td>
          </tr>
        </template>
      </component-search-table>
    </v-card>
    <div class="text-xs-right">
      <v-btn color="error" flat @click="$store.commit('permissions/setDialog', true )" :disabled="selectedRoles.length === 0">
        <v-icon left>remove_circle_outline</v-icon>{{ $tc('delete-role', selectedRoles.length, [selectedRoles.length]) }}
      </v-btn>
      <v-btn color="success" flat @click="$store.commit('permissions/editRole', 0)">
        <v-icon left>add_circle_outline</v-icon>{{ $t('create-role') }}
      </v-btn>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import ComponentSearchTable from '@/components/ComponentSearchTable'

export default {
  name: 'PermissionModuleRoleList',
  components: {
    ComponentSearchTable
  },
  data () {
    return {
      headers: [
        { text: this.$t('id'), value: 'id' },
        { text: this.$t('name'), value: 'name' },
        { text: this.$t('description'), value: 'descr' },
        { sortable: false }
      ]
    }
  },
  computed: {
    ...mapState('permissions', ['selectedRoles', 'roles'])
  },
  methods: {
  },
  created () {
    this.$store.dispatch('permissions/loadRoleData')
  }
}
</script>

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

</style>