Skip to content
Merged
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>9.8.0-beta02</Version>
<Version>9.8.0-beta03</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@namespace BootstrapBlazor.Components
@inherits FilterBase

<div>@NotSupportedMessage</div>
45 changes: 45 additions & 0 deletions src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs
Original file line number Diff line number Diff line change
@@ -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([email protected]) Website: https://www.blazor.zone

namespace BootstrapBlazor.Components;

/// <summary>
/// NotSupportFilter component
/// </summary>
public partial class NotSupportFilter
{
/// <summary>
/// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容
/// </summary>
[Parameter]
public string? NotSupportedMessage { get; set; }

/// <summary>
/// <inheritdoc/>
/// </summary>
protected override void OnParametersSet()
{
base.OnParametersSet();

NotSupportedMessage ??= Localizer[nameof(NotSupportedMessage)];
}

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <returns></returns>
public override FilterKeyValueAction GetFilterConditions()
{
return new();
}

/// <summary>
/// <inheritdoc/>
/// </summary>
public override void Reset()
{

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ else
</FilterProvider>
break;
default:
<div>@NotSupportedMessage</div>
<FilterProvider>
<NotSupportFilter NotSupportedMessage="@NotSupportedMessage"></NotSupportFilter>
</FilterProvider>
break;
}
}
Expand Down
14 changes: 0 additions & 14 deletions src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ public partial class TableColumnFilter : IFilter
[NotNull]
public ITable? Table { get; set; }

[Inject]
[NotNull]
private IStringLocalizer<TableColumnFilter>? Localizer { get; set; }

/// <summary>
/// 获得 过滤小图标样式
/// </summary>
Expand Down Expand Up @@ -87,16 +83,6 @@ protected override void OnInitialized()
_fieldKey = Column.GetFieldName();
}

/// <summary>
/// <inheritdoc/>
/// </summary>
protected override void OnParametersSet()
{
base.OnParametersSet();

NotSupportedMessage ??= Localizer[nameof(NotSupportedMessage)];
}

/// <summary>
/// <inheritdoc/>
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Components/Tab/Tab.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/// <summary>
Expand Down
16 changes: 8 additions & 8 deletions test/UnitTest/Components/TabTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
47 changes: 47 additions & 0 deletions test/UnitTest/Components/TableNotSupportFilterTest.cs
Original file line number Diff line number Diff line change
@@ -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([email protected]) Website: https://www.blazor.zone

namespace UnitTest.Components;

public class TableNotSupportFilterTest : BootstrapBlazorTestBase
{
[Fact]
public void OnFilterAsync_Ok()
{
var cut = Context.RenderComponent<TableColumnFilter>(pb =>
{
pb.Add(a => a.Table, new MockTable());
pb.Add(a => a.Column, new MockColumn());
});

cut.Contains("不支持的类型,请使用 FilterTemplate 自定义过滤组件");

var filter = cut.FindComponent<NotSupportFilter>();
var conditions = filter.Instance.GetFilterConditions();
Assert.Empty(conditions.Filters);

filter.Instance.Reset();
}

class MockTable : ITable
{
public Dictionary<string, IFilterAction> Filters { get; set; } = [];

public Func<Task>? OnFilterAsync { get; set; }

public List<ITableColumn> Columns => [];

public IEnumerable<ITableColumn> GetVisibleColumns() => Columns;
}

class MockColumn : TableColumn<Foo, List<string>>
{
public MockColumn()
{
PropertyType = typeof(List<string>);
FieldName = "Double";
}
}
}