SHA256
StayExportTracking - Edit StayEntry UploadStatus
- Page Details - Added UI to edit UploadStatus. - Page List - Filter by UploadStatus.
This commit is contained in:
1 parent
2f0062b313
commit
7b86b2224f
9 files changed
+237
-29
No files matched your search
@@ -0,0 +1,12 @@
|
||||
<MudText Typo="@TextTypo" Align="Align.Center">
|
||||
@Title
|
||||
</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||
|
||||
@code {
|
||||
[Parameter, EditorRequired]
|
||||
public string Title { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public Typo TextTypo { get; set; } = Typo.subtitle1;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
@using Somnia.GuestLog.Enums.Models
|
||||
@using Somnia.GuestLog.Models.DTOs
|
||||
@using Somnia.GuestLog.Services
|
||||
|
||||
@inject ILocalizerService Localizer;
|
||||
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
@LanguageLocale.control_UploadStatusSelectorDialog_dialogTitle
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField Value="@Localizer.GetEnumValue(CurrentStatus)"
|
||||
Label="@LanguageLocale.control_UploadStatusSelectorDialog_lbCurrentStatus" FullWidth ReadOnly="true" />
|
||||
<MudSelect @bind-Value="selectedStatus"
|
||||
Label="@LanguageLocale.control_UploadStatusSelectorDialog_lbSelectStatus" FullWidth Clearable Required
|
||||
Error="selectErrorText != null" ErrorText="@selectErrorText">
|
||||
@foreach (UploadStatus option in Enum.GetValues<UploadStatus>())
|
||||
{
|
||||
<MudSelectItem Value="new Nullable<UploadStatus>(option)">
|
||||
@Localizer.GetEnumValue(option)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">
|
||||
@LanguageLocale.general_btnCancel
|
||||
</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Submit">
|
||||
@LanguageLocale.general_btnSave
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public UploadStatus CurrentStatus { get; set; } = new();
|
||||
|
||||
private UploadStatus? selectedStatus = null;
|
||||
|
||||
private string? selectErrorText = null;
|
||||
|
||||
private void Cancel() => MudDialog.Cancel();
|
||||
|
||||
private void Submit()
|
||||
{
|
||||
if (selectedStatus == null || selectedStatus == CurrentStatus)
|
||||
{
|
||||
selectErrorText = LanguageLocale.general_validation_invalidOption;
|
||||
return;
|
||||
}
|
||||
|
||||
//Clear errors.
|
||||
selectErrorText = null;
|
||||
|
||||
DialogResult dialogResult = DialogResult.Ok<UploadStatus>(selectedStatus.Value);
|
||||
MudDialog.Close(dialogResult);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
@using System.ComponentModel
|
||||
@using Somnia.GuestLog.Enums.Models
|
||||
@using Somnia.GuestLog.Models.DTOs
|
||||
@using Somnia.GuestLog.Services
|
||||
|
||||
@inject IDataListService dataListService;
|
||||
@inject ILocalizerService Localizer;
|
||||
|
||||
<MudForm Model="@Filter" IsTouchedChanged="@(() => FilterChanged.InvokeAsync(Filter))">
|
||||
<MudStack Row Breakpoint="Breakpoint.LgAndDown" StretchItems="StretchItems.All">
|
||||
@@ -26,6 +28,15 @@
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
<MudSelect @bind-Value="Filter.StayUploadStatus" Label="@LanguageLocale.dto_StayEntry_StayUploadStatus"
|
||||
FullWidth Clearable>
|
||||
@foreach (UploadStatus option in Enum.GetValues<UploadStatus>())
|
||||
{
|
||||
<MudSelectItem Value="new Nullable<UploadStatus>(option)">
|
||||
@Localizer.GetEnumValue(option)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudForm>
|
||||
|
||||
@@ -7,18 +7,16 @@
|
||||
@inject IDataListService dataListService;
|
||||
@inject IValidator<StayEntryDTO> stayValidator;
|
||||
@inject IDialogService dialogService;
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IUserMessageService userMessage;
|
||||
@inject ILocalizerService Localizer;
|
||||
|
||||
|
||||
<MudForm @ref="@_form" Model="@Model" Validation="@((stayValidator as StayEntryDTOValidator)!.ValidateValue)"
|
||||
ReadOnly="@ReadOnly">
|
||||
<MudGrid>
|
||||
<MudItem xs="12" xl=6>
|
||||
<MudItem xs="12" sm="@stayDetailPanelSize">
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">
|
||||
@LanguageLocale.control_StayEntryForm_sectionDetails
|
||||
</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||
<SectionTitle Title="@LanguageLocale.control_StayEntryForm_sectionDetails" />
|
||||
|
||||
<MudStack Row style="@FieldMarginY">
|
||||
<MudDatePicker Date="Model.DateIn" For="@(() => Model.DateIn)"
|
||||
@@ -52,12 +50,25 @@
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" xl=6>
|
||||
@if (FormMode == FormMode.ReadOnly)
|
||||
{
|
||||
<MudItem xs="12" sm="3">
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||
<SectionTitle Title="@LanguageLocale.control_StayEntryForm_sectionUploadStatus" />
|
||||
|
||||
<MudTextField Value="@Localizer.GetEnumValue(Model.StayUploadStatus)"
|
||||
Label="@LanguageLocale.dto_StayEntry_StayUploadStatus" FullWidth ReadOnly />
|
||||
@if (Model.StayUploadStatusTime != null)
|
||||
{
|
||||
<MudTextField @bind-Value="Model.StayUploadStatusTime" For="@(() => Model.StayUploadStatusTime)"
|
||||
Label="@LanguageLocale.dto_StayEntry_StayUploadStatusTime" FullWidth ReadOnly />
|
||||
}
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
}
|
||||
<MudItem xs="12" xl="12">
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%" Width="100%">
|
||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">
|
||||
@LanguageLocale.control_StayEntryForm_sectionGuests
|
||||
</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||
<SectionTitle Title="@LanguageLocale.control_StayEntryForm_sectionGuests" />
|
||||
|
||||
@if (!ReadOnly)
|
||||
{
|
||||
@@ -124,6 +135,7 @@
|
||||
|
||||
|
||||
private bool ReadOnly => FormMode == FormMode.ReadOnly;
|
||||
private int stayDetailPanelSize => FormMode == FormMode.ReadOnly ? 9 : 12;
|
||||
|
||||
|
||||
private MudForm _form = null!;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@attribute [Route($"{GuestConsts.Page_StayEntry_Detail}")]
|
||||
|
||||
@using Somnia.GuestLog.Enums.Models
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
|
||||
@@ -8,12 +9,15 @@
|
||||
@inject NavigationManager Navigation
|
||||
@inject IGuestDocumentEntityService guestDocService
|
||||
@inject IStayEntryEntityService stayService
|
||||
@inject ILocalizerService Localizer;
|
||||
|
||||
|
||||
<PageTitle>Somnia - Guest Docs - Details</PageTitle>
|
||||
<PageTitle>Somnia - Stays - Details</PageTitle>
|
||||
|
||||
<MudStack Row="true" Class="my-4">
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">Stay Entry - "@StayId"</MudText>
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">
|
||||
@LanguageLocale.page_StayEntryDetail_pageTitle - "@StayId"
|
||||
</MudText>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Edit"
|
||||
OnClick="() => BtnEdit()" Disabled>
|
||||
@@ -28,7 +32,27 @@
|
||||
@if (stayModel is not null)
|
||||
{
|
||||
<StayEntryForm Model="stayModel" FormMode="FormMode.ReadOnly" />
|
||||
<MudText Class="mt-4">@CreateTimeString</MudText>
|
||||
|
||||
<MudGrid Class="mt-6">
|
||||
<MudItem xs="6" md="3">
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||
<MudStack Style="margin-block: 0.5em;">
|
||||
<MudTextField @bind-Value="stayModel.CreateTime" Label="@LanguageLocale.dto_StayEntry_CreateTime"
|
||||
FullWidth ReadOnly />
|
||||
<MudTextField @bind-Value="stayModel.UpdateTime" Label="@LanguageLocale.dto_StayEntry_UpdateTime"
|
||||
FullWidth ReadOnly />
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="6" md="3">
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||
<SectionTitle Title="Actions" />
|
||||
<MudButton FullWidth OnClick="BtnUpdateUploadStatus">
|
||||
@LanguageLocale.page_StayEntryList_btnUpdateUploadStatus
|
||||
</MudButton>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
}
|
||||
|
||||
|
||||
@@ -42,21 +66,6 @@
|
||||
|
||||
StayEntryDTO? stayModel = null;
|
||||
|
||||
private string? CreateTimeString
|
||||
{
|
||||
get
|
||||
{
|
||||
if (stayModel is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<string> textList = [];
|
||||
textList.Add($"Created at: {stayModel.CreateTime?.ToString() ?? "???"}");
|
||||
textList.Add($"Last Update Time: {stayModel.UpdateTime?.ToString() ?? "???"}");
|
||||
return string.Join("; ", textList);
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -67,6 +76,11 @@
|
||||
return;
|
||||
} *@
|
||||
|
||||
await LoadModelAsync();
|
||||
}
|
||||
|
||||
private async Task LoadModelAsync()
|
||||
{
|
||||
//Get model from db.
|
||||
stayModel = await stayService.GetDtoByIdAsync(StayId, queryConfig: new(IncludeGuests: true));
|
||||
if (stayModel is null)
|
||||
@@ -77,6 +91,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void BtnEdit()
|
||||
{
|
||||
userMessage.ShowMessage("Not implemented yet!", MessageKind.Info);
|
||||
@@ -88,4 +105,68 @@
|
||||
Navigation.NavigateTo(uri);
|
||||
}
|
||||
|
||||
private async Task BtnUpdateUploadStatus()
|
||||
{
|
||||
Debug.Assert(stayModel != null && stayModel.Id != null);
|
||||
|
||||
DialogOptions dialogOptions = new()
|
||||
{
|
||||
MaxWidth = MaxWidth.Medium,
|
||||
FullWidth = true,
|
||||
BackdropClick = true,
|
||||
CloseOnEscapeKey = true,
|
||||
};
|
||||
|
||||
bool? confirmed = await DialogService.ShowMessageBoxAsync(
|
||||
title: LanguageLocale.general_confirmTitle,
|
||||
message: LanguageLocale.general_confirmAdvanceOperationMsg,
|
||||
yesText: LanguageLocale.general_btnContinue,
|
||||
noText: LanguageLocale.general_btnCancel,
|
||||
options: dialogOptions);
|
||||
|
||||
if (confirmed == null || confirmed.Value == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var parameters =
|
||||
new DialogParameters<UploadStatusSelectorDialog> { { x => x.CurrentStatus, stayModel.StayUploadStatus } };
|
||||
var dialog = await DialogService.ShowAsync<UploadStatusSelectorDialog>(parameters: parameters, options: dialogOptions);
|
||||
DialogResult? dialogRs = await dialog.Result;
|
||||
|
||||
if (dialogRs is null || dialogRs.Canceled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UploadStatus? newUploadStatus = await dialog.GetReturnValueAsync<UploadStatus>();
|
||||
|
||||
if (newUploadStatus is null)
|
||||
{
|
||||
userMessage.ShowMessage("Error! No upload status selected!", MessageKind.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var loadingDialog = await DialogService.ShowAsync<LoadingDialog>();
|
||||
|
||||
//Update StayEntry
|
||||
Result rs = await stayService.UpdateEntryUploadStatusAsync(stayModel.Id.Value, newUploadStatus.Value);
|
||||
if (!rs.IsSuccess)
|
||||
{
|
||||
userMessage.ShowResultWithMessage(rs, "Error updating UploadStatus");
|
||||
loadingDialog.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
//Reload model.
|
||||
await LoadModelAsync();
|
||||
loadingDialog.Close();
|
||||
|
||||
string txtNewStatus = Localizer.GetEnumValue(newUploadStatus);
|
||||
string successMsg = string.Format(LanguageLocale.page_StayEntryDetail_uploadStatusSuccessMsg, txtNewStatus);
|
||||
userMessage.ShowMessage(successMsg, MessageKind.Success);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user