From 4fbe8d34f10a7ed24ae349209323a0c75920c938 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 2 Nov 2020 10:01:32 +0100 Subject: [PATCH 1/2] Add null check for validations component --- .../Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index eb9cab5a73..18ff4bf7a1 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -281,9 +281,7 @@ namespace Volo.Abp.BlazoriseUI protected virtual async Task OpenCreateModalAsync() { - await OnOpeningCreateModalAsync(); - - CreateValidationsRef.ClearAll(); + CreateValidationsRef?.ClearAll(); await CheckCreatePolicyAsync(); @@ -296,11 +294,6 @@ namespace Volo.Abp.BlazoriseUI CreateModal.Show(); } - protected virtual Task OnOpeningCreateModalAsync() - { - return Task.CompletedTask; - } - protected virtual Task CloseCreateModalAsync() { CreateModal.Hide(); @@ -309,9 +302,7 @@ namespace Volo.Abp.BlazoriseUI protected virtual async Task OpenEditModalAsync(TKey id) { - await OnOpeningEditModalAsync(id); - - EditValidationsRef.ClearAll(); + EditValidationsRef?.ClearAll(); await CheckUpdatePolicyAsync(); @@ -325,11 +316,6 @@ namespace Volo.Abp.BlazoriseUI EditModal.Show(); } - protected virtual Task OnOpeningEditModalAsync(TKey id) - { - return Task.CompletedTask; - } - protected virtual TUpdateViewModel MapToEditingEntity(TGetOutputDto entityDto) { return ObjectMapper.Map(entityDto); @@ -363,7 +349,7 @@ namespace Volo.Abp.BlazoriseUI protected virtual async Task CreateEntityAsync() { - if (CreateValidationsRef.ValidateAll()) + if (CreateValidationsRef?.ValidateAll() ?? false) { await OnCreatingEntityAsync(); @@ -390,7 +376,7 @@ namespace Volo.Abp.BlazoriseUI protected virtual async Task UpdateEntityAsync() { - if (EditValidationsRef.ValidateAll()) + if (EditValidationsRef?.ValidateAll() ?? false) { await OnUpdatingEntityAsync(); From 895a94d15994a0c902f4e75ca81cd5b9e434e878 Mon Sep 17 00:00:00 2001 From: Mladen Macanovic Date: Mon, 2 Nov 2020 10:01:57 +0100 Subject: [PATCH 2/2] Removed on OnOpeningCreateModalAsync and OnOpeningEditModalAsync --- .../Pages/Identity/UserManagement.razor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs index b47998f55d..e905215616 100644 --- a/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs +++ b/modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs @@ -61,7 +61,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity HasManagePermissionsPermission; } - protected override async Task OnOpeningCreateModalAsync() + protected override Task OpenCreateModalAsync() { CreateModalSelectedTab = DefaultSelectedTab; @@ -71,7 +71,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity IsAssigned = x.IsDefault }).ToArray(); - await base.OnOpeningCreateModalAsync(); + return base.OpenCreateModalAsync(); } protected override Task OnCreatingEntityAsync() @@ -94,7 +94,7 @@ namespace Volo.Abp.Identity.Blazor.Pages.Identity IsAssigned = userRoleNames.Contains(x.Name) }).ToArray(); - await base.OnOpeningEditModalAsync(id); + await base.OpenEditModalAsync(id); } protected override Task OnUpdatingEntityAsync()