ant-design-blazor/site/AntDesign.Docs/Demos/Components/Modal/ConfirmTemplateDemo.razor
zxyao 6aff9d370c fix(module: dialog): Modal and Drawer render reducing and update document and demo (#1701)
* fix(module: Modal&Drawer): render reducing and demo update

* docs(module: modal): add FAQ section

* docs: add English comments

* fix: wrong format in Modal_service_for_confirm.razor

Co-authored-by: James Yeung <shunjiey@hotmail.com>
2021-07-11 20:48:16 +08:00

56 lines
1.6 KiB
C#

@inherits FeedbackComponent<string, string>
<div>
<Text>Please input "@config"</Text>
value: <Input @bind-Value="value" Placeholder="@config" />
</div>
@code{
string config;
string value;
protected override void OnInitialized()
{
config = this.Options;
base.OnInitialized();
}
public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args)
{
if (FeedbackRef is ConfirmRef confirmRef)
{
confirmRef.Config.OkButtonProps.Loading = true;
await confirmRef.UpdateConfigAsync();
}
else if (FeedbackRef is ModalRef modalRef)
{
modalRef.Config.ConfirmLoading = true;
await modalRef.UpdateConfigAsync();
}
await Task.Delay(1000);
// only the input's value equals the initialized value, the OK button will close the confirm dialog box
if (value != config)
args.Cancel = true;
else
// method 1(not recommended): await (FeedbackRef as ConfirmRef<string>)!.OkAsync(value);
// method 2: await (FeedbackRef as IOkCancelRef<string>)!.OkAsync(value);
await base.OkCancelRefWithResult!.OnOk(value);
await base.OnFeedbackOkAsync(args);
}
/// <summary>
/// If you want <b>Dispose</b> to take effect every time it is closed in Modal, which created by ModalService,
/// set <b>ModalOptions.DestroyOnClose = true</b>
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
Console.WriteLine("Dispose");
base.Dispose(disposing);
}
}