feat: add applying state to VisibilityModal
This commit is contained in:
@@ -42,8 +42,15 @@
|
||||
</div>
|
||||
</Body>
|
||||
<Footer>
|
||||
<button class="btn btn-secondary" @onclick="OnClose">Cancel</button>
|
||||
<button class="btn btn-primary" @onclick="OnApply">Apply</button>
|
||||
<button class="btn btn-secondary" @onclick="OnClose" disabled="@_isApplying">Cancel</button>
|
||||
<button class="btn btn-primary" @onclick="ApplyAsync" disabled="@_isApplying">
|
||||
@if (_isApplying) {
|
||||
<span class="spinner-border spinner-border-sm me-1" role="status" aria-hidden="true"></span>
|
||||
<span>Applying…</span>
|
||||
} else {
|
||||
<span>Apply</span>
|
||||
}
|
||||
</button>
|
||||
</Footer>
|
||||
</ModalFrame>
|
||||
|
||||
@@ -62,6 +69,23 @@
|
||||
[Parameter] public bool CascadeEnabled2 { get; set; }
|
||||
[Parameter] public EventCallback<bool> CascadeEnabled2Changed { get; set; }
|
||||
|
||||
bool _isApplying;
|
||||
|
||||
protected override void OnParametersSet() {
|
||||
if (!Show) _isApplying = false;
|
||||
}
|
||||
|
||||
async Task ApplyAsync() {
|
||||
if (_isApplying) return;
|
||||
_isApplying = true;
|
||||
StateHasChanged();
|
||||
try {
|
||||
await OnApply.InvokeAsync();
|
||||
} finally {
|
||||
_isApplying = false;
|
||||
}
|
||||
}
|
||||
|
||||
async Task SelectVisibility(EVisibility vis) {
|
||||
Visibility = vis;
|
||||
await VisibilityChanged.InvokeAsync(vis);
|
||||
|
||||
Reference in New Issue
Block a user