Browse Source

move confirmation check to the actions component.

pull/5890/head
Ilkay Ilknur 6 years ago
parent
commit
a36ccf1e82
  1. 6
      framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs
  2. 8
      framework/src/Volo.Abp.BlazoriseUI/Components/EntityAction.razor.cs

6
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<AbpUiResource> 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();
}

8
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<string> ConfirmationMessage { get; set; }
[CascadingParameter]
public EntityActions<TItem> 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();
}

Loading…
Cancel
Save