mirror of https://github.com/abpframework/eventhub
14 changed files with 279 additions and 211 deletions
@ -0,0 +1,10 @@ |
|||||
|
using System; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EventHub.Admin.Events.Registrations |
||||
|
{ |
||||
|
public class GetEventRegistrationListInput : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
public Guid EventId { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -1,15 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Application.Dtos; |
|
||||
|
|
||||
namespace EventHub.Admin.Users |
|
||||
{ |
|
||||
public class GetUnregisteredUserEventInput : PagedResultRequestDto |
|
||||
{ |
|
||||
public Guid EventId { get; set; } |
|
||||
public string Username { get; set; } |
|
||||
public string Name { get; set; } |
|
||||
public string Surname { get; set; } |
|
||||
public string Email { get; set; } |
|
||||
public string Sorting { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,9 @@ |
|||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EventHub.Admin.Users |
||||
|
{ |
||||
|
public class GetUserListInput : PagedAndSortedResultRequestDto |
||||
|
{ |
||||
|
public string Username { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -1 +1,70 @@ |
|||||
@inherits EventHubComponentBase |
@using EventHub.Admin.Users |
||||
|
@inherits EventHubComponentBase |
||||
|
@inject IUserAppService UserAppService |
||||
|
|
||||
|
<ModalContent Centered="true"> |
||||
|
<ModalHeader> |
||||
|
<ModalTitle>@L["AddUser"]</ModalTitle> |
||||
|
<CloseButton Clicked="CloseUserPickerModalAsync" /> |
||||
|
</ModalHeader> |
||||
|
<ModalBody> |
||||
|
<div id="UserFilterSection" class="row mt-3"> |
||||
|
<Column ColumnSize="ColumnSize.Is12"> |
||||
|
<Field> |
||||
|
<FieldLabel>@L["UserName"]</FieldLabel> |
||||
|
<TextEdit TValue="string" KeyPress="OnKeyPressed" @bind-Text="@Filter.Username" /> |
||||
|
</Field> |
||||
|
</Column> |
||||
|
</div> |
||||
|
|
||||
|
<DataGrid TItem="UserDto" |
||||
|
Data="UserList" |
||||
|
ReadData="OnDataGridReadAsync" |
||||
|
TotalItems="TotalCount" |
||||
|
ShowPager="true" |
||||
|
PageSize="PageSize" |
||||
|
Responsive="true"> |
||||
|
<DataGridColumns> |
||||
|
<DataGridColumn Sortable="false" TItem="UserDto" Field="@nameof(UserDto.Id)"> |
||||
|
<CaptionTemplate> |
||||
|
<Check TValue="bool" @bind-Checked="@AllUserSelected"></Check> |
||||
|
</CaptionTemplate> |
||||
|
<DisplayTemplate> |
||||
|
@if (SelectAllUsers.ContainsKey(context.Id)) |
||||
|
{ |
||||
|
<Check TValue="bool" @bind-Checked="@SelectAllUsers[context.Id]"></Check> |
||||
|
} |
||||
|
</DisplayTemplate> |
||||
|
</DataGridColumn> |
||||
|
|
||||
|
<DataGridColumn TItem="UserDto" Field="@nameof(UserDto.Username)" Caption="@L["UserName"].Value"> |
||||
|
<DisplayTemplate> |
||||
|
@(context.Username) |
||||
|
</DisplayTemplate> |
||||
|
</DataGridColumn> |
||||
|
|
||||
|
<DataGridColumn TItem="UserDto" Field="@nameof(UserDto.Name)" Caption="@L["Name"].Value"> |
||||
|
<DisplayTemplate> |
||||
|
@(context.Name) |
||||
|
</DisplayTemplate> |
||||
|
</DataGridColumn> |
||||
|
|
||||
|
<DataGridColumn TItem="UserDto" Field="@nameof(UserDto.Surname)" Caption="@L["Surname"].Value"> |
||||
|
<DisplayTemplate> |
||||
|
@(context.Surname) |
||||
|
</DisplayTemplate> |
||||
|
</DataGridColumn> |
||||
|
|
||||
|
<DataGridColumn TItem="UserDto" Field="@nameof(UserDto.Email)" Caption="@L["Email"].Value"> |
||||
|
<DisplayTemplate> |
||||
|
@(context.Email) |
||||
|
</DisplayTemplate> |
||||
|
</DataGridColumn> |
||||
|
</DataGridColumns> |
||||
|
</DataGrid> |
||||
|
</ModalBody> |
||||
|
<ModalFooter> |
||||
|
<Button Color="Color.Secondary" Clicked="CloseUserPickerModalAsync">@L["Cancel"]</Button> |
||||
|
<Button Color="Color.Primary" Clicked="SaveUserPickerFormAsync">@L["Save"]</Button> |
||||
|
</ModalFooter> |
||||
|
</ModalContent> |
||||
|
|||||
@ -0,0 +1,117 @@ |
|||||
|
using Blazorise; |
||||
|
using EventHub.Admin.Users; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Blazorise.DataGrid; |
||||
|
using Microsoft.AspNetCore.Components.Web; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace EventHub.Admin.Web.Components.UserPicker |
||||
|
{ |
||||
|
public partial class UserPicker |
||||
|
{ |
||||
|
[Parameter] |
||||
|
public Modal UserPickerModal { get; set; } |
||||
|
|
||||
|
[Parameter] |
||||
|
public EventCallback SaveFormAsync { get; set; } |
||||
|
|
||||
|
[Parameter] |
||||
|
public List<Guid> SelectedUserIds { get; set; } = new List<Guid>(); |
||||
|
|
||||
|
private GetUserListInput Filter { get; set; } |
||||
|
|
||||
|
private IReadOnlyList<UserDto> UserList { get; set; } |
||||
|
private int CurrentPage { get; set; } |
||||
|
private string CurrentSorting { get; set; } |
||||
|
private int TotalCount { get; set; } |
||||
|
private int PageSize { get; } |
||||
|
public Dictionary<Guid, bool> SelectAllUsers = new(); |
||||
|
|
||||
|
private bool AllUserSelected |
||||
|
{ |
||||
|
get => SelectAllUsers.All(x => x.Value); |
||||
|
set |
||||
|
{ |
||||
|
foreach (var key in SelectAllUsers.Keys) |
||||
|
{ |
||||
|
SelectAllUsers[key] = value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public UserPicker() |
||||
|
{ |
||||
|
Filter = new GetUserListInput(); |
||||
|
PageSize = LimitedResultRequestDto.DefaultMaxResultCount; |
||||
|
} |
||||
|
|
||||
|
protected override async Task OnInitializedAsync() |
||||
|
{ |
||||
|
await GetUsersAsync(); |
||||
|
} |
||||
|
|
||||
|
protected override async Task OnParametersSetAsync() |
||||
|
{ |
||||
|
await GetUsersAsync(); |
||||
|
} |
||||
|
|
||||
|
private async Task GetUsersAsync() |
||||
|
{ |
||||
|
Filter.MaxResultCount = PageSize; |
||||
|
Filter.SkipCount = CurrentPage * PageSize; |
||||
|
Filter.Sorting = CurrentSorting; |
||||
|
|
||||
|
var result = await UserAppService.GetListAsync(Filter); |
||||
|
UserList = result.Items; |
||||
|
TotalCount = (int)result.TotalCount; |
||||
|
|
||||
|
FillSelectedUserList(); |
||||
|
} |
||||
|
|
||||
|
private void FillSelectedUserList() |
||||
|
{ |
||||
|
SelectAllUsers = new Dictionary<Guid, bool>(); |
||||
|
|
||||
|
foreach (var user in UserList) |
||||
|
{ |
||||
|
SelectAllUsers.Add(user.Id, SelectedUserIds.Contains(user.Id)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task OnKeyPressed(KeyboardEventArgs e) |
||||
|
{ |
||||
|
if (e.Code is "Enter" or "NumpadEnter") |
||||
|
{ |
||||
|
await GetUsersAsync(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task OnDataGridReadAsync(DataGridReadDataEventArgs<UserDto> e) |
||||
|
{ |
||||
|
CurrentSorting = e.Columns |
||||
|
.Where(c => c.Direction != SortDirection.None) |
||||
|
.Select(c => c.Field + (c.Direction == SortDirection.Descending ? " DESC" : "")) |
||||
|
.JoinAsString(","); |
||||
|
CurrentPage = e.Page - 1; |
||||
|
|
||||
|
await GetUsersAsync(); |
||||
|
await InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
|
||||
|
public Task CloseUserPickerModalAsync() |
||||
|
{ |
||||
|
UserPickerModal.Hide(); |
||||
|
|
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
|
||||
|
private async Task SaveUserPickerFormAsync() |
||||
|
{ |
||||
|
await SaveFormAsync.InvokeAsync(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue