From a36ccf1e822727c7cf7af0e8c4f3147c99f7a648 Mon Sep 17 00:00:00 2001 From: Ilkay Ilknur Date: Mon, 26 Oct 2020 13:55:16 +0300 Subject: [PATCH] move confirmation check to the actions component. --- framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs | 6 ------ .../Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs | 8 +++++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs index 76f7caf377..4df70152fa 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs @@ -169,7 +169,6 @@ namespace Volo.Abp.BlazoriseUI where TUpdateViewModel : class, new() { [Inject] protected TAppService AppService { get; set; } - [Inject] protected IUiMessageService UiMessageService { get; set; } [Inject] protected IStringLocalizer UiLocalizer { get; set; } [Inject] protected IAuthorizationService AuthorizationService { get; set; } @@ -392,11 +391,6 @@ namespace Volo.Abp.BlazoriseUI { await CheckDeletePolicyAsync(); - if (!await UiMessageService.ConfirmAsync(GetDeleteConfirmationMessage(entity))) - { - return; - } - await AppService.DeleteAsync(entity.Id); await GetEntitiesAsync(); } diff --git a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs index 7d2a96dcf1..6e98865297 100644 --- a/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs +++ b/framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs @@ -1,8 +1,10 @@ using System; using System.Threading.Tasks; using Blazorise; +using Localization.Resources.AbpUi; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Localization; using Volo.Abp.AspNetCore.Components.WebAssembly; namespace Volo.Abp.BlazoriseUI.Components @@ -27,7 +29,7 @@ namespace Volo.Abp.BlazoriseUI.Components public Color Color { get; set; } [Parameter] - public string ConfirmationMessage { get; set; } + public Func ConfirmationMessage { get; set; } [CascadingParameter] public EntityActions ParentActions { get; set; } @@ -48,9 +50,9 @@ namespace Volo.Abp.BlazoriseUI.Components protected internal virtual async Task ActionClickedAsync() { - if (!ConfirmationMessage.IsNullOrEmpty()) + if (ConfirmationMessage != null) { - if (await UiMessageService.ConfirmAsync(ConfirmationMessage)) + if (await UiMessageService.ConfirmAsync(ConfirmationMessage())) { await Clicked.InvokeAsync(); }