From 7044c95de79c550f12459ab3a3fc79315f12fd5c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 25 Jun 2025 08:57:34 +0800 Subject: [PATCH 01/10] =?UTF-8?q?wip:=20=E4=B8=B4=E6=97=B6=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Filters/NotSupportFilter.razor | 4 +++ .../Filters/NotSupportFilter.razor.cs | 33 +++++++++++++++++++ .../Filters/TableColumnFilter.razor | 4 ++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor create mode 100644 src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs diff --git a/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor new file mode 100644 index 00000000000..4403dd9ae2c --- /dev/null +++ b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor @@ -0,0 +1,4 @@ +@namespace BootstrapBlazor.Components +@inherits FilterBase + +
diff --git a/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs new file mode 100644 index 00000000000..c7cc5cdc95a --- /dev/null +++ b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs @@ -0,0 +1,33 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License +// See the LICENSE file in the project root for more information. +// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone + +namespace BootstrapBlazor.Components; + +/// +/// NotSupportFilter component +/// +public partial class NotSupportFilter +{ + private string? FilterRowClassString => CssBuilder.Default("filter-row") + .AddClass("active", TableColumnFilter.HasFilter()) + .Build(); + + /// + /// + /// + /// + public override FilterKeyValueAction GetFilterConditions() + { + return new(); + } + + /// + /// + /// + public override async Task SetFilterConditionsAsync(FilterKeyValueAction filter) + { + await base.SetFilterConditionsAsync(filter); + } +} diff --git a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor index b71429cdb7e..d9198d55752 100644 --- a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor +++ b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor @@ -88,7 +88,9 @@ else break; default: -
@NotSupportedMessage
+ + + break; } } From afad6901293c4968b83eb5854f53bdcefd1a7f78 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 25 Jun 2025 09:11:26 +0800 Subject: [PATCH 02/10] chore: bump version 9.8.0-beta03 Co-Authored-By: shakugans <81663852+shakugans@users.noreply.github.com> --- 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 47812daf5d9..27c98047a53 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@  - 9.8.0-beta02 + 9.8.0-beta03 From e18ebf46838a2a43b70175b125f5b330acb985ad Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 25 Jun 2025 09:12:22 +0800 Subject: [PATCH 03/10] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20NotSuppo?= =?UTF-8?q?rtFilter=20=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Filters/NotSupportFilter.razor | 2 +- .../Filters/NotSupportFilter.razor.cs | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor index 4403dd9ae2c..f68db863a7c 100644 --- a/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor +++ b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor @@ -1,4 +1,4 @@ @namespace BootstrapBlazor.Components @inherits FilterBase -
+
@NotSupportedMessage
diff --git a/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs index c7cc5cdc95a..15ffeac3f5f 100644 --- a/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs +++ b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone +using Microsoft.Extensions.Localization; + namespace BootstrapBlazor.Components; /// @@ -10,9 +12,25 @@ namespace BootstrapBlazor.Components; /// public partial class NotSupportFilter { - private string? FilterRowClassString => CssBuilder.Default("filter-row") - .AddClass("active", TableColumnFilter.HasFilter()) - .Build(); + [Inject] + [NotNull] + private IStringLocalizer? Localizer { get; set; } + + /// + /// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容 + /// + [Parameter] + public string? NotSupportedMessage { get; set; } + + /// + /// + /// + protected override void OnParametersSet() + { + base.OnParametersSet(); + + NotSupportedMessage ??= Localizer[nameof(NotSupportedMessage)]; + } /// /// @@ -26,8 +44,8 @@ public override FilterKeyValueAction GetFilterConditions() /// /// /// - public override async Task SetFilterConditionsAsync(FilterKeyValueAction filter) + public override void Reset() { - await base.SetFilterConditionsAsync(filter); + } } From 1b446f602803be5a9e81fdacae92cc60f07e831c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 25 Jun 2025 09:14:24 +0800 Subject: [PATCH 04/10] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20TableCol?= =?UTF-8?q?umnFilter=20=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Filters/TableColumnFilter.razor | 2 +- .../Components/Filters/TableColumnFilter.razor.cs | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor index d9198d55752..8e13d931832 100644 --- a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor +++ b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor @@ -89,7 +89,7 @@ else break; default: - + break; } diff --git a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs index d0d6238c524..8de3acc17d8 100644 --- a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs +++ b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs @@ -87,16 +87,6 @@ protected override void OnInitialized() _fieldKey = Column.GetFieldName(); } - /// - /// - /// - protected override void OnParametersSet() - { - base.OnParametersSet(); - - NotSupportedMessage ??= Localizer[nameof(NotSupportedMessage)]; - } - /// /// /// From 2818a4cf3723bde69ef42eebee5fa8152e5c8837 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 25 Jun 2025 09:25:53 +0800 Subject: [PATCH 05/10] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E9=87=8D=E7=BD=AE=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Table/Table.razor | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Components/Table/Table.razor b/src/BootstrapBlazor/Components/Table/Table.razor index 70cecd38794..3a3d295b12b 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor +++ b/src/BootstrapBlazor/Components/Table/Table.razor @@ -990,13 +990,15 @@ } @if (ShowResetButton) { - } @if (ShowSearchButton) { - } From f0baef373b7f17b68077fb32586a109a469bd382 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 25 Jun 2025 09:26:06 +0800 Subject: [PATCH 06/10] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=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/TableTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/UnitTest/Components/TableTest.cs b/test/UnitTest/Components/TableTest.cs index 88b3bd46982..4ed8392766a 100644 --- a/test/UnitTest/Components/TableTest.cs +++ b/test/UnitTest/Components/TableTest.cs @@ -3861,7 +3861,7 @@ public async Task CustomerSearchTemplate_Ok() }); }); - var resetButton = cut.Find(".fa-trash-can"); + var resetButton = cut.Find(".btn-table-reset"); await cut.InvokeAsync(() => resetButton.Click()); Assert.Null(searchModel.Name); @@ -3935,7 +3935,7 @@ public async Task SearchTemplate_Null() var table = cut.FindComponent>(); table.Instance.SearchModel.Name = "Test"; - var resetButton = cut.Find(".fa-trash-can"); + var resetButton = cut.Find(".btn-table-reset"); await cut.InvokeAsync(() => resetButton.Click()); Assert.Null(table.Instance.SearchModel.Name); } @@ -4119,7 +4119,7 @@ public async Task ResetSearch_Ok() }); }); - var resetButton = cut.Find(".fa-trash-can"); + var resetButton = cut.Find(".btn-table-reset"); await cut.InvokeAsync(() => resetButton.Click()); Assert.True(reset); From 7a707a7d5de16e5028e0693c314e30124ebe0368 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 25 Jun 2025 09:34:49 +0800 Subject: [PATCH 07/10] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=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/TabTest.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/UnitTest/Components/TabTest.cs b/test/UnitTest/Components/TabTest.cs index 5b47d65a928..fb18a2cb51f 100644 --- a/test/UnitTest/Components/TabTest.cs +++ b/test/UnitTest/Components/TabTest.cs @@ -191,20 +191,20 @@ public async Task IsLoopSwitchTabItem_Ok() pb.Add(a => a.ChildContent, "Tab2-Content"); }); }); - Assert.Equal("Tab2-Content", cut.Find(".tabs-body .d-none").InnerHtml); + Assert.Equal("Tab2-Content", cut.Find(".tabs-body .d-none .tabs-body-content-wrap").InnerHtml); // Click Prev var button = cut.Find(".nav-link-bar.left .nav-link-bar-button"); await cut.InvokeAsync(() => button.Click()); - Assert.Equal("Tab2-Content", cut.Find(".tabs-body .d-none").InnerHtml); + Assert.Equal("Tab2-Content", cut.Find(".tabs-body .d-none .tabs-body-content-wrap").InnerHtml); // Click Next button = cut.Find(".nav-link-bar.right .nav-link-bar-button"); await cut.InvokeAsync(() => button.Click()); - Assert.Equal("Tab1-Content", cut.Find(".tabs-body .d-none").InnerHtml); + Assert.Equal("Tab1-Content", cut.Find(".tabs-body .d-none .tabs-body-content-wrap").InnerHtml); await cut.InvokeAsync(() => button.Click()); - Assert.Equal("Tab1-Content", cut.Find(".tabs-body .d-none").InnerHtml); + Assert.Equal("Tab1-Content", cut.Find(".tabs-body .d-none .tabs-body-content-wrap").InnerHtml); } [Fact] @@ -240,7 +240,7 @@ public void ClickTab_Ok() pb.Add(a => a.ChildContent, "Tab2-Content"); }); }); - Assert.Equal("Tab2-Content", cut.Find(".tabs-body .d-none").InnerHtml); + Assert.Equal("Tab2-Content", cut.Find(".tabs-body .d-none .tabs-body-content-wrap").InnerHtml); // Click TabItem cut.Find(".tabs-item").Click(); @@ -251,14 +251,14 @@ public void ClickTab_Ok() button.Click(); button.Click(); button.Click(); - Assert.Equal("Tab1-Content", cut.Find(".tabs-body .d-none").InnerHtml); + Assert.Equal("Tab1-Content", cut.Find(".tabs-body .d-none .tabs-body-content-wrap").InnerHtml); // Click Next button = cut.Find(".nav-link-bar.right .nav-link-bar-button"); button.Click(); button.Click(); button.Click(); - Assert.Equal("Tab2-Content", cut.Find(".tabs-body .d-none").InnerHtml); + Assert.Equal("Tab2-Content", cut.Find(".tabs-body .d-none .tabs-body-content-wrap").InnerHtml); // Close Assert.Null(closedItem); @@ -342,7 +342,7 @@ public void AddTab_Ok() cut.InvokeAsync(() => tab.AddTab("/", "Tab2", "fa-solid fa-font-awesome", false, true)); cut.InvokeAsync(() => tab.CloseOtherTabs()); - Assert.Equal("Tab1-Body", cut.Find(".tabs-body-content").InnerHtml); + Assert.Equal("Tab1-Body", cut.Find(".tabs-body-content .tabs-body-content-wrap").InnerHtml); // NotFound cut.InvokeAsync(() => tab.AddTab("/Test", "Tab3", "fa-solid fa-font-awesome", false, true)); From b086afda2395a3529a7c31cdfb24e3fbf7a19901 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 25 Jun 2025 09:49:01 +0800 Subject: [PATCH 08/10] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8=E5=9F=BA?= =?UTF-8?q?=E7=B1=BB=E6=9C=AC=E5=9C=B0=E5=8C=96=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Filters/NotSupportFilter.razor.cs | 6 ------ .../Components/Filters/TableColumnFilter.razor.cs | 4 ---- 2 files changed, 10 deletions(-) diff --git a/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs index 15ffeac3f5f..3080a5b7021 100644 --- a/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs +++ b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone -using Microsoft.Extensions.Localization; - namespace BootstrapBlazor.Components; /// @@ -12,10 +10,6 @@ namespace BootstrapBlazor.Components; /// public partial class NotSupportFilter { - [Inject] - [NotNull] - private IStringLocalizer? Localizer { get; set; } - /// /// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容 /// diff --git a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs index 8de3acc17d8..144d11d10ec 100644 --- a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs +++ b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs @@ -50,10 +50,6 @@ public partial class TableColumnFilter : IFilter [NotNull] public ITable? Table { get; set; } - [Inject] - [NotNull] - private IStringLocalizer? Localizer { get; set; } - /// /// 获得 过滤小图标样式 /// From 2cb6b624ab5ee80bc9a513e41147d8e3fd86d937 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 25 Jun 2025 10:05:34 +0800 Subject: [PATCH 09/10] =?UTF-8?q?test:=20=E8=A1=A5=E5=85=85=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/TableNotSupportFilterTest.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/UnitTest/Components/TableNotSupportFilterTest.cs diff --git a/test/UnitTest/Components/TableNotSupportFilterTest.cs b/test/UnitTest/Components/TableNotSupportFilterTest.cs new file mode 100644 index 00000000000..ddefe72a1c8 --- /dev/null +++ b/test/UnitTest/Components/TableNotSupportFilterTest.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the Apache 2.0 License +// See the LICENSE file in the project root for more information. +// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone + +namespace UnitTest.Components; + +public class TableNotSupportFilterTest : BootstrapBlazorTestBase +{ + [Fact] + public void OnFilterAsync_Ok() + { + var cut = Context.RenderComponent(pb => + { + pb.Add(a => a.Table, new MockTable()); + pb.Add(a => a.Column, new MockColumn()); + }); + + cut.Contains("不支持的类型,请使用 FilterTemplate 自定义过滤组件"); + + var filter = cut.FindComponent(); + var conditions = filter.Instance.GetFilterConditions(); + Assert.Empty(conditions.Filters); + + filter.Instance.Reset(); + } + + class MockTable : ITable + { + public Dictionary Filters { get; set; } = []; + + public Func? OnFilterAsync { get; set; } + + public List Columns => []; + + public IEnumerable GetVisibleColumns() => Columns; + } + + class MockColumn : TableColumn> + { + public MockColumn() + { + PropertyType = typeof(List); + FieldName = "Double"; + } + } +} From fccf630caf88bf9da0cbeb1a1ed50d9379f9fe38 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Wed, 25 Jun 2025 10:07:07 +0800 Subject: [PATCH 10/10] =?UTF-8?q?test:=20=E6=9B=B4=E6=96=B0=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Tab/Tab.razor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs index 9057cb18e9b..90f02886b52 100644 --- a/src/BootstrapBlazor/Components/Tab/Tab.razor.cs +++ b/src/BootstrapBlazor/Components/Tab/Tab.razor.cs @@ -487,7 +487,7 @@ public partial class Tab private bool IsPreventDefault => _contextMenuZone != null; private static string? GetTabItemClassString(TabItem item) => CssBuilder.Default("tabs-body-content") - .AddClass("d-none", item is { IsActive: false }) + .AddClass("d-none", !item.IsActive) .Build(); ///