Skip to content

Commit e22894a

Browse files
committed
Merge branch 'main' into refactor-format
2 parents 9401ff9 + 7de5f7e commit e22894a

File tree

14 files changed

+49
-54
lines changed

14 files changed

+49
-54
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<TableColumns>
7272
<TableColumn @bind-Field="@context.DateTime" Width="180" Text="@Localizer["TablesWrapDataResizingColumHeaderText_DateTime"]" />
7373
<TableColumn @bind-Field="@context.Name" Text="@Localizer["TablesWrapDataResizingColumHeaderText_Name"]" />
74-
<TableColumn @bind-Field="@context.Address" Text="@Localizer["TablesWrapDataResizingColumHeaderText_Address"]" Width="200" TextEllipsis="true" ShowTips="true" GetTooltipText="GetTooltipText" />
74+
<TableColumn @bind-Field="@context.Address" Text="@Localizer["TablesWrapDataResizingColumHeaderText_Address"]" Width="200" TextEllipsis="true" ShowTips="true" GetTooltipTextCallback="GetTooltipTextCallback" />
7575
<TableColumn @bind-Field="@context.Education" />
7676
<TableColumn @bind-Field="@context.Count" />
7777
<TableColumn @bind-Field="@context.Complete" />

src/BootstrapBlazor.Server/Components/Samples/Table/TablesWrap.razor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ private Task<QueryData<Foo>> OnQueryAsync(QueryPageOptions options)
3838
return Task.FromResult(new QueryData<Foo>() { Items = items, TotalCount = total, IsSorted = true, IsFiltered = true, IsSearch = true });
3939
}
4040

41-
private static string? GetTooltipText(object? v)
41+
private static async Task<string?> GetTooltipTextCallback(object? v)
4242
{
43+
await Task.Delay(5);
44+
4345
var ret = string.Empty;
4446
if (v is Foo foo)
4547
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5265,7 +5265,7 @@
52655265
"TablesWrapDataResizingTips1": "You can drag the window size, and the <b>address</b> column will be automatically omitted if the window is too small",
52665266
"TablesWrapDataResizingTips2": "Enable text ellipsis by setting <code>TextEllipsis</code>",
52675267
"TablesWrapDataResizingTips3": "<b>Note:</b> It is recommended to use <code>Width</code> to set the column width. If the column width is not set, it will automatically use 200px width inside",
5268-
"TablesWrapDataResizingTips4": "After the text in the cell is omitted, you can use the <code>ShowTips</code> property to control whether to display all the text on mouse hover, the default is <code>false</code>, You can customize the display content of <code>Tooltip</code> by setting the <code>GetTooltipText</code> callback method",
5268+
"TablesWrapDataResizingTips4": "After the text in the cell is omitted, you can use the <code>ShowTips</code> property to control whether to display all the text on mouse hover, the default is <code>false</code>, You can customize the display content of <code>Tooltip</code> by setting the <code>GetTooltipTextCallback</code> callback method",
52695269
"TablesWrapDataResizingTips5": "Drag the address column, the cell display content will automatically increase and decrease",
52705270
"TablesWrapCustomCellTitle": "Custom in-cell typography",
52715271
"TablesWrapCustomCellIntro": "Use templates for special layout of in-cell data",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5265,7 +5265,7 @@
52655265
"TablesWrapDataResizingTips1": "可以拖动窗口大小,窗口过小时 <b>地址</b> 列自动进行省略处理",
52665266
"TablesWrapDataResizingTips2": "通过设置 <code>TextEllipsis</code> 来开启文本超长省略功能",
52675267
"TablesWrapDataResizingTips3": "<b>注意:</b>推荐使用 <code>Width</code> 对列宽度进行设置,如未设置列宽内部自动使用 200px 宽度",
5268-
"TablesWrapDataResizingTips4": "单元格内文本被省略后,可以通过 <code>ShowTips</code> 属性来控制鼠标悬停是否显示全部文本,默认为 <code>false</code>,通过设置 <code>GetTooltipText</code> 回调方法可以自定义 <code>Tooltip</code> 显示内容;注意异步方法 <code>GetTooltipTextCallback</code> 已弃用请勿使用",
5268+
"TablesWrapDataResizingTips4": "单元格内文本被省略后,可以通过 <code>ShowTips</code> 属性来控制鼠标悬停是否显示全部文本,默认为 <code>false</code>,通过设置 <code>GetTooltipTextCallback</code> 回调方法可以自定义 <code>Tooltip</code> 显示内容",
52695269
"TablesWrapDataResizingTips5": "拖动地址列,单元格显示内容自动增加与减少",
52705270
"TablesWrapCustomCellTitle": "自定义单元格内排版",
52715271
"TablesWrapCustomCellIntro": "使用模板对单元格内数据进行特殊布局",

src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,8 @@ public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColu
203203
/// <summary>
204204
/// <inheritdoc/>
205205
/// </summary>
206-
[Obsolete("已弃用,请使用同步方法 GetTooltipText;Deprecated, please use the synchronous method GetTooltipText")]
207-
[ExcludeFromCodeCoverage]
208206
Func<object?, Task<string?>>? ITableColumn.GetTooltipTextCallback { get; set; }
209207

210-
/// <summary>
211-
/// <inheritdoc/>
212-
/// </summary>
213-
Func<object?, string?>? ITableColumn.GetTooltipText { get; set; }
214-
215208
/// <summary>
216209
/// <inheritdoc/>
217210
/// </summary>

src/BootstrapBlazor/Components/Table/ITableColumn.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,8 @@ public interface ITableColumn : IEditorItem
143143
/// <summary>
144144
/// 获得/设置 鼠标悬停提示自定义内容回调委托 默认 null 使用当前值
145145
/// </summary>
146-
[Obsolete("已弃用,请使用同步方法 GetTooltipText;Deprecated, please use the synchronous method GetTooltipText")]
147-
[ExcludeFromCodeCoverage]
148146
Func<object?, Task<string?>>? GetTooltipTextCallback { get; set; }
149147

150-
/// <summary>
151-
/// 获得/设置 鼠标悬停提示自定义内容回调委托 默认 null 使用当前值
152-
/// </summary>
153-
Func<object?, string?>? GetTooltipText { get; set; }
154-
155148
/// <summary>
156149
/// 获得/设置 单元格回调方法
157150
/// </summary>

src/BootstrapBlazor/Components/Table/InternalTableColumn.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,8 @@ class InternalTableColumn(string fieldName, Type fieldType, string? fieldText =
133133

134134
public bool? ShowTips { get; set; }
135135

136-
/// <summary>
137-
/// <inheritdoc/>
138-
/// </summary>
139-
[Obsolete("已弃用,请使用同步方法 GetTooltipText;Deprecated, please use the synchronous method GetTooltipText")]
140-
[ExcludeFromCodeCoverage]
141136
public Func<object?, Task<string?>>? GetTooltipTextCallback { get; set; }
142137

143-
/// <summary>
144-
/// <inheritdoc/>
145-
/// </summary>
146-
public Func<object?, string?>? GetTooltipText { get; set; }
147-
148138
public Type PropertyType { get; } = fieldType;
149139

150140
[ExcludeFromCodeCoverage]

src/BootstrapBlazor/Components/Table/TableColumn.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,8 @@ public class TableColumn<TItem, TType> : BootstrapComponentBase, ITableColumn
261261
/// <inheritdoc/>
262262
/// </summary>
263263
[Parameter]
264-
[Obsolete("已弃用,请使用同步方法 GetTooltipText;Deprecated, please use the synchronous method GetTooltipText")]
265-
[ExcludeFromCodeCoverage]
266264
public Func<object?, Task<string?>>? GetTooltipTextCallback { get; set; }
267265

268-
/// <summary>
269-
/// <inheritdoc/>
270-
/// </summary>
271-
[Parameter]
272-
public Func<object?, string?>? GetTooltipText { get; set; }
273-
274266
/// <summary>
275267
/// 获得/设置 列 td 自定义样式 默认为 null 未设置
276268
/// </summary>

src/BootstrapBlazor/Components/Tooltip/Tooltip.razor.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ public partial class Tooltip : ITooltip
5555
[Parameter]
5656
public string? Title { get; set; }
5757

58+
/// <summary>
59+
/// 获得/设置 获得显示内容异步回调方法 默认 null
60+
/// </summary>
61+
[Parameter]
62+
public Func<Task<string>>? GetTitleCallback { get; set; }
63+
5864
/// <summary>
5965
/// 获得/设置 显示文字是否为 Html 默认为 false
6066
/// </summary>
@@ -119,6 +125,20 @@ protected override void OnParametersSet()
119125
Trigger ??= "focus hover";
120126
}
121127

128+
/// <summary>
129+
/// <inheritdoc/>
130+
/// </summary>
131+
/// <returns></returns>
132+
protected override async Task OnParametersSetAsync()
133+
{
134+
await base.OnParametersSetAsync();
135+
136+
if (string.IsNullOrEmpty(Title) && GetTitleCallback != null)
137+
{
138+
Title ??= await GetTitleCallback();
139+
}
140+
}
141+
122142
/// <summary>
123143
/// 设置参数方法
124144
/// </summary>

src/BootstrapBlazor/Extensions/ITableColumnExtensions.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private static void CopyValue(this ITableColumn col, ITableColumn dest)
105105
if (col.IsVisibleWhenEdit.HasValue) dest.IsVisibleWhenEdit = col.IsVisibleWhenEdit;
106106
if (col.IsReadonlyWhenAdd.HasValue) dest.IsReadonlyWhenAdd = col.IsReadonlyWhenAdd;
107107
if (col.IsReadonlyWhenEdit.HasValue) dest.IsReadonlyWhenEdit = col.IsReadonlyWhenEdit;
108-
if (col.GetTooltipText != null) dest.GetTooltipText = col.GetTooltipText;
108+
if (col.GetTooltipTextCallback != null) dest.GetTooltipTextCallback = col.GetTooltipTextCallback;
109109
if (col.CustomSearch != null) dest.CustomSearch = col.CustomSearch;
110110
if (col.ToolboxTemplate != null) dest.ToolboxTemplate = col.ToolboxTemplate;
111111
if (col.IsRequiredWhenAdd.HasValue) dest.IsRequiredWhenAdd = col.IsRequiredWhenAdd;
@@ -247,32 +247,36 @@ private static RenderFragment RenderTooltip<TItem>(this ITableColumn col, string
247247
{
248248
if (col.GetShowTips())
249249
{
250+
pb.OpenComponent<Tooltip>(0);
251+
pb.SetKey(item);
250252
var tooltipText = text;
251-
if (col.GetTooltipText != null)
253+
if (col.GetTooltipTextCallback != null)
252254
{
253-
tooltipText = col.GetTooltipText(item);
255+
pb.AddAttribute(10, nameof(Tooltip.GetTitleCallback), new Func<Task<string?>>(() => col.GetTooltipTextCallback(item)));
254256
}
255-
pb.OpenComponent<Tooltip>(0);
256-
pb.AddAttribute(1, nameof(Tooltip.Title), tooltipText);
257-
pb.AddAttribute(2, "class", "text-truncate d-block");
257+
else
258+
{
259+
pb.AddAttribute(11, nameof(Tooltip.Title), tooltipText);
260+
}
261+
pb.AddAttribute(12, "class", "text-truncate d-block");
258262
if (col.IsMarkupString)
259263
{
260-
pb.AddAttribute(3, nameof(Tooltip.ChildContent), new RenderFragment(builder => builder.AddMarkupContent(0, text)));
261-
pb.AddAttribute(4, nameof(Tooltip.IsHtml), true);
264+
pb.AddAttribute(13, nameof(Tooltip.ChildContent), new RenderFragment(builder => builder.AddMarkupContent(0, text)));
265+
pb.AddAttribute(14, nameof(Tooltip.IsHtml), true);
262266
}
263267
else
264268
{
265-
pb.AddAttribute(3, nameof(Tooltip.ChildContent), new RenderFragment(builder => builder.AddContent(0, text)));
269+
pb.AddAttribute(15, nameof(Tooltip.ChildContent), new RenderFragment(builder => builder.AddContent(0, text)));
266270
}
267271
pb.CloseComponent();
268272
}
269273
else if (col.IsMarkupString)
270274
{
271-
pb.AddMarkupContent(3, text);
275+
pb.AddMarkupContent(20, text);
272276
}
273277
else
274278
{
275-
pb.AddContent(4, text);
279+
pb.AddContent(30, text);
276280
}
277281
};
278282

0 commit comments

Comments
 (0)