Bläddra i källkod

user edit

develop
Robin Thoni 9 år sedan
förälder
incheckning
4d481683ab

+ 4
- 5
bower.json Visa fil

@@ -8,14 +8,13 @@
8 8
   "dependencies": {
9 9
     "angular": "1.4.x",
10 10
     "jquery": "2.1.x",
11
-    "angular-bootstrap": "0.11.x",
11
+    "angular-bootstrap": "^0.12",
12 12
     "angular-ui-router": "0.2.x",
13 13
     "bootstrap": "3.3.x",
14 14
     "less": "1.7.x",
15 15
     "luticate-utils": "https://git.rthoni.com/repos/luticate-front/utils.git",
16
-    "luticate-auth": "https://git.rthoni.com/repos/luticate-front/auth.git"
17
-  },
18
-  "resolutions": {
19
-    "angular": "1.4.x"
16
+    "luticate-auth": "https://git.rthoni.com/repos/luticate-front/auth.git",
17
+    "angular-dialog-service": "~5.2.8",
18
+    "ngSanitize": "~0.0.2"
20 19
   }
21 20
 }

+ 3
- 1
luticate/app.js Visa fil

@@ -7,7 +7,9 @@ var luticate = angular.module('luticate', [
7 7
     'ui.router',
8 8
     'luticateUtils',
9 9
     'luticateAuth',
10
-    'LocalStorageModule'
10
+    'LocalStorageModule',
11
+    'dialogs.main',
12
+    'ngSanitize'
11 13
 ]);
12 14
 
13 15
 luticate.config(['$stateProvider', '$urlRouterProvider', '$httpProvider',

+ 55
- 0
luticate/controllers/directives/dialogokcancel.js Visa fil

@@ -0,0 +1,55 @@
1
+/**
2
+ * Created by robin on 11/2/15.
3
+ */
4
+
5
+
6
+angular.module('luticate')
7
+    .directive('dialogOkCancel', [
8
+        function () {
9
+            return {
10
+                restrict: 'EA',
11
+                transclude: true,
12
+                templateUrl: 'views/directives/dialogokcancel.html',
13
+                link: function link($scope, element, attrs) {
14
+                    $scope.title = attrs.title;
15
+                    $scope.model = {};
16
+                    $scope.pending = false;
17
+                    $scope.__submit = function()
18
+                    {
19
+                        if ($scope.form.$valid) {
20
+                            $scope.pending = true;
21
+                            $scope.promise = $scope.submitForm();
22
+                            if ($scope.promise)
23
+                            {
24
+                                $scope.promise.then(function(data) {
25
+                                    if ($scope.onDone) {
26
+                                        $scope.onDone(data);
27
+                                    }
28
+                                    $scope.$dismiss();
29
+                                    $scope.pending = false;
30
+                                })
31
+                                    .catch(function(error)
32
+                                    {
33
+                                        if ($scope.onError) {
34
+                                            $scope.onError(error);
35
+                                        }
36
+                                        $scope.pending = false;
37
+                                    });
38
+                            }
39
+                            else {
40
+                                $scope.$dismiss();
41
+                                $scope.pending = false;
42
+                            }
43
+                        }
44
+                    };
45
+                    $scope.__cancel = function()
46
+                    {
47
+                        if ($scope.onCanceled) {
48
+                            $scope.onCanceled();
49
+                        }
50
+                        $scope.$dismiss();
51
+                        $scope.pending = false;
52
+                    };
53
+                }
54
+            };
55
+        }]);

+ 23
- 0
luticate/controllers/modals/useredit.controller.js Visa fil

@@ -0,0 +1,23 @@
1
+/**
2
+ * Created by robin on 11/2/15.
3
+ */
4
+
5
+angular.module('luticate')
6
+    .controller('UserEditController', ['$scope', 'luticateAuthUsers', 'data',
7
+        function($scope, luticateAuthUsers, data) {
8
+            $scope.user = data;
9
+            var promiseEditUser = {
10
+                id: "promiseEditUser",
11
+                loaderGroups: ["modal"]
12
+            };
13
+
14
+            $scope.submitForm = function()
15
+            {
16
+                return luticateAuthUsers.edit({
17
+                    user_id: $scope.user.Id,
18
+                    email: $scope.user.Email,
19
+                    firstname: $scope.user.Firstname,
20
+                    lastname: $scope.user.Lastname
21
+                }, promiseEditUser);
22
+            };
23
+        }]);

+ 8
- 3
luticate/controllers/users.controller.js Visa fil

@@ -1,6 +1,6 @@
1 1
 angular.module('luticate')
2
-    .controller('UsersController', ['$scope', '$state', 'luticateAuthUsers',
3
-        function($scope, $state, luticateAuthUsers) {
2
+    .controller('UsersController', ['$scope', '$state', 'luticateAuthUsers', 'dialogs',
3
+        function($scope, $state, luticateAuthUsers, dialogs) {
4 4
             $scope.page = 0;
5 5
             $scope.perPage = 15;
6 6
             $scope.users = [];
@@ -31,7 +31,12 @@ angular.module('luticate')
31 31
 
32 32
             $scope.displayUser = function(user)
33 33
             {
34
-                console.log(user);
34
+                dialogs.create('views/modals/useredit.html', 'UserEditController', user)
35
+                    .result.then(function (data) {
36
+                        console.log(data);
37
+                    }, function (error) {
38
+                        console.log(error);
39
+                    });
35 40
             };
36 41
 
37 42
             $scope.loadPage($scope.page);

+ 4
- 0
luticate/css/app.less Visa fil

@@ -46,4 +46,8 @@ footer {
46 46
 
47 47
 .pagination-not-current {
48 48
 
49
+}
50
+
51
+.modal-header {
52
+  font-weight: bold;
49 53
 }

+ 4
- 0
luticate/index.html Visa fil

@@ -20,6 +20,8 @@
20 20
     <script src="../bower_components/bootstrap/js/transition.js"></script>
21 21
     <script src="../bower_components/bootstrap/js/dropdown.js"></script>
22 22
     <script src="../bower_components/less/dist/less-1.7.4.js"></script>
23
+    <script src="../bower_components/angular-dialog-service/dist/dialogs.js"></script>
24
+    <script src="../bower_components/angular-sanitize/angular-sanitize.js"></script>
23 25
     <script src="../bower_components/luticate-utils/src/luticateutils.js"></script>
24 26
     <script src="../bower_components/luticate-utils/src/promises.js"></script>
25 27
     <script src="../bower_components/luticate-utils/src/request.js"></script>
@@ -40,9 +42,11 @@
40 42
     <script src="controllers/permissions.controller.js"></script>
41 43
 
42 44
     <!-- Modal Controller -->
45
+    <script src="controllers/modals/useredit.controller.js"></script>
43 46
 
44 47
     <!-- SDK -->
45 48
     <script src="../sdk/cache.js"></script>
49
+    <script src="controllers/directives/dialogokcancel.js"></script>
46 50
 
47 51
     <!-- Directives -->
48 52
 

+ 19
- 0
luticate/views/directives/dialogokcancel.html Visa fil

@@ -0,0 +1,19 @@
1
+<div class="popin modal-content" xmlns="http://www.w3.org/1999/html">
2
+    <form name="form" class="form-horizontal" ng-submit="__submit()">
3
+        <div class="modal-header">{{ title }}</div>
4
+        <div class="modal-body" lu-busy="modal">
5
+            <div class="form-group">
6
+                <ng-transclude></ng-transclude>
7
+            </div>
8
+            <div class="clearfix"></div>
9
+            <!--<span class="error" ng-show="submitted">
10
+                <p class="error" ng-show="{{ e.show }}" ng-repeat="e in submittedErrors" ng-bind-template="{{ e.text | translate }}"></p>
11
+            </span>
12
+            <p class="error" ng-show="{{ e.show }}" ng-repeat="e in alwaysErrors" ng-bind-template="{{ e.text | translate }}"></p>-->
13
+        </div>
14
+        <div class="modal-footer">
15
+            <button type="button" class="btn btn-default" ng-click="__cancel()">Cancel</button>
16
+            <button type="submit" class="btn btn-default" ng-enabled="!pending" ng-click="submitted = true">OK</button>
17
+        </div>
18
+    </form>
19
+</div>

+ 18
- 0
luticate/views/modals/useredit.html Visa fil

@@ -0,0 +1,18 @@
1
+<dialog-ok-cancel title="Edit user {{ user.Username }}">
2
+    <div class="form-group">
3
+        <label for="username" class="col-sm-2 control-label">Username</label>
4
+        <div class="col-sm-9"><input id="username" class="form-control" ng-model="user.Username" readonly/></div>
5
+    </div>
6
+    <div class="form-group">
7
+        <label for="email" class="col-sm-2 control-label">Email</label>
8
+        <div class="col-sm-9"><input id="email" class="form-control" ng-model="user.Email" /></div>
9
+    </div>
10
+    <div class="form-group">
11
+        <label for="firstname" class="col-sm-2 control-label">Firstname</label>
12
+        <div class="col-sm-9"><input id="firstname" class="form-control" ng-model="user.Firstname" /></div>
13
+    </div>
14
+    <div class="form-group">
15
+        <label for="lastname" class="col-sm-2 control-label">Lastname</label>
16
+        <div class="col-sm-9"><input id="lastname" class="form-control" ng-model="user.Lastname" /></div>
17
+    </div>
18
+</dialog-ok-cancel>

Laddar…
Avbryt
Spara