mirror of https://github.com/abpframework/abp.git
2 changed files with 65 additions and 0 deletions
@ -0,0 +1,3 @@ |
|||||
|
<Button form="@Form" Type="@Type" Color="@Color" Block="@Block" PreventDefaultOnSubmit="@PreventDefaultOnSubmit" Disabled="@IsDisabled" Loading="@IsLoading" Clicked="@OnClickedHandler"> |
||||
|
@ChildContent |
||||
|
</Button> |
||||
@ -0,0 +1,62 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Blazorise; |
||||
|
using Microsoft.AspNetCore.Components; |
||||
|
|
||||
|
namespace Volo.Abp.BlazoriseUI.Components |
||||
|
{ |
||||
|
public partial class SubmitButton : ComponentBase |
||||
|
{ |
||||
|
protected bool Submiting { get; set; } |
||||
|
|
||||
|
[Parameter] |
||||
|
public string Form { get; set; } |
||||
|
|
||||
|
[Parameter] |
||||
|
public ButtonType Type { get; set; } = ButtonType.Submit; |
||||
|
|
||||
|
[Parameter] |
||||
|
public Color Color { get; set; } = Color.Primary; |
||||
|
|
||||
|
[Parameter] |
||||
|
public bool PreventDefaultOnSubmit { get; set; } = true; |
||||
|
|
||||
|
[Parameter] |
||||
|
public bool Block { get; set; } |
||||
|
|
||||
|
[Parameter] |
||||
|
public bool? Disabled { get; set; } |
||||
|
|
||||
|
[Parameter] |
||||
|
public EventCallback Clicked { get; set; } |
||||
|
|
||||
|
[Parameter] |
||||
|
public RenderFragment ChildContent { get; set; } |
||||
|
|
||||
|
protected bool IsDisabled |
||||
|
=> Disabled == true || Submiting; |
||||
|
|
||||
|
protected bool IsLoading |
||||
|
=> Submiting; |
||||
|
|
||||
|
protected virtual async Task OnClickedHandler() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
Submiting = true; |
||||
|
|
||||
|
await Clicked.InvokeAsync(null); |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
Submiting = false; |
||||
|
|
||||
|
await InvokeAsync(StateHasChanged); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue