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 diff --git a/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor new file mode 100644 index 00000000000..f68db863a7c --- /dev/null +++ b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor @@ -0,0 +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 new file mode 100644 index 00000000000..3080a5b7021 --- /dev/null +++ b/src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs @@ -0,0 +1,45 @@ +// 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 +{ + /// + /// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容 + /// + [Parameter] + public string? NotSupportedMessage { get; set; } + + /// + /// + /// + protected override void OnParametersSet() + { + base.OnParametersSet(); + + NotSupportedMessage ??= Localizer[nameof(NotSupportedMessage)]; + } + + /// + /// + /// + /// + public override FilterKeyValueAction GetFilterConditions() + { + return new(); + } + + /// + /// + /// + public override void Reset() + { + + } +} diff --git a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor index b71429cdb7e..8e13d931832 100644 --- a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor +++ b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor @@ -88,7 +88,9 @@ else break; default: -
@NotSupportedMessage
+ + + break; } } diff --git a/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs b/src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs index d0d6238c524..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; } - /// /// 获得 过滤小图标样式 /// @@ -87,16 +83,6 @@ protected override void OnInitialized() _fieldKey = Column.GetFieldName(); } - /// - /// - /// - protected override void OnParametersSet() - { - base.OnParametersSet(); - - NotSupportedMessage ??= Localizer[nameof(NotSupportedMessage)]; - } - /// /// /// 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(); /// 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)); 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"; + } + } +}