Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/BootstrapBlazor/Components/Button/Button.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
@inherits ButtonBase

<button @attributes="@AdditionalAttributes" type="@ButtonType.ToDescriptionString()" @onclick="@OnClickButton" id="@Id" class="@ClassName" disabled="@Disabled" role="button" data-bs-placement="@PlacementString" data-bs-trigger="@TriggerString" aria-disabled="@DisabledString" tabindex="@Tab" @onclick:stopPropagation="@StopPropagation" @ref="ButtonElement">
@if (!string.IsNullOrEmpty(ButtonIcon))
@if(IsAsyncLoading)
{
<i class="@ButtonIcon"></i>
<i class="@LoadingIcon"></i>
}
else if (!string.IsNullOrEmpty(Icon))
{
<i class="@Icon"></i>
}
@if (!string.IsNullOrEmpty(Text))
{
Expand Down
2 changes: 0 additions & 2 deletions src/BootstrapBlazor/Components/Button/Button.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ protected virtual async Task OnClickButton()
if (IsAsync && ButtonType == ButtonType.Button)
{
IsAsyncLoading = true;
ButtonIcon = LoadingIcon;
IsDisabled = true;
}

Expand All @@ -65,7 +64,6 @@ protected virtual async Task OnClickButton()
// 恢复按钮
if (IsAsync && ButtonType == ButtonType.Button)
{
ButtonIcon = Icon;
IsDisabled = IsKeepDisabled;
IsAsyncLoading = false;
}
Expand Down
13 changes: 0 additions & 13 deletions src/BootstrapBlazor/Components/Button/ButtonBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public abstract class ButtonBase : TooltipWrapperBase
/// </summary>
protected string? Tab => IsDisabled ? "-1" : null;

/// <summary>
/// 获得/设置 实际按钮渲染图标
/// </summary>
protected string? ButtonIcon { get; set; }

/// <summary>
/// 获得/设置 按钮风格枚举
/// </summary>
Expand Down Expand Up @@ -173,8 +168,6 @@ protected override void OnInitialized()
{
base.OnInitialized();

ButtonIcon = Icon;

if (IsAsync && ValidateForm != null)
{
// 开启异步操作时与 ValidateForm 联动
Expand All @@ -191,11 +184,6 @@ protected override void OnParametersSet()

LoadingIcon ??= IconTheme.GetIconByKey(ComponentIcons.ButtonLoadingIcon);

if (!IsAsyncLoading)
{
ButtonIcon = Icon;
}

if (Tooltip != null && !string.IsNullOrEmpty(TooltipText))
{
Tooltip.SetParameters(TooltipText, TooltipPlacement, TooltipTrigger);
Expand Down Expand Up @@ -260,7 +248,6 @@ public void SetDisable(bool disable)
internal void TriggerAsync(bool loading)
{
IsAsyncLoading = loading;
ButtonIcon = loading ? LoadingIcon : Icon;
SetDisable(loading);
}

Expand Down
3 changes: 0 additions & 3 deletions src/BootstrapBlazor/Components/Button/CountButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ public class CountButton : Button
protected override async Task OnClickButton()
{
IsAsyncLoading = true;
ButtonIcon = LoadingIcon;
IsDisabled = true;

await Task.Run(() => InvokeAsync(HandlerClick));
await UpdateCount();

IsDisabled = false;
ButtonIcon = Icon;
IsAsyncLoading = false;
}

Expand All @@ -65,7 +63,6 @@ private async Task UpdateCount()
{
var count = Count;
var text = Text;
ButtonIcon = null;
while (count > 0)
{
Text = GetCountText(count--, text);
Expand Down
1 change: 0 additions & 1 deletion src/BootstrapBlazor/Components/Button/ExportPdfButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ protected override void OnParametersSet()
base.OnParametersSet();

Icon ??= IconTheme.GetIconByKey(ComponentIcons.TableExportPdfIcon);
ButtonIcon = Icon;
}

/// <summary>
Expand Down
8 changes: 6 additions & 2 deletions src/BootstrapBlazor/Components/Button/PopConfirmButton.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ else
@<DynamicElement TagName="@TagName" OnClick="Show" id="@Id"
class="@ClassString" role="dialog" tabindex="@Tab" data-bb-confirm="@ConfirmString"
data-bs-custom-class="@CustomClassString" data-bs-trigger="@TriggerString" data-bs-placement="@PlacementString">
@if (!string.IsNullOrEmpty(ButtonIcon))
@if(IsAsyncLoading)
{
<i class="@ButtonIcon"></i>
<i class="@LoadingIcon"></i>
}
else if (!string.IsNullOrEmpty(Icon))
{
<i class="@Icon"></i>
}
@if (!string.IsNullOrEmpty(Text))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private async Task OnClickConfirm()
if (IsAsync)
{
IsDisabled = true;
ButtonIcon = LoadingIcon;
IsAsyncLoading = true;
StateHasChanged();
await Task.Run(() => InvokeAsync(OnConfirm));

Expand All @@ -106,7 +106,7 @@ private async Task OnClickConfirm()
else
{
IsDisabled = false;
ButtonIcon = Icon;
IsAsyncLoading = false;
StateHasChanged();
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/BootstrapBlazor/Components/Dropdown/Dropdown.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
TriggerClick="ShowSplit" OnClick="OnClickButton">
@if (ButtonTemplate == null)
{
@if (!string.IsNullOrEmpty(_buttonIcon))
@if (_isAsyncLoading)
{
<i class="@_buttonIcon"></i>
<i class="@LoadingIcon"></i>
}
else if (!string.IsNullOrEmpty(Icon))
{
<i class="@Icon"></i>
}
<span>@ButtonText</span>
}
Expand Down
14 changes: 1 addition & 13 deletions src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,6 @@ public partial class Dropdown<TValue>
/// </summary>
private bool _isAsyncLoading;

/// <summary>
/// 获得/设置 实际按钮渲染图标
/// </summary>
protected string? _buttonIcon { get; set; }

/// <summary>
/// OnParametersSet 方法
/// </summary>
Expand All @@ -234,19 +229,14 @@ protected override void OnParametersSet()
Items = typeof(TValue).ToSelectList();
}

DataSource = Items.ToList();
DataSource = [.. Items];

SelectedItem = DataSource.Find(i => i.Value.Equals(CurrentValueAsString, StringComparison.OrdinalIgnoreCase))
?? DataSource.Find(i => i.Active)
?? DataSource.FirstOrDefault();

FixedButtonText ??= SelectedItem?.Text;
LoadingIcon ??= IconTheme.GetIconByKey(ComponentIcons.ButtonLoadingIcon);

if (_isAsyncLoading == false)
{
_buttonIcon = Icon;
}
}

private IEnumerable<SelectedItem> GetItems() => (IsFixedButtonText && !ShowFixedButtonTextInDropdown)
Expand Down Expand Up @@ -276,7 +266,6 @@ private async Task OnClickButton()
if (IsAsync)
{
_isAsyncLoading = true;
_buttonIcon = LoadingIcon;
IsDisabled = true;
StateHasChanged();
await Task.Yield();
Expand All @@ -287,7 +276,6 @@ private async Task OnClickButton()
// 恢复按钮
if (IsAsync)
{
_buttonIcon = Icon;
IsDisabled = IsKeepDisabled;
_isAsyncLoading = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/Components/Print/PrintButton.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
@attribute [BootstrapModuleAutoLoader("Print/PrintButton.razor.js")]

<a @attributes="@AdditionalAttributes" id="@Id" href="@PreviewUrl" class="@ClassName" disabled="@Disabled" role="button" aria-disabled="@DisabledString" tabindex="@Tab">
@if (!string.IsNullOrEmpty(ButtonIcon))
@if (!string.IsNullOrEmpty(Icon))
{
<i class="@ButtonIcon"></i>
<i class="@Icon"></i>
}
@if (!string.IsNullOrEmpty(Text))
{
Expand Down
1 change: 0 additions & 1 deletion src/BootstrapBlazor/Components/Print/PrintButton.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ protected override void OnParametersSet()
base.OnParametersSet();

Icon ??= IconTheme.GetIconByKey(ComponentIcons.PrintButtonIcon);
ButtonIcon = Icon;
}
}