Skip to content

Commit 54cb560

Browse files
authored
feat(CardUpload): add BeforeActionButtonTemplate parameter (#7030)
* feat(CardUpload): add BeforeActionButtonTemplate parameter * test: 增加单元测试
1 parent 365c07f commit 54cb560

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/BootstrapBlazor/Components/Upload/CardUpload.razor

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
<div class="upload-item-size"><span>@item.GetFileName()</span> (@item.Size.ToFileSizeString())</div>
3333
<div class="upload-item-actions">
3434
<div class="btn-group">
35-
@if (ActionButtonTemplate != null)
35+
@if (BeforeActionButtonTemplate != null)
3636
{
37-
@ActionButtonTemplate(item)
37+
@BeforeActionButtonTemplate(item)
3838
}
3939
@if (ShowZoomButton)
4040
{
@@ -54,6 +54,10 @@
5454
<i class="@CancelIcon"></i>
5555
</button>
5656
}
57+
@if (ActionButtonTemplate != null)
58+
{
59+
@ActionButtonTemplate(item)
60+
}
5761
</div>
5862
@if (ShowDeleteButton)
5963
{

src/BootstrapBlazor/Components/Upload/CardUpload.razor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ public partial class CardUpload<TValue>
6060
[Parameter]
6161
public RenderFragment<UploadFile>? IconTemplate { get; set; }
6262

63+
/// <summary>
64+
/// 获得/设置 操作按钮模板
65+
/// </summary>
66+
[Parameter]
67+
public RenderFragment<UploadFile>? BeforeActionButtonTemplate { get; set; }
68+
6369
/// <summary>
6470
/// 获得/设置 操作按钮模板
6571
/// </summary>

test/UnitTest/Components/UploadCardTest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,17 @@ public void ActionButtonTemplate_Ok()
229229
[
230230
new() { FileName = "test.png" }
231231
]);
232+
pb.Add(a => a.BeforeActionButtonTemplate, file => pb =>
233+
{
234+
pb.AddMarkupContent(0, "<button class=\"before-action-button-test\"></button>");
235+
});
232236
pb.Add(a => a.ActionButtonTemplate, file => pb =>
233237
{
234238
pb.AddMarkupContent(0, "<button class=\"action-button-test\"></button>");
235239
});
236240
});
237241

242+
cut.Contains("before-action-button-test");
238243
cut.Contains("action-button-test");
239244
}
240245

0 commit comments

Comments
 (0)