async Task HandleValidSubmitAsync(EditContext editContext)
        {
            var response = await AnyErrors(editContext);

            message = response;
        }
Пример #2
0
 public void ChangePasswordInvalidFormSubmitted(EditContext editContext)
 {
     authorization_result = null;
 }
Пример #3
0
 protected override void OnInitialized()
 {
     _editContext = new EditContext(Blog);
     _messages    = new ValidationMessageStore(_editContext);
     base.OnInitialized();
 }
 /// <summary>
 /// Callback that is invoked when the form is submitted with no errors.
 /// </summary>
 ///
 /// <param name="_">The context.</param>.
 private async Task OnValidSubmitAsync(EditContext _)
 {
     await this.SaveChangesModal.ShowAsync();
 }
Пример #5
0
 public static bool IsValid(this EditContext editContext) =>
 !editContext?.GetValidationMessages().Any() ?? throw new ArgumentNullException(nameof(editContext));
Пример #6
0
 protected void Add(Model.Attribute toMove)
 {
     Product.Descriptions.Add(new AttributeDescription(string.Empty, attributeId: toMove.Id, attribute: toMove));
     Attributes.Remove(toMove);
     EditContext.NotifyFieldChanged(FieldIdentifier.Create(() => Product.Descriptions));
 }
Пример #7
0
 protected override void OnInitialized()
 {
     base.OnInitialized();
     EditContext = new EditContext(User);
 }
Пример #8
0
        private async Task OnValidSubmit(EditContext editContext)
        {
            await OnFinish.InvokeAsync(editContext);

            OnFinishEvent?.Invoke(this);
        }
Пример #9
0
 private async Task OnInvalidSubmit(EditContext editContext)
 {
     await OnFinishFailed.InvokeAsync(editContext);
 }
Пример #10
0
 public void OnValidSubmit(EditContext context)
 {
     success = true;
     StateHasChanged();
     NavigationManager.NavigateTo("/SignIn");
 }
Пример #11
0
 protected void InvalidSubmit(EditContext context)
 {
     JS.InvokeVoidAsync("klazor.console", JsonConvert.SerializeObject(context, Formatting.Indented));
 }
Пример #12
0
 private void HandleSubmit(EditContext editContext)
 {
     Console.WriteLine(editContext);
 }
Пример #13
0
 protected IEnumerable <string> GetValidationMessages()
 {
     return(EditContext.GetValidationMessages(Property));
 }
Пример #14
0
 /// <summary>
 /// Creates an instance of <see cref="ValidationMessageStore"/>.
 /// </summary>
 /// <param name="editContext">The <see cref="EditContext"/> with which this store should be associated.</param>
 public ValidationMessageStore(EditContext editContext)
 {
     _editContext = editContext ?? throw new ArgumentNullException(nameof(editContext));
 }
 public void OnEditContestChanged(EditContext context)
 {
     LocalEditContext = context;
 }
Пример #16
0
 public void Reset()
 {
     _controls.ForEach(item => item.Reset());
     _editContext = new EditContext(Model);
 }
Пример #17
0
 private static void ValidateField(EditContext editContext, ValidationMessageStore messages, in FieldIdentifier fieldIdentifier)
Пример #18
0
 public void ValidationReset()
 {
     _editContext = new EditContext(Model);
 }
Пример #19
0
 protected void Remove(AttributeDescription toMove)
 {
     Attributes.Add(toMove.Attribute);
     Product.Descriptions.Remove(toMove);
     EditContext.NotifyFieldChanged(FieldIdentifier.Create(() => Product.Descriptions));
 }
Пример #20
0
        protected async Task <List <ButtonUI> > GetButtonsAsync(IEnumerable <Button> buttons, EditContext editContext)
        {
            return(await buttons
                   .GetAllButtons()
                   .Where(button => button.IsCompatible(editContext))
                   .WhereAsync(async button =>
            {
                var authorizationChallenge = await _authorizationService.AuthorizeAsync(
                    _httpContextAccessor.HttpContext.User,
                    editContext.Entity,
                    button.GetOperation(editContext));

                return authorizationChallenge.Succeeded;
            })
                   .ToListAsync(button => button.ToUI(editContext)));
        }
 public override string GetFieldCssClass(EditContext editContext,
                                         in FieldIdentifier fieldIdentifier)
Пример #22
0
 private Task OnInValidSubmit(EditContext context)
 {
     Trace1.Log("数据非法");
     return(Task.CompletedTask);
 }
 /// <summary>
 /// Callback that is invoked when the form is submitted with errors.
 /// </summary>
 ///
 /// <param name="_">The context.</param>.
 private void OnInvalidSubmit(EditContext _)
 {
     // Show a toast message
     this.Toaster.Error(this.Localizer.GetString(SharedResources.FORM_INVALID_FIELDS));
 }
Пример #24
0
 public void ResetForm()
 {
     MessageModel = new MessageModel();
     editContext  = new EditContext(MessageModel);
 }
Пример #25
0
 public void InvalidFormSubmitted(EditContext editContext)
 {
 }
 protected override void OnInitialized()
 {
     EditContext = new EditContext(File);
     EditContext.SetFieldCssClassProvider(new MyFieldClassProvider());
 }
Пример #27
0
        protected virtual async Task OnFileSelectedAsync(ChangeEventArgs args)
        {
            EditContext.NotifyPropertyBusy(Property);

            UploadCompletion = 0.01;

            var files = await FileReaderService.CreateReference(_fileInput).EnumerateFilesAsync();

            if (files.Count() > 1)
            {
                EditContext.AddValidationMessage(Property, "This editor only supports single files for now.");
            }

            var file = files.FirstOrDefault();

            if (file == null)
            {
                return;
            }

            var fileInfo = await file.ReadFileInfoAsync();

            IEnumerable <string> validationMessages;

            try
            {
                validationMessages = await FileUploadHandler.ValidateFileAsync(fileInfo);
            }
            catch
            {
                validationMessages = new[] { "Failed to validate file." };
            }

            if (!validationMessages.Any())
            {
                try
                {
                    using var uploadedFile = await UploadFileToTempFileAsync(file, 8192, fileInfo.Size, (completion) =>
                    {
                        Console.WriteLine(completion);

                        if (completion - UploadCompletion > 1)
                        {
                            UploadCompletion = completion;
                            StateHasChanged();
                        }
                    });

                    UploadCompletion = 0.0;
                    StateHasChanged();

                    var value = await FileUploadHandler.SaveFileAsync(fileInfo, uploadedFile);

                    SetValueFromObject(value);

                    EditContext.NotifyPropertyFinished(Property);
                    EditContext.NotifyPropertyChanged(Property);
                }
                catch
                {
                    validationMessages = new[] { "Failed to upload file." };
                }
            }

            if (validationMessages.Any())
            {
                foreach (var message in validationMessages)
                {
                    EditContext.AddValidationMessage(Property, message);
                }

                EditContext.NotifyPropertyFinished(Property);

                UploadCompletion = 0.0;
                StateHasChanged();
                return;
            }
        }
Пример #28
0
 protected override void OnInitialized()
 {
     editContext = new EditContext(product);
     editContext.OnFieldChanged += EditContext_OnFieldChanged;
     Interceptor.RegisterEvent();
 }
Пример #29
0
 internal OperationAuthorizationRequirement GetOperation(EditContext editContext) => GetButtonHandler(editContext).GetOperation(this, editContext);
Пример #30
0
        protected async Task HandleValidSubmit()
        {
            if (!EditContext.Validate())
            {
                return;
            }

            var changes = HandleModificationState.Changes;

            if (!changes.Any())
            {
                await Notifier.NotifyAsync(new Models.Notification
                {
                    Header  = GetModelId(Model),
                    IsError = false,
                    Message = Localizer["No changes"]
                }).ConfigureAwait(false);

                return;
            }

            Model = Model.Clone();

            Id    = GetModelId(Model);
            IsNew = false;

            var keys = changes.Keys
                       .OrderBy(k => k, this);

            try
            {
                foreach (var key in keys)
                {
                    await HandleMoficationList(key, changes[key])
                    .ConfigureAwait(false);
                }

                await Notifier.NotifyAsync(new Models.Notification
                {
                    Header  = GetModelId(Model),
                    Message = Localizer["Saved"]
                }).ConfigureAwait(false);
            }
            catch (AggregateException ae)
            {
                foreach (var e in ae.InnerExceptions)
                {
                    await HandleModificationErrorAsync(e).ConfigureAwait(false);
                }
            }
            catch (Exception e)
            {
                await HandleModificationErrorAsync(e).ConfigureAwait(false);
            }
            finally
            {
                changes.Clear();
            }

            EditContext.MarkAsUnmodified();
            await InvokeAsync(StateHasChanged).ConfigureAwait(false);
        }