Browse Source

permission add/edit/del

develop
Robin Thoni 9 years ago
parent
commit
9854bd1ac9

+ 33
- 0
luticate/controllers/modals/permissionedit.controller.js View File

@@ -0,0 +1,33 @@
1
+/**
2
+ * Created by robin on 11/4/15.
3
+ */
4
+
5
+angular.module('luticate')
6
+    .controller('PermissionEditController', ['$scope', 'luticateAuthPermissions', 'data',
7
+        function($scope, luticateAuthPermissions, data) {
8
+            if (data != null) {
9
+                $scope.permission = data;
10
+                $scope.permission.IsNew = false;
11
+            }
12
+            else {
13
+                $scope.permission = {
14
+                    Name: "",
15
+                    Value: false,
16
+                    IsNew: true
17
+                }
18
+            }
19
+
20
+            $scope.submitForm = function()
21
+            {
22
+                var perm = {
23
+                    permission_name: $scope.permission.Name.toUpperCase(),
24
+                    permission_value: $scope.permission.Value
25
+                };
26
+                if (!$scope.permission.IsNew) {
27
+                    return luticateAuthPermissions.edit(perm);
28
+                }
29
+                else {
30
+                    return luticateAuthPermissions.add(perm);
31
+                }
32
+            }
33
+        }]);

+ 36
- 2
luticate/controllers/permissions.controller.js View File

@@ -1,5 +1,39 @@
1 1
 angular.module('luticate')
2
-    .controller('PermissionsController', ['$scope', '$state', 'luticatePromises',
3
-        function($scope, $state, luticatePromises) {
2
+    .controller('PermissionsController', ['$scope', 'luticateAuthPermissions',
3
+        function($scope, luticateAuthPermissions) {
4
+            $scope.columns = [
5
+                {
6
+                    name: "Name",
7
+                    width: 6,
8
+                    getValue: function(item) {
9
+                        return item.Name;
10
+                    }
11
+                }, {
12
+                    name: "Value",
13
+                    width: 5,
14
+                    getValue: function(item) {
15
+                        return item.Value ? "Allowed" : "Disallowed";
16
+                    }
17
+                }
18
+            ];
4 19
 
20
+            $scope.getLoadPagePromise = function(page, perPage, promise)
21
+            {
22
+                return luticateAuthPermissions.getAll({page: page, perPage: perPage}, promise);
23
+            };
24
+
25
+            $scope.getDelPromise = function(id, promise)
26
+            {
27
+                return luticateAuthPermissions.del({permission_name: id}, promise);
28
+            };
29
+
30
+            $scope.getEditController = function()
31
+            {
32
+                return "PermissionEdit";
33
+            };
34
+
35
+            $scope.getItemId = function(item)
36
+            {
37
+                return item.Name;
38
+            };
5 39
     }]);

+ 4
- 0
luticate/css/app.less View File

@@ -50,4 +50,8 @@ footer {
50 50
 
51 51
 .modal-header {
52 52
   font-weight: bold;
53
+}
54
+
55
+.input-permission-name {
56
+  text-transform: uppercase;
53 57
 }

+ 2
- 0
luticate/index.html View File

@@ -34,6 +34,7 @@
34 34
     <script src="../bower_components/luticate-auth/src/luticateauth.js"></script>
35 35
     <script src="../bower_components/luticate-auth/src/users.js"></script>
36 36
     <script src="../bower_components/luticate-auth/src/groups.js"></script>
37
+    <script src="../bower_components/luticate-auth/src/permissions.js"></script>
37 38
     <script src="../bower_components/luticate-auth/src/cache.js"></script>
38 39
 
39 40
     <!-- scripts -->
@@ -50,6 +51,7 @@
50 51
     <!-- Modal Controller -->
51 52
     <script src="controllers/modals/useredit.controller.js"></script>
52 53
     <script src="controllers/modals/groupedit.controller.js"></script>
54
+    <script src="controllers/modals/permissionedit.controller.js"></script>
53 55
 
54 56
     <!-- SDK -->
55 57
     <script src="../sdk/cache.js"></script>

+ 20
- 0
luticate/views/modals/permissionedit.html View File

@@ -0,0 +1,20 @@
1
+<dialog-ok-cancel title="{{ permission.IsNew ? 'Add' : 'Edit'}} permission {{ permission.Name }}">
2
+    <div class="form-group">
3
+        <label for="name" class="col-sm-2 control-label">Name</label>
4
+        <div class="col-sm-9">
5
+            <input id="name" class="form-control input-permission-name" ng-model="permission.Name" required ng-disabled="!permission.IsNew"/>
6
+        </div>
7
+    </div>
8
+    <div class="form-group">
9
+        <label class="col-sm-2 control-label">Allowed</label>
10
+        <div class="col-sm-9">
11
+            <div class="btn-group">
12
+                <a class="btn btn-default dropdown-toggle btn-select" data-toggle="dropdown" href="">{{ permission.Value ? 'Yes' : 'No' }} <span class="caret"></span></a>
13
+                <ul class="dropdown-menu">
14
+                    <li><a href="" ng-click="permission.Value = false">No</a></li>
15
+                    <li><a href="" ng-click="permission.Value = true">Yes</a></li>
16
+                </ul>
17
+            </div>
18
+        </div>
19
+    </div>
20
+</dialog-ok-cancel>

+ 1
- 4
luticate/views/permissions.html View File

@@ -1,7 +1,4 @@
1 1
 <!-- Page Content -->
2 2
 <div class="container">
3
-
4
-    <div class="row">
5
-
6
-    </div>
3
+    <lu-table class="row col-sm-8 col-sm-offset-2" ></lu-table>
7 4
 </div>

Loading…
Cancel
Save