summaryrefslogtreecommitdiffstats
path: root/webapp/src/components/PermissionModuleRoleList.vue
blob: 67fbb9f9a64fe0f02a9fee1a8e74e60339376f19 (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
<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>
      <data-table :value="selectedRoles"  @input="$store.commit('permissions/setSelectedRoles', $event)" :headers="headers" :items="roles">
        <div slot="action" slot-scope="row" style="text-align: right" v-if="canEdit">
          <v-btn flat icon color="primary" @click.stop="$store.commit('permissions/editRole', row.item.id)"><v-icon>edit</v-icon></v-btn>
        </div>
      </data-table>
    </v-card>
    <div class="text-xs-right" v-if="canEdit">
      <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 DataTable from '@/components/DataTable'

export default {
  name: 'PermissionModuleRoleList',
  components: {
    DataTable
  },
  data () {
    return {
      headers: [
        { text: this.$t('id'), key: 'id' },
        { text: this.$t('name'), key: 'name' },
        { text: this.$t('description'), key: 'descr' },
        { sortable: false, key: 'action', width: '60px' }
      ],
      canEdit: false
    }
  },
  computed: {
    ...mapState('permissions', ['selectedRoles', 'roles'])
  },
  methods: {
  },
  created () {
    this.$http.get('/api/permissions/permissions.editrole').then(response => {
      this.canEdit = response.data
    })
  }
}
</script>

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

</style>