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 = $('' + - '' + - '
    '; + 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