From 3b245c0998714c5f79defd0f756ae83002273c17 Mon Sep 17 00:00:00 2001
From: Christian Hofmaier
Date: Fri, 15 Feb 2019 15:14:30 +0000
Subject: [permissionmanager]Integrate new data-table + api format

---
 webapp/src/components/PermissionModuleEdit.vue | 64 +++++++-------------------
 1 file changed, 17 insertions(+), 47 deletions(-)

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

diff --git a/webapp/src/components/PermissionModuleEdit.vue b/webapp/src/components/PermissionModuleEdit.vue
index 13a4b17..dd1e3e9 100644
--- a/webapp/src/components/PermissionModuleEdit.vue
+++ b/webapp/src/components/PermissionModuleEdit.vue
@@ -37,7 +37,7 @@
   <v-dialog
     :value="$store.state.permissions.edit"
     @input="$store.commit('permissions/setEdit', $event)"
-    max-width="800px"
+    max-width="1000px"
     scrollable
     persistent
   >
@@ -111,22 +111,7 @@
               </v-stepper-content>
 
               <v-stepper-content step="2" class="stepper-padding-0">
-                <component-search-table v-model="permissionsSelected" :headers="permissionHeaders" :items="permissions" 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.name }}</td>
-                      <td>{{ props.data.item.descr }}</td>
-                      <td>{{ props.data.item.groupdependent }}</td>
-                    </tr>
-                  </template>
-                </component-search-table>
+                <data-table v-model="permissionsSelected" :headers="permissionHeaders" :items="permissions"/>
               </v-stepper-content>
 
               <v-stepper-content step="3" class="stepper-padding-0">
@@ -138,22 +123,7 @@
                     color="primary"
                   ></v-switch>
                 </v-flex>
-                <component-search-table v-model="groupsSelected" :headers="groupHeaders" :items="groups" 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.description }}</td>
-                    </tr>
-                  </template>
-                </component-search-table>
+                <data-table v-model="groupsSelected" :headers="groupHeaders" :items="groups"/>
               </v-stepper-content>
 
               <v-stepper-content step="4">
@@ -233,13 +203,13 @@
 
 <script>
 import _arrayIncludes from 'lodash/_arrayIncludes'
-import ComponentSearchTable from '@/components/ComponentSearchTable'
+import DataTable from '@/components/DataTable'
 
 export default {
   name: 'PermissionModuleEdit',
   props: ['roleId'],
   components: {
-    ComponentSearchTable
+    DataTable
   },
   data () {
     return {
@@ -253,14 +223,14 @@ export default {
       groupsSummary: [],
       recursiveSwitch: false,
       permissionHeaders: [
-        { text: this.$t('name'), value: 'name' },
-        { text: this.$t('description'), value: 'descr' },
-        { text: this.$t('groupdependent'), value: 'groupdependent' }
+        { text: this.$t('name'), key: 'name' },
+        { text: this.$t('description'), key: 'descr' },
+        { text: this.$t('groupdependent'), key: 'groupdependent' }
       ],
       groupHeaders: [
-        { text: this.$t('id'), value: 'id' },
-        { text: this.$t('name'), value: 'name' },
-        { text: this.$t('description'), value: 'description' }
+        { text: this.$t('id'), key: 'id' },
+        { text: this.$t('name'), key: 'name' },
+        { text: this.$t('description'), key: 'description' }
       ],
       roleName: '',
       roleDescr: ''
@@ -271,7 +241,7 @@ export default {
       if (this.$refs.form.validate()) {
         const filteredPermissions = this.permissionsSelected.map(x => x.id)
         const filteredGroups = this.groupsSelected.map(x => x.id)
-        this.$http.post('/api/permissions/saveRole', {
+        this.$http.post('/api/roles' + (this.roleId === 0 ? '' : '/' + this.roleId), {
           id: this.roleId,
           name: this.roleName,
           descr: this.roleDescr,
@@ -288,7 +258,7 @@ export default {
       }
     },
     loadRole (roleId) {
-      this.$http('/api/permissions/getRoleById/' + this.roleId).then(response => {
+      this.$http('/api/roles/' + this.roleId).then(response => {
         this.roleName = response.data.name
         this.roleDescr = response.data.descr
         this.permissionsSelected = response.data.permissions
@@ -315,7 +285,7 @@ export default {
         var self = this
         // _arrayIncludes.js
         this.groupsSelected.forEach(function (group) {
-          promises.push(self.$http('/api/groups/getGroup?all=true&id=' + group.id).then(response => {
+          promises.push(self.$http('/api/groups/' + group.id + '&all').then(response => {
             response.data.subgroups.forEach(function (subgroup) {
               if (!(_arrayIncludes(self.groupsSelected, subgroup) || _arrayIncludes(childGroups, subgroup))) {
                 childGroups.push(subgroup)
@@ -336,12 +306,12 @@ export default {
       this.stepCompleted = Math.max(3, this.stepCompleted)
     },
     loadGroups () {
-      this.$http('/api/groups/getList').then(response => {
+      this.$http('/api/groups').then(response => {
         this.groups = response.data
       })
     },
     loadPermissions () {
-      this.$http('/api/permissions/getPermissionList').then(response => {
+      this.$http('/api/permissions').then(response => {
         this.permissions = response.data
       })
     }
@@ -381,7 +351,7 @@ export default {
 <style scoped>
 .table-container {
   padding: 0;
-  height: 700px;
+  max-height: 700px;
 }
 .stepper-padding-0 {
   padding: 0;
-- 
cgit v1.2.3-55-g7522

