Show user name while edit
This commit is contained in:
@ -17,6 +17,11 @@
|
|||||||
@errorMessage
|
@errorMessage
|
||||||
</RadzenAlert>
|
</RadzenAlert>
|
||||||
<RadzenStack Gap="1rem" class="rz-p-sm-4">
|
<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">
|
<RadzenFormField Text="Роль" Variant="Variant.Outlined">
|
||||||
<ChildContent>
|
<ChildContent>
|
||||||
<RadzenDropDown Data="@roles" TextProperty="Name" ValueProperty="Id" @bind-Value="@Input.RoleId" Disabled="@Input.RoleDisabled" Name="Role" style="width: 100%" />
|
<RadzenDropDown Data="@roles" TextProperty="Name" ValueProperty="Id" @bind-Value="@Input.RoleId" Disabled="@Input.RoleDisabled" Name="Role" style="width: 100%" />
|
||||||
@ -54,6 +59,8 @@
|
|||||||
@code {
|
@code {
|
||||||
sealed class InputModel
|
sealed class InputModel
|
||||||
{
|
{
|
||||||
|
public string UserName { get; set; }
|
||||||
|
|
||||||
public bool RoleDisabled { get; set; }
|
public bool RoleDisabled { get; set; }
|
||||||
|
|
||||||
public string RoleId { get; set; }
|
public string RoleId { get; set; }
|
||||||
@ -72,10 +79,7 @@
|
|||||||
public required string CurrentUserId { get; set; }
|
public required string CurrentUserId { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public required string UserId { get; set; }
|
public required AppUserWithRole UserWithRole { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public required string RoleId { get; set; }
|
|
||||||
|
|
||||||
[SupplyParameterFromForm]
|
[SupplyParameterFromForm]
|
||||||
InputModel Input { get; set; } = new();
|
InputModel Input { get; set; } = new();
|
||||||
@ -84,8 +88,9 @@
|
|||||||
{
|
{
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
|
|
||||||
Input.RoleDisabled = CurrentUserId == UserId;
|
Input.UserName = UserWithRole.User.UserName;
|
||||||
Input.RoleId = RoleId;
|
Input.RoleDisabled = CurrentUserId == UserWithRole.User.Id;
|
||||||
|
Input.RoleId = UserWithRole.Role.Id;
|
||||||
|
|
||||||
roles = await RoleManager.Roles.OrderBy(x => x.Priority).ToListAsync();
|
roles = await RoleManager.Roles.OrderBy(x => x.Priority).ToListAsync();
|
||||||
}
|
}
|
||||||
@ -99,7 +104,7 @@
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await UsersService.UpdateUserAsync(UserId, input.RoleId, input.Password);
|
await UsersService.UpdateUserAsync(UserWithRole.User.Id, input.RoleId, input.Password);
|
||||||
|
|
||||||
DialogService.Close(true);
|
DialogService.Close(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,8 +110,7 @@
|
|||||||
new Dictionary<string, object>()
|
new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
{ nameof(Dialogs.EditUser.CurrentUserId), currentUserId },
|
{ nameof(Dialogs.EditUser.CurrentUserId), currentUserId },
|
||||||
{ nameof(Dialogs.EditUser.UserId), userWithRole.User.Id },
|
{ nameof(Dialogs.EditUser.UserWithRole), userWithRole }
|
||||||
{ nameof(Dialogs.EditUser.RoleId), userWithRole.Role.Id }
|
|
||||||
},
|
},
|
||||||
new DialogOptions()
|
new DialogOptions()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user