Browse Source

Role and User client side Blazorise validations

pull/5973/head
Mladen Macanovic 6 years ago
parent
commit
1a44a268f8
  1. 2
      framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs
  2. 28
      framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs
  3. 49
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor
  4. 38
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs
  5. 219
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor
  6. 47
      modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs

2
framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs

@ -335,7 +335,7 @@ namespace Volo.Abp.BlazoriseUI
var entityDto = await AppService.GetAsync(id);
EditingEntityId = id;
EditingEntity = MapToEditingEntity(entityDto);
EditingEntity.ApplyState(MapToEditingEntity(entityDto));
EditModal.Show();
}

28
framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs

@ -110,7 +110,7 @@ namespace System
/// <summary>
/// Resets all fields of a given object to their default values.
/// </summary>
/// <typeparam name="T">Type of the object</typeparam>
/// <typeparam name="T">Type of the object.</typeparam>
/// <param name="obj">An object</param>
/// <param name="customReset">Alternative custom method to reset the values.</param>
/// <returns>Returns the original object.</returns>
@ -137,5 +137,31 @@ namespace System
return obj;
}
/// <summary>
/// Applies all fields of a given object from it's counterpart.
/// </summary>
/// <typeparam name="T">Type of the object.</typeparam>
/// <param name="obj">An object.</param>
/// <param name="other">An object from which we copy the values.</param>
/// <returns>Returns the original object.</returns>
public static T ApplyState<T>(this T obj, T other)
{
// This code is not production ready and it should be removed once
// the proper validation in Blazorise is done!
var properties = typeof(T).GetProperties();
foreach (var property in properties)
{
if (!property.CanWrite)
{
continue;
}
property.SetValue(obj, typeof(T).GetProperty(property.Name).GetValue(other));
}
return obj;
}
}
}

49
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor

@ -1,5 +1,5 @@
@page "/identity/roles"
@attribute [Authorize(IdentityPermissions.Roles.Default)]
@attribute [Authorize( IdentityPermissions.Roles.Default )]
@using Volo.Abp.Identity
@using Microsoft.AspNetCore.Authorization
@using Microsoft.Extensions.Localization
@ -7,14 +7,13 @@
@using Volo.Abp.PermissionManagement.Blazor.Components
@inherits RoleManagementBase
@inject IStringLocalizer<IdentityResource> L
@* ************************* PAGE HEADER ************************* *@
<Row>
<Column ColumnSize="ColumnSize.Is6">
<h1>@L["Roles"]</h1>
</Column>
<Column ColumnSize="ColumnSize.Is6">
@if (HasCreatePermission)
@if ( HasCreatePermission )
{
<Paragraph Alignment="TextAlignment.Right">
<Button Color="Color.Primary" Clicked="OpenCreateModalAsync">@L["NewRole"]</Button>
@ -31,7 +30,7 @@
ShowPager="true"
PageSize="PageSize">
<DataGridColumns>
@if (ShouldShowEntityActions)
@if ( ShouldShowEntityActions )
{
<DataGridColumn Width="150px" TItem="IdentityRoleDto" Field="@nameof(IdentityRoleDto.Name)" Sortable="false" Caption="@L["Actions"].Value">
<DisplayTemplate>
@ -40,15 +39,15 @@
@L["Actions"]
</DropdownToggle>
<DropdownMenu>
@if (HasUpdatePermission)
@if ( HasUpdatePermission )
{
<DropdownItem Clicked="() => OpenEditModalAsync(context.As<IdentityRoleDto>().Id)">@L["Edit"]</DropdownItem>
}
@if (HasManagePermissionsPermission)
@if ( HasManagePermissionsPermission )
{
<DropdownItem Clicked="() => PermissionManagementModal.OpenAsync(PermissionProviderName, context.As<IdentityRoleDto>().Name)">@L["Permissions"]</DropdownItem>
}
@if (HasDeletePermission)
@if ( HasDeletePermission )
{
<DropdownItem Clicked="() => DeleteEntityAsync(context.As<IdentityRoleDto>())">@L["Delete"]</DropdownItem>
}
@ -60,11 +59,11 @@
<DataGridColumn TItem="IdentityRoleDto" Field="@nameof(IdentityRoleDto.Name)" Caption="@L["RoleName"].Value">
<DisplayTemplate>
@(context.As<IdentityRoleDto>().Name)
@if (context.As<IdentityRoleDto>().IsDefault)
@if ( context.As<IdentityRoleDto>().IsDefault )
{
<Badge Color="Color.Primary">@L["DisplayName:IsDefault"]</Badge>
}
@if (context.As<IdentityRoleDto>().IsPublic)
@if ( context.As<IdentityRoleDto>().IsPublic )
{
<Badge Color="Color.Light">@L["DisplayName:IsPublic"]</Badge>
}
@ -74,7 +73,7 @@
</DataGrid>
@* ************************* CREATE MODAL ************************* *@
@if (HasCreatePermission)
@if ( HasCreatePermission )
{
<Modal @ref="CreateModal">
<ModalBackdrop />
@ -84,7 +83,7 @@
<CloseButton Clicked="CloseCreateModalAsync" />
</ModalHeader>
<ModalBody>
<Validations @ref="@ValidationsRef" Mode="ValidationMode.Auto" Model="@NewEntity" ValidateOnLoad="false">
<Validations @ref="@CreateValidationsRef" Mode="ValidationMode.Auto" Model="@NewEntity" ValidateOnLoad="false">
<Validation>
<Field>
<FieldLabel>@L["DisplayName:RoleName"]</FieldLabel>
@ -103,13 +102,13 @@
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="CloseCreateModalAsync">@L["Cancel"]</Button>
<Button Color="Color.Primary" Clicked="OnCreateEntityClicked">@L["Save"]</Button>
<Button Color="Color.Primary" Clicked="CreateEntityAsync">@L["Save"]</Button>
</ModalFooter>
</ModalContent>
</Modal>
}
@* ************************* EDIT MODAL ************************* *@
@if (HasUpdatePermission)
@if ( HasUpdatePermission )
{
<Modal @ref="EditModal">
<ModalBackdrop />
@ -119,17 +118,23 @@
<CloseButton Clicked="CloseEditModalAsync" />
</ModalHeader>
<ModalBody>
<EditForm id="IdentityRoleEditForm" Model="@EditingEntity" OnValidSubmit="UpdateEntityAsync">
<Validations @ref="@EditValidationsRef" Mode="ValidationMode.Auto" Model="@EditingEntity" ValidateOnLoad="false">
<input type="hidden" name="ConcurrencyStamp" @bind-value="EditingEntity.ConcurrencyStamp" />
<Validation>
<Field>
<FieldLabel>@L["DisplayName:RoleName"]</FieldLabel>
<TextEdit @bind-Text="EditingEntity.Name">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Field>
<FieldLabel>@L["DisplayName:RoleName"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.Name" />
</Field>
<Field>
<Check TValue="bool" @bind-checked="@EditingEntity.IsDefault">@L["DisplayName:IsDefault"]</Check>
<Check TValue="bool" @bind-checked="@EditingEntity.IsPublic">@L["DisplayName:IsPublic"]</Check>
<Check TValue="bool" @bind-Checked="@EditingEntity.IsDefault">@L["DisplayName:IsDefault"]</Check>
<Check TValue="bool" @bind-Checked="@EditingEntity.IsPublic">@L["DisplayName:IsPublic"]</Check>
</Field>
</EditForm>
</Validations>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="CloseEditModalAsync">@L["Cancel"]</Button>
@ -139,4 +144,4 @@
</Modal>
}
<PermissionManagementModal @ref="PermissionManagementModal"/>
<PermissionManagementModal @ref="PermissionManagementModal" />

38
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/RoleManagement.razor.cs

@ -8,7 +8,7 @@ using Volo.Abp.PermissionManagement.Blazor.Components;
namespace Volo.Abp.Identity.Blazor.Pages.Identity
{
public abstract class RoleManagementBase : AbpCrudPageBase<IIdentityRoleAppService,IdentityRoleDto, Guid, PagedAndSortedResultRequestDto, IdentityRoleCreateDto, IdentityRoleUpdateDto>
public abstract class RoleManagementBase : AbpCrudPageBase<IIdentityRoleAppService, IdentityRoleDto, Guid, PagedAndSortedResultRequestDto, IdentityRoleCreateDto, IdentityRoleUpdateDto>
{
protected const string PermissionProviderName = "R";
@ -18,7 +18,9 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
protected bool ShouldShowEntityActions { get; set; }
protected Validations ValidationsRef { get; set; }
protected Validations CreateValidationsRef { get; set; }
protected Validations EditValidationsRef { get; set; }
public RoleManagementBase()
{
@ -42,13 +44,39 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
HasManagePermissionsPermission;
}
protected virtual Task OnCreateEntityClicked()
protected override Task OpenCreateModalAsync()
{
CreateValidationsRef.ClearAll();
return base.OpenCreateModalAsync();
}
protected override Task OpenEditModalAsync(Guid id)
{
EditValidationsRef.ClearAll();
return base.OpenEditModalAsync(id);
}
protected override Task CreateEntityAsync()
{
if ( ValidationsRef.ValidateAll() )
if (CreateValidationsRef.ValidateAll())
{
CreateModal.Hide();
return CreateEntityAsync();
return base.CreateEntityAsync();
}
return Task.CompletedTask;
}
protected override Task UpdateEntityAsync()
{
if (EditValidationsRef.ValidateAll())
{
EditModal.Hide();
return base.UpdateEntityAsync();
}
return Task.CompletedTask;

219
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor

@ -1,19 +1,18 @@
@page "/identity/users"
@attribute [Authorize(IdentityPermissions.Users.Default)]
@attribute [Authorize( IdentityPermissions.Users.Default )]
@using Microsoft.AspNetCore.Authorization
@using Microsoft.Extensions.Localization
@using Volo.Abp.Identity.Localization
@using Volo.Abp.PermissionManagement.Blazor.Components
@inherits UserManagementBase
@inject IStringLocalizer<IdentityResource> L
@* ************************* PAGE HEADER ************************* *@
<Row>
<Column ColumnSize="ColumnSize.Is6">
<h1>@L["Users"]</h1>
</Column>
<Column ColumnSize="ColumnSize.Is6">
@if (HasCreatePermission)
@if ( HasCreatePermission )
{
<Paragraph Alignment="TextAlignment.Right">
<Button Color="Color.Primary" Clicked="OpenCreateModalAsync">@L["NewUser"]</Button>
@ -30,7 +29,7 @@
ShowPager="true"
PageSize="PageSize">
<DataGridColumns>
@if (ShouldShowEntityActions)
@if ( ShouldShowEntityActions )
{
<DataGridColumn Width="150px" TItem="IdentityUserDto" Field="@nameof(IdentityUserDto.UserName)" Sortable="false" Caption="@L["Actions"].Value">
<DisplayTemplate>
@ -39,17 +38,17 @@
@L["Actions"]
</DropdownToggle>
<DropdownMenu>
@if (HasUpdatePermission)
@if ( HasUpdatePermission )
{
<DropdownItem Clicked="() => OpenEditModalAsync(context.As<IdentityUserDto>().Id)">@L["Edit"]</DropdownItem>
}
@if (HasManagePermissionsPermission)
@if ( HasManagePermissionsPermission )
{
<DropdownItem Clicked="() => PermissionManagementModal.OpenAsync(PermissionProviderName, context.As<IdentityUserDto>().Id.ToString())">@L["Permissions"]</DropdownItem>
}
@if (HasDeletePermission)
@if ( HasDeletePermission )
{
<DropdownDivider/>
<DropdownDivider />
<DropdownItem Clicked="() => DeleteEntityAsync(context.As<IdentityUserDto>())">@L["Delete"]</DropdownItem>
}
</DropdownMenu>
@ -76,17 +75,17 @@
</DataGrid>
@* ************************* CREATE MODAL ************************* *@
@if (HasCreatePermission)
@if ( HasCreatePermission )
{
<Modal @ref="CreateModal">
<ModalBackdrop/>
<ModalBackdrop />
<ModalContent IsCentered="true">
<ModalHeader>
<ModalTitle>@L["NewUser"]</ModalTitle>
<CloseButton Clicked="CloseCreateModalAsync"/>
<CloseButton Clicked="CloseCreateModalAsync" />
</ModalHeader>
<ModalBody>
<EditForm id="IdentityUserCreateForm" Model="@NewEntity" OnValidSubmit="CreateEntityAsync">
<Validations @ref="@CreateValidationsRef" Mode="ValidationMode.Auto" Model="@NewEntity" ValidateOnLoad="false">
<Tabs @bind-SelectedTab="@CreateModalSelectedTab">
<Items>
<Tab Name="UserInformations">@L["UserInformations"]</Tab>
@ -94,71 +93,107 @@
</Items>
<Content>
<TabPanel Name="UserInformations">
<Validation>
<Field>
<FieldLabel>@L["DisplayName:UserName"]</FieldLabel>
<TextEdit @bind-Text="NewEntity.UserName">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Validation>
<Field>
<FieldLabel>@L["DisplayName:Name"]</FieldLabel>
<TextEdit @bind-Text="NewEntity.Name">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Validation>
<Field>
<FieldLabel>@L["DisplayName:Surname"]</FieldLabel>
<TextEdit @bind-Text="NewEntity.Surname">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Validation>
<Field>
<FieldLabel>@L["DisplayName:Password"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-Text="NewEntity.Password">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Validation>
<Field>
<FieldLabel>@L["DisplayName:Email"]</FieldLabel>
<TextEdit @bind-Text="NewEntity.Email">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Validation>
<Field>
<FieldLabel>@L["DisplayName:PhoneNumber"]</FieldLabel>
<TextEdit @bind-Text="NewEntity.PhoneNumber">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Field>
<FieldLabel>@L["DisplayName:UserName"]</FieldLabel>
<TextEdit @bind-text="NewEntity.UserName"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:Name"]</FieldLabel>
<TextEdit @bind-text="NewEntity.Name"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:Surname"]</FieldLabel>
<TextEdit @bind-text="NewEntity.Surname"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:Password"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-text="NewEntity.Password"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:Email"]</FieldLabel>
<TextEdit @bind-text="NewEntity.Email"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:PhoneNumber"]</FieldLabel>
<TextEdit @bind-text="NewEntity.PhoneNumber"/>
</Field>
<Field>
<Check TValue="bool" @bind-checked="@NewEntity.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Check>
<Check TValue="bool" @bind-Checked="@NewEntity.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Check>
</Field>
</TabPanel>
<TabPanel Name="Roles">
@if (NewUserRoles != null)
@if ( NewUserRoles != null )
{
@foreach (var role in NewUserRoles)
@foreach ( var role in NewUserRoles )
{
<Field>
<input type="hidden" @bind-value="@role.Name"/>
<Check TValue="bool" @bind-checked="@role.IsAssigned">@role.Name</Check>
<input type="hidden" @bind-value="@role.Name" />
<Check TValue="bool" @bind-Checked="@role.IsAssigned">@role.Name</Check>
</Field>
}
}
</TabPanel>
</Content>
</Tabs>
</EditForm>
</Validations>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="CloseCreateModalAsync">@L["Cancel"]</Button>
<Button form="IdentityUserCreateForm" Color="Color.Primary" Clicked="CreateEntityAsync">@L["Save"]</Button>
<Button Color="Color.Primary" Clicked="CreateEntityAsync">@L["Save"]</Button>
</ModalFooter>
</ModalContent>
</Modal>
}
@* ************************* EDIT MODAL ************************* *@
@if (HasUpdatePermission)
@if ( HasUpdatePermission )
{
<Modal @ref="EditModal">
<ModalBackdrop/>
<ModalBackdrop />
<ModalContent IsCentered="true">
<ModalHeader>
<ModalTitle>@L["Edit"]</ModalTitle>
<CloseButton Clicked="CloseEditModalAsync"/>
<CloseButton Clicked="CloseEditModalAsync" />
</ModalHeader>
<ModalBody>
<EditForm id="IdentityUserEditForm" Model="@EditingEntity" OnValidSubmit="UpdateEntityAsync">
<input type="hidden" name="ConcurrencyStamp" @bind-value="EditingEntity.ConcurrencyStamp"/>
<Validations @ref="@EditValidationsRef" Mode="ValidationMode.Auto" Model="@NewEntity" ValidateOnLoad="false">
<input type="hidden" name="ConcurrencyStamp" @bind-value="EditingEntity.ConcurrencyStamp" />
<Tabs @bind-SelectedTab="@EditModalSelectedTab">
<Items>
@ -168,55 +203,89 @@
<Content>
<TabPanel Name="UserInformations">
<Field>
<FieldLabel>@L["DisplayName:UserName"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.UserName"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:Name"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.Name"/>
<Validation>
<FieldLabel>@L["DisplayName:UserName"]</FieldLabel>
<TextEdit @bind-Text="EditingEntity.UserName">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Validation>
</Field>
<Validation>
<Field>
<FieldLabel>@L["DisplayName:Name"]</FieldLabel>
<TextEdit @bind-Text="EditingEntity.Name">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Field>
<FieldLabel>@L["DisplayName:Surname"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.Surname"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:Password"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-text="EditingEntity.Password"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:Email"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.Email"/>
</Field>
<Field>
<FieldLabel>@L["DisplayName:PhoneNumber"]</FieldLabel>
<TextEdit @bind-text="EditingEntity.PhoneNumber"/>
<TextEdit @bind-Text="EditingEntity.Surname">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
<Validation>
<Field>
<FieldLabel>@L["DisplayName:Password"]</FieldLabel>
<TextEdit Role="TextRole.Password" @bind-Text="EditingEntity.Password">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Validation>
<Field>
<FieldLabel>@L["DisplayName:Email"]</FieldLabel>
<TextEdit @bind-Text="EditingEntity.Email">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Validation>
<Field>
<FieldLabel>@L["DisplayName:PhoneNumber"]</FieldLabel>
<TextEdit @bind-Text="EditingEntity.PhoneNumber">
<Feedback>
<ValidationError />
</Feedback>
</TextEdit>
</Field>
</Validation>
<Field>
<Check TValue="bool" @bind-checked="EditingEntity.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Check>
<Check TValue="bool" @bind-Checked="EditingEntity.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Check>
</Field>
</TabPanel>
<TabPanel Name="Roles">
@if (EditUserRoles != null)
@if ( EditUserRoles != null )
{
@foreach (var role in EditUserRoles)
@foreach ( var role in EditUserRoles )
{
<Field>
<input type="hidden" @bind-value="@role.Name"/>
<Check TValue="bool" @bind-checked="@role.IsAssigned">@role.Name</Check>
<input type="hidden" @bind-value="@role.Name" />
<Check TValue="bool" @bind-Checked="@role.IsAssigned">@role.Name</Check>
</Field>
}
}
</TabPanel>
</Content>
</Tabs>
</EditForm>
</Validations>
</ModalBody>
<ModalFooter>
<Button Color="Color.Secondary" Clicked="CloseEditModalAsync">@L["Cancel"]</Button>
<Button form="IdentityUserEditForm" Color="Color.Primary" Clicked="UpdateEntityAsync">@L["Save"]</Button>
<Button Color="Color.Primary" Clicked="UpdateEntityAsync">@L["Save"]</Button>
</ModalFooter>
</ModalContent>
</Modal>
}
<PermissionManagementModal @ref="PermissionManagementModal"/>
<PermissionManagementModal @ref="PermissionManagementModal" />

47
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blazorise;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.BlazoriseUI;
using Volo.Abp.PermissionManagement.Blazor.Components;
@ -29,6 +30,10 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
protected string EditModalSelectedTab = DefaultSelectedTab;
protected Validations CreateValidationsRef { get; set; }
protected Validations EditValidationsRef { get; set; }
public UserManagementBase()
{
ObjectMapperContext = typeof(AbpIdentityBlazorModule);
@ -60,44 +65,62 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity
protected override Task OpenCreateModalAsync()
{
CreateValidationsRef.ClearAll();
CreateModalSelectedTab = DefaultSelectedTab;
NewUserRoles = Roles.Select(x => new AssignedRoleViewModel
{
Name = x.Name,
IsAssigned = x.IsDefault
}).ToArray();
{
Name = x.Name,
IsAssigned = x.IsDefault
}).ToArray();
return base.OpenCreateModalAsync();
}
protected override Task CreateEntityAsync()
{
NewEntity.RoleNames = NewUserRoles.Where(x => x.IsAssigned).Select(x => x.Name).ToArray();
if (CreateValidationsRef.ValidateAll())
{
CreateModal.Hide();
NewEntity.RoleNames = NewUserRoles.Where(x => x.IsAssigned).Select(x => x.Name).ToArray();
return base.CreateEntityAsync();
return base.CreateEntityAsync();
}
return Task.CompletedTask;
}
protected override async Task OpenEditModalAsync(Guid id)
{
EditValidationsRef.ClearAll();
EditModalSelectedTab = DefaultSelectedTab;
var userRoleNames = (await AppService.GetRolesAsync(id)).Items.Select(r => r.Name).ToList();
EditUserRoles = Roles.Select(x => new AssignedRoleViewModel
{
Name = x.Name,
IsAssigned = userRoleNames.Contains(x.Name)
}).ToArray();
{
Name = x.Name,
IsAssigned = userRoleNames.Contains(x.Name)
}).ToArray();
await base.OpenEditModalAsync(id);
}
protected override Task UpdateEntityAsync()
{
EditingEntity.RoleNames = EditUserRoles.Where(x => x.IsAssigned).Select(x => x.Name).ToArray();
if (EditValidationsRef.ValidateAll())
{
EditModal.Hide();
EditingEntity.RoleNames = EditUserRoles.Where(x => x.IsAssigned).Select(x => x.Name).ToArray();
return base.UpdateEntityAsync();
}
return base.UpdateEntityAsync();
return Task.CompletedTask;
}
}

Loading…
Cancel
Save