Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.6.1-beta02</Version>
<Version>9.6.1-beta03</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
21 changes: 20 additions & 1 deletion src/BootstrapBlazor/Extensions/DialogServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,29 @@
namespace BootstrapBlazor.Components;

/// <summary>
/// DialogService 扩展方法
/// DialogService extensions method
/// </summary>
public static class DialogServiceExtensions
{
/// <summary>
/// Show dialog with generic type.
/// </summary>
/// <param name="service">DialogService 服务实例</param>
/// <param name="title">对话框标题,优先级高于 <see cref="DialogOption.Title"/></param>
/// <param name="parameters">TComponent 组件所需要的参数集合</param>
/// <param name="dialog">指定弹窗组件 默认为 null 使用 <see cref="BootstrapBlazorRoot"/> 组件内置弹窗组件</param>
public static Task Show<TComponent>(this DialogService service, string title, IDictionary<string, object?>? parameters = null, Dialog? dialog = null) where TComponent : IComponent
{
var option = new DialogOption();
if (!string.IsNullOrEmpty(title))
{
option.Title = title;
}
option.ShowFooter = false;
option.Component = BootstrapDynamicComponent.CreateComponent<TComponent>(parameters);
return service.Show(option, dialog);
}

/// <summary>
/// 弹出搜索对话框
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions test/UnitTest/Components/DialogTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,11 @@ await cut.InvokeAsync(() => dialog.ShowCloseDialog<MockValidateFormDialog>("Clos
}));
await cut.InvokeAsync(() => modal.Instance.CloseCallback());
#endregion

#region Show Extensions Method
await cut.InvokeAsync(() => dialog.Show<MockValidateFormDialog>("Test Title"));
await cut.InvokeAsync(() => modal.Instance.CloseCallback());
#endregion
}

private class MockValidateFormDialog : ComponentBase
Expand Down