Show user name while edit

This commit is contained in:
2025-11-04 15:53:24 +09:00
parent eea085607b
commit 9799086b53
2 changed files with 13 additions and 9 deletions

View File

@ -17,6 +17,11 @@
@errorMessage
</RadzenAlert>
<RadzenStack Gap="1rem" class="rz-p-sm-4">
<RadzenFormField Text="Логин" Variant="Variant.Outlined">
<ChildContent>
<RadzenTextBox Name="UserName" @bind-Value=@Input.UserName Disabled="true" />
</ChildContent>
</RadzenFormField>
<RadzenFormField Text="Роль" Variant="Variant.Outlined">
<ChildContent>
<RadzenDropDown Data="@roles" TextProperty="Name" ValueProperty="Id" @bind-Value="@Input.RoleId" Disabled="@Input.RoleDisabled" Name="Role" style="width: 100%" />
@ -54,6 +59,8 @@
@code {
sealed class InputModel
{
public string UserName { get; set; }
public bool RoleDisabled { get; set; }
public string RoleId { get; set; }
@ -72,10 +79,7 @@
public required string CurrentUserId { get; set; }
[Parameter]
public required string UserId { get; set; }
[Parameter]
public required string RoleId { get; set; }
public required AppUserWithRole UserWithRole { get; set; }
[SupplyParameterFromForm]
InputModel Input { get; set; } = new();
@ -84,8 +88,9 @@
{
await base.OnInitializedAsync();
Input.RoleDisabled = CurrentUserId == UserId;
Input.RoleId = RoleId;
Input.UserName = UserWithRole.User.UserName;
Input.RoleDisabled = CurrentUserId == UserWithRole.User.Id;
Input.RoleId = UserWithRole.Role.Id;
roles = await RoleManager.Roles.OrderBy(x => x.Priority).ToListAsync();
}
@ -99,7 +104,7 @@
try
{
await UsersService.UpdateUserAsync(UserId, input.RoleId, input.Password);
await UsersService.UpdateUserAsync(UserWithRole.User.Id, input.RoleId, input.Password);
DialogService.Close(true);
}