Skip to content

Commit 6a17658

Browse files
authored
feat(Table): add MoreButtonText/Color parameter (#7429)
* feat: 增加 Color/Text 参数 * doc: 更新示例文档 * chore: bump version 10.1.5-beta03 * test: 增加单元测试 * test: 更新单元测试
1 parent 8c329b9 commit 6a17658

10 files changed

Lines changed: 39 additions & 8 deletions

File tree

src/BootstrapBlazor.Server/Components/Samples/Table/TablesColumn.razor

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@
221221
<DemoBlock Title="@Localizer["ShowMoreButtonTitle"]" Introduction="@Localizer["ShowMoreButtonIntro"]" Name="ShowMoreButton">
222222
<section ignore>
223223
<p>@((MarkupString)Localizer["ShowMoreButtonDesc"].Value)</p>
224+
<p>@((MarkupString)Localizer["MoreButtonTextDesc"].Value)</p>
225+
<p>@((MarkupString)Localizer["MoreButtonColorDesc"].Value)</p>
224226
<Pre>&lt;MoreButtonDropdownTemplate&gt;
225227
&lt;DropdownItem Text="Action1" Icon="fa-solid fa-flag" OnClick="@@(() =&gt; OnAction(context, "Action1"))"&gt;&lt;/DropdownItem&gt;
226228
&lt;Divider&gt;&lt;/Divider&gt;

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5111,7 +5111,9 @@
51115111
"ColumnOrderIntro": "Set the order by setting the <code>Order</code> parameter of <code>TableColumn</code>",
51125112
"ShowMoreButtonTitle": "ShowMoreButton",
51135113
"ShowMoreButtonIntro": "By setting the <code>ShowMoreButton</code> parameter, a <b>More</b> button appears when the row expands. Furthermore, by setting the <code>MoreButtonDropdownTemplate</code> template, the dropdown menu options are customized. This design significantly reduces the amount of row space occupied.",
5114-
"ShowMoreButtonDesc": "<code>MoreButtonDropdownTemplate</code> Context <code>context</code> is the instance of the current row."
5114+
"ShowMoreButtonDesc": "<code>MoreButtonDropdownTemplate</code> Context <code>context</code> is the instance of the current row.",
5115+
"MoreButtonTextDesc": "Set the button's text using <code>MoreButtonText</code>",
5116+
"MoreButtonColorDesc": "Set the button color using <code>MoreButtonColor</code>"
51155117
},
51165118
"BootstrapBlazor.Server.Components.Samples.Table.TablesColumnDrag": {
51175119
"TablesColumnTitle": "Table Column",

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5111,7 +5111,9 @@
51115111
"ColumnOrderIntro": "通过设置 <code>TableColumn</code> 的 <code>Order</code> 参数进行设置顺序",
51125112
"ShowMoreButtonTitle": "更多按钮",
51135113
"ShowMoreButtonIntro": "通过设置 <code>ShowMoreButton</code> 参数使行扩展按钮出现 <b>更多</b> 按钮,通过设置 <code>MoreButtonDropdownTemplate</code> 模板自定义下拉菜单选项,通过这样的设计大大减少行空间占用",
5114-
"ShowMoreButtonDesc": "<code>MoreButtonDropdownTemplate</code> 上下文 <code>context</code> 为当前行实例"
5114+
"ShowMoreButtonDesc": "<code>MoreButtonDropdownTemplate</code> 上下文 <code>context</code> 为当前行实例",
5115+
"MoreButtonTextDesc": "通过 <code>MoreButtonText</code> 设置按钮显示文本",
5116+
"MoreButtonColorDesc": "通过 <code>MoreButtonColor</code> 设置按钮颜色"
51155117
},
51165118
"BootstrapBlazor.Server.Components.Samples.Table.TablesColumnDrag": {
51175119
"TablesColumnTitle": "Table 表格",

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Razor">
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>10.1.5-beta02</Version>
4+
<Version>10.1.5-beta03</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Table/Table.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@
10411041
</td>;
10421042

10431043
RenderFragment<TItem> RenderMoreButton => item =>
1044-
@<Dropdown TValue="string" Color="Color.Secondary" IsFixedButtonText="true" FixedButtonText="更多"
1044+
@<Dropdown TValue="string" Color="@MoreButtonColor" IsFixedButtonText="true" FixedButtonText="@MoreButtonText"
10451045
Size="Size.ExtraSmall" IsPopover="true" Icon="@MoreButtonIcon">
10461046
<ItemsTemplate>
10471047
@if (MoreButtonDropdownTemplate != null)

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -157,6 +157,18 @@ public partial class Table<TItem>
157157
[Parameter]
158158
public bool ShowMoreButton { get; set; }
159159

160+
/// <summary>
161+
/// 获得/设置 更多按钮颜色 默认 <see cref="Color.Secondary"/>
162+
/// </summary>
163+
[Parameter]
164+
public Color MoreButtonColor { get; set; } = Color.Secondary;
165+
166+
/// <summary>
167+
/// 获得/设置 更多按钮文本 默认 null 读取资源文件设置文本
168+
/// </summary>
169+
[Parameter]
170+
public string? MoreButtonText { get; set; }
171+
160172
/// <summary>
161173
/// 获得/设置 行内更多按钮下拉框模板 默认 null
162174
/// </summary>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,5 +434,7 @@ private void OnInitLocalization()
434434
AlignCenterTooltipText ??= Localizer[nameof(AlignCenterTooltipText)];
435435
AlignRightText ??= Localizer[nameof(AlignRightText)];
436436
AlignRightTooltipText ??= Localizer[nameof(AlignRightTooltipText)];
437+
438+
MoreButtonText ??= Localizer[nameof(MoreButtonText)];
437439
}
438440
}

src/BootstrapBlazor/Locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@
256256
"AlignRightText": "Right",
257257
"AlignRightTooltipText": "Click to align text in this column to the right",
258258
"ColumnListSelectAllText": "All",
259-
"ColumnListSelectInvertText": "Invert"
259+
"ColumnListSelectInvertText": "Invert",
260+
"MoreButtonText": "More"
260261
},
261262
"BootstrapBlazor.Components.EditDialog": {
262263
"CloseButtonText": "Close",

src/BootstrapBlazor/Locales/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@
256256
"AlignRightText": "右对齐",
257257
"AlignRightTooltipText": "点击后本列文本右对齐",
258258
"ColumnListSelectAllText": "全选",
259-
"ColumnListSelectInvertText": "反选"
259+
"ColumnListSelectInvertText": "反选",
260+
"MoreButtonText": "更多"
260261
},
261262
"BootstrapBlazor.Components.EditDialog": {
262263
"CloseButtonText": "关闭",

test/UnitTest/Components/TableTest.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8869,6 +8869,15 @@ public void Table_ShowMoreButton_Ok(TableRenderMode mode)
88698869
});
88708870

88718871
cut.Contains("<div>dropdown-item-more-template</div");
8872+
cut.Contains("更多");
8873+
8874+
cut.Render(pb =>
8875+
{
8876+
pb.Add(a => a.MoreButtonText, "more_button");
8877+
pb.Add(a => a.MoreButtonColor, Color.Danger);
8878+
});
8879+
8880+
cut.Contains("more_button");
88728881
}
88738882

88748883
[Fact]

0 commit comments

Comments
 (0)