Skip to content

Commit 10fc77c

Browse files
authored
feat(Table): add NotSupportedColumnFilterMessage parameter (#6302)
* feat(Table): 增加 NotSupportedMessage 参数 * doc: 增加文档地址提示 * test: 更新单元测试 * refactor: 更改参数名称 * doc: 增加 html 支持 * refactor: 增加标签
1 parent 2dc0cff commit 10fc77c

File tree

10 files changed

+34
-10
lines changed

10 files changed

+34
-10
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@namespace BootstrapBlazor.Components
22
@inherits FilterBase
33

4-
<div>@NotSupportedMessage</div>
4+
<div>@(new MarkupString(NotSupportedColumnFilterMessage))</div>

src/BootstrapBlazor/Components/Filters/NotSupportFilter.razor.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public partial class NotSupportFilter
1414
/// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容
1515
/// </summary>
1616
[Parameter]
17-
public string? NotSupportedMessage { get; set; }
17+
[NotNull]
18+
public string? NotSupportedColumnFilterMessage { get; set; }
1819

1920
/// <summary>
2021
/// <inheritdoc/>
@@ -23,7 +24,7 @@ protected override void OnParametersSet()
2324
{
2425
base.OnParametersSet();
2526

26-
NotSupportedMessage ??= Localizer[nameof(NotSupportedMessage)];
27+
NotSupportedColumnFilterMessage ??= Localizer[nameof(NotSupportedColumnFilterMessage)];
2728
}
2829

2930
/// <summary>

src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ else
8989
break;
9090
default:
9191
<FilterProvider>
92-
<NotSupportFilter NotSupportedMessage="@NotSupportedMessage"></NotSupportFilter>
92+
<NotSupportFilter NotSupportedColumnFilterMessage="@NotSupportedColumnFilterMessage">
93+
</NotSupportFilter>
9394
</FilterProvider>
9495
break;
9596
}

src/BootstrapBlazor/Components/Filters/TableColumnFilter.razor.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ public partial class TableColumnFilter : IFilter
2828
/// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容
2929
/// </summary>
3030
[Parameter]
31-
public string? NotSupportedMessage { get; set; }
31+
[ExcludeFromCodeCoverage]
32+
[Obsolete("已弃用,请使用 NotSupportedColumnFilterMessage 参数; Deprecated, please use NotSupportedColumnFilterMessage parameter")]
33+
public string? NotSupportedMessage { get => NotSupportedColumnFilterMessage; set => NotSupportedColumnFilterMessage = value; }
34+
35+
/// <summary>
36+
/// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容
37+
/// </summary>
38+
[Parameter]
39+
public string? NotSupportedColumnFilterMessage { get; set; }
3240

3341
/// <summary>
3442
/// 获得 相关联 ITableColumn 实例

src/BootstrapBlazor/Components/Table/Table.razor

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,11 @@
586586
}
587587
@if (col.GetFilterable() && !ShowFilterHeader)
588588
{
589-
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this" IsActive="@Filters.ContainsKey(fieldName)" @onclick:stopPropagation></TableColumnFilter>
589+
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this"
590+
IsActive="@Filters.ContainsKey(fieldName)"
591+
NotSupportedColumnFilterMessage="@NotSupportedColumnFilterMessage"
592+
@onclick:stopPropagation>
593+
</TableColumnFilter>
590594
}
591595
@if (col.GetSortable())
592596
{
@@ -655,7 +659,9 @@
655659
<div class="table-cell">
656660
@if(col.GetFilterable())
657661
{
658-
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this" IsHeaderRow="true"></TableColumnFilter>
662+
<TableColumnFilter Icon="@FilterIcon" Column="col" Table="this" IsHeaderRow="true"
663+
NotSupportedColumnFilterMessage="@NotSupportedColumnFilterMessage">
664+
</TableColumnFilter>
659665
}
660666
</div>
661667
</th>

src/BootstrapBlazor/Components/Table/Table.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ namespace BootstrapBlazor.Components;
1616
[CascadingTypeParameter(nameof(TItem))]
1717
public partial class Table<TItem> : ITable, IModelEqualityComparer<TItem> where TItem : class
1818
{
19+
/// <summary>
20+
/// 获得/设置 不支持过滤类型提示信息 默认 null 读取资源文件内容
21+
/// </summary>
22+
[Parameter]
23+
public string? NotSupportedColumnFilterMessage { get; set; }
24+
1925
/// <summary>
2026
/// 获得/设置 Loading 模板
2127
/// </summary>

src/BootstrapBlazor/Locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
"Contains": "Contains",
275275
"NotContains": "NotContains",
276276
"EnumFilter.AllText": "All",
277-
"NotSupportedMessage": "Unsupported filter type, Please customize the filter use FilterTemplate",
277+
"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>",
278278
"MultiFilterSearchPlaceHolderText": "Please enter ...",
279279
"MultiFilterSelectAllText": "Select All"
280280
},

src/BootstrapBlazor/Locales/zh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
"Contains": "包含",
275275
"NotContains": "不包含",
276276
"EnumFilter.AllText": "全选",
277-
"NotSupportedMessage": "不支持的类型,请使用 FilterTemplate 自定义过滤组件",
277+
"NotSupportedColumnFilterMessage": "<p>不支持的类型,请使用 <code>FilterTemplate</code> 自定义过滤组件</p><div>请参考文档 <a href=\"https://www.blazor.zone/table/filter#CustomFilter\" target=\"_blank\">CustomFilter</a></div>",
278278
"MultiFilterSearchPlaceHolderText": "请输入 ...",
279279
"MultiFilterSelectAllText": "全选"
280280
},

test/UnitTest/Components/TableNotSupportFilterTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ public void OnFilterAsync_Ok()
1212
{
1313
var cut = Context.RenderComponent<TableColumnFilter>(pb =>
1414
{
15+
pb.Add(a => a.NotSupportedColumnFilterMessage, "不支持的类型");
1516
pb.Add(a => a.Table, new MockTable());
1617
pb.Add(a => a.Column, new MockColumn());
1718
});
1819

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

2122
var filter = cut.FindComponent<NotSupportFilter>();
2223
var conditions = filter.Instance.GetFilterConditions();

test/UnitTest/Components/TableTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ public async Task CustomSearch_Ok()
451451
{
452452
pb.AddChildContent<Table<Foo>>(pb =>
453453
{
454+
pb.Add(a => a.NotSupportedColumnFilterMessage, "test-not-support");
454455
pb.Add(a => a.SearchText, "张三");
455456
pb.Add(a => a.TableColumns, foo => builder =>
456457
{

0 commit comments

Comments
 (0)