async Task HandleValidSubmitAsync(EditContext editContext) { var response = await AnyErrors(editContext); message = response; }
public void ChangePasswordInvalidFormSubmitted(EditContext editContext) { authorization_result = null; }
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(); }
public static bool IsValid(this EditContext editContext) => !editContext?.GetValidationMessages().Any() ?? throw new ArgumentNullException(nameof(editContext));
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)); }
protected override void OnInitialized() { base.OnInitialized(); EditContext = new EditContext(User); }
private async Task OnValidSubmit(EditContext editContext) { await OnFinish.InvokeAsync(editContext); OnFinishEvent?.Invoke(this); }
private async Task OnInvalidSubmit(EditContext editContext) { await OnFinishFailed.InvokeAsync(editContext); }
public void OnValidSubmit(EditContext context) { success = true; StateHasChanged(); NavigationManager.NavigateTo("/SignIn"); }
protected void InvalidSubmit(EditContext context) { JS.InvokeVoidAsync("klazor.console", JsonConvert.SerializeObject(context, Formatting.Indented)); }
private void HandleSubmit(EditContext editContext) { Console.WriteLine(editContext); }
protected IEnumerable <string> GetValidationMessages() { return(EditContext.GetValidationMessages(Property)); }
/// <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; }
public void Reset() { _controls.ForEach(item => item.Reset()); _editContext = new EditContext(Model); }
private static void ValidateField(EditContext editContext, ValidationMessageStore messages, in FieldIdentifier fieldIdentifier)
public void ValidationReset() { _editContext = new EditContext(Model); }
protected void Remove(AttributeDescription toMove) { Attributes.Add(toMove.Attribute); Product.Descriptions.Remove(toMove); EditContext.NotifyFieldChanged(FieldIdentifier.Create(() => Product.Descriptions)); }
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)
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)); }
public void ResetForm() { MessageModel = new MessageModel(); editContext = new EditContext(MessageModel); }
public void InvalidFormSubmitted(EditContext editContext) { }
protected override void OnInitialized() { EditContext = new EditContext(File); EditContext.SetFieldCssClassProvider(new MyFieldClassProvider()); }
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; } }
protected override void OnInitialized() { editContext = new EditContext(product); editContext.OnFieldChanged += EditContext_OnFieldChanged; Interceptor.RegisterEvent(); }
internal OperationAuthorizationRequirement GetOperation(EditContext editContext) => GetButtonHandler(editContext).GetOperation(this, editContext);
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); }