Explorar el Código

remove multiple

tags/v0.1.0
Robin Thoni hace 8 años
padre
commit
879cc430df
Se han modificado 2 ficheros con 63 adiciones y 15 borrados
  1. 51
    2
      app/controllers/pkguid.controller.js
  2. 12
    13
      app/views/pkguid.html

+ 51
- 2
app/controllers/pkguid.controller.js Ver fichero

@@ -1,6 +1,6 @@
1 1
 angular.module('app')
2
-    .controller('PkGuidController', ['$scope', 'pkGuidBusiness', 'AppUtilsBusiness',
3
-        function($scope, pkGuidBusiness, AppUtilsBusiness) {
2
+    .controller('PkGuidController', ['$scope', 'pkGuidBusiness', 'AppUtilsBusiness', '$mdDialog',
3
+        function($scope, pkGuidBusiness, AppUtilsBusiness, $mdDialog) {
4 4
 
5 5
             $scope.selected = [];
6 6
 
@@ -13,9 +13,58 @@ angular.module('app')
13 13
             $scope.pkGuids = null;
14 14
             $scope.error = null;
15 15
 
16
+            $scope.askRemoveOne = function (pkguid) {
17
+                var confirm = $mdDialog.confirm()
18
+                    .title('Confirm deletion')
19
+                    .textContent('Do you really want to delete PkGuid \'' + pkguid.someText + '\'?')
20
+                    .ok('Delete')
21
+                    .cancel('Cancel');
22
+                $mdDialog.show(confirm).then(function() {
23
+                    $scope.error = null;
24
+                    $scope.promise = pkGuidBusiness.deleteDbo(pkguid.id).then(function(data)
25
+                    {
26
+                        $scope.getPkGuids();
27
+                    }, function(error)
28
+                    {
29
+                        $scope.error = error;
30
+                    });
31
+                }, function () {});
32
+            };
33
+
34
+            $scope.askRemoveSelected = function () {
35
+                var confirm = $mdDialog.confirm()
36
+                    .title('Confirm deletion')
37
+                    .textContent('Do you really want to delete ' + $scope.selected.length + ' PkGuids?')
38
+                    .ok('Delete')
39
+                    .cancel('Cancel');
40
+                $mdDialog.show(confirm).then(function() {
41
+                    $scope.error = null;
42
+                    $scope.removeFirstSelected();
43
+
44
+                }, function () {});
45
+            };
46
+
47
+            $scope.removeFirstSelected = function() {
48
+                if ($scope.selected.length == 0) {
49
+                    $scope.getPkGuids();
50
+                }
51
+                else {
52
+                    pkGuidBusiness.deleteDbo($scope.selected[0].id)
53
+                        .then(function(data)
54
+                    {
55
+                        $scope.selected = $scope.selected.splice(1);
56
+                        $scope.removeFirstSelected();
57
+                    }, function(error)
58
+                    {
59
+                        $scope.error = error;
60
+                    });
61
+                }
62
+            };
63
+
16 64
             $scope.getPkGuids = function()
17 65
             {
18 66
                 $scope.error = null;
67
+                $scope.selected = [];
19 68
                 var orderBy = AppUtilsBusiness.convertOrderBy($scope.query.order);
20 69
                 $scope.promise = pkGuidBusiness.getMultiple(orderBy, $scope.query.page - 1, $scope.query.limit).then(function(data)
21 70
                 {

+ 12
- 13
app/views/pkguid.html Ver fichero

@@ -5,11 +5,9 @@
5 5
             <div class="md-toolbar-tools">
6 6
                 <span>PkGuids</span>
7 7
                 <span flex></span>
8
-                <a ui-sref="pkguid_add">
9
-                    <md-button class="md-icon-button" ng-click="">
10
-                        <md-icon class="material-icons">add</md-icon>
11
-                    </md-button>
12
-                </a>
8
+                <md-button class="md-icon-button" ui-sref="pkguid_add">
9
+                    <md-icon class="material-icons">add</md-icon>
10
+                </md-button>
13 11
                 <md-button class="md-icon-button" ng-click="getPkGuids()">
14 12
                     <md-icon class="material-icons">refresh</md-icon>
15 13
                 </md-button>
@@ -19,7 +17,7 @@
19 17
             <div class="md-toolbar-tools">
20 18
                 <span>{{selected.length}} {{selected.length > 1 ? 'PkGuids' : 'PkGuid'}} selected</span>
21 19
                 <span flex></span>
22
-                <md-button class="md-icon-button">
20
+                <md-button class="md-icon-button" ng-click="askRemoveSelected()">
23 21
                     <md-icon class="material-icons">delete</md-icon>
24 22
                 </md-button>
25 23
             </div>
@@ -36,6 +34,7 @@
36 34
                     <th md-column md-order-by="someInt" md-numeric>Some Int</th>
37 35
                     <th md-column md-order-by="createdAt">Created At</th>
38 36
                     <th md-column md-order-by="updatedAt">Updated At</th>
37
+                    <th md-column>Actions</th>
39 38
                 </tr>
40 39
                 </thead>
41 40
                 <tbody md-body>
@@ -44,14 +43,14 @@
44 43
                     <td md-cell>{{item.someText}}</td>
45 44
                     <td md-cell>{{item.someInt}}</td>
46 45
                     <td md-cell>{{item.createdAt | date : 'medium'}}</td>
46
+                    <td md-cell>{{item.updatedAt == null ? 'Never' : item.updatedAt | date : 'medium'}}</td>
47 47
                     <td md-cell>
48
-                        {{item.updatedAt == null ? 'Never' : item.updatedAt | date : 'medium'}}
49
-                        <span flex></span>
50
-                        <a ui-sref="pkguid_edit({id: item.id, pkguid: item})">
51
-                            <md-button class="md-icon-button">
52
-                                <md-icon class="material-icons">mode_edit</md-icon>
53
-                            </md-button>
54
-                        </a>
48
+                        <md-button class="md-icon-button" ui-sref="pkguid_edit({id: item.id, pkguid: item})">
49
+                            <md-icon class="material-icons">mode_edit</md-icon>
50
+                        </md-button>
51
+                        <md-button class="md-icon-button" ng-click="askRemoveOne(item)">
52
+                            <md-icon class="material-icons">delete</md-icon>
53
+                        </md-button>
55 54
                     </td>
56 55
                 </tr>
57 56
                 </tbody>

Loading…
Cancelar
Guardar