|
@@ -3,8 +3,8 @@
|
3
|
3
|
*/
|
4
|
4
|
|
5
|
5
|
angular.module('luticateUtils')
|
6
|
|
- .directive('luEditTable', ['dialogs', 'luticateDialogErrorHelper',
|
7
|
|
- function(dialogs, luticateDialogErrorHelper) {
|
|
6
|
+ .directive('luEditTable', ['dialogs', 'luticateDialogErrorHelper', 'luticateAuthCache',
|
|
7
|
+ function(dialogs, luticateDialogErrorHelper, luticateAuthCache) {
|
8
|
8
|
return {
|
9
|
9
|
restrict: 'E',
|
10
|
10
|
scope: {
|
|
@@ -44,9 +44,50 @@ angular.module('luticateUtils')
|
44
|
44
|
};
|
45
|
45
|
|
46
|
46
|
|
47
|
|
- $scope.tableOptions.canCheck = $scope.tableOptions.canDelete;
|
|
47
|
+ if ($scope.tableOptions.canDel == null) {
|
|
48
|
+ $scope.tableOptions.canDel = function()
|
|
49
|
+ {
|
|
50
|
+ return false;
|
|
51
|
+ }
|
|
52
|
+ }
|
|
53
|
+ if (typeof $scope.tableOptions.canDel == 'string') {
|
|
54
|
+ var permDel = $scope.tableOptions.canDel;
|
|
55
|
+ $scope.tableOptions.canDel = function()
|
|
56
|
+ {
|
|
57
|
+ return luticateAuthCache.hasEffectivePermission(permDel);
|
|
58
|
+ }
|
|
59
|
+ }
|
|
60
|
+ $scope.tableOptions.canCheck = $scope.tableOptions.canDel;
|
|
61
|
+
|
|
62
|
+ if ($scope.tableOptions.canEdit == null) {
|
|
63
|
+ $scope.tableOptions.canEdit = function()
|
|
64
|
+ {
|
|
65
|
+ return false;
|
|
66
|
+ }
|
|
67
|
+ }
|
|
68
|
+ if (typeof $scope.tableOptions.canEdit == 'string') {
|
|
69
|
+ var permEdit = $scope.tableOptions.canEdit;
|
|
70
|
+ $scope.tableOptions.canEdit = function()
|
|
71
|
+ {
|
|
72
|
+ return luticateAuthCache.hasEffectivePermission(permEdit);
|
|
73
|
+ }
|
|
74
|
+ }
|
48
|
75
|
$scope.tableOptions.canClick = $scope.tableOptions.canEdit;
|
49
|
76
|
|
|
77
|
+ if ($scope.tableOptions.canAdd == null) {
|
|
78
|
+ $scope.tableOptions.canAdd = function()
|
|
79
|
+ {
|
|
80
|
+ return false;
|
|
81
|
+ }
|
|
82
|
+ }
|
|
83
|
+ if (typeof $scope.tableOptions.canAdd == 'string') {
|
|
84
|
+ var permAdd = $scope.tableOptions.canAdd;
|
|
85
|
+ $scope.tableOptions.canAdd = function()
|
|
86
|
+ {
|
|
87
|
+ return luticateAuthCache.hasEffectivePermission(permAdd);
|
|
88
|
+ }
|
|
89
|
+ }
|
|
90
|
+
|
50
|
91
|
|
51
|
92
|
$scope.deleteItems = function () {
|
52
|
93
|
if ($scope.tableOptions.checkedItems.length == 0) {
|
|
@@ -60,7 +101,7 @@ angular.module('luticateUtils')
|
60
|
101
|
var item = $scope.tableOptions.checkedItems[0];
|
61
|
102
|
$scope.tableOptions.getDelPromise(item, promiseDelItems)
|
62
|
103
|
.then(function (data) {
|
63
|
|
- $scope.tableOptions.onItemDeleted(item, $scope);
|
|
104
|
+ $scope.tableOptions.onItemDeleted(item);
|
64
|
105
|
$scope.tableOptions.checkedItems.splice(0, 1);
|
65
|
106
|
$scope.deleteItems();
|
66
|
107
|
}, function (error) {
|
|
@@ -91,7 +132,7 @@ angular.module('luticateUtils').run(['$templateCache', function($templateCache)
|
91
|
132
|
' <lu-basic-table options="tableOptions"></lu-basic-table>' +
|
92
|
133
|
'<div class="col-sm-12">' +
|
93
|
134
|
' <button class="btn btn-default" type="button" ng-click="deleteItems()"' +
|
94
|
|
-'ng-disabled="tableOptions.checkedItems.length == 0" ng-show="tableOptions.canDelete()">' +
|
|
135
|
+'ng-disabled="tableOptions.checkedItems.length == 0" ng-show="tableOptions.canDel()">' +
|
95
|
136
|
' <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Delete' +
|
96
|
137
|
' </button>' +
|
97
|
138
|
' <button class="btn btn-default" type="button" ng-click="addItem()" ng-show="tableOptions.canAdd()">' +
|