SHA256
GuestLog - StayEntry detail view and improvements:
- Added detail view for StayEntries. - Added button to delete StayEntries. - Improve queries of StayEntries using a "query config" record. - Enabled LazyLoading for all database relations. This will make easier to find cases where required relations aren't explicitly loaded.
This commit is contained in:
@@ -69,17 +69,7 @@
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
|
||||
<MudMessageBox @ref="_msgBoxConfirmDelete" Title="@LanguageLocale.general_confirmTitle"
|
||||
CancelText="@LanguageLocale.general_btnCancel">
|
||||
<MessageContent>
|
||||
@LanguageLocale.general_confirmDeleteMsg
|
||||
</MessageContent>
|
||||
<YesButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.DeleteForever">
|
||||
@LanguageLocale.general_btnDelete
|
||||
</MudButton>
|
||||
</YesButton>
|
||||
</MudMessageBox>
|
||||
<ConfirmDeleteMsgBox @ref="_msgBoxConfirmDelete" />
|
||||
|
||||
|
||||
@code {
|
||||
@@ -92,7 +82,7 @@
|
||||
private GuestDocFilterDTO docFilter = new GuestDocFilterDTO();
|
||||
|
||||
private MudDataGrid<GuestDocumentDTO> _dataGrid = null!;
|
||||
private MudMessageBox _msgBoxConfirmDelete = null!;
|
||||
private ConfirmDeleteMsgBox _msgBoxConfirmDelete = null!;
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -145,7 +135,7 @@
|
||||
|
||||
private async Task BtnDeleteItem(GuestDocumentDTO item)
|
||||
{
|
||||
bool? confirmDelete = await _msgBoxConfirmDelete.ShowAsync();
|
||||
bool? confirmDelete = await _msgBoxConfirmDelete.MsgBox.ShowAsync();
|
||||
|
||||
if (confirmDelete is null || confirmDelete.Value == false)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
@attribute [Route($"{GuestConsts.Page_StayEntry_Detail}")]
|
||||
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IDialogService DialogService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IGuestDocumentService guestDocService
|
||||
@inject IStayEntryService stayService
|
||||
|
||||
|
||||
<PageTitle>Somnia - Guest Docs - Details</PageTitle>
|
||||
|
||||
<MudStack Row="true" Class="my-4">
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">Stay Entry - "@StayId"</MudText>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Edit"
|
||||
OnClick="() => BtnEdit()" Disabled>
|
||||
@LanguageLocale.general_btnEdit
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="() => BtnReturn()">
|
||||
@LanguageLocale.general_btnReturn
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
@if (stayModel is not null)
|
||||
{
|
||||
<StayEntryForm Model="stayModel" ReadOnly="true" />
|
||||
}
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public long StayId { get; set; }
|
||||
|
||||
StayEntryDTO? stayModel = null;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@* if (StayId is default)
|
||||
{
|
||||
Snackbar.Add("No Id provided!!", Severity.Error);
|
||||
Navigation.NotFound();
|
||||
return;
|
||||
} *@
|
||||
|
||||
//Get model from db.
|
||||
stayModel = await stayService.GetDtoByIdAsync(StayId, queryConfig: new(IncludeGuests: true));
|
||||
if (stayModel is null)
|
||||
{
|
||||
Snackbar.Add($"Stay not found with ID: '{StayId}'", Severity.Error);
|
||||
Navigation.NotFound();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnEdit()
|
||||
{
|
||||
Snackbar.Add("Not implemented yet!", Severity.Info);
|
||||
}
|
||||
|
||||
private void BtnReturn()
|
||||
{
|
||||
Navigation.NavigateTo(GuestConsts.Page_StayEntry_List);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
<PropertyColumn Property="x => x.UpdateTime" Title="@LanguageLocale.dto_GuestDocument_UpdateTime" />
|
||||
|
||||
@* <TemplateColumn CellClass="d-flex justify-between" Title="Options" StickyRight Hideable="false"
|
||||
<TemplateColumn CellClass="d-flex justify-between" Title="Options" StickyRight Hideable="false"
|
||||
ShowColumnOptions="false">
|
||||
<CellTemplate>
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Info"
|
||||
@@ -51,13 +51,15 @@
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Delete"
|
||||
OnClick="() => BtnDeleteItem(context.Item)" />
|
||||
</CellTemplate>
|
||||
</TemplateColumn> *@
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="StayEntryDTO" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
|
||||
<ConfirmDeleteMsgBox @ref="_confirmDeleteMsgBox" />
|
||||
|
||||
@code {
|
||||
|
||||
private bool _dataLoading = true;
|
||||
@@ -67,6 +69,7 @@
|
||||
private IEnumerable<StayEntryDTO> stayEntryList = [];
|
||||
|
||||
private MudDataGrid<StayEntryDTO> _dataGrid = null!;
|
||||
private ConfirmDeleteMsgBox _confirmDeleteMsgBox = null!;
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -102,6 +105,34 @@
|
||||
Navigation.NavigateTo(GuestConsts.Page_StayEntry_New);
|
||||
}
|
||||
|
||||
|
||||
private async Task BtnViewDetails(StayEntryDTO item)
|
||||
{
|
||||
string itemId = $"{item.Id ?? -1}";
|
||||
string uri = GuestConsts.Page_StayEntry_Detail.Replace(GuestConsts.Page_StayEntry_Detail_Param_Id, itemId);
|
||||
Navigation.NavigateTo(uri);
|
||||
}
|
||||
|
||||
private async Task BtnDeleteItem(StayEntryDTO item)
|
||||
{
|
||||
bool? confirmDelete = await _confirmDeleteMsgBox.MsgBox.ShowAsync();
|
||||
|
||||
if (confirmDelete is null || confirmDelete.Value == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool deleted = await StayEntryService.DeleteEntryAsync(item);
|
||||
if (!deleted)
|
||||
{
|
||||
Snackbar.Add($"Error deleting Stay {item.Id}", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
Snackbar.Add($"Stay {item.Id} deleted!", Severity.Success);
|
||||
await LoadDataAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user