Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@namespace BootstrapBlazor.Components
@inherits FilterBase

<div>@NotSupportedMessage</div>
<div>@(new MarkupString(NotSupportedColumnFilterMessage))</div>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public partial class NotSupportFilter
/// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容
/// </summary>
[Parameter]
public string? NotSupportedMessage { get; set; }
[NotNull]
public string? NotSupportedColumnFilterMessage { get; set; }

/// <summary>
/// <inheritdoc/>
Expand All @@ -23,7 +24,7 @@ protected override void OnParametersSet()
{
base.OnParametersSet();

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

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ else
break;
default:
<FilterProvider>
<NotSupportFilter NotSupportedMessage="@NotSupportedMessage"></NotSupportFilter>
<NotSupportFilter NotSupportedColumnFilterMessage="@NotSupportedColumnFilterMessage">
</NotSupportFilter>
</FilterProvider>
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ public partial class TableColumnFilter : IFilter
/// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容
/// </summary>
[Parameter]
public string? NotSupportedMessage { get; set; }
[ExcludeFromCodeCoverage]
[Obsolete("已弃用,请使用 NotSupportedColumnFilterMessage 参数; Deprecated, please use NotSupportedColumnFilterMessage parameter")]
public string? NotSupportedMessage { get => NotSupportedColumnFilterMessage; set => NotSupportedColumnFilterMessage = value; }

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

/// <summary>
/// 获得 相关联 ITableColumn 实例
Expand Down
10 changes: 8 additions & 2 deletions src/BootstrapBlazor/Components/Table/Table.razor
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,11 @@
}
@if (col.GetFilterable() && !ShowFilterHeader)
{
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this" IsActive="@Filters.ContainsKey(fieldName)" @onclick:stopPropagation></TableColumnFilter>
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this"
IsActive="@Filters.ContainsKey(fieldName)"
NotSupportedColumnFilterMessage="@NotSupportedColumnFilterMessage"
@onclick:stopPropagation>
</TableColumnFilter>
}
@if (col.GetSortable())
{
Expand Down Expand Up @@ -655,7 +659,9 @@
<div class="table-cell">
@if(col.GetFilterable())
{
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this" IsHeaderRow="true"></TableColumnFilter>
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this" IsHeaderRow="true"
NotSupportedColumnFilterMessage="@NotSupportedColumnFilterMessage">
</TableColumnFilter>
}
</div>
</th>
Expand Down
6 changes: 6 additions & 0 deletions src/BootstrapBlazor/Components/Table/Table.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ namespace BootstrapBlazor.Components;
[CascadingTypeParameter(nameof(TItem))]
public partial class Table<TItem> : ITable, IModelEqualityComparer<TItem> where TItem : class
{
/// <summary>
/// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容
/// </summary>
[Parameter]
public string? NotSupportedColumnFilterMessage { get; set; }

/// <summary>
/// 获得/设置 Loading 模板
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
"Contains": "Contains",
"NotContains": "NotContains",
"EnumFilter.AllText": "All",
"NotSupportedMessage": "Unsupported filter type, Please customize the filter use FilterTemplate",
"NotSupportedColumnFilterMessage": "<p>Unsupported filter type, Please customize the filter use <code>FilterTemplate</code></p><div>Please refer <a href=\"https://www.blazor.zone/table/filter#CustomFilter\" target=\"_blank\">CustomFilter</a></div>",
"MultiFilterSearchPlaceHolderText": "Please enter ...",
"MultiFilterSelectAllText": "Select All"
},
Expand Down
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/Locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
"Contains": "包含",
"NotContains": "不包含",
"EnumFilter.AllText": "全选",
"NotSupportedMessage": "不支持的类型,请使用 FilterTemplate 自定义过滤组件",
"NotSupportedColumnFilterMessage": "<p>不支持的类型,请使用 <code>FilterTemplate</code> 自定义过滤组件</p><div>请参考文档 <a href=\"https://www.blazor.zone/table/filter#CustomFilter\" target=\"_blank\">CustomFilter</a></div>",
"MultiFilterSearchPlaceHolderText": "请输入 ...",
"MultiFilterSelectAllText": "全选"
},
Expand Down
3 changes: 2 additions & 1 deletion test/UnitTest/Components/TableNotSupportFilterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ public void OnFilterAsync_Ok()
{
var cut = Context.RenderComponent<TableColumnFilter>(pb =>
{
pb.Add(a => a.NotSupportedColumnFilterMessage, "不支持的类型");
pb.Add(a => a.Table, new MockTable());
pb.Add(a => a.Column, new MockColumn());
});

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

var filter = cut.FindComponent<NotSupportFilter>();
var conditions = filter.Instance.GetFilterConditions();
Expand Down
1 change: 1 addition & 0 deletions test/UnitTest/Components/TableTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ public async Task CustomSearch_Ok()
{
pb.AddChildContent<Table<Foo>>(pb =>
{
pb.Add(a => a.NotSupportedColumnFilterMessage, "test-not-support");
pb.Add(a => a.SearchText, "张三");
pb.Add(a => a.TableColumns, foo => builder =>
{
Expand Down