From fa305f7e3b65368b7ba90ae25a34b1a713af4270 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 12:14:13 +0800 Subject: [PATCH 01/24] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20Select=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/SelectTest.cs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 test/UnitTest/Components/SelectTest.cs diff --git a/test/UnitTest/Components/SelectTest.cs b/test/UnitTest/Components/SelectTest.cs new file mode 100644 index 000000000..47f30aa6e --- /dev/null +++ b/test/UnitTest/Components/SelectTest.cs @@ -0,0 +1,9 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +// Website: https://www.blazor.zone or https://argozhang.github.io/ + +namespace UnitTest.Components; + +public class SelectTest : BootstrapBlazorTestBase +{ +} -- Gitee From 630da51e62909b48835e662e5afc6f68615c773c Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 13:51:59 +0800 Subject: [PATCH 02/24] =?UTF-8?q?test:=20=E9=87=8D=E6=9E=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=B6=88=E9=99=A4=E8=AD=A6=E5=91=8A=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/DialogTest.cs | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/UnitTest/Components/DialogTest.cs b/test/UnitTest/Components/DialogTest.cs index 5ed50df3a..ba539a0a6 100644 --- a/test/UnitTest/Components/DialogTest.cs +++ b/test/UnitTest/Components/DialogTest.cs @@ -241,12 +241,12 @@ public class DialogTest : BootstrapBlazorTestBase Assert.Equal(2, cut.FindComponents().Count); // 关闭第二个弹窗 - var btnClose = cut.FindAll(".btn-close").Last(); + var btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); Assert.Equal(1, cut.FindComponents().Count); // 关闭第一个弹窗 - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); Assert.Equal(0, cut.FindComponents().Count); #endregion @@ -257,7 +257,7 @@ public class DialogTest : BootstrapBlazorTestBase FullScreenSize = FullScreenSize.Large })); Assert.Contains("modal-fullscreen-lg-down", cut.Markup); - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); #endregion @@ -267,7 +267,7 @@ public class DialogTest : BootstrapBlazorTestBase IsCentered = true })); Assert.Contains("modal-dialog-centered", cut.Markup); - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); cut.InvokeAsync(() => dialog.Show(new DialogOption() @@ -275,7 +275,7 @@ public class DialogTest : BootstrapBlazorTestBase IsCentered = false })); Assert.DoesNotContain("modal-dialog-centered", cut.Markup); - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); #endregion @@ -285,7 +285,7 @@ public class DialogTest : BootstrapBlazorTestBase IsKeyboard = true })); Assert.Contains("data-bs-keyboard=\"true\"", cut.Markup); - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); cut.InvokeAsync(() => dialog.Show(new DialogOption() @@ -293,7 +293,7 @@ public class DialogTest : BootstrapBlazorTestBase IsKeyboard = false })); Assert.DoesNotContain("data-bs-keyboard\"false\"", cut.Markup); - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); #endregion @@ -302,7 +302,7 @@ public class DialogTest : BootstrapBlazorTestBase { ShowHeaderCloseButton = true })); - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); cut.InvokeAsync(() => dialog.Show(new DialogOption() @@ -310,7 +310,7 @@ public class DialogTest : BootstrapBlazorTestBase ShowHeaderCloseButton = false })); Assert.DoesNotContain("btn-close", cut.Markup); - btnClose = cut.FindAll(".btn-secondary").Last(); + btnClose = cut.FindAll(".btn-secondary")[cut.FindAll(".btn-secondary").Count - 1]; btnClose.Click(); #endregion @@ -320,7 +320,7 @@ public class DialogTest : BootstrapBlazorTestBase ShowPrintButton = true })); Assert.Contains("btn-print", cut.Markup); - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); cut.InvokeAsync(() => dialog.Show(new DialogOption() @@ -328,7 +328,7 @@ public class DialogTest : BootstrapBlazorTestBase ShowPrintButton = false })); Assert.DoesNotContain("btn-print", cut.Markup); - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); cut.InvokeAsync(() => dialog.Show(new DialogOption() @@ -339,7 +339,7 @@ public class DialogTest : BootstrapBlazorTestBase })); Assert.Contains("btn-print", cut.Markup); Assert.Contains("Print-Test", cut.Markup); - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); #endregion @@ -353,7 +353,7 @@ public class DialogTest : BootstrapBlazorTestBase })); Assert.Contains("Save-Test", cut.Markup); Assert.Contains("Close-Test", cut.Markup); - btnClose = cut.FindAll(".btn-close").Last(); + btnClose = cut.FindAll(".btn-close")[cut.FindAll(".btn-close").Count - 1]; btnClose.Click(); #endregion @@ -370,7 +370,7 @@ public class DialogTest : BootstrapBlazorTestBase return Task.FromResult(save); } })); - btnClose = cut.FindAll(".btn-primary").Last(); + btnClose = cut.FindAll(".btn-primary")[cut.FindAll(".btn-primary").Count - 1]; btnClose.Click(); Assert.True(save); #endregion -- Gitee From cef65e69394606c3fa42c789e46ceda29557c9f1 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 22:52:46 +0800 Subject: [PATCH 03/24] =?UTF-8?q?refactor:=20=E7=B2=BE=E7=AE=80=20placehol?= =?UTF-8?q?der=20=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Select/Select.razor.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/BootstrapBlazor/Components/Select/Select.razor.cs b/src/BootstrapBlazor/Components/Select/Select.razor.cs index c35781a40..bcf886173 100644 --- a/src/BootstrapBlazor/Components/Select/Select.razor.cs +++ b/src/BootstrapBlazor/Components/Select/Select.razor.cs @@ -139,19 +139,7 @@ public partial class Select : ISelect { base.OnParametersSet(); - if (NullableUnderlyingType != null) - { - if (string.IsNullOrEmpty(PlaceHolder)) - { - // 设置 placeholder - if (AdditionalAttributes != null && AdditionalAttributes.TryGetValue("placeholder", out var pl)) - { - PlaceHolder = pl?.ToString(); - AdditionalAttributes.Remove("placeholder"); - } - } - PlaceHolder ??= Localizer[nameof(PlaceHolder)]; - } + PlaceHolder ??= Localizer[nameof(PlaceHolder)]; // 内置对枚举类型的支持 var t = NullableUnderlyingType ?? typeof(TValue); -- Gitee From 8dc090e2716d16539062d5c01146470a79dee5cc Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 22:53:13 +0800 Subject: [PATCH 04/24] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=20Enum=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E5=80=99=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Select/Select.razor.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/BootstrapBlazor/Components/Select/Select.razor.cs b/src/BootstrapBlazor/Components/Select/Select.razor.cs index bcf886173..4411cdb24 100644 --- a/src/BootstrapBlazor/Components/Select/Select.razor.cs +++ b/src/BootstrapBlazor/Components/Select/Select.razor.cs @@ -152,12 +152,6 @@ public partial class Select : ISelect private void ResetSelectedItem() { - // 合并 Items 与 Options 集合 - if (!Items.Any() && typeof(TValue).IsEnum()) - { - Items = typeof(TValue).ToSelectList(); - } - if (string.IsNullOrEmpty(SearchText)) { DataSource = Items.ToList(); -- Gitee From fc14e2a536246f30c4efbf5d6226ed00be2d85c5 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 22:57:56 +0800 Subject: [PATCH 05/24] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=20IsDisabl?= =?UTF-8?q?ed=20=E6=9D=A1=E4=BB=B6=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Select/Select.razor.cs | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/BootstrapBlazor/Components/Select/Select.razor.cs b/src/BootstrapBlazor/Components/Select/Select.razor.cs index 4411cdb24..ab80cec66 100644 --- a/src/BootstrapBlazor/Components/Select/Select.razor.cs +++ b/src/BootstrapBlazor/Components/Select/Select.razor.cs @@ -213,40 +213,37 @@ public partial class Select : ISelect /// private async Task OnItemClick(SelectedItem item) { - if (!IsDisabled && !item.IsDisabled) + var ret = true; + if (OnBeforeSelectedItemChange != null) { - var ret = true; - if (OnBeforeSelectedItemChange != null) + ret = await OnBeforeSelectedItemChange(item); + if (ret) { - ret = await OnBeforeSelectedItemChange(item); - if (ret) + // 返回 True 弹窗提示 + var option = new SwalOption() { - // 返回 True 弹窗提示 - var option = new SwalOption() - { - Category = SwalCategory, - Title = SwalTitle, - Content = SwalContent, - IsConfirm = true - }; - if (!string.IsNullOrEmpty(SwalFooter)) - { - option.ShowFooter = true; - option.FooterTemplate = builder => builder.AddContent(0, SwalFooter); - } - ret = await SwalService.ShowModal(option); - } - else + Category = SwalCategory, + Title = SwalTitle, + Content = SwalContent, + IsConfirm = true + }; + if (!string.IsNullOrEmpty(SwalFooter)) { - // 返回 False 直接运行 - ret = true; + option.ShowFooter = true; + option.FooterTemplate = builder => builder.AddContent(0, SwalFooter); } + ret = await SwalService.ShowModal(option); } - if (ret) + else { - await ItemChanged(item); + // 返回 False 直接运行 + ret = true; } } + if (ret) + { + await ItemChanged(item); + } } /// -- Gitee From 1669a511c1beb895a6ac20bbc2fad054a059a590 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 22:58:07 +0800 Subject: [PATCH 06/24] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Shared/Locales/en.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor.Shared/Locales/en.json b/src/BootstrapBlazor.Shared/Locales/en.json index beab3601f..abb26e2a3 100644 --- a/src/BootstrapBlazor.Shared/Locales/en.json +++ b/src/BootstrapBlazor.Shared/Locales/en.json @@ -1438,7 +1438,7 @@ "Block3Intro": "The values in the text box change as you change the drop-down option by binding the Model.Name property to the component with Select .", "Block4Title": "Select cascading binding", "Block4Intro": "The second drop-down box dynamically populates the content by selecting the different options for the first drop-down box.", - "ButtonText1": "Example of a window intermediate joint", + "ButtonText1": "In Dialog", "Block5Title": "Select client validation", "Block5Intro": "When the drop-down box is not selected, it is blocked when the submit button is clicked.", "Option1": "Please select ...", -- Gitee From 4d4347ff9ddbb44858dd1fb3136b19ed6fa76761 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 22:58:40 +0800 Subject: [PATCH 07/24] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=9A=84=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs b/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs index ddac91673..769574f31 100644 --- a/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs +++ b/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs @@ -62,11 +62,6 @@ public class SwalOption : PopupOptionBase /// 此属性给模态弹窗时使用 public bool IsConfirm { get; set; } - /// - /// 获得/设置 是否保持弹窗内组件状态 默认为 false 不保持 - /// - public bool KeepChildrenState { get; set; } - /// /// 获得/设置 按钮模板 /// -- Gitee From 16edadef10adc0362656ef1c107bfb4609a1d37d Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 22:58:56 +0800 Subject: [PATCH 08/24] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Select/SelectBase.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/BootstrapBlazor/Components/Select/SelectBase.cs b/src/BootstrapBlazor/Components/Select/SelectBase.cs index 9ddbdaa79..915ebadfd 100644 --- a/src/BootstrapBlazor/Components/Select/SelectBase.cs +++ b/src/BootstrapBlazor/Components/Select/SelectBase.cs @@ -17,31 +17,31 @@ public abstract class SelectBase : ValidateBase protected SelectedItem? SelectedItem { get; set; } /// - /// 获得/设置 按钮颜色 + /// 获得/设置 颜色 默认 Color.None 无设置 /// [Parameter] - public Color Color { get; set; } = Color.None; + public Color Color { get; set; } /// - /// 获得/设置 SWal 图标 + /// 获得/设置 Swal 图标 默认 Question /// [Parameter] public SwalCategory SwalCategory { get; set; } = SwalCategory.Question; /// - /// 获得/设置 Swal 标题 + /// 获得/设置 Swal 标题 默认 null /// [Parameter] public string? SwalTitle { get; set; } /// - /// 获得/设置 Swal 内容 + /// 获得/设置 Swal 内容 默认 null /// [Parameter] public string? SwalContent { get; set; } /// - /// 获得/设置 是否显示 Swal Footer + /// 获得/设置 Footer 默认 null /// [Parameter] public string? SwalFooter { get; set; } -- Gitee From 74971c10eea40642d5d00fbf5bbaabe2b56412d5 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 22:59:19 +0800 Subject: [PATCH 09/24] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=8F=AF=E4=B8=BA=E7=A9=BA=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Select/SelectOption.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/BootstrapBlazor/Components/Select/SelectOption.cs b/src/BootstrapBlazor/Components/Select/SelectOption.cs index e601dc694..095c109fa 100644 --- a/src/BootstrapBlazor/Components/Select/SelectOption.cs +++ b/src/BootstrapBlazor/Components/Select/SelectOption.cs @@ -9,28 +9,28 @@ namespace BootstrapBlazor.Components; /// /// SelectOption 组件 /// -public partial class SelectOption : ComponentBase +public class SelectOption : ComponentBase { /// /// 获得/设置 显示名称 /// [Parameter] - public string Text { get; set; } = ""; + public string? Text { get; set; } /// /// 获得/设置 选项值 /// [Parameter] - public string Value { get; set; } = ""; + public string? Value { get; set; } /// - /// 获得/设置 是否选中 + /// 获得/设置 是否选中 默认 false /// [Parameter] public bool Active { get; set; } /// - /// 获得/设置 是否禁用 + /// 获得/设置 是否禁用 默认 false /// [Parameter] public bool IsDisabled { get; set; } @@ -39,7 +39,7 @@ public partial class SelectOption : ComponentBase /// 获得/设置 分组名称 /// [Parameter] - public string GroupName { get; set; } = ""; + public string? GroupName { get; set; } /// /// 父组件通过级联参数获得 @@ -60,9 +60,9 @@ public partial class SelectOption : ComponentBase private SelectedItem ToSelectedItem() => new() { Active = Active, - GroupName = GroupName, - Text = Text, - Value = Value, + GroupName = GroupName ?? "", + Text = Text ?? "", + Value = Value ?? "", IsDisabled = IsDisabled }; } -- Gitee From 06694fc97078309d4e7cc3ad8e3b4eae77a50c63 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 22:59:34 +0800 Subject: [PATCH 10/24] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs b/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs index 769574f31..612918678 100644 --- a/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs +++ b/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs @@ -86,10 +86,11 @@ public class SwalOption : PopupOptionBase [nameof(Size)] = Size.Medium, [nameof(ModalDialog.IsCentered)] = true, [nameof(ModalDialog.IsScrolling)] = false, - [nameof(ModalDialog.ShowCloseButton)] = false, - [nameof(ShowFooter)] = false, + [nameof(ModalDialog.ShowCloseButton)] = ShowClose, + [nameof(ShowFooter)] = ShowFooter, [nameof(ModalDialog.Title)] = Title, - [nameof(BodyContext)] = BodyContext + [nameof(BodyContext)] = BodyContext, + [nameof(FooterTemplate)] = FooterTemplate }; return parameters; } -- Gitee From 14f09a866b3f198bc60355b2d4f6d9f94a8ac28f Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 23:00:01 +0800 Subject: [PATCH 11/24] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20OnSearchText?= =?UTF-8?q?Changed=20=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/SelectTest.cs | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/UnitTest/Components/SelectTest.cs b/test/UnitTest/Components/SelectTest.cs index 47f30aa6e..6da0769f6 100644 --- a/test/UnitTest/Components/SelectTest.cs +++ b/test/UnitTest/Components/SelectTest.cs @@ -2,8 +2,48 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Website: https://www.blazor.zone or https://argozhang.github.io/ +using BootstrapBlazor.Shared; + namespace UnitTest.Components; public class SelectTest : BootstrapBlazorTestBase { + [Fact] + public void OnSearchTextChanged_Null() + { + var cut = Context.RenderComponent(pb => + { + pb.AddChildContent>(pb => + { + pb.Add(a => a.ShowSearch, true); + pb.Add(a => a.Items, new List() + { + new SelectedItem("1", "Test1"), + new SelectedItem("2", "Test2") { IsDisabled = true } + }); + }); + }); + + var ctx = cut.FindComponent>(); + ctx.InvokeAsync(() => ctx.Instance.ConfirmSelectedItem(0)); + + // 搜索 T + ctx.Find(".search-text").Input("T"); + ctx.InvokeAsync(() => ctx.Instance.ConfirmSelectedItem(0)); + + ctx.SetParametersAndRender(pb => + { + pb.Add(a => a.OnBeforeSelectedItemChange, item => Task.FromResult(false)); + pb.Add(a => a.OnSelectedItemChanged, item => Task.CompletedTask); + }); + ctx.InvokeAsync(() => ctx.Instance.ConfirmSelectedItem(0)); + + ctx.SetParametersAndRender(pb => + { + pb.Add(a => a.OnBeforeSelectedItemChange, item => Task.FromResult(true)); + pb.Add(a => a.SwalFooter, "test-footer"); + }); + //ctx.InvokeAsync(() => ctx.Instance.ConfirmSelectedItem(0)); + //cut.Find(".swal .btn-danger").Click(); + } } -- Gitee From b2667ffee7dc846122b5fb2ec5479b0d68d65431 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 23:00:17 +0800 Subject: [PATCH 12/24] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20Options=20?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=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/SelectTest.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/UnitTest/Components/SelectTest.cs b/test/UnitTest/Components/SelectTest.cs index 6da0769f6..4d6524f43 100644 --- a/test/UnitTest/Components/SelectTest.cs +++ b/test/UnitTest/Components/SelectTest.cs @@ -46,4 +46,22 @@ public class SelectTest : BootstrapBlazorTestBase //ctx.InvokeAsync(() => ctx.Instance.ConfirmSelectedItem(0)); //cut.Find(".swal .btn-danger").Click(); } + + [Fact] + public void Options_Ok() + { + var cut = Context.RenderComponent>(pb => + { + pb.Add(a => a.Options, builder => + { + builder.OpenComponent(0); + builder.AddAttribute(1, "Text", "Test-Select"); + builder.CloseComponent(); + + builder.OpenComponent(2); + builder.CloseComponent(); + }); + }); + Assert.Contains("Test-Select", cut.Markup); + } } -- Gitee From 294c1466d2946ec05e99df3e382a7a59074c94b7 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 23:00:37 +0800 Subject: [PATCH 13/24] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20SelectOption?= =?UTF-8?q?=20=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/SelectTest.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/UnitTest/Components/SelectTest.cs b/test/UnitTest/Components/SelectTest.cs index 4d6524f43..fc0a2325e 100644 --- a/test/UnitTest/Components/SelectTest.cs +++ b/test/UnitTest/Components/SelectTest.cs @@ -64,4 +64,17 @@ public class SelectTest : BootstrapBlazorTestBase }); Assert.Contains("Test-Select", cut.Markup); } + + [Fact] + public void SelectOption_Ok() + { + var cut = Context.RenderComponent(pb => + { + pb.Add(a => a.Text, "Test-SelectOption"); + pb.Add(a => a.GroupName, "Test-GroupName"); + pb.Add(a => a.IsDisabled, false); + pb.Add(a => a.Active, true); + pb.Add(a => a.Value, ""); + }); + } } -- Gitee From 5ca34c97ef897d9ae91645a8015ca311b3883361 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 23:00:55 +0800 Subject: [PATCH 14/24] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE=E5=80=BC=E7=B1=BB=E5=9E=8B=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/SelectTest.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/UnitTest/Components/SelectTest.cs b/test/UnitTest/Components/SelectTest.cs index fc0a2325e..4d0ba707a 100644 --- a/test/UnitTest/Components/SelectTest.cs +++ b/test/UnitTest/Components/SelectTest.cs @@ -77,4 +77,24 @@ public class SelectTest : BootstrapBlazorTestBase pb.Add(a => a.Value, ""); }); } + + [Fact] + public void Enum_Ok() + { + var cut = Context.RenderComponent>(); + Assert.Equal(2, cut.FindAll(".dropdown-item").Count); + } + + [Fact] + public void NullableEnum_Ok() + { + var cut = Context.RenderComponent>(pb => + { + pb.Add(a => a.AdditionalAttributes, new Dictionary() + { + ["placeholder"] = "" + }); + }); + Assert.Equal(3, cut.FindAll(".dropdown-item").Count); + } } -- Gitee From baa92dae7d879864e112cf07c79b2172c3a02478 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sun, 6 Feb 2022 23:09:49 +0800 Subject: [PATCH 15/24] =?UTF-8?q?revert:=20=E6=92=A4=E9=94=80=E6=9B=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs b/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs index 612918678..769574f31 100644 --- a/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs +++ b/src/BootstrapBlazor/Components/SweetAlert/SwalOption.cs @@ -86,11 +86,10 @@ public class SwalOption : PopupOptionBase [nameof(Size)] = Size.Medium, [nameof(ModalDialog.IsCentered)] = true, [nameof(ModalDialog.IsScrolling)] = false, - [nameof(ModalDialog.ShowCloseButton)] = ShowClose, - [nameof(ShowFooter)] = ShowFooter, + [nameof(ModalDialog.ShowCloseButton)] = false, + [nameof(ShowFooter)] = false, [nameof(ModalDialog.Title)] = Title, - [nameof(BodyContext)] = BodyContext, - [nameof(FooterTemplate)] = FooterTemplate + [nameof(BodyContext)] = BodyContext }; return parameters; } -- Gitee From 9dfd3bfc0c76231c05f79604983fa42e87b2e087 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Mon, 7 Feb 2022 00:49:38 +0800 Subject: [PATCH 16/24] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=B2=BE=E7=AE=80=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/BaseComponents/IdComponentBase.cs | 1 + src/BootstrapBlazor/Components/Select/Select.razor.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/BaseComponents/IdComponentBase.cs b/src/BootstrapBlazor/Components/BaseComponents/IdComponentBase.cs index d0b469e87..ff23a3840 100644 --- a/src/BootstrapBlazor/Components/BaseComponents/IdComponentBase.cs +++ b/src/BootstrapBlazor/Components/BaseComponents/IdComponentBase.cs @@ -15,6 +15,7 @@ public abstract class IdComponentBase : BootstrapComponentBase /// 获得/设置 组件 id 属性 /// [Parameter] + [NotNull] public virtual string? Id { get; set; } [Inject] diff --git a/src/BootstrapBlazor/Components/Select/Select.razor.cs b/src/BootstrapBlazor/Components/Select/Select.razor.cs index ab80cec66..9e574006f 100644 --- a/src/BootstrapBlazor/Components/Select/Select.razor.cs +++ b/src/BootstrapBlazor/Components/Select/Select.razor.cs @@ -109,7 +109,7 @@ public partial class Select : ISelect /// /// 获得/设置 Select 内部 Input 组件 Id /// - private string? InputId => string.IsNullOrEmpty(Id) ? null : $"{Id}_input"; + private string? InputId => $"{Id}_input"; /// /// 获得/设置 搜索文字 -- Gitee From 304e54c1ffed05052a6302c6425a8eff9f04b2dd Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Mon, 7 Feb 2022 02:06:25 +0800 Subject: [PATCH 17/24] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E7=A9=BA?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Layout/LayoutBase.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/BootstrapBlazor/Components/Layout/LayoutBase.cs b/src/BootstrapBlazor/Components/Layout/LayoutBase.cs index fb3bc7157..300431c31 100644 --- a/src/BootstrapBlazor/Components/Layout/LayoutBase.cs +++ b/src/BootstrapBlazor/Components/Layout/LayoutBase.cs @@ -192,10 +192,13 @@ public abstract class LayoutBase : BootstrapComponentBase, IAsyncDisposable private async void Navigation_LocationChanged(object? sender, LocationChangedEventArgs e) { - var auth = await OnAuthorizing!(e.Location); - if (!auth) + if (OnAuthorizing != null) { - Navigation.NavigateTo(NotAuthorizeUrl, true); + var auth = await OnAuthorizing(e.Location); + if (!auth) + { + Navigation.NavigateTo(NotAuthorizeUrl, true); + } } } -- Gitee From e6c64659d3b0b5e641ad98d393cbd3ba0d5df438 Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Mon, 7 Feb 2022 02:06:36 +0800 Subject: [PATCH 18/24] =?UTF-8?q?refactor:=20=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/UnitTest/Components/PrintTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/UnitTest/Components/PrintTest.cs b/test/UnitTest/Components/PrintTest.cs index 8badf0b32..3e3a08fcd 100644 --- a/test/UnitTest/Components/PrintTest.cs +++ b/test/UnitTest/Components/PrintTest.cs @@ -33,10 +33,10 @@ public class PrintTest : BootstrapBlazorTestBase var printService = cut.Services.CreateScope().ServiceProvider.GetRequiredService(); Assert.ThrowsAsync(() => printService.PrintAsync