mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-16 01:41:14 +08:00
6bf817d1ea
* refactor: change the name of ModalRef to ConfirmRef in order to create a Modal dialog in service mode BREAKING CHANGE: all using of ModalRef must rename to ConfirmRef * refactor: chang the name of ModalTemplate to ConfirmTemplate in order to create a Modal dialog in service mode BREAKING CHANGE: all using of ModalTemplate must rename to ConfirmTemplate * feat(module: modal): support creating Modal dialog from ModalService Co-authored-by: James Yeung <shunjiey@hotmail.com>
61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public class ConfirmTemplate<TComponentOptions, TResult> : TemplateComponentBase<TComponentOptions>, IModalTemplate
|
|
{
|
|
[Parameter]
|
|
public ConfirmRef<TResult> ConfirmRef { get; set; }
|
|
|
|
/// <summary>
|
|
/// Emit Ok and return values
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task OnOkAsync(TResult result)
|
|
{
|
|
await (ConfirmRef.OnOk?.Invoke(result) ?? Task.CompletedTask);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Emit Cancel and return values
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public async Task OnCancelAsync(TResult result)
|
|
{
|
|
await (ConfirmRef.OnCancel?.Invoke(result) ?? Task.CompletedTask);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Close the Modal
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected async Task CloseAsync()
|
|
{
|
|
await ConfirmRef.CloseAsync();
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
base.OnInitialized();
|
|
ConfirmRef.ModalTemplate = this;
|
|
}
|
|
|
|
|
|
public virtual Task CancelAsync(ModalClosingEventArgs args)
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
public virtual Task OkAsync(ModalClosingEventArgs args)
|
|
{
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
}
|
|
}
|