-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
index.js
141 lines (132 loc) · 5.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
(function ($) {
var l = abp.localization.getResource('AbpIdentity');
var _identityRoleAppService = volo.abp.identity.identityRole;
var _permissionsModal = new abp.ModalManager(
abp.appPath + 'AbpPermissionManagement/PermissionManagementModal'
);
var _editModal = new abp.ModalManager(
abp.appPath + 'Identity/Roles/EditModal'
);
var _createModal = new abp.ModalManager(
abp.appPath + 'Identity/Roles/CreateModal'
);
var _dataTable = null;
abp.ui.extensions.entityActions.get('identity.role').addContributor(
function(actionList) {
return actionList.addManyTail(
[
{
text: l('Edit'),
visible: abp.auth.isGranted(
'AbpIdentity.Roles.Update'
),
action: function (data) {
_editModal.open({
id: data.record.id,
});
},
},
{
text: l('Permissions'),
visible: abp.auth.isGranted(
'AbpIdentity.Roles.ManagePermissions'
),
action: function (data) {
_permissionsModal.open({
providerName: 'R',
providerKey: data.record.name,
});
},
},
{
text: l('Delete'),
visible: function (data) {
return (
!data.isStatic &&
abp.auth.isGranted(
'AbpIdentity.Roles.Delete'
)
); //TODO: Check permission
},
confirmMessage: function (data) {
return l(
'RoleDeletionConfirmationMessage',
data.record.name
);
},
action: function (data) {
_identityRoleAppService
.delete(data.record.id)
.then(function () {
_dataTable.ajax.reload();
});
},
}
]
);
}
);
abp.ui.extensions.tableColumns.get('identity.role').addContributor(
function (columnList) {
columnList.addManyTail(
[
{
title: l("Actions"),
rowAction: {
items: abp.ui.extensions.entityActions.get('identity.role').actions.toArray()
}
},
{
title: l('RoleName'),
data: 'name',
render: function (data, type, row) {
var name = '<span>' + data + '</span>';
if (row.isDefault) {
name +=
'<span class="badge badge-pill badge-success ml-1">' +
l('DisplayName:IsDefault') +
'</span>';
}
if (row.isPublic) {
name +=
'<span class="badge badge-pill badge-info ml-1">' +
l('DisplayName:IsPublic') +
'</span>';
}
return name;
},
}
]
);
},
0 //adds as the first contributor
);
$(function () {
var _$wrapper = $('#IdentityRolesWrapper');
var _$table = _$wrapper.find('table');
_dataTable = _$table.DataTable(
abp.libs.datatables.normalizeConfiguration({
order: [[1, 'asc']],
searching: false,
processing: true,
serverSide: true,
scrollX: true,
paging: true,
ajax: abp.libs.datatables.createAjax(
_identityRoleAppService.getList
),
columnDefs: abp.ui.extensions.tableColumns.get('identity.role').columns.toArray()
})
);
_createModal.onResult(function () {
_dataTable.ajax.reload();
});
_editModal.onResult(function () {
_dataTable.ajax.reload();
});
_$wrapper.find('button[name=CreateRole]').click(function (e) {
e.preventDefault();
_createModal.open();
});
});
})(jQuery);