Started CreateApplication.razor
This commit is contained in:
		| @@ -2,9 +2,9 @@ | ||||
| @using System.Reflection | ||||
| @using BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers | ||||
| @typeparam TItem where TItem : class | ||||
|     @typeparam TMember where TMember : struct, Enum | ||||
| @typeparam TMember where TMember : struct, Enum | ||||
|  | ||||
| <InputSelect TValue="TMember"  @bind-Value="selected"> | ||||
| <InputSelect TValue="TMember" @bind-Value="selected"> | ||||
|     @foreach (var value in enumValues) | ||||
|     { | ||||
|         <option value="@value.Key">@value.Value</option> | ||||
| @@ -16,6 +16,8 @@ | ||||
|  | ||||
|     [Parameter, EditorRequired] public Expression<Func<TItem, TMember>> EnumProperty { get; set; } = null!; | ||||
|  | ||||
|     [Parameter] public Action? OnChanged { get; set; } | ||||
|  | ||||
|     private Dictionary<TMember, string> enumValues = new(); | ||||
|     private PropertyInfo modelMemberInfo = null!; | ||||
|     private TMember selected; | ||||
| @@ -33,12 +35,17 @@ | ||||
|  | ||||
|     protected override void OnAfterRender(bool firstRender) | ||||
|     { | ||||
|         OnValueChanged(); | ||||
|         var current = (TMember)modelMemberInfo.GetValue(Model)!; | ||||
|         if (!current.Equals(selected)) | ||||
|         { | ||||
|             OnValueChanged(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void OnValueChanged() | ||||
|     { | ||||
|         modelMemberInfo.SetValue(Model, selected); | ||||
|         OnChanged?.Invoke(); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services | ||||
| @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider | ||||
| @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider | ||||
| @using VisaApiClient | ||||
|  | ||||
| <div> | ||||
| @@ -22,7 +21,7 @@ | ||||
|     <div > | ||||
|         <label> | ||||
|             Issue date:<br/> | ||||
|             <InputDate DisplayName="Issue date" class="rounded" @bind-Value="Passport.IssueDate" max="DateTimeProvider.Now()"/> | ||||
|             <InputDate DisplayName="Issue date" class="rounded" @bind-Value="Passport.IssueDate" max="@formattedDate"/> | ||||
|         </label><br/> | ||||
|         <ValidationMessage For="() => Passport.IssueDate"></ValidationMessage> | ||||
|     </div><br/> | ||||
| @@ -30,14 +29,14 @@ | ||||
|     <div > | ||||
|         <label> | ||||
|             Expiration date:<br/> | ||||
|             <InputDate DisplayName="Expiration date" class="rounded" @bind-Value="Passport.ExpirationDate" min="DateTimeProvider.Now()"/> | ||||
|             <InputDate DisplayName="Expiration date" class="rounded" @bind-Value="Passport.ExpirationDate" min="@formattedDate"/> | ||||
|         </label><br/> | ||||
|         <ValidationMessage For="() => Passport.ExpirationDate"></ValidationMessage> | ||||
|     </div> | ||||
| </div> | ||||
|  | ||||
| @code { | ||||
|     private string now = DateTime.Now.ToString("yyyy-MM-dd"); | ||||
|     private string formattedDate = null!; | ||||
|  | ||||
|     [Parameter, EditorRequired] public PassportModel Passport { get; set; } = null!; | ||||
|  | ||||
| @@ -47,6 +46,7 @@ | ||||
|     { | ||||
|         Passport.IssueDate = DateTime.Now; | ||||
|         Passport.ExpirationDate = DateTime.Now; | ||||
|         formattedDate = DateTimeProvider.FormattedNow(); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| @using BlazorWebAssemblyVisaApiClient.FluentValidation.Applicants.Models | ||||
|  | ||||
| @using BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models | ||||
| <div> | ||||
|     <div > | ||||
|         <label > | ||||
|   | ||||
| @@ -1,46 +0,0 @@ | ||||
| <h3>CustomValidation</h3> | ||||
|  | ||||
| @code { | ||||
|     private ValidationMessageStore? messageStore; | ||||
|  | ||||
|     [CascadingParameter] | ||||
|     private EditContext? CurrentEditContext { get; set; } | ||||
|  | ||||
|     protected override void OnInitialized() | ||||
|     { | ||||
|         if (CurrentEditContext is null) | ||||
|         { | ||||
|             throw new InvalidOperationException( | ||||
|                 $"{nameof(CustomValidation)} requires a cascading " + | ||||
|                 $"parameter of type {nameof(EditContext)}. " + | ||||
|                 $"For example, you can use {nameof(CustomValidation)} " + | ||||
|                 $"inside an {nameof(EditForm)}."); | ||||
|         } | ||||
|  | ||||
|         messageStore = new(CurrentEditContext); | ||||
|  | ||||
|         CurrentEditContext.OnValidationRequested += (_, _) => | ||||
|             messageStore?.Clear(); | ||||
|         CurrentEditContext.OnFieldChanged += (_, e) => | ||||
|             messageStore?.Clear(e.FieldIdentifier); | ||||
|     } | ||||
|  | ||||
|     public void DisplayErrors(Dictionary<string, List<string>> errors) | ||||
|     { | ||||
|         if (CurrentEditContext is not null) | ||||
|         { | ||||
|             foreach (var err in errors) | ||||
|             { | ||||
|                 messageStore?.Add(CurrentEditContext.Field(err.Key), err.Value); | ||||
|             } | ||||
|  | ||||
|             CurrentEditContext.NotifyValidationStateChanged(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void ClearErrors() | ||||
|     { | ||||
|         messageStore?.Clear(); | ||||
|         CurrentEditContext?.NotifyValidationStateChanged(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,33 @@ | ||||
| @using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider | ||||
| @using VisaApiClient | ||||
|  | ||||
| <div> | ||||
|     <label> | ||||
|         Destination Country:<br/> | ||||
|         <InputText DisplayName="Issuer of permission to destination Country" class="rounded" | ||||
|                    @bind-Value="PermissionToDestCountry.Issuer"/> | ||||
|     </label><br/> | ||||
|     <ValidationMessage For="() => PermissionToDestCountry.Issuer"></ValidationMessage><br/> | ||||
|  | ||||
|     <label> | ||||
|         Expiration date:<br/> | ||||
|         <InputDate DisplayName="Expiration date of permission to destination Country" class="rounded" | ||||
|                    @bind-Value="PermissionToDestCountry.ExpirationDate" | ||||
|                    max="@formattedDate"/> | ||||
|     </label><br/> | ||||
|     <ValidationMessage For="() => PermissionToDestCountry.ExpirationDate"></ValidationMessage> | ||||
| </div> | ||||
|  | ||||
| @code { | ||||
|     private string formattedDate = null!; | ||||
|  | ||||
|     [Parameter, EditorRequired] public PermissionToDestCountryModel PermissionToDestCountry { get; set; } = null!; | ||||
|  | ||||
|     [Inject] IDateTimeProvider DateTimeProvider { get; set; } = null!; | ||||
|  | ||||
|     protected override void OnInitialized() | ||||
|     { | ||||
|         formattedDate = DateTimeProvider.FormattedNow(); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -9,7 +9,7 @@ | ||||
|     [Parameter] | ||||
|     public RenderFragment? ChildContent { get; set; } | ||||
|  | ||||
|     public string StatusText { get; set; } = string.Empty; | ||||
|     public string StatusText { get; private set; } = string.Empty; | ||||
|  | ||||
|     public void SetMessage(string message) | ||||
|     { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user