Skip to content

Commit 97bd421

Browse files
ArgoZhangAApuci
andauthored
feat(Select): add ShowSwal parameter (#6053)
* feat: 增加 ShowSwal 参数 * doc: 更新文档 * chore: bump version 9.6.4-beta03 Co-Authored-By: AApuci <[email protected]> * doc: 更新参数文档 * doc: 更新文档 --------- Co-authored-by: AApuci <[email protected]>
1 parent 521f95a commit 97bd421

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

src/BootstrapBlazor.Server/Components/Samples/Selects.razor.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,14 @@ private AttributeItem[] GetAttributes() =>
439439
Type = "string",
440440
ValueList = " — ",
441441
DefaultValue = " — "
442+
},
443+
new()
444+
{
445+
Name = nameof(Select<string>.ShowSwal),
446+
Description = Localizer["SelectsShowSwal"],
447+
Type = "bool",
448+
ValueList = "true|false",
449+
DefaultValue = "true"
442450
}
443451
];
444452
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3267,7 +3267,8 @@
32673267
"TextConvertToValueCallback": "Callback method when input text changes in edit mode",
32683268
"SelectsIsEditable": "Whether editable",
32693269
"SelectsIsVirtualize": "Wether to enable virtualize",
3270-
"SelectsDefaultVirtualizeItemText": "The text string corresponding to the first load value when virtual scrolling is turned on is separated by commas"
3270+
"SelectsDefaultVirtualizeItemText": "The text string corresponding to the first load value when virtual scrolling is turned on is separated by commas",
3271+
"SelectsShowSwal": "Whether show the swal confirm popup"
32713272
},
32723273
"BootstrapBlazor.Server.Components.Samples.Sliders": {
32733274
"SlidersTitle": "Slider",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3267,7 +3267,8 @@
32673267
"TextConvertToValueCallback": "编辑模式下输入文本变化时回调方法",
32683268
"SelectsIsEditable": "是否可编辑",
32693269
"SelectsIsVirtualize": "是否开启虚拟滚动",
3270-
"SelectsDefaultVirtualizeItemText": "开启虚拟滚动时首次加载 Value 对应的文本字符串用逗号分割"
3270+
"SelectsDefaultVirtualizeItemText": "开启虚拟滚动时首次加载 Value 对应的文本字符串用逗号分割",
3271+
"SelectsShowSwal": "是否显示 Swal 确认弹窗"
32713272
},
32723273
"BootstrapBlazor.Server.Components.Samples.Sliders": {
32733274
"SlidersTitle": "Slider 滑块",

src/BootstrapBlazor/BootstrapBlazor.csproj

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

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

77
<ItemGroup>

src/BootstrapBlazor/Components/Select/Select.razor.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ public partial class Select<TValue> : ISelect, ILookup
5757
[Parameter]
5858
public Func<SelectedItem, Task<bool>>? OnBeforeSelectedItemChange { get; set; }
5959

60+
/// <summary>
61+
/// Gets or sets whether to show the Swal confirmation popup when <see cref="OnBeforeSelectedItemChange"/> returns true. Default is true.
62+
/// 获得/设置 是否显示 Swal 确认弹窗
63+
/// </summary>
64+
[Parameter]
65+
public bool ShowSwal { get; set; } = true;
66+
6067
/// <summary>
6168
/// Gets or sets the callback method when the selected item changes.
6269
/// </summary>
@@ -338,7 +345,7 @@ private async Task OnClickItem(SelectedItem item)
338345
if (OnBeforeSelectedItemChange != null)
339346
{
340347
ret = await OnBeforeSelectedItemChange(item);
341-
if (ret)
348+
if (ret && ShowSwal)
342349
{
343350
// Return true to show modal
344351
var option = new SwalOption()
@@ -354,10 +361,6 @@ private async Task OnClickItem(SelectedItem item)
354361
}
355362
ret = await SwalService.ShowModal(option);
356363
}
357-
else
358-
{
359-
return;
360-
}
361364
}
362365
if (ret)
363366
{

0 commit comments

Comments
 (0)