コード例 #1
0
 private static void EnsureValidEditContext(EditContext editContext, Button button)
 {
     if (button.RequiresValidForm(editContext) && !editContext.IsValid())
     {
         throw new InvalidEntityException();
     }
 }
コード例 #2
0
        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();
        }
コード例 #3
0
 private async void PropertyEditContext_OnValidationStateChangedAsync(object?sender, ValidationStateChangedEventArgs e)
 {
     if (!EditContext.IsValid(Property) && e.IsValid == true)
     {
         await EditContext.IsValidAsync();
     }
 }
コード例 #4
0
ファイル: BaseButton.cs プロジェクト: lanicon/RapidCMS
        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);
            }
        }
コード例 #5
0
ファイル: BaseButton.cs プロジェクト: darkmice/RapidCMS
        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);
            }
        }
コード例 #6
0
        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();
            }
        }