diff --git a/src/Volo.Abp.Identity.Web/Pages/Identity/Users/Index.cshtml b/src/Volo.Abp.Identity.Web/Pages/Identity/Users/Index.cshtml
index 06045e1d7d..7b06303c4c 100644
--- a/src/Volo.Abp.Identity.Web/Pages/Identity/Users/Index.cshtml
+++ b/src/Volo.Abp.Identity.Web/Pages/Identity/Users/Index.cshtml
@@ -13,6 +13,7 @@
+
}
diff --git a/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj b/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj
index dbc8386f59..e4e756be91 100644
--- a/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj
+++ b/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj
@@ -16,6 +16,10 @@
+
+
+
+
diff --git a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/helpers/datatables/datatables.record-actions.js b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/helpers/datatables/datatables.record-actions.js
new file mode 100644
index 0000000000..929b62f54d
--- /dev/null
+++ b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/helpers/datatables/datatables.record-actions.js
@@ -0,0 +1,176 @@
+/************************************************************************
+* RECORD-ACTIONS extension for datatables *
+*************************************************************************/
+(function ($) {
+
+ if (!$.fn.dataTableExt) {
+ return;
+ }
+
+ var _createDropdownItem = function (record, fieldItem) {
+ var $li = $('');
+ var $a = $('');
+
+ if (fieldItem.text) {
+ $a.html(fieldItem.text);
+ }
+
+ if (fieldItem.action) {
+ $a.click(function (e) {
+ e.preventDefault();
+
+ if (!$(this).closest('li').hasClass('disabled')) {
+ fieldItem.action({
+ record: record
+ });
+ }
+ });
+ }
+
+ $a.appendTo($li);
+ return $li;
+ }
+
+ var _createButtonDropdown = function (record, field) {
+ var $container = $('')
+ .addClass('dropdown')
+ .addClass('action-button');
+
+ var $dropdownButton = $('')
+ .html(field.text)
+ .addClass('btn btn-primary btn-sm dropdown-toggle')
+ .attr('data-toggle', 'dropdown')
+ .attr('aria-haspopup', 'true')
+ .attr('aria-expanded', 'false');
+
+ if (field.cssClass) {
+ $dropdownButton.addClass(field.cssClass);
+ }
+
+ var $dropdownItemsContainer = $('').addClass('dropdown-menu');
+
+ for (var i = 0; i < field.items.length; i++) {
+ var fieldItem = field.items[i];
+
+ if (fieldItem.visible && !fieldItem.visible({ record: record })) {
+ continue;
+ }
+
+ var $dropdownItem = _createDropdownItem(record, fieldItem);
+
+ if (fieldItem.enabled && !fieldItem.enabled({ record: record })) {
+ $dropdownItem.addClass('disabled');
+ }
+
+ $dropdownItem.appendTo($dropdownItemsContainer);
+ }
+
+ if ($dropdownItemsContainer.find('li').length > 0) {
+ $dropdownItemsContainer.appendTo($container);
+ $dropdownButton.appendTo($container);
+ }
+
+ if ($dropdownItemsContainer.children().length === 0) {
+ return "";
+ }
+
+ return $container;
+ };
+
+ var _createSingleButton = function (record, field) {
+ $(field.element).data(record);
+
+ if (field.visible === undefined) {
+ return field.element;
+ }
+
+ var isVisibilityFunction = typeof field.visible === "function";
+ if (isVisibilityFunction) {
+ if (field.visible()) {
+ return field.element;
+ }
+ } else {
+ if (field.visible) {
+ return field.element;
+ }
+ }
+
+ return "";
+ };
+
+ var _createRowAction = function (record, field, tableInstance) {
+ if (field.items && field.items.length > 1) {
+ return _createButtonDropdown(record, field, tableInstance);
+ } else if (field.element) {
+ var $singleActionButton = _createSingleButton(record, field);
+ if ($singleActionButton != "") {
+ return $singleActionButton.clone(true);
+ }
+ }
+
+ return "";
+ }
+
+ var hideColumnWithoutRedraw = function (tableInstance, colIndex) {
+ tableInstance.fnSetColumnVis(colIndex, false, false);
+ }
+
+ var hideEmptyColumn = function(cellContent, tableInstance, colIndex) {
+ if (cellContent == "") {
+ hideColumnWithoutRedraw(tableInstance, colIndex);
+ }
+ };
+
+ var renderRowActions = function (tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull) {
+ var columns;
+ if (tableInstance.aoColumns) {
+ columns = tableInstance.aoColumns;
+ } else {
+ columns = tableInstance.fnSettings().aoColumns;
+ }
+
+ if (!columns) {
+ return;
+ }
+
+ var cells = $(nRow).children("td");
+
+ for (var colIndex = 0; colIndex < columns.length; colIndex++) {
+ var column = columns[colIndex];
+ if (column.rowAction) {
+ var $actionContainer = _createRowAction(aData, column.rowAction, tableInstance);
+ hideEmptyColumn($actionContainer, tableInstance, colIndex);
+
+ var $actionButton = $(cells[colIndex]).find(".action-button");
+ if ($actionButton.length === 0) {
+ $(cells[colIndex]).append($actionContainer);
+ }
+ }
+ }
+ };
+
+ var _existingApiRenderRowActionsFunction = $.fn.dataTableExt.oApi.renderRowActions;
+ $.fn.dataTableExt.oApi.renderRowActions = function (tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull) {
+ if (_existingApiRenderRowActionsFunction) {
+ _existingApiRenderRowActionsFunction(tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull);
+ }
+
+ renderRowActions(tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull);
+ };
+
+ if (!$.fn.dataTable) {
+ return;
+ }
+
+ var _existingDefaultFnRowCallback = $.fn.dataTable.defaults.fnRowCallback;
+ $.extend(true, $.fn.dataTable.defaults, {
+ fnRowCallback: function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
+ if (_existingDefaultFnRowCallback) {
+ _existingDefaultFnRowCallback(this, nRow, aData, iDisplayIndex, iDisplayIndexFull);
+ }
+
+ renderRowActions(this, nRow, aData, iDisplayIndex, iDisplayIndexFull);
+ }
+ });
+
+})(jQuery);
\ No newline at end of file
diff --git a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.css b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.css
index 4f53b593a8..41fbd4eaf0 100644
--- a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.css
+++ b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.css
@@ -5,4 +5,17 @@
.table td,
.table th {
padding: 8px 10px;
+}
+.dataTable tbody tr td button {
+ cursor: pointer;
+}
+.dataTable tbody tr td div.dropdown ul.dropdown-menu li {
+ cursor: pointer;
+ padding: 5px;
+}
+.dataTable tbody tr td div.dropdown ul.dropdown-menu li a {
+ display: block;
+}
+.dataTable tbody tr td div.dropdown ul.dropdown-menu li:hover {
+ background: #f4f5f8;
}
\ No newline at end of file
diff --git a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.js b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.js
index 7c4f3b37e2..e9149a34c6 100644
--- a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.js
+++ b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.js
@@ -1,5 +1,5 @@
-(function() {
-
+(function () {
+
var l = abp.localization.getResource('AbpIdentity');
var _identityUserAppService = volo.abp.identity.identityUser;
@@ -10,7 +10,7 @@
var _createModal = new abp.ModalManager({
viewUrl: abp.appPath + 'Identity/Users/CreateModal'
});
-
+
var app = new Vue({
el: '#IdentityUsersWrapper',
methods: {
@@ -35,16 +35,37 @@
orderable: false,
autoWidth: false,
defaultContent: '',
- render: function (list, type, record, meta) {
- return '' +
- '' +
- '' +
- '
';
+ rowAction: {
+ text: ' ' + l('Actions') + ' ',
+ items:
+ [
+ {
+ text: l('Edit'),
+ visible: function () {
+ return true;
+ },
+ action: function (data) {
+ _editModal.open({
+ id: data.record.id
+ });
+ }
+ },
+ {
+ text: l('Delete'),
+ visible: function () {
+ return true;
+ },
+ action: function (data) {
+ if (confirm(l('UserDeletionConfirmationMessage', data.record.userName))) {
+ _identityUserAppService
+ .delete(data.record.id)
+ .then(function () {
+ _dataTable.ajax.reload();
+ });
+ }
+ }
+ }
+ ]
}
},
{
@@ -60,28 +81,7 @@
data: "phoneNumber"
}
]
- });
-
- //Update user command
- _$table.on('click', '.update-user', function () { //TODO: To action list!
- _editModal.open({
- id: $(this).data('id')
- });
- });
-
- //Delete user command
- _$table.on('click', '.delete-user', function () { //TODO: To action list!
- var id = $(this).data('id');
- var userName = $(this).data('userName');
-
- if (confirm(l('UserDeletionConfirmationMessage', userName))) {
- _identityUserAppService
- .delete(id)
- .then(function () {
- _dataTable.ajax.reload();
- });
- }
- });
+ });
_createModal.onResult(function () {
_dataTable.ajax.reload();
diff --git a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.less b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.less
index c49b79238d..7534888421 100644
--- a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.less
+++ b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.less
@@ -6,3 +6,33 @@
.table td, .table th {
padding: 8px 10px;
}
+
+.dataTable {
+ tbody {
+ tr {
+ td {
+
+ button {
+ cursor: pointer;
+ }
+
+ div.dropdown {
+ ul.dropdown-menu {
+ li {
+ cursor: pointer;
+ padding: 5px;
+
+ a {
+ display: block;
+ }
+ }
+
+ li:hover {
+ background: #f4f5f8;
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.min.css b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.min.css
index 283dedaa8a..e70b9e330b 100644
--- a/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.min.css
+++ b/src/Volo.Abp.Identity.Web/wwwroot/modules/identity/views/users/index.min.css
@@ -1 +1 @@
-.dataTable{width:100% !important;border-spacing:0 !important;}.table td,.table th{padding:8px 10px;}
\ No newline at end of file
+.dataTable{width:100% !important;border-spacing:0 !important;}.table td,.table th{padding:8px 10px;}.dataTable tbody tr td button{cursor:pointer;}.dataTable tbody tr td div.dropdown ul.dropdown-menu li{cursor:pointer;padding:5px;}.dataTable tbody tr td div.dropdown ul.dropdown-menu li a{display:block;}.dataTable tbody tr td div.dropdown ul.dropdown-menu li:hover{background:#f4f5f8;}
\ No newline at end of file