From 8a5ee4d5e245ebca611db588bed1e5efdab22cc7 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 13 Feb 2022 00:53:00 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20Dialog=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20ShowMaximizeButton=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Dialog/DialogOption.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Dialog/DialogOption.cs b/src/BootstrapBlazor/Components/Dialog/DialogOption.cs index 1ea7eaf23..e33d5fdd4 100644 --- a/src/BootstrapBlazor/Components/Dialog/DialogOption.cs +++ b/src/BootstrapBlazor/Components/Dialog/DialogOption.cs @@ -37,6 +37,11 @@ public class DialogOption /// public FullScreenSize FullScreenSize { get; set; } = FullScreenSize.None; + /// + /// 获得/设置 是否显示最大化按钮 默认 false 不显示 + /// + public bool ShowMaximizeButton { get; set; } + /// /// 获得/设置 是否垂直居中 默认为 true /// @@ -162,7 +167,8 @@ public class DialogOption [nameof(ShowPrintButtonInHeader)] = ShowPrintButtonInHeader, [nameof(IsKeyboard)] = IsKeyboard, [nameof(IsAutoCloseAfterSave)] = IsAutoCloseAfterSave, - [nameof(IsDraggable)] = IsDraggable + [nameof(IsDraggable)] = IsDraggable, + [nameof(ShowMaximizeButton)] = ShowMaximizeButton }; if (!string.IsNullOrEmpty(PrintButtonText)) { -- Gitee From f688d5d2204cb4c5616e9b9f278e3ad9a456926a Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 13 Feb 2022 00:53:15 +0800 Subject: [PATCH 2/5] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Samples/Dialogs.razor | 4 ++++ .../Samples/Dialogs.razor.cs | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor index bbbd7c356..02cf1347c 100644 --- a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor +++ b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor @@ -130,6 +130,10 @@ + + + +

功能介绍

    diff --git a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs index 592c3fc1f..4bf9e26ad 100644 --- a/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs +++ b/src/BootstrapBlazor.Shared/Samples/Dialogs.razor.cs @@ -190,6 +190,19 @@ public sealed partial class Dialogs await DialogService.Show(op); } + private async Task OnMaximizeDialogClick() + { + await DialogService.Show(new DialogOption() + { + Title = $"可控制最大化弹窗", + ShowMaximizeButton = true, + BodyTemplate = builder => + { + builder.AddContent(0, "点击 Header 中最大化按钮弹窗可全屏"); + } + }); + } + private string? InputValue { get; set; } private IEnumerable Emails { get; set; } = Array.Empty(); @@ -380,6 +393,13 @@ public sealed partial class Dialogs Type = "string", ValueList = " — ", DefaultValue = "资源文件中设定值" + }, + new AttributeItem() { + Name = nameof(DialogOption.ShowMaximizeButton), + Description = "是否显示最大化按钮", + Type = "boolean", + ValueList = "true|false", + DefaultValue = "false" } }; } -- Gitee From 3165f6445d044572de6de06d3f8ea12fb237b779 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 13 Feb 2022 01:08:45 +0800 Subject: [PATCH 3/5] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20Dialog=20?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/DialogTest.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/UnitTest/Components/DialogTest.cs b/test/UnitTest/Components/DialogTest.cs index ba539a0a6..9d558b489 100644 --- a/test/UnitTest/Components/DialogTest.cs +++ b/test/UnitTest/Components/DialogTest.cs @@ -26,6 +26,7 @@ public class DialogTest : BootstrapBlazorTestBase HeaderTemplate = builder => builder.AddContent(0, "Test-HeaderTemplate"), FooterTemplate = builder => builder.AddContent(0, "Test-FooterTemplate"), Class = "test-class", + ShowMaximizeButton = true, OnCloseAsync = () => { closed = true; @@ -33,6 +34,9 @@ public class DialogTest : BootstrapBlazorTestBase } })); + // 全屏按钮 + Assert.Contains("btn-maximize", cut.Markup); + // 代码覆盖模板单元测试 Assert.Contains("Test-BodyTemplate", cut.Markup); Assert.Contains("Test-HeaderTemplate", cut.Markup); -- Gitee From e48c1869e1b457fb660f1439900963157f8706b2 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 13 Feb 2022 00:37:21 +0800 Subject: [PATCH 4/5] =?UTF-8?q?refactor:=20=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=B6=88=E9=99=A4=E8=AD=A6=E5=91=8A=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Dialog/Dialog.razor | 2 +- src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs | 2 +- .../Components/Dialog/SearchDialog.razor | 2 +- .../Components/Dialog/SearchDialog.razor.cs | 10 ---------- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/BootstrapBlazor/Components/Dialog/Dialog.razor b/src/BootstrapBlazor/Components/Dialog/Dialog.razor index fb801da09..c667a65ff 100644 --- a/src/BootstrapBlazor/Components/Dialog/Dialog.razor +++ b/src/BootstrapBlazor/Components/Dialog/Dialog.razor @@ -4,6 +4,6 @@ @foreach (var parameter in DialogParameters) { - @RenderDialog(parameter) + @Dialog.RenderDialog(parameter) } diff --git a/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs b/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs index d95fc48a6..84a5e6b44 100644 --- a/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs +++ b/src/BootstrapBlazor/Components/Dialog/Dialog.razor.cs @@ -126,7 +126,7 @@ public partial class Dialog : IDisposable return Task.CompletedTask; } - private RenderFragment RenderDialog(IEnumerable> parameter) => builder => + private static RenderFragment RenderDialog(IEnumerable> parameter) => builder => { builder.OpenComponent(0); builder.AddMultipleAttributes(1, parameter); diff --git a/src/BootstrapBlazor/Components/Dialog/SearchDialog.razor b/src/BootstrapBlazor/Components/Dialog/SearchDialog.razor index 58a6c9aae..be50855d8 100644 --- a/src/BootstrapBlazor/Components/Dialog/SearchDialog.razor +++ b/src/BootstrapBlazor/Components/Dialog/SearchDialog.razor @@ -4,7 +4,7 @@ @if (BodyTemplate != null) { - @BodyTemplate?.Invoke(Model) + @BodyTemplate.Invoke(Model)
    @RenderFooter diff --git a/src/BootstrapBlazor/Components/Dialog/SearchDialog.razor.cs b/src/BootstrapBlazor/Components/Dialog/SearchDialog.razor.cs index 10eb6cf09..d65f7a25e 100644 --- a/src/BootstrapBlazor/Components/Dialog/SearchDialog.razor.cs +++ b/src/BootstrapBlazor/Components/Dialog/SearchDialog.razor.cs @@ -55,15 +55,5 @@ public partial class SearchDialog ResetButtonText ??= Localizer[nameof(ResetButtonText)]; QueryButtonText ??= Localizer[nameof(QueryButtonText)]; - - if (OnSearchClick == null) - { - OnSearchClick = () => Task.CompletedTask; - } - - if (OnResetSearchClick == null) - { - OnResetSearchClick = () => Task.CompletedTask; - } } } -- Gitee From fc9e0f318160a851e9b743ac55b205193a990df0 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 13 Feb 2022 00:37:34 +0800 Subject: [PATCH 5/5] =?UTF-8?q?test:=20=E6=8F=90=E9=AB=98=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A6=86=E7=9B=96=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/DialogTest.cs | 36 ++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/test/UnitTest/Components/DialogTest.cs b/test/UnitTest/Components/DialogTest.cs index 9d558b489..76a352e1c 100644 --- a/test/UnitTest/Components/DialogTest.cs +++ b/test/UnitTest/Components/DialogTest.cs @@ -74,10 +74,22 @@ public class DialogTest : BootstrapBlazorTestBase Title = "Test-SearchDialogTitle", Model = new Foo(), ItemsPerRow = 2, - RowType = RowType.Inline + RowType = RowType.Inline, + LabelAlign = Alignment.Left, + ResetButtonText = null, + QueryButtonText = null, + Items = null }; cut.InvokeAsync(() => dialog.ShowSearchDialog(option)); - cut.InvokeAsync(() => modal.Instance.Close()); + + // 重置按钮委托为空 null + var button = cut.FindComponents