Browse Source

updated luticate utils; added business utils

tags/v0.5.0
Robin Thoni 7 years ago
parent
commit
4656ec93e2

+ 1
- 0
TODO View File

@@ -0,0 +1 @@
1
+move created/updated at translations to common

+ 122
- 114
app/app.js View File

@@ -1,6 +1,81 @@
1 1
 'use strict';
2 2
 
3 3
 /* App Module */
4
+function addCrudStates($stateProvider, itemType, listState, addState, editState) {
5
+    if (listState == null || listState === true) {
6
+        $stateProvider.state(itemType, {
7
+            url: '/' + itemType,
8
+            parent: 'root',
9
+            title: itemType + '.name',
10
+            templateUrl: 'views/' + itemType + '.html',
11
+            controller: itemType + 'Controller'
12
+        });
13
+    }
14
+
15
+    if (addState == null || addState === true) {
16
+        $stateProvider.state(itemType + '_add', {
17
+            url: '/' + itemType + '/add',
18
+            parent: 'root',
19
+            title: itemType + '.add.defaultTitle',
20
+            toolbarTitle: itemType + '.add.defaultToolbarTitle',
21
+            templateUrl: 'views/' + itemType + 'edit.html',
22
+            controller: itemType + 'EditController',
23
+            params: {
24
+                item: null
25
+            }
26
+        });
27
+    }
28
+
29
+
30
+    if (editState == null || editState === true) {
31
+        $stateProvider.state(itemType + '_edit', {
32
+            url: '/' + itemType + '/edit/:id',
33
+            parent: 'root',
34
+            title: itemType + '.edit.defaultTitle',
35
+            toolbarTitle: itemType + '.edit.defaultToolbarTitle',
36
+            templateUrl: 'views/' + itemType + 'edit.html',
37
+            controller: itemType + 'EditController',
38
+            params: {
39
+                item: null
40
+            }
41
+        });
42
+    }
43
+
44
+}
45
+
46
+function addCrudNotifications(luNotificationsBusiness, AppUtilsBusiness, $mdToast, $state, itemType) {
47
+    luNotificationsBusiness.addEventCrudCallback(itemType, function(eventName, entityType, oldEntity, newEntity)
48
+    {
49
+        var text = null;
50
+        if (eventName == luNotificationsBusiness.EVENT_CREATE) {
51
+            text = AppUtilsBusiness.tr(itemType + '.notifications.create', {text: newEntity.toString()});
52
+        }
53
+        else if (eventName == luNotificationsBusiness.EVENT_UPDATE) {
54
+            text = AppUtilsBusiness.tr(itemType + '.notifications.update', {text: newEntity.toString()});
55
+        }
56
+        else if (eventName == luNotificationsBusiness.EVENT_DELETE) {
57
+            text = AppUtilsBusiness.tr(itemType + '.notifications.delete', {text: oldEntity.toString()});
58
+        }
59
+        var toast = $mdToast.simple()
60
+            .textContent(text)
61
+            .action(eventName == luNotificationsBusiness.EVENT_DELETE ? AppUtilsBusiness.tr('common.undo') : AppUtilsBusiness.tr('common.view'))
62
+            .highlightAction(true)
63
+            .highlightClass('md-accent')
64
+            .position('bottom right');
65
+
66
+        $mdToast.show(toast).then(function(response) {
67
+            if (response == 'ok') {
68
+                if (eventName == luNotificationsBusiness.EVENT_DELETE) {
69
+                    oldEntity.id = null;
70
+                    $state.go(itemType + '_add', {item: oldEntity});
71
+                }
72
+                else {
73
+                    $state.go(itemType + '_edit', {id: newEntity.id, item: newEntity});
74
+                }
75
+            }
76
+        }, function (error) {console.log(error)});
77
+    });
78
+}
4 79
 
5 80
 angular.module('app', [
6 81
     'ui.bootstrap',
@@ -16,8 +91,10 @@ angular.module('app', [
16 91
     // 'luticateAuth',
17 92
     'appSdk'
18 93
 ])
19
-    .config(['$stateProvider', '$urlRouterProvider', 'ssSideNavSectionsProvider', '$mdThemingProvider', '$mdIconProvider', '$translateProvider',
20
-        function($stateProvider, $urlRouterProvider, ssSideNavSectionsProvider, $mdThemingProvider, $mdIconProvider, $translateProvider) {
94
+    .config(['$stateProvider', '$urlRouterProvider', 'ssSideNavSectionsProvider', '$mdThemingProvider',
95
+        '$mdIconProvider', '$translateProvider', '$provide',
96
+        function($stateProvider, $urlRouterProvider, ssSideNavSectionsProvider, $mdThemingProvider,
97
+                 $mdIconProvider, $translateProvider, $provide) {
21 98
 
22 99
             // $mdThemingProvider
23 100
             //     .theme('default')
@@ -29,7 +106,27 @@ angular.module('app', [
29 106
             //     .primaryPalette('blue')
30 107
             //     .accentPalette('pink');
31 108
 
32
-            $translateProvider.useSanitizeValueStrategy('escape');
109
+            $provide.decorator("$mdDialog", ['$delegate', function ($delegate) {
110
+                // Get a handle of the show method
111
+                var c = $delegate.show;
112
+
113
+                function decorateDialogShow () {
114
+                    var args = angular.extend({}, arguments[0], {
115
+                        skipHide: true
116
+                    });
117
+                    if (args._options != null) {
118
+                        args._options = angular.extend({}, args._options, {
119
+                            skipHide: true
120
+                        });
121
+                    }
122
+                    return c(args);
123
+                }
124
+
125
+                $delegate.show = decorateDialogShow;
126
+                return $delegate;
127
+            }]);
128
+
129
+            $translateProvider.useSanitizeValueStrategy('escapeParameters');
33 130
             $translateProvider.useMessageFormatInterpolation();
34 131
             $translateProvider.useStaticFilesLoader({
35 132
                 prefix: 'translations/',
@@ -82,19 +179,19 @@ angular.module('app', [
82 179
                 hidden: true
83 180
             },  {
84 181
                 id: 'toogle_2',
85
-                name: 'pkguid.name',
182
+                name: 'pkguids.name',
86 183
                 type: 'heading',
87 184
                 children: [{
88
-                    name: 'pkguid.name',
185
+                    name: 'pkguids.name',
89 186
                     type: 'toggle',
90 187
                     pages: [{
91 188
                         id: 'toogle_2_link_1',
92 189
                         name: 'common.all',
93
-                        state: 'pkguid'
190
+                        state: 'pkguids'
94 191
                     },{
95 192
                         id: 'toogle_2_link_1',
96 193
                         name: 'common.new',
97
-                        state: 'pkguid_add'
194
+                        state: 'pkguids_add'
98 195
                     }]
99 196
                 }]
100 197
             }]);
@@ -117,45 +214,14 @@ angular.module('app', [
117 214
                 controller:'HomeController'
118 215
             });
119 216
 
120
-            $stateProvider.state('pkguid', {
121
-                url:'/pkguids',
122
-                parent: 'root',
123
-                title: "pkguid.name",
124
-                reloadOnSearch: false,
125
-                templateUrl:'views/pkguid.html',
126
-                controller:'PkGuidController'
127
-            });
128
-
129
-            $stateProvider.state('pkguid_add', {
130
-                url:'/pkguids/add',
131
-                parent: 'root',
132
-                title: "pkguid.add.defaultTitle",
133
-                toolbarTitle: "pkguid.add.defaultToolbarTitle",
134
-                reloadOnSearch: false,
135
-                templateUrl:'views/pkguidedit.html',
136
-                controller:'PkGuidEditController',
137
-                params: {
138
-                    pkguid: null
139
-                }
140
-            });
141
-
142
-            $stateProvider.state('pkguid_edit', {
143
-                url:'/pkguids/edit/:id',
144
-                parent: 'root',
145
-                title: "pkguid.edit.defaultTitle",
146
-                toolbarTitle: "pkguid.edit.defaultToolbarTitle",
147
-                reloadOnSearch: false,
148
-                templateUrl:'views/pkguidedit.html',
149
-                controller:'PkGuidEditController',
150
-                params: {
151
-                    pkguid: null
152
-                }
153
-            });
217
+            addCrudStates($stateProvider, 'pkguids');
154 218
 
155 219
             $urlRouterProvider.otherwise('/');
156 220
     }])
157
-    .run(['$rootScope', '$transitions', 'AppUtilsBusiness', 'ssSideNav', '$translate', 'luRequest', '$mdDialog', 'luNotificationsBusiness', '$mdToast', '$state',
158
-        function ($rootScope, $transitions, AppUtilsBusiness, ssSideNav, $translate, luRequest, $mdDialog, luNotificationsBusiness, $mdToast, $state) {
221
+    .run(['$rootScope', '$transitions', 'AppUtilsBusiness', 'ssSideNav', '$translate', 'luRequest', '$mdDialog',
222
+        'luNotificationsBusiness', '$mdToast', '$state', 'pkguidsBusiness',
223
+        function ($rootScope, $transitions, AppUtilsBusiness, ssSideNav, $translate, luRequest, $mdDialog,
224
+                  luNotificationsBusiness, $mdToast, $state, pkguidsBusiness) {
159 225
 
160 226
         AppUtilsBusiness.addApiVersionChangedCallback(function(oldVersion, newVersion) {
161 227
             $mdDialog.show(
@@ -166,72 +232,10 @@ angular.module('app', [
166 232
                     .ok(AppUtilsBusiness.tr('common.ok')));
167 233
         });
168 234
 
169
-        luNotificationsBusiness.init();
170
-
171
-        luNotificationsBusiness.addEventCrudCallback('pkguid', function(eventName, entityType, oldEntity, newEntity)
172
-        {
173
-            var text = null;
174
-            if (eventName == luNotificationsBusiness.EVENT_CREATE) {
175
-                text = AppUtilsBusiness.tr('pkguid.notifications.create', {text: newEntity.someText});
176
-            }
177
-            else if (eventName == luNotificationsBusiness.EVENT_UPDATE) {
178
-                text = AppUtilsBusiness.tr('pkguid.notifications.update', {text: newEntity.someText});
179
-            }
180
-            else if (eventName == luNotificationsBusiness.EVENT_DELETE) {
181
-                text = AppUtilsBusiness.tr('pkguid.notifications.delete', {text: oldEntity.someText});
182
-            }
183
-            var toast = $mdToast.simple()
184
-                .textContent(text)
185
-                .action(eventName == luNotificationsBusiness.EVENT_DELETE ? AppUtilsBusiness.tr('common.undo') : AppUtilsBusiness.tr('common.view'))
186
-                .highlightAction(true)
187
-                .highlightClass('md-accent')
188
-                .position('bottom right');
189
-
190
-            $mdToast.show(toast).then(function(response) {
191
-                if (response == 'ok') {
192
-                    if (eventName == luNotificationsBusiness.EVENT_DELETE) {
193
-                        oldEntity.id = null;
194
-                        $state.go('pkguid_add', {pkguid: oldEntity});
195
-                    }
196
-                    else {
197
-                        $state.go('pkguid_edit', {id: newEntity.id, pkguid: newEntity});
198
-                    }
199
-                }
200
-            });
235
+        luNotificationsBusiness.init({
236
+            'pkguids': pkguidsBusiness
201 237
         });
202
-
203
-        // luNotificationsBusiness.addEventDeleteCallback('pkguid', function(eventName, entityType, oldEntity)
204
-        // {
205
-        //     var toast = $mdToast.simple()
206
-        //         .textContent("PkGuid \'" + oldEntity.someText + "\' was deleted")
207
-        //         .action("Undo")
208
-        //         .highlightAction(true)
209
-        //         .highlightClass('md-accent')
210
-        //         .position('bottom right');
211
-        //
212
-        //     $mdToast.show(toast).then(function(response) {
213
-        //         if (response == 'ok') {
214
-        //             oldEntity.id = null;
215
-        //             $state.go('pkguid_add', {pkguid: oldEntity});
216
-        //         }
217
-        //     });
218
-        // });
219
-        //
220
-        // luNotificationsBusiness.addEventCreateCallback('pkguid', function(eventName, entityType, oldEntity, newEntity)
221
-        // {
222
-        //     var toast = $mdToast.simple()
223
-        //         .textContent("PkGuid \'" + newEntity.someText + "\' was added")
224
-        //         .action("View")
225
-        //         .highlightAction(true)
226
-        //         .highlightClass('md-accent')
227
-        //         .position('bottom right');
228
-        //
229
-        //     $mdToast.show(toast).then(function(response) {
230
-        //         if (response == 'ok') {
231
-        //             $state.go('pkguid_edit', {id: newEntity.id, pkguid: newEntity});
232
-        //         }
233
-        //     });
234
-        // });
238
+        addCrudNotifications(luNotificationsBusiness, AppUtilsBusiness, $mdToast, $state, 'pkguids');
235 239
 
236 240
         $translate('common.appName').then(function() {
237 241
             for (var i = 0; i < ssSideNav.sections.length; ++i) {
@@ -259,11 +263,15 @@ angular.module('app', [
259 263
             var toState = $transitions.$to();
260 264
             var title = toState.title != null ? toState.title : toState.toolbarTitle != null ? toState.toolbarTitle : null;
261 265
             var toolbarTitle = toState.toolbarTitle != null ? toState.toolbarTitle : toState.title != null ? toState.title : null;
262
-            if (title != null) {
263
-                AppUtilsBusiness.setTitle(AppUtilsBusiness.tr(title));
264
-            }
265
-            if (toolbarTitle != null) {
266
-                AppUtilsBusiness.setToolbarTitle(AppUtilsBusiness.tr(toolbarTitle));
267
-            }
266
+            $translate('common.appName').then(function() {
267
+                if (title != null) {
268
+                    AppUtilsBusiness.setTitle(AppUtilsBusiness.tr(title));
269
+                }
270
+                if (toolbarTitle != null) {
271
+                    AppUtilsBusiness.setToolbarTitle(AppUtilsBusiness.tr(toolbarTitle));
272
+                }
273
+            }, function (error) {
274
+                console.error(error);
275
+            });
268 276
         });
269 277
     }]);

+ 9
- 0
app/controllers/filters/formatDate.filter.js View File

@@ -0,0 +1,9 @@
1
+/**
2
+ * Created by robin on 12/22/16.
3
+ */
4
+angular.module('app').filter('formatDate', ['DateUtilsBusiness', function(DateUtilsBusiness) {
5
+    return function(date)
6
+    {
7
+        return DateUtilsBusiness.formatDate(date);
8
+    };
9
+}]);

+ 9
- 0
app/controllers/filters/formatDateTime.filter.js View File

@@ -0,0 +1,9 @@
1
+/**
2
+ * Created by robin on 12/22/16.
3
+ */
4
+angular.module('app').filter('formatDateTime', ['DateUtilsBusiness', function(DateUtilsBusiness) {
5
+    return function(date)
6
+    {
7
+        return DateUtilsBusiness.formatDateTime(date);
8
+    };
9
+}]);

+ 9
- 0
app/controllers/filters/formatTime.filter.js View File

@@ -0,0 +1,9 @@
1
+/**
2
+ * Created by robin on 12/22/16.
3
+ */
4
+angular.module('app').filter('formatTime', ['DateUtilsBusiness', function(DateUtilsBusiness) {
5
+    return function(date)
6
+    {
7
+        return DateUtilsBusiness.formatTime(date);
8
+    };
9
+}]);

+ 6
- 0
app/controllers/filters/urlencode.filter.js View File

@@ -0,0 +1,6 @@
1
+/**
2
+ * Created by robin on 12/22/16.
3
+ */
4
+angular.module('app').filter('urlencode', ['$window', function($window) {
5
+    return $window.encodeURIComponent;
6
+}]);

+ 0
- 86
app/controllers/pkguid.controller.js View File

@@ -1,86 +0,0 @@
1
-angular.module('app')
2
-    .controller('PkGuidController', ['$scope', 'pkGuidBusiness', 'AppUtilsBusiness', '$mdDialog', 'luBusyBusiness',
3
-        function($scope, pkGuidBusiness, AppUtilsBusiness, $mdDialog, luBusyBusiness) {
4
-
5
-            $scope.selected = [];
6
-
7
-            $scope.query = {
8
-                order: 'someText',
9
-                filter: '',
10
-                limit: 5,
11
-                page: 1
12
-            };
13
-
14
-            $scope.busy = luBusyBusiness.reset();
15
-            $scope.appUtils = AppUtilsBusiness;
16
-
17
-            $scope.isFilterShown = false;
18
-            $scope.pkGuids = null;
19
-
20
-            $scope.showFilter = function(show) {
21
-                $scope.isFilterShown = show;
22
-                if (!$scope.isFilterShown) {
23
-                    if ($scope.query.filter != '') {
24
-                        $scope.query.filter = '';
25
-                        $scope.getPkGuids();
26
-                    }
27
-                }
28
-            };
29
-
30
-            $scope.askRemoveOne = function (pkguid) {
31
-                var confirm = $mdDialog.confirm()
32
-                    .title(AppUtilsBusiness.tr('common.confirmDelete'))
33
-                    .textContent(AppUtilsBusiness.tr('pkguid.deleteOne', {text: pkguid.someText}))
34
-                    .ok(AppUtilsBusiness.tr('common.delete'))
35
-                    .cancel(AppUtilsBusiness.tr('common.cancel'));
36
-                $mdDialog.show(confirm).then(function() {
37
-                    pkGuidBusiness.deleteDbo(pkguid.id, 'pkguid.table').then(function(data)
38
-                    {
39
-                        $scope.getPkGuids();
40
-                    }, function(error) {});
41
-                }, function () {});
42
-            };
43
-
44
-            $scope.askRemoveSelected = function () {
45
-                var confirm = $mdDialog.confirm()
46
-                    .title(AppUtilsBusiness.tr('common.confirmDelete'))
47
-                    .textContent(AppUtilsBusiness.tr('pkguid.deleteMultiple', {count: $scope.selected.length}))
48
-                    .ok(AppUtilsBusiness.tr('common.delete'))
49
-                    .cancel(AppUtilsBusiness.tr('common.cancel'));
50
-                $mdDialog.show(confirm).then(function() {
51
-                    $scope.removeFirstSelected();
52
-
53
-                }, function () {});
54
-            };
55
-
56
-            $scope.removeFirstSelected = function() {
57
-                if ($scope.selected.length == 0) {
58
-                    $scope.getPkGuids();
59
-                }
60
-                else {
61
-                    pkGuidBusiness.deleteDbo($scope.selected[0].id, 'pkguid.table')
62
-                        .then(function(data)
63
-                    {
64
-                        $scope.selected = $scope.selected.splice(1);
65
-                        $scope.removeFirstSelected();
66
-                    }, function(error) {});
67
-                }
68
-            };
69
-
70
-            $scope.getPkGuids = function()
71
-            {
72
-                $scope.selected = [];
73
-                var orderBy = AppUtilsBusiness.convertOrderBy($scope.query.order);
74
-                pkGuidBusiness.getMultiple(orderBy, $scope.query.filter, $scope.query.page - 1, $scope.query.limit, 'pkguid.table').then(function(data)
75
-                {
76
-                    $scope.pkGuids = data;
77
-                }, function(error)
78
-                {
79
-                    $scope.pkGuids = null;
80
-                });
81
-            };
82
-
83
-
84
-
85
-            $scope.getPkGuids();
86
-    }]);

+ 0
- 78
app/controllers/pkguidedit.controller.js View File

@@ -1,78 +0,0 @@
1
-angular.module('app')
2
-    .controller('PkGuidEditController', ['$scope', '$state', '$mdDialog', 'pkGuidBusiness', 'AppUtilsBusiness', 'luBusyBusiness',
3
-        function ($scope, $state, $mdDialog, pkGuidBusiness, AppUtilsBusiness, luBusyBusiness) {
4
-
5
-            $scope.pkguid = null;
6
-            $scope.defaultPkguid = {
7
-                id: null,
8
-                someText: "Test.",
9
-                someInt: 42
10
-            };
11
-
12
-            $scope.busy = luBusyBusiness.reset();
13
-            $scope.appUtils = AppUtilsBusiness;
14
-
15
-            $scope.setTitle = function()
16
-            {
17
-                if ($scope.pkguid.id != null) {
18
-                    AppUtilsBusiness.setTitle(AppUtilsBusiness.tr('pkguid.edit.title', {text: $scope.pkguid.someText}));
19
-                    AppUtilsBusiness.setToolbarTitle(AppUtilsBusiness.tr('pkguid.edit.toolbarTitle', {text: $scope.pkguid.someText}));
20
-                }
21
-            };
22
-
23
-            $scope.submit = function () {
24
-                if ($scope.pkguid.id == null) {
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) {});
29
-                }
30
-                else {
31
-                    pkGuidBusiness.editSingleByIdDbo($scope.pkguid.id, $scope.pkguid, 'pkguid.edit').then(function (data) {
32
-                        $scope.pkguid = data;
33
-                        $scope.setTitle();
34
-                    }, function (error) {});
35
-                }
36
-            };
37
-
38
-            $scope.askRemoveOne = function (pkguid) {
39
-                var confirm = $mdDialog.confirm()
40
-                    .title(AppUtilsBusiness.tr('common.confirmDelete'))
41
-                    .textContent(AppUtilsBusiness.tr('pkguid.deleteOne', {text: pkguid.someText}))
42
-                    .ok(AppUtilsBusiness.tr('common.delete'))
43
-                    .cancel(AppUtilsBusiness.tr('common.cancel'));
44
-                $mdDialog.show(confirm).then(function() {
45
-                    pkGuidBusiness.deleteDbo(pkguid.id, 'pkguid.edit').then(function(data)
46
-                    {
47
-                        $state.go('pkguid');
48
-                    }, function(error) {});
49
-                }, function () {});
50
-            };
51
-
52
-
53
-            if ($state.params != null) {
54
-                if ($state.params.pkguid != null) {
55
-                    $scope.pkguid = $state.params.pkguid;
56
-                    $scope.setTitle();
57
-                }
58
-                else if ($state.params.id != null) {
59
-                    pkGuidBusiness.getSingleById($state.params.id, 'pkguid.edit').then(function(data)
60
-                    {
61
-                        $scope.pkguid = data;
62
-                        $scope.setTitle();
63
-                    }, function (error) {
64
-                        $scope.pkguid = null;
65
-                        $scope.setTitle();
66
-                    });
67
-                }
68
-                else {
69
-                    $scope.pkguid = angular.copy($scope.defaultPkguid);
70
-                    $scope.setTitle();
71
-                }
72
-            }
73
-            else {
74
-                $scope.pkguid = angular.copy($scope.defaultPkguid);
75
-                $scope.setTitle();
76
-            }
77
-
78
-        }]);

+ 100
- 0
app/controllers/pkguids.controller.js View File

@@ -0,0 +1,100 @@
1
+angular.module('app')
2
+    .controller('pkguidsController', ['$scope', '$stateParams', 'pkguidsBusiness', 'listControllerBuilder',
3
+        function($scope, $stateParams, pkguidsBusiness, listControllerBuilder) {
4
+
5
+            $scope.business = pkguidsBusiness;
6
+            $scope.itemType = 'pkguids';
7
+            $scope.defaultOrder = 'someText';
8
+            listControllerBuilder.create($scope, $stateParams);
9
+
10
+            $scope.getAddItem = function()
11
+            {
12
+                return {
13
+                    someText: $scope.query.filter
14
+                };
15
+            };
16
+
17
+            $scope.init();
18
+
19
+            // $scope.selected = [];
20
+            //
21
+            // $scope.query = {
22
+            //     order: 'someText',
23
+            //     filter: '',
24
+            //     limit: 5,
25
+            //     page: 1
26
+            // };
27
+            //
28
+            // $scope.busy = luBusyBusiness.reset();
29
+            // $scope.appUtils = AppUtilsBusiness;
30
+            //
31
+            // $scope.isFilterShown = false;
32
+            // $scope.pkGuids = null;
33
+            //
34
+            // $scope.showFilter = function(show) {
35
+            //     $scope.isFilterShown = show;
36
+            //     if (!$scope.isFilterShown) {
37
+            //         if ($scope.query.filter != '') {
38
+            //             $scope.query.filter = '';
39
+            //             $scope.getPkGuids();
40
+            //         }
41
+            //     }
42
+            // };
43
+            //
44
+            // $scope.askRemoveOne = function (pkguid) {
45
+            //     var confirm = $mdDialog.confirm()
46
+            //         .title(AppUtilsBusiness.tr('common.confirmDelete'))
47
+            //         .textContent(AppUtilsBusiness.tr('pkguid.deleteOne', {text: pkguid.someText}))
48
+            //         .ok(AppUtilsBusiness.tr('common.delete'))
49
+            //         .cancel(AppUtilsBusiness.tr('common.cancel'));
50
+            //     $mdDialog.show(confirm).then(function() {
51
+            //         pkGuidBusiness.deleteDbo(pkguid.id, 'pkguid.table').then(function(data)
52
+            //         {
53
+            //             $scope.getPkGuids();
54
+            //         }, function(error) {});
55
+            //     }, function () {});
56
+            // };
57
+            //
58
+            // $scope.askRemoveSelected = function () {
59
+            //     var confirm = $mdDialog.confirm()
60
+            //         .title(AppUtilsBusiness.tr('common.confirmDelete'))
61
+            //         .textContent(AppUtilsBusiness.tr('pkguid.deleteMultiple', {count: $scope.selected.length}))
62
+            //         .ok(AppUtilsBusiness.tr('common.delete'))
63
+            //         .cancel(AppUtilsBusiness.tr('common.cancel'));
64
+            //     $mdDialog.show(confirm).then(function() {
65
+            //         $scope.removeFirstSelected();
66
+            //
67
+            //     }, function () {});
68
+            // };
69
+            //
70
+            // $scope.removeFirstSelected = function() {
71
+            //     if ($scope.selected.length == 0) {
72
+            //         $scope.getPkGuids();
73
+            //     }
74
+            //     else {
75
+            //         pkGuidBusiness.deleteDbo($scope.selected[0].id, 'pkguid.table')
76
+            //             .then(function(data)
77
+            //         {
78
+            //             $scope.selected = $scope.selected.splice(1);
79
+            //             $scope.removeFirstSelected();
80
+            //         }, function(error) {});
81
+            //     }
82
+            // };
83
+            //
84
+            // $scope.getPkGuids = function()
85
+            // {
86
+            //     $scope.selected = [];
87
+            //     var orderBy = AppUtilsBusiness.convertOrderBy($scope.query.order);
88
+            //     pkGuidBusiness.getMultiple(orderBy, $scope.query.filter, $scope.query.page - 1, $scope.query.limit, 'pkguid.table').then(function(data)
89
+            //     {
90
+            //         $scope.pkGuids = data;
91
+            //     }, function(error)
92
+            //     {
93
+            //         $scope.pkGuids = null;
94
+            //     });
95
+            // };
96
+            //
97
+            //
98
+            //
99
+            // $scope.getPkGuids();
100
+    }]);

+ 87
- 0
app/controllers/pkguidsedit.controller.js View File

@@ -0,0 +1,87 @@
1
+angular.module('app')
2
+    .controller('pkguidsEditController', ['$scope', '$stateParams', 'pkguidsBusiness', 'editControllerBuilder',
3
+        function ($scope, $stateParams, pkguidsBusiness, editControllerBuilder) {
4
+
5
+            $scope.business = pkguidsBusiness;
6
+            $scope.itemType = 'pkguids';
7
+            editControllerBuilder.create($scope, $stateParams);
8
+
9
+
10
+            $scope.setupExitConfirm();
11
+
12
+            $scope.init($stateParams);
13
+
14
+            // $scope.pkguid = null;
15
+            // $scope.defaultPkguid = {
16
+            //     id: null,
17
+            //     someText: "Test.",
18
+            //     someInt: 42
19
+            // };
20
+            //
21
+            // $scope.busy = luBusyBusiness.reset();
22
+            // $scope.appUtils = AppUtilsBusiness;
23
+            //
24
+            // $scope.setTitle = function()
25
+            // {
26
+            //     if ($scope.pkguid.id != null) {
27
+            //         AppUtilsBusiness.setTitle(AppUtilsBusiness.tr('pkguid.edit.title', {text: $scope.pkguid.someText}));
28
+            //         AppUtilsBusiness.setToolbarTitle(AppUtilsBusiness.tr('pkguid.edit.toolbarTitle', {text: $scope.pkguid.someText}));
29
+            //     }
30
+            // };
31
+            //
32
+            // $scope.submit = function () {
33
+            //     if ($scope.pkguid.id == null) {
34
+            //         pkGuidBusiness.addDbo($scope.pkguid, 'pkguid.edit').then(function (data) {
35
+            //             $scope.pkguid = data;
36
+            //             $state.go('pkguid_edit', {pkguid: $scope.pkguid, id: $scope.pkguid.id});
37
+            //         }, function (error) {});
38
+            //     }
39
+            //     else {
40
+            //         pkGuidBusiness.editSingleByIdDbo($scope.pkguid.id, $scope.pkguid, 'pkguid.edit').then(function (data) {
41
+            //             $scope.pkguid = data;
42
+            //             $scope.setTitle();
43
+            //         }, function (error) {});
44
+            //     }
45
+            // };
46
+            //
47
+            // $scope.askRemoveOne = function (pkguid) {
48
+            //     var confirm = $mdDialog.confirm()
49
+            //         .title(AppUtilsBusiness.tr('common.confirmDelete'))
50
+            //         .textContent(AppUtilsBusiness.tr('pkguid.deleteOne', {text: pkguid.someText}))
51
+            //         .ok(AppUtilsBusiness.tr('common.delete'))
52
+            //         .cancel(AppUtilsBusiness.tr('common.cancel'));
53
+            //     $mdDialog.show(confirm).then(function() {
54
+            //         pkGuidBusiness.deleteDbo(pkguid.id, 'pkguid.edit').then(function(data)
55
+            //         {
56
+            //             $state.go('pkguid');
57
+            //         }, function(error) {});
58
+            //     }, function () {});
59
+            // };
60
+            //
61
+            //
62
+            // if ($state.params != null) {
63
+            //     if ($state.params.pkguid != null) {
64
+            //         $scope.pkguid = $state.params.pkguid;
65
+            //         $scope.setTitle();
66
+            //     }
67
+            //     else if ($state.params.id != null) {
68
+            //         pkGuidBusiness.getSingleById($state.params.id, 'pkguid.edit').then(function(data)
69
+            //         {
70
+            //             $scope.pkguid = data;
71
+            //             $scope.setTitle();
72
+            //         }, function (error) {
73
+            //             $scope.pkguid = null;
74
+            //             $scope.setTitle();
75
+            //         });
76
+            //     }
77
+            //     else {
78
+            //         $scope.pkguid = angular.copy($scope.defaultPkguid);
79
+            //         $scope.setTitle();
80
+            //     }
81
+            // }
82
+            // else {
83
+            //     $scope.pkguid = angular.copy($scope.defaultPkguid);
84
+            //     $scope.setTitle();
85
+            // }
86
+
87
+        }]);

+ 3
- 3
app/controllers/toolbar.controller.js View File

@@ -3,10 +3,10 @@
3 3
  */
4 4
 
5 5
 angular.module('app')
6
-    .controller('ToolBarController', ['$scope', '$rootScope', '$mdSidenav',
7
-        function ($scope, $rootScope, $mdSidenav) {
6
+    .controller('ToolBarController', ['$scope', '$rootScope', '$mdSidenav', 'AppUtilsBusiness',
7
+        function ($scope, $rootScope, $mdSidenav, AppUtilsBusiness) {
8 8
 
9
-            $scope.title = '';
9
+            $scope.title = AppUtilsBusiness.getToolbarTitle();
10 10
 
11 11
             $scope.toggleSideBar = function () {
12 12
                 $mdSidenav('left').toggle();

+ 17
- 6
app/index.html View File

@@ -49,9 +49,9 @@
49 49
     <script src="../bower_components/signalr/jquery.signalR.min.js"></script>
50 50
     <script src="/signalr/hubs"></script>
51 51
     <script src="../bower_components/angular-signalr-hub/signalr-hub.min.js"></script>
52
+    <script src="../bower_components/moment/moment.js"></script>
53
+    <script src="../bower_components/angular-moment/angular-moment.min.js"></script>
52 54
     <!--<script src="../bower_components/luticate-auth/dist/luticate-auth.min.js"></script>-->
53
-    <!--<script src="../bower_components/angular-dialog-service/dist/dialogs.js"></script>-->
54
-    <!--<script src="../bower_components/angular-sanitize/angular-sanitize.js"></script>-->
55 55
 
56 56
     <!-- scripts -->
57 57
     <script src="app.js"></script>
@@ -60,19 +60,30 @@
60 60
     <script src="controllers/sidebar.controller.js"></script>
61 61
     <script src="controllers/toolbar.controller.js"></script>
62 62
     <script src="controllers/home.controller.js"></script>
63
-    <script src="controllers/pkguid.controller.js"></script>
64
-    <script src="controllers/pkguidedit.controller.js"></script>
63
+    <script src="controllers/pkguids.controller.js"></script>
64
+    <script src="controllers/pkguidsedit.controller.js"></script>
65 65
 
66 66
     <!-- Modal Controller -->
67 67
 
68 68
     <!-- SDK -->
69 69
     <script src="../sdk/sdk.js"></script>
70 70
     <script src="../sdk/Business/apputils.business.js"></script>
71
-    <script src="../sdk/DataAccess/pkguid.dataaccess.js"></script>
72
-    <script src="../sdk/Business/pkguid.business.js"></script>
71
+    <script src="../sdk/Business/dateUtils.business.js"></script>
72
+    <script src="../sdk/Business/editcontrollerbuilder.business.js"></script>
73
+    <script src="../sdk/Business/listcontrollerbuilder.business.js"></script>
74
+    <script src="../sdk/Business/itemTracker.business.js"></script>
75
+    <script src="../sdk/Business/items.business.js"></script>
76
+    <script src="../sdk/DataAccess/pkguids.dataaccess.js"></script>
77
+    <script src="../sdk/Business/pkguids.business.js"></script>
73 78
 
74 79
     <!-- Directives -->
75 80
 
81
+    <!-- Filters -->
82
+    <script src="controllers/filters/formatDate.filter.js"></script>
83
+    <script src="controllers/filters/formatTime.filter.js"></script>
84
+    <script src="controllers/filters/formatDateTime.filter.js"></script>
85
+    <script src="controllers/filters/urlencode.filter.js"></script>
86
+
76 87
     <!-- endbuild -->
77 88
 
78 89
 </head>

+ 54
- 0
app/less/app.less View File

@@ -78,6 +78,60 @@ md-toolbar.md-table-toolbar form .md-errors-spacer {
78 78
   display: none;
79 79
 }
80 80
 
81
+.md-button.md-icon-button.no-margin {
82
+  margin: 0;
83
+  padding: 0;
84
+}
85
+
86
+md-dialog {
87
+  min-width: 50%;
88
+}
89
+
90
+.overme {
91
+  overflow: hidden;
92
+  white-space: nowrap;
93
+  text-overflow: ellipsis;
94
+}
95
+
96
+.md-icon-timepicker {
97
+  margin-bottom: 25px !important;
98
+}
99
+
100
+md-table-container tbody tr {
101
+  &:hover {
102
+    background-color: rgba(0, 0, 0, 0.08);
103
+  }
104
+}
105
+
106
+.col-icon(@count) {
107
+  width: 60px * @count;
108
+  white-space: nowrap;
109
+}
110
+
111
+.col-icon-1 {
112
+  .col-icon(1);
113
+}
114
+
115
+.col-icon-2 {
116
+  .col-icon(2);
117
+}
118
+
119
+.col-icon-3 {
120
+  .col-icon(3);
121
+}
122
+
123
+.col-icon-4 {
124
+  .col-icon(4);
125
+}
126
+
127
+.md-button-fix {
128
+  padding-top: 8px;
129
+}
130
+
131
+.has-changed-warning {
132
+  padding-left: 8px;
133
+}
134
+
81 135
 /**
82 136
 ========================================================
83 137
 **/

+ 12
- 5
app/translations/en.json View File

@@ -1,7 +1,7 @@
1 1
 {
2 2
   "common": {
3 3
     "appName": "MyApp",
4
-    "filter": "Filter",
4
+    "filter": "Search",
5 5
     "all": "All",
6 6
     "new": "New",
7 7
     "refresh": "Refresh",
@@ -10,6 +10,7 @@
10 10
     "never": "Never",
11 11
     "delete": "Delete",
12 12
     "edit": "Edit",
13
+    "editDialog": "Fast edit",
13 14
     "submit": "Submit",
14 15
     "menu": "Menu",
15 16
     "cancel": "Cancel",
@@ -18,7 +19,13 @@
18 19
     "view": "View",
19 20
     "save": "Save",
20 21
     "back": "Back",
22
+    "yes": "yes",
23
+    "unsavedChanged": "Unsaved data",
21 24
     "confirmDelete": "Confirm deletion",
25
+    "confirmExit": {
26
+      "title": "Unsaved data",
27
+      "content": "Do you really ant to leave without saving?"
28
+    },
22 29
     "pagination": {
23 30
       "of": "of",
24 31
       "page": "Page:",
@@ -29,20 +36,20 @@
29 36
     "updateDetected": {
30 37
       "title": "Update detected",
31 38
       "text": "The server has been updated from version {oldVersion} to {newVersion}.\nPlease perform a full refresh by pressing Ctrl+F5 to load the new version.\nNot doing it may leads to undefined behaviors."
32
-    }
39
+    },
40
+    "createdAt": "Created at",
41
+    "updatedAt": "Updated at"
33 42
   },
34 43
   "home": {
35 44
     "name": "Home",
36 45
     "welcome": "Welcome Home!"
37 46
   },
38
-  "pkguid": {
47
+  "pkguids": {
39 48
     "name": "PkGuids",
40 49
     "selectedItems": "{count} {count, select, 1{PkGuid} other{PkGuids}} selected",
41 50
     "id": "Id",
42 51
     "someText": "Some Text",
43 52
     "someInt": "Some Int",
44
-    "createdAt": "Created At",
45
-    "updatedAt": "Updated At",
46 53
     "deleteOne": "Do you really want to delete PkGuid '{text}'?",
47 54
     "deleteMultiple": "Do you really want to delete {count} {count, select, 1{PkGuid} other{PkGuids}}?",
48 55
     "edit": {

+ 0
- 86
app/views/pkguid.html View File

@@ -1,86 +0,0 @@
1
-<div layout="column" layout-fill layout-align="top" angular-busy="appUtils.cgBusy('pkguid.table')">
2
-
3
-    <div flex>
4
-        <md-toolbar class="md-table-toolbar md-default" ng-show="!isFilterShown && selected.length == 0">
5
-            <div class="md-toolbar-tools">
6
-                <span>{{ 'pkguid.name' | translate }}</span>
7
-                <span flex></span>
8
-                <md-button class="md-icon-button" ng-click="showFilter(true)" title="{{ 'common.filter' | translate }}">
9
-                    <md-icon class="material-icons">filter_list</md-icon>
10
-                </md-button>
11
-                <md-button class="md-icon-button" ui-sref="pkguid_add" title="{{ 'common.new' | translate }}">
12
-                    <md-icon class="material-icons">add</md-icon>
13
-                </md-button>
14
-                <md-button class="md-icon-button" ng-click="getPkGuids()" title="{{ 'common.refresh' | translate }}">
15
-                    <md-icon class="material-icons">refresh</md-icon>
16
-                </md-button>
17
-            </div>
18
-        </md-toolbar>
19
-        <md-toolbar class="md-table-toolbar md-default" ng-show="isFilterShown && selected.length == 0">
20
-            <div class="md-toolbar-tools">
21
-                <md-icon class="material-icons">search</md-icon>
22
-                <form autocomplete="off">
23
-                    <md-input-container class="md-block" flex-gt-sm>
24
-                        <label>{{ 'common.filter' | translate }}</label>
25
-                        <input type="text" ng-model="query.filter" ng-model-options="{debounce: 500}" ng-change="getPkGuids()">
26
-                    </md-input-container>
27
-
28
-                </form>
29
-                <md-button class="md-icon-button" ng-click="showFilter(false)" title="{{ 'common.close' | translate }}">
30
-                    <md-icon class="material-icons">close</md-icon>
31
-                </md-button>
32
-            </div>
33
-        </md-toolbar>
34
-        <md-toolbar class="md-table-toolbar alternate" ng-show="selected.length > 0">
35
-            <div class="md-toolbar-tools">
36
-                <span>{{ 'pkguid.selectedItems' | translate:{count:selected.length} }}</span>
37
-                <span flex></span>
38
-                <md-button class="md-icon-button" ng-click="askRemoveSelected()" title="{{ 'common.delete' | translate }}">
39
-                    <md-icon class="material-icons">delete</md-icon>
40
-                </md-button>
41
-            </div>
42
-        </md-toolbar>
43
-    </div>
44
-
45
-    <div flex>
46
-        <md-table-container>
47
-            <table md-table md-row-select multiple ng-model="selected" >
48
-                <thead md-head md-order="query.order" md-on-reorder="getPkGuids">
49
-                <tr md-row>
50
-                    <th md-column md-order-by="id"><span>{{ 'pkguid.id' | translate }}</span></th>
51
-                    <th md-column md-order-by="someText"><span>{{ 'pkguid.someText' | translate }}</span></th>
52
-                    <th md-column md-order-by="someInt" md-numeric>{{ 'pkguid.someInt' | translate }}</th>
53
-                    <th md-column md-order-by="createdAt">{{ 'pkguid.createdAt' | translate }}</th>
54
-                    <th md-column md-order-by="updatedAt">{{ 'pkguid.updatedAt' | translate }}</th>
55
-                    <th md-column>{{ 'common.actions' | translate }}</th>
56
-                </tr>
57
-                </thead>
58
-                <tbody md-body>
59
-                <tr md-row md-select="item" md-select-id="id" ng-repeat="item in pkGuids.data">
60
-                    <td md-cell>{{item.id}}</td>
61
-                    <td md-cell>{{item.someText}}</td>
62
-                    <td md-cell>{{item.someInt}}</td>
63
-                    <td md-cell>{{item.createdAt | date : 'medium'}}</td>
64
-                    <td md-cell>{{item.updatedAt == null ? ('common.never' | translate ) : (item.updatedAt | date : 'medium')}}</td>
65
-                    <td md-cell>
66
-                        <md-button class="md-icon-button" ui-sref="pkguid_edit({id: item.id, pkguid: item})" title="{{ 'common.edit' | translate }}">
67
-                            <md-icon class="material-icons">mode_edit</md-icon>
68
-                        </md-button>
69
-                        <md-button class="md-icon-button" ng-click="askRemoveOne(item)" title="{{ 'common.delete' | translate }}">
70
-                            <md-icon class="material-icons">delete</md-icon>
71
-                        </md-button>
72
-                    </td>
73
-                </tr>
74
-                </tbody>
75
-            </table>
76
-        </md-table-container>
77
-    </div>
78
-
79
-    <md-table-pagination md-label="{{appUtils.mdTableLabels()}}" class="col-xs-11" md-limit="query.limit" md-limit-options="[5, 10, 15]"
80
-                         md-page="query.page" md-total="{{pkGuids.count}}" md-on-paginate="getPkGuids" md-page-select></md-table-pagination>
81
-
82
-    <div ng-repeat="error in busy.errors('pkguid.table')" class="isa_error">
83
-        <i class="fa fa-times-circle"></i>
84
-        {{ error.data.message }}
85
-    </div>
86
-</div>

+ 0
- 40
app/views/pkguidedit.html View File

@@ -1,40 +0,0 @@
1
-<div layout="column" ng-cloak class="md-inline-form" angular-busy="appUtils.cgBusy('pkguid.edit')">
2
-    <div flex>
3
-
4
-        <md-toolbar class="md-table-toolbar md-default" >
5
-            <div class="md-toolbar-tools">
6
-                <md-button class="md-icon-button" ui-sref="pkguid" title="{{ 'common.back' | translate }}">
7
-                    <md-icon class="material-icons">arrow_back</md-icon>
8
-                </md-button>
9
-                <span>{{ 'pkguid.name' | translate:{count:selected.length} }}</span>
10
-                <span flex></span>
11
-                <md-button class="md-icon-button" ng-show="pkguid.id != null" ng-click="askRemoveOne(pkguid)" title="{{ 'common.delete' | translate }}">
12
-                    <md-icon class="material-icons">delete</md-icon>
13
-                </md-button>
14
-            </div>
15
-        </md-toolbar>
16
-    </div>
17
-    <md-content layout-padding>
18
-        <form name="editForm">
19
-            <div layout-gt-sm="row">
20
-                <md-input-container class="md-block" flex-gt-sm>
21
-                    <label>{{ 'pkguid.someText' | translate }}</label>
22
-                    <input required ng-model="pkguid.someText">
23
-                </md-input-container>
24
-
25
-                <md-input-container class="md-block" flex-gt-sm>
26
-                    <label>{{ 'pkguid.someInt' | translate }}</label>
27
-                    <input required type="number" ng-model="pkguid.someInt">
28
-                </md-input-container>
29
-            </div>
30
-            <div flex>
31
-                <md-progress-linear ng-disabled="!running" md-mode="indeterminate"></md-progress-linear>
32
-            </div>
33
-            <md-button class="md-raised md-primary" type="submit" ng-click="!editForm.$invalid && submit()">{{ 'common.save' | translate }}</md-button>
34
-            <div ng-repeat="error in busy.errors('pkguid.edit')" class="isa_error">
35
-                <i class="fa fa-times-circle"></i>
36
-                {{ error.data.message }}
37
-            </div>
38
-        </form>
39
-    </md-content>
40
-</div>

+ 116
- 0
app/views/pkguids.html View File

@@ -0,0 +1,116 @@
1
+<div layout="column" layout-fill layout-align="top" angular-busy="appUtils.cgBusy(itemType + '.table')">
2
+
3
+    <div flex>
4
+        <md-toolbar class="md-table-toolbar md-default" ng-show="isModal || (!isFilterShown && selected.length == 0)">
5
+            <div class="md-toolbar-tools">
6
+                <span>{{ itemType + '.name' | translate }}</span>
7
+                <span flex></span>
8
+                <md-button ng-show="isModal && items != null" class="md-icon-button" ng-click="addItemDialog()" title="{{ 'common.new' | translate }}">
9
+                    <md-icon class="material-icons">add</md-icon>
10
+                </md-button>
11
+                <md-button ng-show="!isModal" class="md-icon-button" ui-sref="{{itemType}}_add" title="{{ 'common.new' | translate }}">
12
+                    <md-icon class="material-icons">add</md-icon>
13
+                </md-button>
14
+                <md-button ng-show="!isModal" class="md-icon-button" ng-click="showFilter(true)" title="{{ 'common.filter' | translate }}">
15
+                    <md-icon class="material-icons">search</md-icon>
16
+                </md-button>
17
+                <md-button ng-show="!isModal" class="md-icon-button" ng-click="getItems()" title="{{ 'common.refresh' | translate }}">
18
+                    <md-icon class="material-icons">refresh</md-icon>
19
+                </md-button>
20
+            </div>
21
+        </md-toolbar>
22
+        <md-toolbar class="md-table-toolbar md-default" ng-show="isModal || (isFilterShown && selected.length == 0)">
23
+            <div class="md-toolbar-tools">
24
+                <md-icon class="material-icons">search</md-icon>
25
+                <form autocomplete="off">
26
+                    <md-input-container class="md-block" flex-gt-sm>
27
+                        <label>{{ 'common.filter' | translate }}</label>
28
+                        <input type="text" ng-model="query.filter" ng-model-options="{debounce: 500}" ng-change="getItems()">
29
+                    </md-input-container>
30
+
31
+                </form>
32
+                <md-button ng-show="!isModal" class="md-icon-button" ng-click="showFilter(false)" title="{{ 'common.close' | translate }}">
33
+                    <md-icon class="material-icons">close</md-icon>
34
+                </md-button>
35
+                <md-button class="md-icon-button" ng-click="getItems()" title="{{ 'common.refresh' | translate }}">
36
+                    <md-icon class="material-icons">refresh</md-icon>
37
+                </md-button>
38
+            </div>
39
+        </md-toolbar>
40
+        <md-toolbar class="md-table-toolbar alternate" ng-show="selected.length > 0">
41
+            <div class="md-toolbar-tools">
42
+                <span>{{ itemType + '.selectedItems' | translate:{count:selected.length} }}</span>
43
+                <span flex></span>
44
+                <md-button class="md-icon-button" ng-click="askRemoveSelected()" title="{{ 'common.delete' | translate }}">
45
+                    <md-icon class="material-icons">delete</md-icon>
46
+                </md-button>
47
+            </div>
48
+        </md-toolbar>
49
+    </div>
50
+
51
+    <div flex>
52
+        <md-table-container>
53
+            <table md-table md-row-select multiple ng-model="selected" >
54
+                <thead md-head md-order="query.order" md-on-reorder="getItems">
55
+                <tr md-row>
56
+                    <th md-column md-order-by="id"><span>{{ itemType + '.id' | translate }}</span></th>
57
+                    <th md-column md-order-by="someText"><span>{{ itemType + '.someText' | translate }}</span></th>
58
+                    <th md-column md-order-by="someInt" md-numeric>{{ itemType + '.someInt' | translate }}</th>
59
+                    <th md-column md-order-by="createdAt">{{ 'common.createdAt' | translate }}</th>
60
+                    <th md-column md-order-by="updatedAt">{{ 'common.updatedAt' | translate }}</th>
61
+                    <th class="col-icon-1" md-column>{{ 'common.actions' | translate }}</th>
62
+                </tr>
63
+                </thead>
64
+                <tbody md-body>
65
+                <tr md-row md-select="item" md-select-id="id" ng-repeat="item in items.data">
66
+                    <td md-cell>{{item.id}}</td>
67
+                    <td md-cell>{{item.someText}}</td>
68
+                    <td md-cell>{{item.someInt}}</td>
69
+                    <td md-cell>{{item.createdAt | formatDateTime}}</td>
70
+                    <td md-cell>{{item.updatedAt == null ? ('common.never' | translate ) : (item.updatedAt | formatDateTime)}}</td>
71
+                    <td class="col-icon-1" md-cell>
72
+                        <md-menu ng-show="!isModal">
73
+                            <md-button class="md-icon-button" ng-click="$mdOpenMenu($event)">
74
+                                <md-icon class="material-icons">more_vert</md-icon>
75
+                            </md-button>
76
+                            <md-menu-content>
77
+                                <md-menu-item>
78
+                                    <md-button ui-sref="{{itemType}}_edit({id: item.id, item: item})">
79
+                                        <md-icon class="material-icons">mode_edit</md-icon>
80
+                                        {{ 'common.edit' | translate }}
81
+                                    </md-button>
82
+                                </md-menu-item>
83
+                                <md-menu-item>
84
+                                    <md-button ng-click="editItem(item)">
85
+                                        <md-icon class="material-icons">border_color</md-icon>
86
+                                        {{ 'common.editDialog' | translate }}
87
+                                    </md-button>
88
+                                </md-menu-item>
89
+                                <md-menu-divider></md-menu-divider>
90
+                                <md-menu-item>
91
+                                    <md-button ng-click="askRemoveOne(item)">
92
+                                        <md-icon class="material-icons">delete</md-icon>
93
+                                        {{ 'common.delete' | translate }}
94
+                                    </md-button>
95
+                                </md-menu-item>
96
+                            </md-menu-content>
97
+                        </md-menu>
98
+
99
+                        <md-button ng-show="isModal" class="md-icon-button" ng-click="selectItem(item)" title="{{ 'common.select' | translate }}">
100
+                            <md-icon class="material-icons">done</md-icon>
101
+                        </md-button>
102
+                    </td>
103
+                </tr>
104
+                </tbody>
105
+            </table>
106
+        </md-table-container>
107
+    </div>
108
+
109
+    <md-table-pagination md-label="{{appUtils.mdTableLabels()}}" class="col-xs-11" md-limit="query.limit" md-limit-options="[5, 10, 20]"
110
+                         md-page="query.page" md-total="{{items.count}}" md-on-paginate="getItems" md-page-select></md-table-pagination>
111
+
112
+    <div ng-repeat="error in busy.errors('intra.' + itemType + '.table')" class="isa_error">
113
+        <i class="fa fa-times-circle"></i>
114
+        {{ error.data.message }}
115
+    </div>
116
+</div>

+ 50
- 0
app/views/pkguidsedit.html View File

@@ -0,0 +1,50 @@
1
+<div layout="column" ng-cloak class="md-inline-form" angular-busy="appUtils.cgBusy(itemType + '.edit')">
2
+    <md-toolbar class="md-table-toolbar md-default" >
3
+        <div class="md-toolbar-tools">
4
+            <md-button ng-show="!isModal" class="md-icon-button" ng-click="cancel()" title="{{ 'common.back' | translate }}">
5
+                <md-icon class="material-icons">arrow_back</md-icon>
6
+            </md-button>
7
+            <span>{{ isModal ? title : (itemType + '.name' | translate:{count:selected.length}) }}</span>
8
+            <span class="has-changed-warning" ng-show="hasChanged()">
9
+                <md-icon title="{{ 'common.unsavedChanged' | translate }}" class="material-icons">warning</md-icon>
10
+            </span>
11
+            <span flex></span>
12
+            <md-button class="md-icon-button" ng-show="item.id != null && !isModal" ng-click="askRemoveOne(item)" title="{{ 'common.delete' | translate }}">
13
+                <md-icon class="material-icons">delete</md-icon>
14
+            </md-button>
15
+        </div>
16
+    </md-toolbar>
17
+    <md-content layout-padding>
18
+        <form name="editForm">
19
+            <div layout-gt-sm="row">
20
+                <md-input-container class="md-block" flex-gt-sm>
21
+                    <label>{{ itemType + '.someText' | translate }}</label>
22
+                    <input required ng-model="item.someText">
23
+                </md-input-container>
24
+
25
+                <md-input-container class="md-block" flex-gt-sm>
26
+                    <label>{{ itemType + '.someInt' | translate }}</label>
27
+                    <input required type="number" ng-model="item.someInt">
28
+                </md-input-container>
29
+            </div>
30
+            <div flex>
31
+                <md-progress-linear ng-disabled="!running" md-mode="indeterminate"></md-progress-linear>
32
+            </div>
33
+            <div flex layout-gt-sm="row" layout-align=" center">
34
+                <div layout="column">
35
+                    <span class="md-caption" ng-show="item.createdAt != null">{{ 'common.createdAt' | translate }} {{ item.createdAt | formatDateTime }}</span>
36
+                    <span class="md-caption" ng-show="item.updatedAt != null">{{ 'common.updatedAt' | translate }} {{ item.updatedAt | formatDateTime }}</span>
37
+                </div>
38
+                <span flex></span>
39
+                <div>
40
+                    <md-button ng-show="isModal" class="md-raised" type="button" ng-click="cancel()">{{ 'common.cancel' | translate }}</md-button>
41
+                    <md-button class="md-raised md-primary" type="submit" ng-click="!editForm.$invalid && submit()">{{ 'common.save' | translate }}</md-button>
42
+                </div>
43
+            </div>
44
+            <div ng-repeat="error in busy.errors(itemType + '.edit')" class="isa_error">
45
+                <i class="fa fa-times-circle"></i>
46
+                {{ error.data.message }}
47
+            </div>
48
+        </form>
49
+    </md-content>
50
+</div>

+ 3
- 2
bower.json View File

@@ -20,9 +20,10 @@
20 20
     "angular-translate-loader-static-files": "^2.13.1",
21 21
     "angular-translate-interpolation-messageformat": "^2.13.1",
22 22
     "angular-busy2": "^5.2.0",
23
-    "luticate2-utils": "https://git.rthoni.com/luticate2/front-utils.git#develop",
23
+    "luticate2-utils": "https://git.rthoni.com/luticate2/front-utils.git#0.5.x",
24 24
     "angular-signalr-hub": "^1.6.2",
25
-    "signalr": "^2.2.1"
25
+    "signalr": "^2.2.1",
26
+    "angular-moment": "^1.0.1"
26 27
   },
27 28
   "resolutions": {
28 29
     "angular": "1.6.x",

+ 0
- 0
sdk/.gitkeep View File


+ 0
- 0
sdk/Business/.gitkeep View File


+ 8
- 0
sdk/Business/apputils.business.js View File

@@ -11,6 +11,8 @@
11 11
 
12 12
             var AppUtilsBusiness = {};
13 13
 
14
+            AppUtilsBusiness.toolbarTitle = null;
15
+
14 16
             AppUtilsBusiness.convertOrderBy = function(orderBy)
15 17
             {
16 18
                 if (orderBy[0] == '-') {
@@ -29,9 +31,15 @@
29 31
 
30 32
             AppUtilsBusiness.setToolbarTitle = function(title)
31 33
             {
34
+                AppUtilsBusiness.toolbarTitle = title;
32 35
                 $rootScope.$emit('toolbar.title', {title: title});
33 36
             };
34 37
 
38
+            AppUtilsBusiness.getToolbarTitle = function()
39
+            {
40
+                return AppUtilsBusiness.toolbarTitle;
41
+            };
42
+
35 43
             AppUtilsBusiness.mdTableLabels = function()
36 44
             {
37 45
                 return {

+ 80
- 0
sdk/Business/dateUtils.business.js View File

@@ -0,0 +1,80 @@
1
+/**
2
+ * Created by robin on 12/29/16.
3
+ */
4
+
5
+(function () {
6
+    'use strict';
7
+
8
+    angular.module('appSdk')
9
+        .factory('DateUtilsBusiness', [
10
+            function() {
11
+
12
+                var DateUtilsBusiness = {};
13
+                var dateFormat = 'DD MMM YYYY'; //TODO
14
+                var timeFormat = 'HH[h]mm'; //TODO
15
+                var dateTimeFormat = dateFormat + ' ' + timeFormat; //TODO
16
+
17
+                DateUtilsBusiness.areSameDates = function(date1, date2)
18
+                {
19
+                    if (date1 == null || date2 == null) {
20
+                        return date1 == date2;
21
+                    }
22
+                    return date1.getTime() == date2.getTime();
23
+                };
24
+
25
+                DateUtilsBusiness.format = function (date, format) {
26
+                    if (date == null) {
27
+                        return null;
28
+                    }
29
+                    return moment(date).format(format);
30
+                };
31
+
32
+                DateUtilsBusiness.formatDate = function(date)
33
+                {
34
+                    return DateUtilsBusiness.format(date, dateFormat);
35
+                };
36
+
37
+                DateUtilsBusiness.formatTime = function(date)
38
+                {
39
+                    return DateUtilsBusiness.format(date, timeFormat);
40
+                };
41
+
42
+                DateUtilsBusiness.formatDateTime = function(date)
43
+                {
44
+                    return DateUtilsBusiness.format(date, dateTimeFormat);
45
+                };
46
+
47
+                DateUtilsBusiness.parse = function(date, format, strict)
48
+                {
49
+                    if (date == null) {
50
+                        return null;
51
+                    }
52
+                    if (strict == null) {
53
+                        strict = true;
54
+                    }
55
+                    var d = moment(date, format, strict);
56
+                    if (d.isValid()) {
57
+                        return d.toDate();
58
+                    }
59
+                    return null;
60
+                };
61
+
62
+                DateUtilsBusiness.parseDate = function(date, strict)
63
+                {
64
+                    return DateUtilsBusiness.parse(date, dateFormat, strict);
65
+                };
66
+
67
+                DateUtilsBusiness.parseTime = function(date, strict)
68
+                {
69
+                    return DateUtilsBusiness.parse(date, timeFormat, strict);
70
+                };
71
+
72
+                DateUtilsBusiness.parseDateTime = function(date, strict)
73
+                {
74
+                    return DateUtilsBusiness.parse(date, dateTimeFormat, strict);
75
+                };
76
+
77
+
78
+                return DateUtilsBusiness;
79
+            }]);
80
+})();

+ 292
- 0
sdk/Business/editcontrollerbuilder.business.js View File

@@ -0,0 +1,292 @@
1
+/**
2
+ * Created by robin on 12/15/16.
3
+ */
4
+
5
+(function () {
6
+    'use strict';
7
+
8
+    angular.module('appSdk')
9
+        .factory('editControllerBuilder', ['luBusyBusiness', 'AppUtilsBusiness', '$transitions',
10
+            'ItemsBusiness', 'itemTracker', '$state', '$q', '$mdDialog',
11
+            function (luBusyBusiness, AppUtilsBusiness, $transitions,
12
+                      ItemsBusiness, itemTracker, $state, $q, $mdDialog) {
13
+
14
+                var EditControllerBuilder = {};
15
+
16
+                EditControllerBuilder.create = function ($scope, $stateParams) {
17
+
18
+                    $scope.busy = luBusyBusiness.reset();
19
+                    $scope.appUtils = AppUtilsBusiness;
20
+
21
+                    $scope.isModal = $stateParams.isModal != null && $stateParams.isModal;
22
+
23
+                    $scope.defaultItem = $scope.business.initDbo({});
24
+                    $scope.title = null;
25
+                    $scope.item = null;
26
+
27
+                    if ($scope.onSubmit == undefined) {
28
+                        $scope.onSubmit = null;
29
+                    }
30
+                    if ($scope.onItemChanged == undefined) {
31
+                        $scope.onItemChanged = null;
32
+                    }
33
+
34
+                    $scope.watches = {};
35
+
36
+                    $scope.itemTracker = itemTracker.create(function(item)
37
+                    {
38
+                        $scope.item = item;
39
+                        $scope.setTitle();
40
+                        if ($scope.onItemChanged != null) {
41
+                            $scope.onItemChanged();
42
+                        }
43
+                    });
44
+
45
+                    $scope.hasChanged = function()
46
+                    {
47
+                        return $scope.itemTracker.hasChanged();
48
+                    };
49
+
50
+                    $scope.unwatchSaved = function(fieldId, fieldObj) {
51
+                        var k = fieldId  + ',' + fieldObj;
52
+                        if ($scope.watches[k] != null) {
53
+                            $scope.watches[k]();
54
+                            delete $scope.watches[k];
55
+                        }
56
+                    };
57
+
58
+                    $scope.saveWatch = function(fieldId, fieldObj, unwatch) {
59
+                        var k = fieldId  + ',' + fieldObj;
60
+                        $scope.watches[k] = unwatch;
61
+                    };
62
+
63
+                    $scope.unwatchId = function(fieldId, fieldObj) {
64
+                        $scope.unwatchSaved(fieldId, fieldObj);
65
+                    };
66
+
67
+                    $scope.watchId = function(fieldId, fieldObj)
68
+                    {
69
+                        $scope.unwatchId(fieldId, fieldObj);
70
+                        var unwatch = $scope.$watch(function()
71
+                        {
72
+                            return $scope.item == null || $scope.item[fieldObj] == null ? null : $scope.item[fieldObj].id;
73
+                        }, function (newValue, oldValue) {
74
+                            if (newValue != oldValue && $scope.item != null) {
75
+                                $scope.item[fieldId] = newValue;
76
+                            }
77
+                        });
78
+                        $scope.saveWatch(fieldId, fieldObj, unwatch);
79
+                    };
80
+
81
+                    $scope.unwatchIds = function(fieldIds, fieldObjs) {
82
+                        $scope.unwatchSaved(fieldIds, fieldObjs);
83
+                    };
84
+
85
+                    $scope.watchIds = function(fieldIds, fieldObjs)
86
+                    {
87
+                        $scope.unwatchIds(fieldIds, fieldObjs);
88
+                        var unwatch = $scope.$watchCollection(function()
89
+                        {
90
+                            return $scope.item == null || $scope.item[fieldObjs] == null ? null : $scope.item[fieldObjs];
91
+                        }, function (newValue, oldValue) {
92
+                            if ($scope.item == null != null && (newValue != null || oldValue != null)) {
93
+                                if (newValue == null) {
94
+                                    $scope.item[fieldIds] = null;
95
+                                }
96
+                                else {
97
+                                    $scope.item[fieldIds] = newValue.map(function(item)
98
+                                    {
99
+                                        return item.id;
100
+                                    });
101
+                                }
102
+                            }
103
+                        });
104
+                        $scope.saveWatch(fieldIds, fieldObjs, unwatch);
105
+                    };
106
+
107
+                    $scope.removeListItem = function(list, index)
108
+                    {
109
+                        $scope.item[list].splice(index, 1);
110
+                    };
111
+
112
+                    $scope.editItem = function(item)
113
+                    {
114
+                        ItemsBusiness.editDialog(item, true).then(function(data) {}, function (error) {});
115
+                    };
116
+
117
+                    $scope.addItem = function(type, listObj)
118
+                    {
119
+                        ItemsBusiness.addDialog(type).then(function(data)
120
+                        {
121
+                            $scope.item[listObj].push(data);
122
+                        }, function(error) {});
123
+                    };
124
+
125
+                    $scope.pickItem = function(type, listObj)
126
+                    {
127
+                        ItemsBusiness.pickDialog(type).then(function(data)
128
+                        {
129
+                            $scope.item[listObj].push(data);
130
+                        }, function(error) {});
131
+                    };
132
+
133
+                    $scope.convertList = function(listObj, listIds)
134
+                    {
135
+                        $scope.item[listIds] = $scope.item[listObj].map(function(item)
136
+                        {
137
+                            return item.id;
138
+                        });
139
+                    };
140
+
141
+                    $scope.askRemoveOne = function (item) {
142
+                        ItemsBusiness.deleteDialog(item, $scope.itemType + '.edit').then(function(data)
143
+                        {
144
+                            $state.go($scope.itemType);
145
+                        }, function(error) {});
146
+                    };
147
+
148
+                    $scope.loadArray = function(ids, objects, loader)
149
+                    {
150
+                        var objs = [];
151
+                        for (var i = 0; i < $scope.item[ids].length; ++i) {
152
+                            (function(a) {
153
+                                var obj = $scope.item[objects].find(function (item) {
154
+                                    return item.id == $scope.item[ids][a];
155
+                                });
156
+                                if (obj == null) {
157
+                                    objs.push(null);
158
+                                    loader($scope.item[ids][a]).then(function (data) {
159
+                                        objs[a] = data;
160
+                                        var idx = objs.findIndex(function (item) {
161
+                                            return item == null;
162
+                                        });
163
+                                        if (idx == -1) {
164
+                                            $scope.item[objects] = objs;
165
+                                            $scope.itemTracker.setItem($scope.item);
166
+                                        }
167
+                                    }, function (error) {
168
+                                    });
169
+                                }
170
+                                else {
171
+                                    objs.push(obj);
172
+                                }
173
+                            })(i);
174
+                        }
175
+                    };
176
+
177
+                    $scope.cancel = function()
178
+                    {
179
+                        if ($scope.isModal) {
180
+                            $scope.itemTracker.mayAskExitConfirm().then(function()
181
+                            {
182
+                                $mdDialog.cancel();
183
+                            }, function (error) {});
184
+                        }
185
+                        else {
186
+                            $state.go($scope.itemType);
187
+                        }
188
+                    };
189
+
190
+                    $scope.setTitle = function()
191
+                    {
192
+                        if ($scope.item != null && $scope.item.id != null) {
193
+                            var text = $scope.item.toString();
194
+                            $scope.title = AppUtilsBusiness.tr($scope.itemType + '.edit.title', {text: text});
195
+                            if (!$scope.isModal) {
196
+                                AppUtilsBusiness.setTitle($scope.title);
197
+                                AppUtilsBusiness.setToolbarTitle(AppUtilsBusiness.tr($scope.itemType + '.edit.toolbarTitle', {text: text}));
198
+                            }
199
+                        }
200
+                        else {
201
+                            if ($scope.isModal) {
202
+                                $scope.title = AppUtilsBusiness.tr($scope.itemType + '.add.defaultTitle');
203
+                            }
204
+                        }
205
+                    };
206
+
207
+                    $scope.setupExitConfirm = function()
208
+                    {
209
+                        var onTransitionStartOff = $transitions.onStart({}, function ($transitions) {
210
+                            if ($scope.itemTracker.hasChanged()) {
211
+                                $scope.itemTracker.askExitConfirm().then(function () {
212
+                                    onTransitionStartOff();
213
+                                    var toState = $transitions.$to();
214
+                                    var params = $transitions.params('to');
215
+                                    var options = $transitions.options();
216
+                                    $state.go(toState, params, options);
217
+                                }, function () {
218
+                                });
219
+                                return $q.reject(null);
220
+                            }
221
+                            onTransitionStartOff();
222
+                        });
223
+                        $scope.$on('$destroy', function () {
224
+                            onTransitionStartOff();
225
+                        });
226
+                    };
227
+
228
+                    $scope.submit = function()
229
+                    {
230
+                        $scope._submit($scope.item)
231
+                    };
232
+
233
+                    $scope._submit = function (item) {
234
+                        if ($scope.onSubmit != null) {
235
+                            $scope.onSubmit(item);
236
+                        }
237
+
238
+                        if (item.id == null) {
239
+                            $scope.business.addDbo(item, $scope.itemType + '.edit').then(function (data) {
240
+                                $scope.itemTracker.setItem(data);
241
+
242
+                                if ($scope.isModal) {
243
+                                    $mdDialog.hide(data);
244
+                                }
245
+                                else {
246
+                                    $state.go($scope.itemType);
247
+                                }
248
+                            }, function (error) {});
249
+                        }
250
+                        else {
251
+                            $scope.business.editSingleByIdDbo(item.id, item, $scope.itemType + '.edit').then(function (data) {
252
+                                $scope.itemTracker.setItem(data);
253
+                                if ($scope.isModal) {
254
+                                    $mdDialog.hide(data);
255
+                                }
256
+                            }, function (error) {});
257
+                        }
258
+                    };
259
+
260
+                    $scope.init = function($stateParams, customInit)
261
+                    {
262
+                        if ($stateParams != null) {
263
+                            var item = $stateParams.item;
264
+                            if (item != null) {
265
+                                if (item._itemType == $scope.itemType || item._itemType == null) {
266
+                                    $scope.itemTracker.setItem($scope.business.initDbo(item));
267
+                                }
268
+                                else if (customInit != null) {
269
+                                    customInit(item);
270
+                                }
271
+                            }
272
+                            else if ($stateParams.id != null) {
273
+                                $scope.business.getSingleById($stateParams.id, $scope.itemType + '.edit').then(function(data)
274
+                                {
275
+                                    $scope.itemTracker.setItem(data);
276
+                                }, function (error) {
277
+                                    $scope.itemTracker.setItem(null);
278
+                                });
279
+                            }
280
+                            else {
281
+                                $scope.itemTracker.setItem(angular.copy($scope.defaultItem));
282
+                            }
283
+                        }
284
+                        else {
285
+                            $scope.itemTracker.setItem(angular.copy($scope.defaultItem));
286
+                        }
287
+                    };
288
+                };
289
+
290
+                return EditControllerBuilder;
291
+            }]);
292
+})();

+ 56
- 0
sdk/Business/itemTracker.business.js View File

@@ -0,0 +1,56 @@
1
+/**
2
+ * Created by robin on 12/29/16.
3
+ */
4
+
5
+(function () {
6
+    'use strict';
7
+
8
+    angular.module('appSdk')
9
+        .factory('itemTracker', ['$q', '$mdDialog', 'AppUtilsBusiness',
10
+            function($q, $mdDialog, AppUtilsBusiness) {
11
+
12
+                var itemTrackerBuilder = {};
13
+
14
+                itemTrackerBuilder.create = function(callback) {
15
+                    var itemTracker = {};
16
+
17
+                    itemTracker.item = null;
18
+                    itemTracker.savedItem = null;
19
+
20
+                    itemTracker.setItem = function (item) {
21
+                        itemTracker.savedItem = angular.copy(item);
22
+                        itemTracker.item = item;
23
+                        if (callback) {
24
+                            callback(item);
25
+                        }
26
+                    };
27
+
28
+                    itemTracker.hasChanged = function () {
29
+                        return (itemTracker.savedItem != null && itemTracker.savedItem.id == null) || !angular.equals(itemTracker.item, itemTracker.savedItem);
30
+                    };
31
+
32
+                    itemTracker.askExitConfirm = function () {
33
+                        var confirm = $mdDialog.confirm()
34
+                            .title(AppUtilsBusiness.tr('common.confirmExit.title'))
35
+                            .textContent(AppUtilsBusiness.tr('common.confirmExit.content'))
36
+                            .ok(AppUtilsBusiness.tr('common.yes'))
37
+                            .cancel(AppUtilsBusiness.tr('common.cancel'));
38
+                        return $mdDialog.show(confirm);
39
+                    };
40
+
41
+                    itemTracker.mayAskExitConfirm = function () {
42
+                        if (itemTracker.hasChanged()) {
43
+                            return itemTracker.askExitConfirm();
44
+                        }
45
+                        else {
46
+                            var deferred = $q.defer();
47
+                            deferred.resolve(null);
48
+                            return deferred.promise;
49
+                        }
50
+                    };
51
+
52
+                    return itemTracker;
53
+                };
54
+                return itemTrackerBuilder;
55
+            }]);
56
+})();

+ 138
- 0
sdk/Business/items.business.js View File

@@ -0,0 +1,138 @@
1
+/**
2
+ * Created by robin on 12/15/16.
3
+ */
4
+
5
+(function () {
6
+    'use strict';
7
+
8
+    angular.module('appSdk')
9
+        .factory('ItemsBusiness', ['$mdDialog', '$q', '$injector', 'AppUtilsBusiness',
10
+            function ($mdDialog, $q, $injector, AppUtilsBusiness) {
11
+
12
+                var ItemsBusiness = {};
13
+
14
+                ItemsBusiness.extendDeep = function extendDeep(dst) {
15
+                    angular.forEach(arguments, function(obj) {
16
+                        if (obj !== dst) {
17
+                            angular.forEach(obj, function(value, key) {
18
+                                if (dst[key] && dst[key].constructor && dst[key].constructor === Object) {
19
+                                    extendDeep(dst[key], value);
20
+                                } else {
21
+                                    dst[key] = value;
22
+                                }
23
+                            });
24
+                        }
25
+                    });
26
+                    return dst;
27
+                };
28
+
29
+                ItemsBusiness.editDialog = function (item, updateItem) {
30
+                    var deferred = $q.defer();
31
+                    $mdDialog.show({
32
+                        controller: item._itemType + 'EditController',
33
+                        templateUrl: 'views/' + item._itemType + 'edit.html',
34
+                        clickOutsideToClose: false,
35
+                        escapeToClose: false,
36
+                        locals: {
37
+                            $stateParams: {
38
+                                item: angular.copy(item),
39
+                                id: item.id,
40
+                                isModal: true
41
+                            }
42
+                        }
43
+                    }).then(function(data)
44
+                    {
45
+                        if (updateItem) {
46
+                            ItemsBusiness.extendDeep(item, data);
47
+                        }
48
+                        deferred.resolve(data);
49
+                    }, deferred.reject);
50
+                    return deferred.promise;
51
+                };
52
+
53
+                ItemsBusiness.addDialog = function (itemType, defaultItem) {
54
+                    return $mdDialog.show({
55
+                        controller: itemType + 'EditController',
56
+                        templateUrl: 'views/' + itemType + 'edit.html',
57
+                        clickOutsideToClose: false,
58
+                        escapeToClose: false,
59
+                        locals: {
60
+                            $stateParams: {
61
+                                item: defaultItem,
62
+                                id: null,
63
+                                isModal: true
64
+                            }
65
+                        }
66
+                    });
67
+                };
68
+
69
+                ItemsBusiness.deleteConfirmDialog = function (item) {
70
+                    var confirm = $mdDialog.confirm()
71
+                        .title(AppUtilsBusiness.tr('common.confirmDelete'))
72
+                        .textContent(AppUtilsBusiness.tr(item._itemType + '.deleteOne', {text: item.toString()}))
73
+                        .ok(AppUtilsBusiness.tr('common.delete'))
74
+                        .cancel(AppUtilsBusiness.tr('common.cancel'));
75
+                    return $mdDialog.show(confirm);
76
+                };
77
+
78
+                ItemsBusiness.deleteDialog = function (item, luBusyGroups) {
79
+                    var deferred = $q.defer();
80
+                    ItemsBusiness.deleteConfirmDialog(item).then(function()
81
+                    {
82
+                        var business = $injector.get(item._itemType + 'Business');
83
+                        business.deleteDbo(item.id, luBusyGroups)
84
+                            .then(deferred.resolve, deferred.reject);
85
+                    }, deferred.reject);
86
+                    return deferred.promise;
87
+                };
88
+
89
+                ItemsBusiness.deleteMultipleConfirmDialog = function (items) {
90
+                    var confirm = $mdDialog.confirm()
91
+                        .title(AppUtilsBusiness.tr('common.confirmDelete'))
92
+                        .textContent(AppUtilsBusiness.tr(items[0]._itemType + '.deleteMultiple', {count: items.length}))
93
+                        .ok(AppUtilsBusiness.tr('common.delete'))
94
+                        .cancel(AppUtilsBusiness.tr('common.cancel'));
95
+                    return $mdDialog.show(confirm);
96
+                };
97
+
98
+                ItemsBusiness.deleteMultipleDialog = function (items, luBusyGroups) {
99
+                    var deferred = $q.defer();
100
+                    ItemsBusiness.deleteMultipleConfirmDialog(items).then(function()
101
+                    {
102
+                        var business = $injector.get(items[0]._itemType + 'Business');
103
+                        ItemsBusiness.deleteFirst(items, business, deferred, luBusyGroups);
104
+                    }, deferred.reject);
105
+                    return deferred.promise;
106
+                };
107
+
108
+                ItemsBusiness.deleteFirst = function(items, business, deferred, luBusyGroups) {
109
+                    if (items.length == 0) {
110
+                        deferred.resolve();
111
+                    }
112
+                    else {
113
+                        business.deleteDbo(items[0].id, luBusyGroups)
114
+                            .then(function(data)
115
+                            {
116
+                                items.splice(0, 1);
117
+                                ItemsBusiness.deleteFirst(items, business, deferred, luBusyGroups);
118
+                            }, deferred.reject);
119
+                    }
120
+                };
121
+
122
+                ItemsBusiness.pickDialog = function (itemType) {
123
+                    return $mdDialog.show({
124
+                        controller: itemType + 'Controller',
125
+                        templateUrl: 'views/' + itemType + '.html',
126
+                        clickOutsideToClose: true,
127
+                        escapeToClose: true,
128
+                        locals: {
129
+                            $stateParams: {
130
+                                isModal: true
131
+                            }
132
+                        }
133
+                    });
134
+                };
135
+
136
+                return ItemsBusiness;
137
+            }]);
138
+})();

+ 145
- 0
sdk/Business/listcontrollerbuilder.business.js View File

@@ -0,0 +1,145 @@
1
+/**
2
+ * Created by robin on 12/15/16.
3
+ */
4
+
5
+(function () {
6
+    'use strict';
7
+
8
+    angular.module('appSdk')
9
+        .factory('listControllerBuilder', ['luBusyBusiness', 'AppUtilsBusiness', '$transitions',
10
+            'ItemsBusiness', 'itemTracker', '$state', '$q', '$mdDialog',
11
+            function (luBusyBusiness, AppUtilsBusiness, $transitions,
12
+                      ItemsBusiness, itemTracker, $state, $q, $mdDialog) {
13
+
14
+                var EditControllerBuilder = {};
15
+
16
+                EditControllerBuilder.create = function ($scope, $stateParams) {
17
+
18
+                    $scope.busy = luBusyBusiness.reset();
19
+                    $scope.appUtils = AppUtilsBusiness;
20
+
21
+                    $scope.isModal = $stateParams.isModal != null && $stateParams.isModal;
22
+                    $scope.isFilterShown = false;
23
+
24
+                    $scope.defaultItem = $scope.business.initDbo({});
25
+                    $scope.items = null;
26
+                    $scope.selected = [];
27
+
28
+                    if ($scope.defaultOrder == null) {
29
+                        $scope.defaultOrder = undefined;
30
+                    }
31
+                    if (typeof defaultFilter !== 'function') {
32
+                        var defaultFilter = $scope.defaultFilter;
33
+                        if (defaultFilter == null) {
34
+                            defaultFilter = '';
35
+                        }
36
+                        $scope.defaultFilter = function () {
37
+                            return defaultFilter;
38
+                        };
39
+                    }
40
+                    if ($scope.defaultLimit == null) {
41
+                        $scope.defaultLimit = 20;
42
+                    }
43
+                    if ($scope.defaultPage == null) {
44
+                        $scope.defaultPage = 1;
45
+                    }
46
+
47
+                    $scope.query = {
48
+                        order: $scope.defaultOrder,
49
+                        filter: $scope.defaultFilter(),
50
+                        limit: $scope.defaultLimit,
51
+                        page: $scope.defaultPage
52
+                    };
53
+
54
+                    if ($scope.getAddItem == null) {
55
+                        $scope.getAddItem = function () {
56
+                            return null;
57
+                        };
58
+                    }
59
+
60
+                    $scope.showFilter = function(show) {
61
+                        $scope.isFilterShown = show;
62
+                        if (!$scope.isFilterShown) {
63
+                            var defaultFilter = $scope.defaultFilter();
64
+                            if ($scope.query.filter != defaultFilter) {
65
+                                $scope.query.filter = defaultFilter;
66
+                                $scope.getItems();
67
+                            }
68
+                        }
69
+                    };
70
+
71
+                    $scope.selectItem = function(item)
72
+                    {
73
+                        $mdDialog.hide(item);
74
+                    };
75
+
76
+                    $scope.addItemDialog = function()
77
+                    {
78
+                        var defaultItem = $scope.getAddItem();
79
+                        ItemsBusiness.addDialog($scope.itemType, defaultItem).then(function(data)
80
+                        {
81
+                            $mdDialog.hide(data);
82
+                        }, function (error) {
83
+                            $mdDialog.cancel(error);
84
+                        })
85
+                    };
86
+
87
+                    $scope.editItem = function(item)
88
+                    {
89
+                        ItemsBusiness.editDialog(item, true).then(function(data) {
90
+                            console.log(item, data);
91
+                        }, function (error) {});
92
+                    };
93
+
94
+                    $scope.askRemoveOne = function (item) {
95
+                        ItemsBusiness.deleteDialog(item, $scope.itemType + '.table').then(function(data)
96
+                        {
97
+                            $scope.getItems();
98
+                        }, function(error) {});
99
+                    };
100
+
101
+                    $scope.askRemoveSelected = function () {
102
+                        if ($scope.selected.length == 0) {
103
+                            return;
104
+                        }
105
+                        else if ($scope.selected.length == 1) {
106
+                            $scope.askRemoveOne($scope.selected[0]);
107
+                        }
108
+                        else {
109
+                            ItemsBusiness.deleteMultipleDialog($scope.selected, $scope.itemType + '.table')
110
+                                .then(function () {
111
+                                    $scope.getItems();
112
+                                }, function (error) {
113
+                                });
114
+                        }
115
+                    };
116
+
117
+                    $scope.getOrderBy = function(orderBy)
118
+                    {
119
+                        return orderBy;
120
+                    };
121
+
122
+                    $scope.getItems = function()
123
+                    {
124
+                        $scope.selected = [];
125
+                        var orderBy = AppUtilsBusiness.convertOrderBy($scope.query.order);
126
+                        $scope.business.getMultiple($scope.getOrderBy(orderBy), $scope.query.filter, $scope.query.page - 1, $scope.query.limit, $scope.itemType + '.table').then(function(data)
127
+                        {
128
+                            $scope.items = data;
129
+                        }, function(error)
130
+                        {
131
+                            $scope.items = null;
132
+                        });
133
+                    };
134
+
135
+                    $scope.init = function()
136
+                    {
137
+                        if (!$scope.isModal) {
138
+                            $scope.getItems();
139
+                        }
140
+                    };
141
+                };
142
+
143
+                return EditControllerBuilder;
144
+            }]);
145
+})();

+ 0
- 15
sdk/Business/pkguid.business.js View File

@@ -1,15 +0,0 @@
1
-/**
2
- * Created by robin on 12/12/16.
3
- */
4
-
5
-(function () {
6
-    'use strict';
7
-
8
-    angular.module('appSdk')
9
-        .factory('pkGuidBusiness', ['luWebApiCrudBusiness', 'pkGuidDataAccess', function (luWebApiCrudBusiness, pkGuidDataAccess) {
10
-
11
-            var Business = luWebApiCrudBusiness.create(pkGuidDataAccess);
12
-
13
-            return Business;
14
-        }]);
15
-})();

+ 15
- 0
sdk/Business/pkguids.business.js View File

@@ -0,0 +1,15 @@
1
+/**
2
+ * Created by robin on 12/12/16.
3
+ */
4
+
5
+(function () {
6
+    'use strict';
7
+
8
+    angular.module('appSdk')
9
+        .factory('pkguidsBusiness', ['luWebApiCrudBusiness', 'pkguidsDataAccess', function (luWebApiCrudBusiness, pkguidsDataAccess) {
10
+
11
+            var Business = luWebApiCrudBusiness.create(pkguidsDataAccess);
12
+
13
+            return Business;
14
+        }]);
15
+})();

+ 0
- 15
sdk/DataAccess/pkguid.dataaccess.js View File

@@ -1,15 +0,0 @@
1
-/**
2
- * Created by robin on 12/12/16.
3
- */
4
-
5
-(function () {
6
-    'use strict';
7
-
8
-    angular.module('appSdk')
9
-        .factory('pkGuidDataAccess', ['luWebApiCrudDataAccess', function (luWebApiCrudDataAccess) {
10
-
11
-            var DataAccess = luWebApiCrudDataAccess.create('/api/pkguid');
12
-
13
-            return DataAccess;
14
-        }]);
15
-})();

+ 27
- 0
sdk/DataAccess/pkguids.dataaccess.js View File

@@ -0,0 +1,27 @@
1
+/**
2
+ * Created by robin on 12/12/16.
3
+ */
4
+
5
+(function () {
6
+    'use strict';
7
+
8
+    angular.module('appSdk')
9
+        .factory('pkguidsDataAccess', ['luWebApiCrudDataAccess', function (luWebApiCrudDataAccess) {
10
+
11
+            var DataAccess = luWebApiCrudDataAccess.create('/api/pkguid');
12
+
13
+            DataAccess.defaultDbo = {
14
+                id: null,
15
+                someText: null,
16
+                someInt: null,
17
+                createdAt: null,
18
+                updatedAt: null,
19
+                _itemType: 'pkguids',
20
+                toString: function () {
21
+                    return (this.someText != '' && this.someText != null) ? this.someText : this.id;
22
+                }
23
+            };
24
+
25
+            return DataAccess;
26
+        }]);
27
+})();

Loading…
Cancel
Save