private static void EnsureValidEditContext(EditContext editContext, Button button) { if (button.RequiresValidForm(editContext) && !editContext.IsValid()) { throw new InvalidEntityException(); } }
private void ValidationStateChangeHandler(object?sender, ValidationStateChangedEventArgs eventArgs) { var state = ValidationState.None; if (!EditContext.WasValidated(Property)) { state |= ValidationState.NotValidated; } else { if (EditContext.IsValid(Property)) { state |= ValidationState.Valid; } else { state |= ValidationState.Invalid; } } if (EditContext.IsModified()) { state |= ValidationState.Modified; } State = state; StateHasChanged(); }
private async void PropertyEditContext_OnValidationStateChangedAsync(object?sender, ValidationStateChangedEventArgs e) { if (!EditContext.IsValid(Property) && e.IsValid == true) { await EditContext.IsValidAsync(); } }
protected async Task ButtonClickAsync(object?customData = null) { if (Model.RequiresValidForm && !(EditContext?.IsValid() ?? true)) { return; } if (!Model.ShouldConfirm || await JsRuntime.InvokeAsync <bool>("confirm", LanguageResolver.ResolveText("Are you sure?"))) { Model.NotifyClick(EditContext, customData); } }
protected async Task ButtonClickAsync(object?customData = null) { if (Model.RequiresValidForm && !(EditContext?.IsValid() ?? true)) { return; } // TODO: make message configurable if (!Model.ShouldConfirm || await JsRuntime.InvokeAsync <bool>("confirm", "Are you sure?")) { Model.NotifyClick(EditContext, customData); } }
protected async Task ButtonClickAsync(object?customData = null) { try { IsDisabled = true; StateHasChanged(); if (Model.RequiresValidForm && !(EditContext?.IsValid() ?? true)) { return; } if (!Model.ShouldConfirm || await JsRuntime.InvokeAsync <bool>("confirm", LanguageResolver.ResolveText("Are you sure?"))) { await Model.NotifyClickAsync(EditContext !, customData); } } finally { IsDisabled = false; StateHasChanged(); } }