浏览代码

permissions users get/add/edit/del

develop
Robin Thoni 9 年前
父节点
当前提交
7516782093

+ 7
- 2
luticate/controllers/modals/useredit.controller.js 查看文件

@@ -3,8 +3,8 @@
3 3
  */
4 4
 
5 5
 angular.module('luticate')
6
-    .controller('UserEditController', ['$scope', 'luticateAuthUsers', 'data', '$q',
7
-        function($scope, luticateAuthUsers, data, $q) {
6
+    .controller('UserEditController', ['$scope', 'luticateAuthUsers', 'data', '$q', 'dialogs',
7
+        function($scope, luticateAuthUsers, data, $q, dialogs) {
8 8
             if (data != null) {
9 9
                 $scope.user = data;
10 10
             }
@@ -76,4 +76,9 @@ angular.module('luticate')
76 76
                     return luticateAuthUsers.add(user, promiseAddUser);
77 77
                 }
78 78
             };
79
+
80
+            $scope.editPermissions = function(user)
81
+            {
82
+                dialogs.create('views/modals/userpermissions.html', 'UserPermissionsController', user);
83
+            };
79 84
         }]);

+ 46
- 0
luticate/controllers/modals/userpermissions.controller.js 查看文件

@@ -0,0 +1,46 @@
1
+/**
2
+ * Created by robin on 11/2/15.
3
+ */
4
+
5
+angular.module('luticate')
6
+    .controller('UserPermissionsController', ['$scope', 'luticateAuthPermissionsUser', 'data',
7
+        function($scope, luticateAuthPermissionsUser, data) {
8
+
9
+            $scope.user = data;
10
+
11
+            $scope.luPermissionEdit = {
12
+                item: $scope.user,
13
+
14
+                getGetAllPromise: function (page, perPage, promise) {
15
+                    return luticateAuthPermissionsUser.getAll({
16
+                        user_id: this.item.Id,
17
+                        page: page,
18
+                        perPage: perPage
19
+                    }, promise);
20
+                },
21
+
22
+                getAddPermissionPromise: function (permission_name, permission_value, promise) {
23
+                    return luticateAuthPermissionsUser.add({
24
+                        user_id: this.item.Id,
25
+                        permission_name: permission_name,
26
+                        permission_value: permission_value
27
+                    }, promise);
28
+                },
29
+
30
+                getEditPermissionPromise: function (permission_name, permission_value, promise) {
31
+                    return luticateAuthPermissionsUser.edit({
32
+                        user_id: this.item.Id,
33
+                        permission_name: permission_name,
34
+                        permission_value: permission_value
35
+                    }, promise);
36
+                },
37
+
38
+                getDelPermissionPromise: function (permission_name, promise) {
39
+                    return luticateAuthPermissionsUser.del({
40
+                        user_id: this.item.Id,
41
+                        permission_name: permission_name
42
+                    }, promise);
43
+                }
44
+            };
45
+
46
+        }]);

+ 4
- 0
luticate/index.html 查看文件

@@ -28,13 +28,16 @@
28 28
     <script src="../bower_components/luticate-utils/src/request.js"></script>
29 29
     <script src="../bower_components/luticate-utils/src/lubusy.js"></script>
30 30
     <script src="../bower_components/luticate-utils/src/lutable.js"></script>
31
+    <script src="../bower_components/luticate-utils/src/lupermissionsedit.js"></script>
31 32
     <script src="../bower_components/luticate-utils/src/modals/dialogerror.js"></script>
32 33
     <script src="../bower_components/luticate-utils/src/modals/dialogerrorhelper.js"></script>
33 34
     <script src="../bower_components/luticate-utils/src/modals/dialogokcancel.js"></script>
35
+    <script src="../bower_components/luticate-utils/src/modals/dialogclose.js"></script>
34 36
     <script src="../bower_components/luticate-auth/src/luticateauth.js"></script>
35 37
     <script src="../bower_components/luticate-auth/src/users.js"></script>
36 38
     <script src="../bower_components/luticate-auth/src/groups.js"></script>
37 39
     <script src="../bower_components/luticate-auth/src/permissions.js"></script>
40
+    <script src="../bower_components/luticate-auth/src/permissionsuser.js"></script>
38 41
     <script src="../bower_components/luticate-auth/src/cache.js"></script>
39 42
 
40 43
     <!-- scripts -->
@@ -52,6 +55,7 @@
52 55
     <script src="controllers/modals/useredit.controller.js"></script>
53 56
     <script src="controllers/modals/groupedit.controller.js"></script>
54 57
     <script src="controllers/modals/permissionedit.controller.js"></script>
58
+    <script src="controllers/modals/userpermissions.controller.js"></script>
55 59
 
56 60
     <!-- SDK -->
57 61
     <script src="../sdk/cache.js"></script>

+ 3
- 0
luticate/views/modals/useredit.html 查看文件

@@ -41,4 +41,7 @@
41 41
             <p class="error" ng-show="form.password2.$error.same_passwords">Passwords do not match</p>
42 42
         </div>
43 43
     </div>
44
+    <div class="form-group">
45
+        <button type="button" class="btn btn-default col-sm-offset-2" ng-click="editPermissions(user)">Edit Permissions</button>
46
+    </div>
44 47
 </dialog-ok-cancel>

+ 4
- 0
luticate/views/modals/userpermissions.html 查看文件

@@ -0,0 +1,4 @@
1
+<!-- Page Content -->
2
+<dialog-close title="Edit {{ user.Username }} permissions">
3
+    <lu-permission-edit lu-model="luPermissionEdit"></lu-permission-edit>
4
+</dialog-close>

正在加载...
取消
保存