SHA256
GuestLog - GuestDocument detail view and creation improvements.
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
@attribute [Route($"{GuestConsts.Page_GuestDocs_List}")]
|
||||
|
||||
@using Microsoft.EntityFrameworkCore;
|
||||
@using Somnia.GuestLog.Models.Entities;
|
||||
@using Somnia.GuestLog.Infrastructure;
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
|
||||
@inject IDbContextFactory<GuestLogContext> contextFactory
|
||||
@inject IGuestDocumentService GuestDocService
|
||||
@inject NavigationManager Navigation
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IDialogService DialogService
|
||||
|
||||
|
||||
<PageTitle>Somnia - Guest Docs</PageTitle>
|
||||
|
||||
@@ -28,10 +29,10 @@
|
||||
}
|
||||
</MudSelect>
|
||||
|
||||
<MudDataGrid @ref="_dataGrid" T="GuestDocument" Items="@guestDocList" Loading="@_dataLoading" ReadOnly="true"
|
||||
<MudDataGrid @ref="_dataGrid" T="GuestDocumentDTO" Items="@guestDocList" Loading="@_dataLoading" ReadOnly="true"
|
||||
Hideable="true" ColumnsPanelReordering="true">
|
||||
<ToolBarContent>
|
||||
<MudText Typo="Typo.subtitle1">Documents List</MudText>
|
||||
<MudText Typo="Typo.subtitle1">Document List</MudText>
|
||||
<MudStack Class="ml-auto" Row="true" AlignItems="AlignItems.End">
|
||||
<MudButton StartIcon="@Icons.Material.Outlined.Refresh" Variant="Variant.Outlined" Size="Size.Small"
|
||||
OnClick="() => LoadDataAsync()">
|
||||
@@ -63,13 +64,13 @@
|
||||
|
||||
|
||||
@code {
|
||||
private IEnumerable<GuestDocument> guestDocList = [];
|
||||
private IEnumerable<GuestDocumentDTO> guestDocList = [];
|
||||
|
||||
private bool _dataLoading = true;
|
||||
private HashSet<string> _moduleList = [];
|
||||
private HashSet<string> _selectedModuleList = [];
|
||||
|
||||
private MudDataGrid<GuestDocument>? _dataGrid;
|
||||
private MudDataGrid<GuestDocumentDTO>? _dataGrid;
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -84,18 +85,8 @@
|
||||
private async Task LoadDataAsync(bool showMsg = true)
|
||||
{
|
||||
_dataLoading = true;
|
||||
using var dbContext = await contextFactory.CreateDbContextAsync();
|
||||
|
||||
IQueryable<GuestDocument> query = dbContext.GuestDocuments.AsQueryable();
|
||||
|
||||
@* if (_selectedModuleList.Count > 0)
|
||||
{
|
||||
query = query.Where(c => _selectedModuleList.Contains(c.Module));
|
||||
} *@
|
||||
|
||||
guestDocList = await query
|
||||
.OrderByDescending(e => e.UpdateTime)
|
||||
.ToListAsync();
|
||||
guestDocList = await GuestDocService.GetDtoListAsync();
|
||||
|
||||
if (showMsg)
|
||||
{
|
||||
@@ -125,10 +116,18 @@
|
||||
_dataGrid.ShowColumnsPanel(args);
|
||||
}
|
||||
|
||||
private Task BtnViewDetails(GuestDocument item)
|
||||
private async Task BtnViewDetails(GuestDocumentDTO item)
|
||||
{
|
||||
Snackbar.Add($"Show details of {item.DocumentNum}", Severity.Info);
|
||||
return Task.CompletedTask;
|
||||
var parameters =
|
||||
new DialogParameters<GuestDocDetailsDialog> { { x => x.DocumentDTO, item } };
|
||||
var options = new DialogOptions()
|
||||
{
|
||||
FullScreen = true,
|
||||
CloseButton = true,
|
||||
CloseOnEscapeKey = true,
|
||||
};
|
||||
|
||||
await DialogService.ShowAsync<GuestDocDetailsDialog>("GuestDoc Details", parameters, options);
|
||||
}
|
||||
|
||||
private void BtnNewGuest()
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
@inject IDbContextFactory<GuestLogContext> contextFactory
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IDialogService DialogService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IGuestDocumentService guestDocService
|
||||
|
||||
@@ -53,13 +54,18 @@
|
||||
|
||||
Snackbar.Add($"Document '{model.DocumentNum}' creating...", Severity.Info);
|
||||
|
||||
//Show Loading dialog...
|
||||
var loadingDialog = await DialogService.ShowAsync<LoadingDialog>();
|
||||
|
||||
bool isCreated = await guestDocService.CreateDocumentAsync(model);
|
||||
if (!isCreated)
|
||||
{
|
||||
Snackbar.Add($"Error creating Document '{model.DocumentNum}'", Severity.Error);
|
||||
loadingDialog.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
Snackbar.Add($"Document '{model.DocumentNum}' Created!", Severity.Success);
|
||||
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user