Browse Source

new lu busy business; added angular busy

tags/v0.1.0
Robin Thoni 8 years ago
parent
commit
dcc7061d95

+ 1
- 0
app/app.js View File

@@ -10,6 +10,7 @@ angular.module('app', [
10 10
     'md.data.table',
11 11
     'sasrio.angular-material-sidenav',
12 12
     'pascalprecht.translate',
13
+    'angular-busy',
13 14
     'luticate2Utils',
14 15
     // 'luticateAuth',
15 16
     'appSdk'

+ 9
- 15
app/controllers/pkguid.controller.js View File

@@ -1,6 +1,6 @@
1 1
 angular.module('app')
2
-    .controller('PkGuidController', ['$scope', 'pkGuidBusiness', 'AppUtilsBusiness', '$mdDialog',
3
-        function($scope, pkGuidBusiness, AppUtilsBusiness, $mdDialog) {
2
+    .controller('PkGuidController', ['$scope', 'pkGuidBusiness', 'AppUtilsBusiness', '$mdDialog', 'luBusyBusiness',
3
+        function($scope, pkGuidBusiness, AppUtilsBusiness, $mdDialog, luBusyBusiness) {
4 4
 
5 5
             $scope.selected = [];
6 6
 
@@ -11,9 +11,11 @@ angular.module('app')
11 11
                 page: 1
12 12
             };
13 13
 
14
+            $scope.busy = luBusyBusiness.reset();
15
+            $scope.appUtils = AppUtilsBusiness;
16
+
14 17
             $scope.isFilterShown = false;
15 18
             $scope.pkGuids = null;
16
-            $scope.error = null;
17 19
 
18 20
             $scope.showFilter = function(show) {
19 21
                 $scope.isFilterShown = show;
@@ -32,13 +34,11 @@ angular.module('app')
32 34
                     .ok(AppUtilsBusiness.tr('common.delete'))
33 35
                     .cancel(AppUtilsBusiness.tr('common.cancel'));
34 36
                 $mdDialog.show(confirm).then(function() {
35
-                    $scope.error = null;
36
-                    $scope.promise = pkGuidBusiness.deleteDbo(pkguid.id).then(function(data)
37
+                    pkGuidBusiness.deleteDbo(pkguid.id, 'pkguid.table').then(function(data)
37 38
                     {
38 39
                         $scope.getPkGuids();
39 40
                     }, function(error)
40 41
                     {
41
-                        $scope.error = error;
42 42
                     });
43 43
                 }, function () {});
44 44
             };
@@ -50,7 +50,6 @@ angular.module('app')
50 50
                     .ok(AppUtilsBusiness.tr('common.delete'))
51 51
                     .cancel(AppUtilsBusiness.tr('common.cancel'));
52 52
                 $mdDialog.show(confirm).then(function() {
53
-                    $scope.error = null;
54 53
                     $scope.removeFirstSelected();
55 54
 
56 55
                 }, function () {});
@@ -61,30 +60,25 @@ angular.module('app')
61 60
                     $scope.getPkGuids();
62 61
                 }
63 62
                 else {
64
-                    $scope.promise = pkGuidBusiness.deleteDbo($scope.selected[0].id)
63
+                    pkGuidBusiness.deleteDbo($scope.selected[0].id, 'pkguid.table')
65 64
                         .then(function(data)
66 65
                     {
67 66
                         $scope.selected = $scope.selected.splice(1);
68 67
                         $scope.removeFirstSelected();
69
-                    }, function(error)
70
-                    {
71
-                        $scope.error = error;
72
-                    });
68
+                    }, function(error) {});
73 69
                 }
74 70
             };
75 71
 
76 72
             $scope.getPkGuids = function()
77 73
             {
78
-                $scope.error = null;
79 74
                 $scope.selected = [];
80 75
                 var orderBy = AppUtilsBusiness.convertOrderBy($scope.query.order);
81
-                $scope.promise = pkGuidBusiness.getMultiple(orderBy, $scope.query.filter, $scope.query.page - 1, $scope.query.limit).then(function(data)
76
+                pkGuidBusiness.getMultiple(orderBy, $scope.query.filter, $scope.query.page - 1, $scope.query.limit, 'pkguid.table').then(function(data)
82 77
                 {
83 78
                     $scope.pkGuids = data;
84 79
                 }, function(error)
85 80
                 {
86 81
                     $scope.pkGuids = null;
87
-                    $scope.error = error;
88 82
                 });
89 83
             };
90 84
 

+ 11
- 25
app/controllers/pkguidedit.controller.js View File

@@ -1,6 +1,6 @@
1 1
 angular.module('app')
2
-    .controller('PkGuidEditController', ['$scope', '$state', '$mdDialog', 'pkGuidBusiness', 'AppUtilsBusiness',
3
-        function ($scope, $state, $mdDialog, pkGuidBusiness, AppUtilsBusiness) {
2
+    .controller('PkGuidEditController', ['$scope', '$state', '$mdDialog', 'pkGuidBusiness', 'AppUtilsBusiness', 'luBusyBusiness',
3
+        function ($scope, $state, $mdDialog, pkGuidBusiness, AppUtilsBusiness, luBusyBusiness) {
4 4
 
5 5
             $scope.pkguid = null;
6 6
             $scope.defaultPkguid = {
@@ -9,9 +9,8 @@ angular.module('app')
9 9
                 someInt: 42
10 10
             };
11 11
 
12
-            $scope.running = false;
13
-
14
-            $scope.error = null;
12
+            $scope.busy = luBusyBusiness.reset();
13
+            $scope.appUtils = AppUtilsBusiness;
15 14
 
16 15
             $scope.setTitle = function()
17 16
             {
@@ -22,26 +21,17 @@ angular.module('app')
22 21
             };
23 22
 
24 23
             $scope.submit = function () {
25
-                $scope.error = null;
26
-                $scope.running = true;
27 24
                 if ($scope.pkguid.id == null) {
28
-                    pkGuidBusiness.addDbo($scope.pkguid).then(function (data) {
29
-                        $scope.running = false;
30
-                        $state.go('pkguid_edit', {pkguid: data, id: data.id});
31
-                    }, function (error) {
32
-                        $scope.running = false;
33
-                        $scope.error = error;
34
-                    });
25
+                    pkGuidBusiness.addDbo($scope.pkguid, 'pkguid.edit').then(function (data) {
26
+                        $scope.pkguid = data;
27
+                        $state.go('pkguid_edit', {pkguid: $scope.pkguid, id: $scope.pkguid.id});
28
+                    }, function (error) {});
35 29
                 }
36 30
                 else {
37
-                    pkGuidBusiness.editSingleByIdDbo($scope.pkguid.id, $scope.pkguid).then(function (data) {
38
-                        $scope.running = false;
31
+                    pkGuidBusiness.editSingleByIdDbo($scope.pkguid.id, $scope.pkguid, 'pkguid.edit').then(function (data) {
39 32
                         $scope.pkguid = data;
40 33
                         $scope.setTitle();
41
-                    }, function (error) {
42
-                        $scope.running = false;
43
-                        $scope.error = error;
44
-                    });
34
+                    }, function (error) {});
45 35
                 }
46 36
             };
47 37
 
@@ -52,15 +42,11 @@ angular.module('app')
52 42
                     $scope.setTitle();
53 43
                 }
54 44
                 else if ($state.params.id != null) {
55
-                    $scope.running = true;
56
-                    pkGuidBusiness.getSingleById($state.params.id).then(function(data)
45
+                    pkGuidBusiness.getSingleById($state.params.id, 'pkguid.edit').then(function(data)
57 46
                     {
58
-                        $scope.running = false;
59 47
                         $scope.pkguid = data;
60 48
                         $scope.setTitle();
61 49
                     }, function (error) {
62
-                        $scope.running = false;
63
-                        $scope.error = error;
64 50
                         $scope.pkguid = null;
65 51
                         $scope.setTitle();
66 52
                     });

+ 2
- 0
app/index.html View File

@@ -10,6 +10,7 @@
10 10
     <link rel="stylesheet" href="../bower_components/angular-material/angular-material.min.css"/>
11 11
     <link rel="stylesheet" href="../bower_components/angular-material-data-table/dist/md-data-table.min.css"/>
12 12
     <link rel="stylesheet" href="../bower_components/angular-material-sidenav/angular-material-sidenav.css"/>
13
+    <link rel="stylesheet" href="../bower_components/angular-busy2/dist/angular-busy.css"/>
13 14
     <!--<link rel="stylesheet" href="../bower_components/luticate-utils/src/lubusy.css">-->
14 15
     <!-- endbuild -->
15 16
 
@@ -44,6 +45,7 @@
44 45
     <script src="../bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js"></script>
45 46
     <script src="../bower_components/messageformat/messageformat.js"></script>
46 47
     <script src="../bower_components/angular-translate-interpolation-messageformat/angular-translate-interpolation-messageformat.min.js"></script>
48
+    <script src="../bower_components/angular-busy2/dist/angular-busy.js"></script>
47 49
     <!--<script src="../bower_components/luticate-auth/dist/luticate-auth.min.js"></script>-->
48 50
     <!--<script src="../bower_components/angular-dialog-service/dist/dialogs.js"></script>-->
49 51
     <!--<script src="../bower_components/angular-sanitize/angular-sanitize.js"></script>-->

+ 2
- 1
app/translations/en.json View File

@@ -19,7 +19,8 @@
19 19
       "page": "Page:",
20 20
       "rowsPerPage": "Items per page:"
21 21
     },
22
-    "createdBy": "Created with ❤ by"
22
+    "createdBy": "Created with ❤ by",
23
+    "busyLoading": "Loading..."
23 24
   },
24 25
   "home": {
25 26
     "name": "Home",

+ 6
- 0
app/views/busy-template.html View File

@@ -0,0 +1,6 @@
1
+<div class="custom-template">
2
+    <div flex>
3
+        <md-progress-linear md-mode="indeterminate"></md-progress-linear>
4
+    </div>
5
+    <div class="custom-message" ng-bind="$message"></div>
6
+</div>

+ 4
- 5
app/views/pkguid.html View File

@@ -1,4 +1,4 @@
1
-<div layout="column" layout-fill layout-align="top">
1
+<div layout="column" layout-fill layout-align="top" angular-busy="appUtils.cgBusy('pkguid.table')">
2 2
 
3 3
     <div flex>
4 4
         <md-toolbar class="md-table-toolbar md-default" ng-show="!isFilterShown && selected.length == 0">
@@ -44,7 +44,7 @@
44 44
 
45 45
     <div flex>
46 46
         <md-table-container>
47
-            <table md-table md-row-select multiple ng-model="selected" md-progress="promise">
47
+            <table md-table md-row-select multiple ng-model="selected" >
48 48
                 <thead md-head md-order="query.order" md-on-reorder="getPkGuids">
49 49
                 <tr md-row>
50 50
                     <th md-column md-order-by="id"><span>{{ 'pkguid.id' | translate }}</span></th>
@@ -76,11 +76,10 @@
76 76
         </md-table-container>
77 77
     </div>
78 78
 
79
-    <md-table-pagination md-label="{of: '{{ 'common.pagination.of' | translate }}', page: '{{ 'common.pagination.page' | translate }}', rowsPerPage: '{{ 'common.pagination.rowsPerPage' | translate }}'}"
80
-                         class="col-xs-11" md-limit="query.limit" md-limit-options="[5, 10, 15]"
79
+    <md-table-pagination md-label="{{appUtils.mdTableLabels()}}" class="col-xs-11" md-limit="query.limit" md-limit-options="[5, 10, 15]"
81 80
                          md-page="query.page" md-total="{{pkGuids.count}}" md-on-paginate="getPkGuids" md-page-select></md-table-pagination>
82 81
 
83
-    <div class="isa_error" ng-show="error != null">
82
+    <div ng-repeat="error in busy.errors('pkguid.table')" class="isa_error">
84 83
         <i class="fa fa-times-circle"></i>
85 84
         {{ error.data.message }}
86 85
     </div>

+ 2
- 2
app/views/pkguidedit.html View File

@@ -1,4 +1,4 @@
1
-<div layout="column" ng-cloak class="md-inline-form">
1
+<div layout="column" ng-cloak class="md-inline-form" angular-busy="appUtils.cgBusy('pkguid.edit')">
2 2
     <md-content layout-padding>
3 3
         <form name="editForm">
4 4
             <div layout-gt-sm="row">
@@ -18,7 +18,7 @@
18 18
             <div>
19 19
                 <md-button type="submit" ng-click="!editForm.$invalid && submit()">{{ 'common.submit' | translate }}</md-button>
20 20
             </div>
21
-            <div class="isa_error" ng-show="error != null">
21
+            <div ng-repeat="error in busy.errors('pkguid.edit')" class="isa_error">
22 22
                 <i class="fa fa-times-circle"></i>
23 23
                 {{ error.data.message }}
24 24
             </div>

+ 2
- 1
bower.json View File

@@ -19,6 +19,7 @@
19 19
     "material-design-icons": "^3.0.1",
20 20
     "angular-translate": "^2.13.1",
21 21
     "angular-translate-loader-static-files": "^2.13.1",
22
-    "angular-translate-interpolation-messageformat": "^2.13.1"
22
+    "angular-translate-interpolation-messageformat": "^2.13.1",
23
+    "angular-busy2": "^5.2.0"
23 24
   }
24 25
 }

+ 19
- 1
sdk/Business/apputils.business.js View File

@@ -6,7 +6,7 @@
6 6
     'use strict';
7 7
 
8 8
     angular.module('appSdk')
9
-        .factory('AppUtilsBusiness', ['$rootScope', '$translate', function($rootScope, $translate) {
9
+        .factory('AppUtilsBusiness', ['$rootScope', '$translate', 'luBusyBusiness', function($rootScope, $translate, luBusyBusiness) {
10 10
 
11 11
             var AppUtilsBusiness = {};
12 12
 
@@ -31,6 +31,24 @@
31 31
                 $rootScope.$emit('toolbar.title', {title: title});
32 32
             };
33 33
 
34
+            AppUtilsBusiness.mdTableLabels = function()
35
+            {
36
+                return {
37
+                    of: AppUtilsBusiness.tr('common.pagination.of'),
38
+                    page: AppUtilsBusiness.tr('common.pagination.page'),
39
+                    rowsPerPage: AppUtilsBusiness.tr('common.pagination.rowsPerPage')
40
+                };
41
+            };
42
+
43
+            AppUtilsBusiness.cgBusy = function(luBusyGroup)
44
+            {
45
+                return {
46
+                    promise: luBusyBusiness.promise(luBusyGroup),
47
+                    message: AppUtilsBusiness.tr('common.busyLoading'),
48
+                    templateUrl:'views/busy-template.html'
49
+                };
50
+            };
51
+
34 52
             AppUtilsBusiness.tr = function(id, data)
35 53
             {
36 54
                 return $translate.instant(id, data);

Loading…
Cancel
Save