Robin Thoni 9 роки тому
джерело
коміт
e3bf79e55f

+ 10
- 2
luticate/controllers/modals/groupedit.controller.js Переглянути файл

@@ -19,15 +19,23 @@ angular.module('luticate')
19 19
             $scope.submitForm = function()
20 20
             {
21 21
                 if ($scope.group.Id != null) {
22
+                    var promiseEditGroup = {
23
+                        id: "promiseEditGroup",
24
+                        loaderGroups: ["modal"]
25
+                    };
22 26
                     return luticateAuthGroups.edit({
23 27
                         group_id: $scope.group.Id,
24 28
                         group_name: $scope.group.Name
25
-                    });
29
+                    }, promiseEditGroup);
26 30
                 }
27 31
                 else {
32
+                    var promiseAddGroup = {
33
+                        id: "promiseAddGroup",
34
+                        loaderGroups: ["modal"]
35
+                    };
28 36
                     return luticateAuthGroups.add({
29 37
                         group_name: $scope.group.Name
30
-                    });
38
+                    }, promiseAddGroup);
31 39
                 }
32 40
             };
33 41
 

+ 19
- 16
luticate/controllers/modals/groupusers.controller.js Переглянути файл

@@ -3,8 +3,8 @@
3 3
  */
4 4
 
5 5
 angular.module('luticate')
6
-    .controller('GroupUsersController', ['$scope', 'luticateAuthGroups', 'data',
7
-        function($scope, luticateAuthGroups, data) {
6
+    .controller('GroupUsersController', ['$scope', 'luticateAuthGroups', 'data', 'dialogs',
7
+        function($scope, luticateAuthGroups, data, dialogs) {
8 8
 
9 9
             $scope.group = data;
10 10
 
@@ -37,9 +37,20 @@ angular.module('luticate')
37 37
                     }
38 38
                 ],
39 39
 
40
-                permissions: {
41
-                    add: 'LU_GROUP_USER_ADD',
42
-                    del: 'LU_GROUP_USER_DEL'
40
+                onItemClicked: function(item)
41
+                {
42
+                    $scope.itemPicker.luBasicTableScope.toggleCheckedItem(item);
43
+                },
44
+
45
+                editData: $scope.group,
46
+
47
+                canAdd: 'LU_GROUP_USER_ADD',
48
+
49
+                canDel: 'LU_GROUP_USER_DEL',
50
+
51
+                canEdit: function()
52
+                {
53
+                    return true;
43 54
                 },
44 55
 
45 56
                 getLoadPagePromise: function (page, perPage, promise) {
@@ -58,20 +69,12 @@ angular.module('luticate')
58 69
                 },
59 70
 
60 71
                 getEditController: function () {
61
-                    return "UserPicker";
62
-                },
63
-
64
-                onEdited: function(item) {
65
-
66
-                },
67
-
68
-                onItemSelectionChanged: function(item, selected) {
69
-
72
+                    return "GroupUsersAdd";
70 73
                 },
71 74
 
72
-                displayItem: function(item, scope)
75
+                getItemText: function(item)
73 76
                 {
74
-                    scope.toggleSelectedItem(item);
77
+                    return item.Username;
75 78
                 }
76 79
             };
77 80
 

+ 89
- 0
luticate/controllers/modals/groupusersadd.controller.js Переглянути файл

@@ -0,0 +1,89 @@
1
+/**
2
+ * Created by robin on 11/6/15.
3
+ */
4
+
5
+angular.module('luticate')
6
+    .controller('GroupUsersAddController', ['$scope', 'luticateAuthUsers', 'data', '$q', 'dialogs', 'luticateAuthGroups',
7
+        function($scope, luticateAuthUsers, data, $q, dialogs, luticateAuthGroups) {
8
+            $scope.selectedUsers = [];
9
+            $scope.group = data;
10
+            $scope.userPicker = {
11
+                columns: [
12
+                    {
13
+                        name: "Username",
14
+                        width: 3,
15
+                        getValue: function (item) {
16
+                            return item.Username;
17
+                        }
18
+                    }, {
19
+                        name: "Email",
20
+                        width: 3,
21
+                        getValue: function (item) {
22
+                            return item.Email;
23
+                        }
24
+                    }, {
25
+                        name: "Firstname",
26
+                        width: 3,
27
+                        getValue: function (item) {
28
+                            return item.Firstname;
29
+                        }
30
+                    }, {
31
+                        name: "Lastname",
32
+                        width: 3,
33
+                        getValue: function (item) {
34
+                            return item.Lastname;
35
+                        }
36
+                    }
37
+                ],
38
+
39
+                canAdd: 'LU_USER_ADD',
40
+
41
+                canDel: 'LU_USER_DEL',
42
+
43
+                canEdit: 'LU_USER_EDIT',
44
+
45
+                getLoadPagePromise: function (page, perPage, promise) {
46
+                    return luticateAuthUsers.getAll({page: page, perPage: perPage}, promise);
47
+                },
48
+
49
+                getItemText: function(item)
50
+                {
51
+                    return item.Username;
52
+                }
53
+            };
54
+
55
+            $scope.addUser = function(defer)
56
+            {
57
+                if ($scope.userPicker.pickedItems.length == 0) {
58
+                    defer.resolve();
59
+                    return;
60
+                }
61
+
62
+                var promiseAddUser = {
63
+                    id: "promiseAddUser",
64
+                    loaderGroups: ["modal"]
65
+                };
66
+
67
+                var user = $scope.userPicker.pickedItems[0];
68
+                luticateAuthGroups.usersAdd({
69
+                    group_id: $scope.group.Id,
70
+                    user_id: user.Id
71
+                }, promiseAddUser).then(function(data)
72
+                {
73
+                    $scope.userPicker.pickedItems.splice(0, 1);
74
+                    $scope.addUser(defer);
75
+                }, function(error)
76
+                {
77
+                    defer.reject(error);
78
+                });
79
+            };
80
+
81
+            $scope.submitForm = function()
82
+            {
83
+                var defer = $q.defer();
84
+
85
+                $scope.addUser(defer);
86
+
87
+                return defer.promise;
88
+            };
89
+        }]);

+ 10
- 2
luticate/controllers/modals/permissionedit.controller.js Переглянути файл

@@ -26,10 +26,18 @@ angular.module('luticate')
26 26
                     permission_value: $scope.permission.Value
27 27
                 };
28 28
                 if (!$scope.permission.IsNew) {
29
-                    return luticateAuthPermissions.edit(perm);
29
+                    var promiseEditPermission = {
30
+                        id: "promiseEditPermission",
31
+                        loaderGroups: ["modal"]
32
+                    };
33
+                    return luticateAuthPermissions.edit(perm, promiseEditPermission);
30 34
                 }
31 35
                 else {
32
-                    return luticateAuthPermissions.add(perm);
36
+                    var promiseAddPermission = {
37
+                        id: "promiseAddPermission",
38
+                        loaderGroups: ["modal"]
39
+                    };
40
+                    return luticateAuthPermissions.add(perm, promiseAddPermission);
33 41
                 }
34 42
             }
35 43
         }]);

+ 12
- 13
luticate/controllers/modals/useredit.controller.js Переглянути файл

@@ -31,22 +31,13 @@ angular.module('luticate')
31 31
                 same_passwords: 'userPassword.value==$value'
32 32
             };
33 33
 
34
-            var promiseEditUser = {
35
-                id: "promiseEditUser",
36
-                loaderGroups: ["modal"]
37
-            };
38
-            var promiseAddUser = {
39
-                id: "promiseAddUser",
40
-                loaderGroups: ["modal"]
41
-            };
42
-            var promiseSetPassword = {
43
-                id: "promiseSetPassword",
44
-                loaderGroups: ["modal"]
45
-            };
46
-
47 34
             $scope.submitForm = function()
48 35
             {
49 36
                 if ($scope.user.Id != null) {
37
+                    var promiseEditUser = {
38
+                        id: "promiseEditUser",
39
+                        loaderGroups: ["modal"]
40
+                    };
50 41
                     var defer = $q.defer();
51 42
                     if (luticateAuthCache.hasEffectivePermission("LU_USER_EDIT")) {
52 43
                         luticateAuthUsers.edit({
@@ -66,6 +57,10 @@ angular.module('luticate')
66 57
                     return defer.promise;
67 58
                 }
68 59
                 else {
60
+                    var promiseAddUser = {
61
+                        id: "promiseAddUser",
62
+                        loaderGroups: ["modal"]
63
+                    };
69 64
                     var user = {
70 65
                         username: $scope.user.Username,
71 66
                         email: $scope.user.Email,
@@ -79,6 +74,10 @@ angular.module('luticate')
79 74
 
80 75
             $scope.mayEditPassword = function(defer)
81 76
             {
77
+                var promiseSetPassword = {
78
+                    id: "promiseSetPassword",
79
+                    loaderGroups: ["modal"]
80
+                };
82 81
                 if ($scope.userPassword.value != ""
83 82
                     && luticateAuthCache.hasEffectivePermission("LU_USER_SET_PASSWORD")) {
84 83
                     luticateAuthUsers.setPassword({

+ 0
- 56
luticate/controllers/modals/userpicker.controller.js Переглянути файл

@@ -1,56 +0,0 @@
1
-/**
2
- * Created by robin on 11/6/15.
3
- */
4
-
5
-angular.module('luticate')
6
-    .controller('UserPickerController', ['$scope', 'luticateAuthUsers', 'data', '$q', 'dialogs', 'luticateAuthCache',
7
-        function($scope, luticateAuthUsers, data, $q, dialogs, luticateAuthCache) {
8
-            $scope.selectedUsers = [];
9
-            $scope.userPicker = {
10
-                columns: [
11
-                    {
12
-                        name: "Username",
13
-                        width: 3,
14
-                        getValue: function (item) {
15
-                            return item.Username;
16
-                        }
17
-                    }, {
18
-                        name: "Email",
19
-                        width: 3,
20
-                        getValue: function (item) {
21
-                            return item.Email;
22
-                        }
23
-                    }, {
24
-                        name: "Firstname",
25
-                        width: 3,
26
-                        getValue: function (item) {
27
-                            return item.Firstname;
28
-                        }
29
-                    }, {
30
-                        name: "Lastname",
31
-                        width: 3,
32
-                        getValue: function (item) {
33
-                            return item.Lastname;
34
-                        }
35
-                    }
36
-                ],
37
-
38
-                permissions: {
39
-                    add: 'LU_USER_ADD',
40
-                    del: 'LU_USER_DEL',
41
-                    edit: 'LU_USER_EDIT'
42
-                },
43
-
44
-                getLoadPagePromise: function (page, perPage, promise) {
45
-                    return luticateAuthUsers.getAll({page: page, perPage: perPage}, promise);
46
-                },
47
-
48
-                getDelPromise: function (id, promise) {
49
-                    return luticateAuthUsers.del({user_id: id}, promise);
50
-                },
51
-
52
-                getEditController: function () {
53
-                    return "UserEdit";
54
-                }
55
-            };
56
-        }]);

+ 0
- 9
luticate/css/app.less Переглянути файл

@@ -39,15 +39,6 @@ footer {
39 39
   margin: 50px 0;
40 40
 }
41 41
 
42
-
43
-.pagination-current {
44
-  font-weight: bold;
45
-}
46
-
47
-.pagination-not-current {
48
-
49
-}
50
-
51 42
 .modal-header {
52 43
   font-weight: bold;
53 44
 }

+ 3
- 1
luticate/index.html Переглянути файл

@@ -8,6 +8,8 @@
8 8
     <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css">
9 9
     <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
10 10
     <link rel="stylesheet" href="../bower_components/luticate-utils/src/lubusy.css">
11
+    <link rel="stylesheet" href="../bower_components/luticate-utils/src/lubasictable.css">
12
+    <link rel="stylesheet" href="../bower_components/luticate-utils/src/lupickertable.css">
11 13
     <link rel="stylesheet/less" href="css/app.less">
12 14
     <!-- bower component -->
13 15
     <script src="../bower_components/jquery/dist/jquery.js"></script>
@@ -62,7 +64,7 @@
62 64
     <script src="controllers/modals/permissionedit.controller.js"></script>
63 65
     <script src="controllers/modals/userpermissions.controller.js"></script>
64 66
     <script src="controllers/modals/usereffectivepermissions.controller.js"></script>
65
-    <script src="controllers/modals/userpicker.controller.js"></script>
67
+    <script src="controllers/modals/groupusersadd.controller.js"></script>
66 68
     <script src="controllers/modals/grouppermissions.controller.js"></script>
67 69
     <script src="controllers/modals/groupusers.controller.js"></script>
68 70
 

+ 3
- 1
luticate/views/lupickertable.html Переглянути файл

@@ -1,5 +1,7 @@
1 1
 <div class="col-sm-3">
2
-    <div ng-repeat="item in pickerOptions.pickedItems">
2
+    Selected items:
3
+    <div ng-repeat="item in pickerOptions.pickedItems" ng-click="unPickItem(item)"
4
+         class="col-sm-12 lu-picker-table-picked-items">
3 5
         {{ pickerOptions.getItemText(item) }}
4 6
     </div>
5 7
 </div>

+ 1
- 1
luticate/views/modals/groupusers.html Переглянути файл

@@ -1,4 +1,4 @@
1 1
 <!-- Page Content -->
2 2
 <dialog-close title="Edit {{ group.Name }} users">
3
-    <lu-table options="itemPicker" class="row col-sm-8 col-sm-offset-2" ></lu-table>
3
+    <lu-edit-table options="itemPicker" class="row col-sm-8 col-sm-offset-2" ></lu-edit-table>
4 4
 </dialog-close>

luticate/views/modals/userpicker.html → luticate/views/modals/groupusersadd.html Переглянути файл

@@ -1,3 +1,3 @@
1
-<dialog-close title="Select users">
1
+<dialog-ok-cancel title="Select users">
2 2
     <lu-picker-table options="userPicker" ></lu-picker-table>
3
-</dialog-close>
3
+</dialog-ok-cancel>

+ 4
- 2
luticate/views/test.html Переглянути файл

@@ -1,5 +1,7 @@
1 1
 <div class="container">
2
-    <!--<lu-basic-table options="luBasicTable" class="row col-sm-8 col-sm-offset-2" ></lu-basic-table>
3
-    <lu-edit-table options="luEditTable" class="row col-sm-8 col-sm-offset-2" ></lu-edit-table>-->
2
+    <lu-basic-table options="luBasicTable" class="row col-sm-8 col-sm-offset-2" ></lu-basic-table>
3
+    <lu-edit-table options="luEditTable" class="row col-sm-8 col-sm-offset-2" ></lu-edit-table>
4
+    <div class="clearfix"></div>
5
+    <br />
4 6
     <lu-picker-table options="luUserPicker" class="row col-sm-8 col-sm-offset-2"></lu-picker-table>
5 7
 </div>

Завантаження…
Відмінити
Зберегти