diff --git a/src/Somnia.GuestLog/Components/Controls/GuestDocForm.razor b/src/Somnia.GuestLog/Components/Forms/GuestDocForm.razor similarity index 94% rename from src/Somnia.GuestLog/Components/Controls/GuestDocForm.razor rename to src/Somnia.GuestLog/Components/Forms/GuestDocForm.razor index e96410f..92a6ee1 100644 --- a/src/Somnia.GuestLog/Components/Controls/GuestDocForm.razor +++ b/src/Somnia.GuestLog/Components/Forms/GuestDocForm.razor @@ -26,7 +26,7 @@ } + Required ReadOnly="@ReadOnlyDocId" /> @@ -34,7 +34,7 @@ Clearable OpenTo="OpenTo.Year" Editable /> @@ -51,13 +51,13 @@ + OnBlur="@(() => Model.Name = Model.Name?.ToUpper())" /> + OnBlur="@(() => Model.Surname = Model.Surname?.ToUpper())" /> + OnBlur="@(() => Model.Surname2 = Model.Surname2?.ToUpper())" /> + InputType="InputType.Telephone" /> + InputType="InputType.Email" /> diff --git a/src/Somnia.GuestLog/Components/Pages/DebugPages/Empty.razor b/src/Somnia.GuestLog/Components/Pages/DebugPages/Empty.razor new file mode 100644 index 0000000..ca51ccb --- /dev/null +++ b/src/Somnia.GuestLog/Components/Pages/DebugPages/Empty.razor @@ -0,0 +1,15 @@ +@page "/debug/empty" + + +@inject ILogger logger; +@inject ISnackbar Snackbar +@inject IDialogService DialogService + +DEBUG - Empty + +Empty Page for Debug + + +@code { + +} diff --git a/src/Somnia.GuestLog/Components/Pages/GuestDocuments/GuestDocDetail.razor b/src/Somnia.GuestLog/Components/Pages/GuestDocuments/GuestDocDetail.razor index 1887437..3ba30d6 100644 --- a/src/Somnia.GuestLog/Components/Pages/GuestDocuments/GuestDocDetail.razor +++ b/src/Somnia.GuestLog/Components/Pages/GuestDocuments/GuestDocDetail.razor @@ -7,9 +7,7 @@ @inject IDialogService DialogService @inject NavigationManager Navigation @inject IGuestDocumentService guestDocService - - -@inject FluentValidation.IValidator docIdValidator; +@inject IStayEntryService stayService Somnia - Guest Docs - Details @@ -17,8 +15,8 @@ Guest Document - "@docId" - + @LanguageLocale.general_btnEdit + + + + + + + + Total Stays: @(guestStaysLoading ? "Loading..." : guestStayList.Count()) + + + @LanguageLocale.dto_StayEntry_DateIn + @LanguageLocale.dto_StayEntry_DateOut + @LanguageLocale.dto_StayEntry_RoomCount + @LanguageLocale.dto_StayEntry_RoomNumber + + + + @context.DateIn + + + @context.DateOut + + + @context.RoomCount + + + @context.RoomNumber + + + + @LanguageLocale.general_noResults + + + + + + + + } @code { @@ -42,6 +79,10 @@ GuestDocumentDTO? documentModel = null; + IEnumerable guestStayList = []; + bool guestStaysLoading = true; + + protected override async Task OnInitializedAsync() { if (docId is null) @@ -78,4 +119,22 @@ { Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List); } + + private async Task LoadTabGuestStays() + { + //Only load when there is no data. + if (guestStayList.Count() > 0) + { + return; + } + + if (documentModel is null || documentModel.DocumentType is null || documentModel.DocumentNum is null) + { + throw new InvalidOperationException(); + } + + guestStaysLoading = true; + guestStayList = await stayService.GetStaysWithGuest(documentModel.DocumentType, documentModel.DocumentNum); + guestStaysLoading = false; + } } \ No newline at end of file diff --git a/src/Somnia.GuestLog/Components/Pages/GuestDocuments/GuestDocList.razor b/src/Somnia.GuestLog/Components/Pages/GuestDocuments/GuestDocList.razor index 9d6782f..68eb8cb 100644 --- a/src/Somnia.GuestLog/Components/Pages/GuestDocuments/GuestDocList.razor +++ b/src/Somnia.GuestLog/Components/Pages/GuestDocuments/GuestDocList.razor @@ -16,7 +16,7 @@ @LanguageLocale.page_GuestDocList_pageTitle + StartIcon="@Icons.Material.Filled.Search" OnClick="() => BtnSearchDataAsync()"> @LanguageLocale.general_btnSearch - - - - - @foreach (string docType in dataListService.GetDataListByName(GuestConsts.DataList_DocumentTypes)) - { - - @dataListService.GetLocalizedValue(GuestConsts.DataList_DocumentTypes, docType) - - } - - - - - - - - - + { { x => x.DocumentDTO, item } }; - var options = new DialogOptions() - { - FullScreen = true, - CloseButton = true, - CloseOnEscapeKey = true, - }; + GuestDocIdDTO idDto = GuestDocIdDTO.BuildFromDto(item) ?? throw new InvalidOperationException(); - await DialogService.ShowAsync("GuestDoc Details", parameters, options); + string itemId = GuestDocIdDTO.EncodeAsString(idDto); + string uri = GuestConsts.Page_GuestDocs_Detail.Replace(GuestConsts.Page_GuestDocs_Detail_Param_DocId, itemId); + Navigation.NavigateTo(uri); } private async Task BtnDeleteItem(GuestDocumentDTO item) diff --git a/src/Somnia.GuestLog/GuestConsts.cs b/src/Somnia.GuestLog/GuestConsts.cs index 870331f..dea0f0b 100644 --- a/src/Somnia.GuestLog/GuestConsts.cs +++ b/src/Somnia.GuestLog/GuestConsts.cs @@ -5,7 +5,8 @@ public static class GuestConsts public const string Page_GuestDocs_List = "/guest-documents"; public const string Page_GuestDocs_New = "/guest-documents/new"; - public const string Page_GuestDocs_Detail = "/guest-documents/d/{docId}"; + public const string Page_GuestDocs_Detail = $"/guest-documents/d/{Page_GuestDocs_Detail_Param_DocId}"; + public const string Page_GuestDocs_Detail_Param_DocId = "{docId}"; public const string Page_StayEntry_List = "/stayEntries"; public const string Page_StayEntry_New = "/stayEntries/new"; diff --git a/src/Somnia.GuestLog/Models/DTOs/GuestDocIdDTO.cs b/src/Somnia.GuestLog/Models/DTOs/GuestDocIdDTO.cs index 3a17309..f5186a9 100644 --- a/src/Somnia.GuestLog/Models/DTOs/GuestDocIdDTO.cs +++ b/src/Somnia.GuestLog/Models/DTOs/GuestDocIdDTO.cs @@ -25,4 +25,18 @@ public class GuestDocIdDTO DocumentNum = parts[1] }; } + + public static GuestDocIdDTO? BuildFromDto(GuestDocumentDTO? dto) + { + if (dto is null || dto.DocumentType is null || dto.DocumentNum is null) + { + return null; + } + + return new() + { + DocumentType = dto.DocumentType, + DocumentNum = dto.DocumentNum + }; + } } diff --git a/src/Somnia.GuestLog/Program.cs b/src/Somnia.GuestLog/Program.cs index 695e599..18efcf9 100644 --- a/src/Somnia.GuestLog/Program.cs +++ b/src/Somnia.GuestLog/Program.cs @@ -23,7 +23,13 @@ builder.Services.AddDbContextFactory(options => builder.Services.AddDatabaseDeveloperPageExceptionFilter(); // Add MudBlazor services -builder.Services.AddMudServices(); +builder.Services.AddMudServices(c => +{ + c.SnackbarConfiguration.PositionClass = MudBlazor.Defaults.Classes.Position.TopCenter; + c.SnackbarConfiguration.ShowTransitionDuration = 300; + c.SnackbarConfiguration.HideTransitionDuration = 500; + c.SnackbarConfiguration.VisibleStateDuration = 10000; +}); // Add components services to the container. builder.Services.AddRazorComponents() diff --git a/src/Somnia.GuestLog/Validators/GuestDocIdDTOValidator.cs b/src/Somnia.GuestLog/Validators/GuestDocIdDTOValidator.cs index 179acb6..1ebae66 100644 --- a/src/Somnia.GuestLog/Validators/GuestDocIdDTOValidator.cs +++ b/src/Somnia.GuestLog/Validators/GuestDocIdDTOValidator.cs @@ -8,7 +8,7 @@ namespace Somnia.GuestLog.Validators; /// /// Validator for GuestDocumentDTO which contains multiple rules and can be shared with the back end API /// -public class GuestDocIdDTOValidator : AbstractValidator +public class GuestDocIdDTOValidator : ValueValidator { public GuestDocIdDTOValidator(IDataListService dataListService) { @@ -34,11 +34,4 @@ public class GuestDocIdDTOValidator : AbstractValidator .WithMessage("Invalid NIE") .When(x => x.DocumentType == GuestConsts.DocumentType_NIE); } - - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GuestDocIdDTO)model, x => - x.IncludeProperties(propertyName))); - return result.IsValid ? [] : result.Errors.Select(e => e.ErrorMessage); - }; } diff --git a/src/Somnia.GuestLog/Validators/GuestDocumentDTOValidator.cs b/src/Somnia.GuestLog/Validators/GuestDocumentDTOValidator.cs index a04a1d4..a9491aa 100644 --- a/src/Somnia.GuestLog/Validators/GuestDocumentDTOValidator.cs +++ b/src/Somnia.GuestLog/Validators/GuestDocumentDTOValidator.cs @@ -8,7 +8,7 @@ namespace Somnia.GuestLog.Validators; /// /// Validator for GuestDocumentDTO which contains multiple rules and can be shared with the back end API /// -public class GuestDocumentDTOValidator : AbstractValidator +public class GuestDocumentDTOValidator : ValueValidator { public GuestDocumentDTOValidator(IDataListService dataListService) { @@ -82,11 +82,4 @@ public class GuestDocumentDTOValidator : AbstractValidator // RuleForEach(x => x.OrderDetails) // .SetValidator(new OrderDetailsModelFluentValidator()); } - - public Func>> ValidateValue => async (model, propertyName) => - { - var result = await ValidateAsync(ValidationContext.CreateWithOptions((GuestDocumentDTO)model, x => - x.IncludeProperties(propertyName))); - return result.IsValid ? [] : result.Errors.Select(e => e.ErrorMessage); - }; }