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
     'md.data.table',
10
     'md.data.table',
11
     'sasrio.angular-material-sidenav',
11
     'sasrio.angular-material-sidenav',
12
     'pascalprecht.translate',
12
     'pascalprecht.translate',
13
+    'angular-busy',
13
     'luticate2Utils',
14
     'luticate2Utils',
14
     // 'luticateAuth',
15
     // 'luticateAuth',
15
     'appSdk'
16
     'appSdk'

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

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

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

1
 angular.module('app')
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
             $scope.pkguid = null;
5
             $scope.pkguid = null;
6
             $scope.defaultPkguid = {
6
             $scope.defaultPkguid = {
9
                 someInt: 42
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
             $scope.setTitle = function()
15
             $scope.setTitle = function()
17
             {
16
             {
22
             };
21
             };
23
 
22
 
24
             $scope.submit = function () {
23
             $scope.submit = function () {
25
-                $scope.error = null;
26
-                $scope.running = true;
27
                 if ($scope.pkguid.id == null) {
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
                 else {
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
                         $scope.pkguid = data;
32
                         $scope.pkguid = data;
40
                         $scope.setTitle();
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
                     $scope.setTitle();
42
                     $scope.setTitle();
53
                 }
43
                 }
54
                 else if ($state.params.id != null) {
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
                         $scope.pkguid = data;
47
                         $scope.pkguid = data;
60
                         $scope.setTitle();
48
                         $scope.setTitle();
61
                     }, function (error) {
49
                     }, function (error) {
62
-                        $scope.running = false;
63
-                        $scope.error = error;
64
                         $scope.pkguid = null;
50
                         $scope.pkguid = null;
65
                         $scope.setTitle();
51
                         $scope.setTitle();
66
                     });
52
                     });

+ 2
- 0
app/index.html View File

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

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

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

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

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
-<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
     <div flex>
3
     <div flex>
4
         <md-toolbar class="md-table-toolbar md-default" ng-show="!isFilterShown && selected.length == 0">
4
         <md-toolbar class="md-table-toolbar md-default" ng-show="!isFilterShown && selected.length == 0">
44
 
44
 
45
     <div flex>
45
     <div flex>
46
         <md-table-container>
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
                 <thead md-head md-order="query.order" md-on-reorder="getPkGuids">
48
                 <thead md-head md-order="query.order" md-on-reorder="getPkGuids">
49
                 <tr md-row>
49
                 <tr md-row>
50
                     <th md-column md-order-by="id"><span>{{ 'pkguid.id' | translate }}</span></th>
50
                     <th md-column md-order-by="id"><span>{{ 'pkguid.id' | translate }}</span></th>
76
         </md-table-container>
76
         </md-table-container>
77
     </div>
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
                          md-page="query.page" md-total="{{pkGuids.count}}" md-on-paginate="getPkGuids" md-page-select></md-table-pagination>
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
         <i class="fa fa-times-circle"></i>
83
         <i class="fa fa-times-circle"></i>
85
         {{ error.data.message }}
84
         {{ error.data.message }}
86
     </div>
85
     </div>

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

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
     <md-content layout-padding>
2
     <md-content layout-padding>
3
         <form name="editForm">
3
         <form name="editForm">
4
             <div layout-gt-sm="row">
4
             <div layout-gt-sm="row">
18
             <div>
18
             <div>
19
                 <md-button type="submit" ng-click="!editForm.$invalid && submit()">{{ 'common.submit' | translate }}</md-button>
19
                 <md-button type="submit" ng-click="!editForm.$invalid && submit()">{{ 'common.submit' | translate }}</md-button>
20
             </div>
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
                 <i class="fa fa-times-circle"></i>
22
                 <i class="fa fa-times-circle"></i>
23
                 {{ error.data.message }}
23
                 {{ error.data.message }}
24
             </div>
24
             </div>

+ 2
- 1
bower.json View File

19
     "material-design-icons": "^3.0.1",
19
     "material-design-icons": "^3.0.1",
20
     "angular-translate": "^2.13.1",
20
     "angular-translate": "^2.13.1",
21
     "angular-translate-loader-static-files": "^2.13.1",
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
     'use strict';
6
     'use strict';
7
 
7
 
8
     angular.module('appSdk')
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
             var AppUtilsBusiness = {};
11
             var AppUtilsBusiness = {};
12
 
12
 
31
                 $rootScope.$emit('toolbar.title', {title: title});
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
             AppUtilsBusiness.tr = function(id, data)
52
             AppUtilsBusiness.tr = function(id, data)
35
             {
53
             {
36
                 return $translate.instant(id, data);
54
                 return $translate.instant(id, data);

Loading…
Cancel
Save