From ecd0c2b14d886042a5c85c2a48825cf0761dc0c3 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 7 Mar 2022 11:42:35 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20IsLink=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Button/PopConfirmButtonBase.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/BootstrapBlazor/Components/Button/PopConfirmButtonBase.cs b/src/BootstrapBlazor/Components/Button/PopConfirmButtonBase.cs index af549c817..52882c1b3 100644 --- a/src/BootstrapBlazor/Components/Button/PopConfirmButtonBase.cs +++ b/src/BootstrapBlazor/Components/Button/PopConfirmButtonBase.cs @@ -11,6 +11,12 @@ namespace BootstrapBlazor.Components; /// public abstract class PopConfirmButtonBase : ButtonBase { + /// + /// 获得/设置 是否为 A 标签 默认 false 使用 button 渲染 + /// + [Parameter] + public bool IsLink { get; set; } + /// /// 获得/设置 弹窗显示位置 /// @@ -78,4 +84,14 @@ public abstract class PopConfirmButtonBase : ButtonBase /// [Parameter] public string ConfirmIcon { get; set; } = "fa fa-exclamation-circle text-info"; + + /// + /// + /// + protected string TagName => IsLink ? "a" : "button"; + + /// + /// + /// + protected string? ElementType => IsLink ? null : "button"; } -- Gitee From f55f2c02e46031afeb93a53574daeee2a8d4356f Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 7 Mar 2022 11:43:08 +0800 Subject: [PATCH 2/6] =?UTF-8?q?refactor:=20=E6=94=B9=E7=94=A8=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E7=BB=84=E4=BB=B6=E6=B8=B2=E6=9F=93=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Button/PopConfirmButton.razor | 6 ++++-- .../Components/Button/PopConfirmButton.razor.cs | 17 +++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor b/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor index 69c1c1caa..d98bb8d5c 100644 --- a/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor +++ b/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor @@ -1,7 +1,9 @@ @namespace BootstrapBlazor.Components @inherits PopConfirmButtonBase - + diff --git a/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor.cs b/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor.cs index 5f79dd0e8..a0590d8bb 100644 --- a/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor.cs +++ b/src/BootstrapBlazor/Components/Button/PopConfirmButton.razor.cs @@ -26,15 +26,20 @@ public partial class PopConfirmButton private bool Submit { get; set; } /// - /// OnInitialized 方法 + /// OnParametersSet 方法 /// - protected override void OnInitialized() + protected override void OnParametersSet() { - base.OnInitialized(); + base.OnParametersSet(); ConfirmButtonText ??= Localizer[nameof(ConfirmButtonText)]; CloseButtonText ??= Localizer[nameof(CloseButtonText)]; Content ??= Localizer[nameof(Content)]; + + if (IsLink) + { + Color = Color.None; + } } /// @@ -74,11 +79,7 @@ public partial class PopConfirmButton Icon = ConfirmIcon, OnConfirm = Confirm, OnClose = OnClose, - Callback = async () => - { - // 调用 JS 进行弹窗 等待 弹窗点击确认回调 - await JSRuntime.InvokeVoidAsync(Id, "bb_confirm"); - } + Callback = async () => await JSRuntime.InvokeVoidAsync(Id, "bb_confirm") }); } } -- Gitee From 97a8e4364dc51ebda37ef423bde594dfd49287f9 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 7 Mar 2022 11:43:23 +0800 Subject: [PATCH 3/6] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E7=A1=AE=E8=AE=A4=E6=8C=89=E9=92=AE=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Shared/Samples/PopoverConfirms.razor | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor.Shared/Samples/PopoverConfirms.razor b/src/BootstrapBlazor.Shared/Samples/PopoverConfirms.razor index bba118cf6..3c9c45a7f 100644 --- a/src/BootstrapBlazor.Shared/Samples/PopoverConfirms.razor +++ b/src/BootstrapBlazor.Shared/Samples/PopoverConfirms.razor @@ -26,7 +26,7 @@ - + @@ -48,6 +48,11 @@ + + + + -- Gitee From c840b03214e49e0a1f2817130ede3be857bde60e Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 7 Mar 2022 11:45:42 +0800 Subject: [PATCH 4/6] =?UTF-8?q?doc:=20=E5=A2=9E=E5=8A=A0=20IsLink=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Samples/PopoverConfirms.razor.cs | 200 +++++++++--------- 1 file changed, 104 insertions(+), 96 deletions(-) diff --git a/src/BootstrapBlazor.Shared/Samples/PopoverConfirms.razor.cs b/src/BootstrapBlazor.Shared/Samples/PopoverConfirms.razor.cs index ada0a0ba8..3eed4abd0 100644 --- a/src/BootstrapBlazor.Shared/Samples/PopoverConfirms.razor.cs +++ b/src/BootstrapBlazor.Shared/Samples/PopoverConfirms.razor.cs @@ -2,6 +2,7 @@ // 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.Components; using BootstrapBlazor.Shared.Common; using BootstrapBlazor.Shared.Components; using Microsoft.AspNetCore.Components.Forms; @@ -84,84 +85,91 @@ public sealed partial class PopoverConfirms /// private static IEnumerable GetAttributes() => new AttributeItem[] { - // TODO: 移动到数据库中 - new AttributeItem() { - Name = "Text", - Description = "显示标题", - Type = "string", - ValueList = "", - DefaultValue = "删除" - }, - new AttributeItem() { - Name = "Icon", - Description = "按钮图标", - Type = "string", - ValueList = "", - DefaultValue = "fa fa-remove" - }, - new AttributeItem() { - Name = "CloseButtonText", - Description = "关闭按钮显示文字", - Type = "string", - ValueList = "", - DefaultValue = "关闭" - }, - new AttributeItem() { - Name = "CloseButtonColor", - Description = "确认按钮颜色", - Type = "Color", - ValueList = "None / Active / Primary / Secondary / Success / Danger / Warning / Info / Light / Dark / Link", - DefaultValue = "Secondary" - }, - new AttributeItem() { - Name = "Color", - Description = "颜色", - Type = "Color", - ValueList = "None / Active / Primary / Secondary / Success / Danger / Warning / Info / Light / Dark / Link", - DefaultValue = "None" - }, - new AttributeItem() { - Name = "ConfirmButtonText", - Description = "确认按钮显示文字", - Type = "string", - ValueList = "", - DefaultValue = "确定" - }, - new AttributeItem() { - Name = "ConfirmButtonColor", - Description = "确认按钮颜色", - Type = "None / Active / Primary / Secondary / Success / Danger / Warning / Info / Light / Dark / Link", - ValueList = "", - DefaultValue = "Primary" - }, - new AttributeItem() { - Name = "ConfirmIcon", - Description = "确认框图标", - Type = "string", - ValueList = "", - DefaultValue = "fa fa-exclamation-circle text-info" - }, - new AttributeItem() { - Name = "Content", - Description = "显示文字", - Type = "string", - ValueList = "", - DefaultValue = "确认删除吗?" - }, - new AttributeItem() { - Name = "Placement", - Description = "位置", - Type = "Placement", - ValueList = "Auto / Top / Left / Bottom / Right", - DefaultValue = "Auto" - }, - new AttributeItem() { - Name = "Title", - Description = "Popover 弹窗标题", - Type = "string", - ValueList = "", - DefaultValue = " " - }, + // TODO: 移动到数据库中 + new AttributeItem() { + Name = nameof(PopConfirmButton.IsLink), + Description = "是否为 A 标签渲染组件", + Type = "bool", + ValueList = "true/false", + DefaultValue = "false" + }, + new AttributeItem() { + Name = "Text", + Description = "显示标题", + Type = "string", + ValueList = "", + DefaultValue = "删除" + }, + new AttributeItem() { + Name = "Icon", + Description = "按钮图标", + Type = "string", + ValueList = "", + DefaultValue = "fa fa-remove" + }, + new AttributeItem() { + Name = "CloseButtonText", + Description = "关闭按钮显示文字", + Type = "string", + ValueList = "", + DefaultValue = "关闭" + }, + new AttributeItem() { + Name = "CloseButtonColor", + Description = "确认按钮颜色", + Type = "Color", + ValueList = "None / Active / Primary / Secondary / Success / Danger / Warning / Info / Light / Dark / Link", + DefaultValue = "Secondary" + }, + new AttributeItem() { + Name = "Color", + Description = "颜色", + Type = "Color", + ValueList = "None / Active / Primary / Secondary / Success / Danger / Warning / Info / Light / Dark / Link", + DefaultValue = "None" + }, + new AttributeItem() { + Name = "ConfirmButtonText", + Description = "确认按钮显示文字", + Type = "string", + ValueList = "", + DefaultValue = "确定" + }, + new AttributeItem() { + Name = "ConfirmButtonColor", + Description = "确认按钮颜色", + Type = "None / Active / Primary / Secondary / Success / Danger / Warning / Info / Light / Dark / Link", + ValueList = "", + DefaultValue = "Primary" + }, + new AttributeItem() { + Name = "ConfirmIcon", + Description = "确认框图标", + Type = "string", + ValueList = "", + DefaultValue = "fa fa-exclamation-circle text-info" + }, + new AttributeItem() { + Name = "Content", + Description = "显示文字", + Type = "string", + ValueList = "", + DefaultValue = "确认删除吗?" + }, + new AttributeItem() { + Name = "Placement", + Description = "位置", + Type = "Placement", + ValueList = "Auto / Top / Left / Bottom / Right", + DefaultValue = "Auto" + }, + new AttributeItem() { + Name = "Title", + Description = "Popover 弹窗标题", + Type = "string", + ValueList = "", + DefaultValue = " " + } }; /// @@ -170,23 +178,23 @@ public sealed partial class PopoverConfirms /// private static IEnumerable GetEvents() => new EventItem[] { - new EventItem() - { - Name = "OnConfirm", - Description="点击确认时回调方法", - Type ="Func" - }, - new EventItem() - { - Name = "OnClose", - Description="点击关闭时回调方法", - Type ="Func" - }, - new EventItem() - { - Name = "OnBeforeClick", - Description="点击确认弹窗前回调方法 返回真时弹出弹窗 返回假时不弹出", - Type ="Func>" - }, + new EventItem() + { + Name = "OnConfirm", + Description="点击确认时回调方法", + Type ="Func" + }, + new EventItem() + { + Name = "OnClose", + Description="点击关闭时回调方法", + Type ="Func" + }, + new EventItem() + { + Name = "OnBeforeClick", + Description="点击确认弹窗前回调方法 返回真时弹出弹窗 返回假时不弹出", + Type ="Func>" + } }; } -- Gitee From d4bb3c5153d49705c4496e76a5845f7afe498536 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 7 Mar 2022 12:27:56 +0800 Subject: [PATCH 5/6] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0=20IsLink=20?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=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/PopConfirmButtonTest.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/UnitTest/Components/PopConfirmButtonTest.cs b/test/UnitTest/Components/PopConfirmButtonTest.cs index 0f7c94873..142b3708b 100644 --- a/test/UnitTest/Components/PopConfirmButtonTest.cs +++ b/test/UnitTest/Components/PopConfirmButtonTest.cs @@ -105,5 +105,12 @@ public class PopConfirmButtonTest : PopoverTestBase // Confirm buttons = cut.FindAll(".popover-confirm-buttons button"); cut.InvokeAsync(() => buttons[1].Click()); + + // IsLink + popButton.SetParametersAndRender(pb => + { + pb.Add(a => a.IsLink, true); + }); + Assert.Contains("a data-bs-toggle=\"confirm\"", popButton.Markup); } } -- Gitee From 39c67a6149bc8be065a1a1e312e5ab1941c5fd17 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 7 Mar 2022 12:31:32 +0800 Subject: [PATCH 6/6] chore: bump version 6.4.1 --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index ebcd3ad7d..dd5152c34 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 6.4.1-beta03 + 6.4.1 -- Gitee