Skip to content

Commit

Permalink
Adjustments during peer review
Browse files Browse the repository at this point in the history
  • Loading branch information
carlsixsmith-moj committed Sep 3, 2024
1 parent d45099b commit feca250
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 34 deletions.
6 changes: 4 additions & 2 deletions src/Application/Features/Documents/DTOs/DocumentDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class DocumentDto
{
[Description("Id")] public Guid? Id { get; set; }

[Description("Title")] public string? Title { get; set; }
[Description("File Name")] public string? Title { get; set; }

[Description("Description")] public string? Description { get; set; }

Expand All @@ -24,6 +24,7 @@ public class DocumentDto

[Description("Content")] public string? Content { get; set; }
[Description("Created By")] public string CreatedBy { get; set; } = string.Empty;
[Description("Created By Name")] public string CreatedByName { get; set; } = string.Empty;
[Description("Created Date")] public DateTime Created { get; set; }

[Description("Owner")] public ApplicationUserDto? Owner { get; set; }
Expand All @@ -33,7 +34,8 @@ private class Mapping : Profile
public Mapping()
{
CreateMap<Document, DocumentDto>(MemberList.None)
.ForMember(x => x.TenantName, s => s.MapFrom(y => y.Tenant!.Name));
.ForMember(x => x.TenantName, s => s.MapFrom(y => y.Tenant!.Name))
.ForMember(x => x.CreatedByName, s => s.MapFrom(y => y.Owner!.DisplayName));
CreateMap<DocumentDto, Document>(MemberList.None)
.ForMember(x => x.Tenant, s => s.Ignore())
.ForMember(x => x.Owner, s => s.Ignore());
Expand Down
54 changes: 34 additions & 20 deletions src/Server.UI/Pages/Participants/Components/CaseDocuments.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@using Cfo.Cats.Application.Features.Documents.Queries
@using Cfo.Cats.Application.SecurityConstants
@using System.Net.Http.Json
@using Humanizer

@inherits CatsComponentBase

Expand All @@ -20,39 +21,52 @@
height: 120px !important;
}
</style>
<MudLoading Loading="_loading" />
@if (_notFound)
{
<MudAlert>
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined" Square="true" Class="my-2">No documents yet.</MudAlert>
</MudAlert>
}
else
{
<MudDataGrid T="DocumentDto" FixedHeader="true"
<MudDataGrid T="DocumentDto" FixedHeader="true" Loading="_loading"
FixedFooter="true"
Virtualize="true"
Height="calc(100vh - 330px)"
Items="@_documents"
Hover="true">

<Columns>
<TemplateColumn CellStyle="width:60px" Title="@ConstantString.Actions" Sortable="false">
<CellTemplate>
<MudMenu Icon="@Icons.Material.Filled.Edit" Variant="Variant.Filled" Size="Size.Small"
Dense="true" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" IconColor="Color.Info" AnchorOrigin="Origin.CenterLeft">
<MudMenuItem OnClick="@(() => OpenDocumentDialog(context.Item))">@ConstantString.View</MudMenuItem>
</MudMenu>
</CellTemplate>
</TemplateColumn>
<PropertyColumn Property="x => x.Title" Title="@L[_currentDto.GetMemberDescription(x => x.Title)]" />
<PropertyColumn Property="x => x.Description" Title="@L[_currentDto.GetMemberDescription(x => x.Description)]" />
<PropertyColumn Property="x => x.Created" Title="@L[_currentDto.GetMemberDescription(x => x.Created)]" />
<PropertyColumn Property="x => UserService.DataSource.First(u => u.Id == x.CreatedBy).DisplayName" Title="@L[_currentDto.GetMemberDescription(x => x.CreatedBy)]" />
<TemplateColumn>
<PropertyColumn Property="x => x.CreatedBy" Title="@L[_currentDto.GetMemberDescription(x => x.CreatedBy)]">
<CellTemplate>
<MudButton Size="@Size.Small" StartIcon="@Icons.Material.Outlined.ViewColumn" OnClick="@(() => OpenDocumentDialog(context.Item))">Open</MudButton>
<div>
<MudText Typo="Typo.body2">@context.Item.CreatedByName</MudText>
<MudText Typo="Typo.body2">@context.Item.Created.Humanize()</MudText>
</div>
</CellTemplate>
</TemplateColumn>
</PropertyColumn>
<PropertyColumn Property="x => x.TenantId" Title="@L[_currentDto.GetMemberDescription(x => x.TenantName)]">
<CellTemplate>
<div>
<MudText Typo="Typo.body2">@context.Item.TenantName</MudText>
<MudText Typo="Typo.body2" Class="mud-text-secondary">@context.Item.TenantId</MudText>
</div>
</CellTemplate>
</PropertyColumn>
</Columns>
<NoRecordsContent>
<MudText>@ConstantString.NoRecords</MudText>
</NoRecordsContent>
<LoadingContent>
<MudText>@ConstantString.Loading</MudText>
</LoadingContent>
</MudDataGrid>
}


@code {
bool _loading = true;
bool _notFound = false;
private DocumentDto[] _documents = [];
private DocumentDto _currentDto = new() { Id = Guid.Empty };

Expand All @@ -76,7 +90,6 @@ else
{
ParticipantId = ParticipantId
});
_notFound = _documents.Count() == 0;
}
}finally{
_loading = false;
Expand All @@ -86,7 +99,7 @@ else
public async Task OpenDocumentDialog(DocumentDto item)
{
await DialogService.ShowAsync<ViewDocumentDialog>(
"View Document Dialog",
"Document",
new DialogParameters<ViewDocumentDialog>()
{
{ x => x.Model, item }
Expand All @@ -96,7 +109,8 @@ else
MaxWidth = MaxWidth.ExtraExtraLarge,
Position=DialogPosition.Center,
FullWidth = true,
CloseButton = true
CloseButton = true,
CloseOnEscapeKey = true,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
}
</style>

<MudDialog Style="height: 100%">
<DialogContent>
@if (Model is not null)
{
@if (fileBase64 != null && extension!.Equals("pdf", StringComparison.CurrentCultureIgnoreCase))
{
@if (Model is not null)
{
<MudDialog Style="height: 100%">
<TitleContent>
<MudText Typo="Typo.h6">
<MudIcon Icon="@Icons.Material.Filled.DocumentScanner" Class="mr-3" />
@Model.Title
</MudText>
</TitleContent>
<DialogContent>
@if (fileBase64 != null && extension!.Equals("pdf", StringComparison.CurrentCultureIgnoreCase))
{
<object data="data:application/pdf;base64,@fileBase64" type="application/pdf" class="full-size-object">
<p>PDF cannot be displayed.</p>
</object>
Expand All @@ -36,12 +42,14 @@
{
<MudLoading Loading="true" />
}
}
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">@ConstantString.Close</MudButton>
</DialogActions>
</MudDialog>
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">@ConstantString.Close</MudButton>
</DialogActions>
</MudDialog>
}



@code {
[CascadingParameter] private MudDialogInstance MudDialog { get; set; } = default!;
Expand Down

0 comments on commit feca250

Please sign in to comment.