WIP: Record history
This commit is contained in:
@@ -72,6 +72,9 @@
|
||||
|
||||
<MudDivider Class="my-4"/>
|
||||
|
||||
<MudTabs Elevation="0" Rounded="true" ApplyEffectsToContainer="true" PanelClass="pt-4">
|
||||
<MudTabPanel Text="Details" Icon="@Icons.Material.Filled.TableChart">
|
||||
|
||||
<MudTable Items="@records"
|
||||
Dense="true"
|
||||
Striped="true"
|
||||
@@ -218,6 +221,133 @@
|
||||
</MudButton>
|
||||
}
|
||||
}
|
||||
</MudTabPanel>
|
||||
|
||||
<MudTabPanel Text="History" Icon="@Icons.Material.Filled.History">
|
||||
@if (isLoadingHistory)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
|
||||
}
|
||||
else if (selectedRecordForHistory != null || selectedDeletedRecordForHistory != null)
|
||||
{
|
||||
<MudPaper Class="pa-4 mb-4" Outlined="true">
|
||||
<MudText Typo="Typo.h6">
|
||||
History for Record:
|
||||
@if (selectedDeletedRecordForHistory != null)
|
||||
{
|
||||
<MudText Typo="Typo.h6" Inline="true" Color="Color.Error">@selectedDeletedRecordForHistory.Code (Deleted)</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
@selectedRecordForHistory?.Code
|
||||
}
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Text"
|
||||
Color="Color.Primary"
|
||||
OnClick="ClearHistorySelection"
|
||||
StartIcon="@Icons.Material.Filled.ArrowBack"
|
||||
Size="Size.Small">
|
||||
Back to list
|
||||
</MudButton>
|
||||
</MudPaper>
|
||||
|
||||
@if (!recordHistory.Any())
|
||||
{
|
||||
<MudAlert Severity="Severity.Info">No history available for this record.</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTimeline TimelineOrientation="TimelineOrientation.Vertical" TimelinePosition="TimelinePosition.Start">
|
||||
@foreach (var history in recordHistory)
|
||||
{
|
||||
<MudTimelineItem Color="@GetHistoryColor(history.ChangeType)" Size="Size.Small">
|
||||
<ItemOpposite>
|
||||
<MudText Color="Color.Default" Typo="Typo.body2">
|
||||
@history.ChangedAt.ToString("g")
|
||||
</MudText>
|
||||
</ItemOpposite>
|
||||
<ItemContent>
|
||||
<MudPaper Elevation="3" Class="pa-3">
|
||||
<MudText Typo="Typo.body1">
|
||||
<strong>@history.ChangeType</strong> by @history.ChangedByName
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mt-2">
|
||||
@history.FormattedChange
|
||||
</MudText>
|
||||
</MudPaper>
|
||||
</ItemContent>
|
||||
</MudTimelineItem>
|
||||
}
|
||||
</MudTimeline>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.h6" Class="mb-3">Active Records</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mb-2">Select a record to view its history:</MudText>
|
||||
|
||||
<MudTable Items="@records"
|
||||
Dense="true"
|
||||
Striped="true"
|
||||
Hover="true"
|
||||
FixedHeader="true"
|
||||
Height="300px"
|
||||
OnRowClick="@((TableRowClickEventArgs<RecordDto> args) => OnRecordClickForHistory(args))"
|
||||
T="RecordDto"
|
||||
Style="cursor: pointer;">
|
||||
<HeaderContent>
|
||||
<MudTh>Code</MudTh>
|
||||
<MudTh>Description</MudTh>
|
||||
<MudTh>Modified</MudTh>
|
||||
<MudTh>Modified By</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Code">@context.Code</MudTd>
|
||||
<MudTd DataLabel="Description">@context.Desc1</MudTd>
|
||||
<MudTd DataLabel="Modified">@context.ModifiedAt.ToString("g")</MudTd>
|
||||
<MudTd DataLabel="Modified By">@GetModifiedByUsername(context.ModifiedById)</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
|
||||
<MudDivider Class="my-4"/>
|
||||
|
||||
<MudText Typo="Typo.h6" Class="mb-3">Deleted Records</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mb-2">Select a deleted record to view its history:</MudText>
|
||||
|
||||
@if (deletedRecords.Any())
|
||||
{
|
||||
<MudTable Items="@deletedRecords"
|
||||
Dense="true"
|
||||
Striped="true"
|
||||
Hover="true"
|
||||
FixedHeader="true"
|
||||
Height="200px"
|
||||
OnRowClick="@((TableRowClickEventArgs<DeletedRecordDto> args) => OnDeletedRecordClickForHistory(args))"
|
||||
T="DeletedRecordDto"
|
||||
Style="cursor: pointer;">
|
||||
<HeaderContent>
|
||||
<MudTh>Code</MudTh>
|
||||
<MudTh>Description</MudTh>
|
||||
<MudTh>Deleted</MudTh>
|
||||
<MudTh>Deleted By</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Code">
|
||||
<MudText Color="Color.Error">@context.Code</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Description">@context.Desc1</MudTd>
|
||||
<MudTd DataLabel="Deleted">@context.DeletedAt.ToString("g")</MudTd>
|
||||
<MudTd DataLabel="Deleted By">@context.DeletedByName</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Dense="true">No deleted records found.</MudAlert>
|
||||
}
|
||||
}
|
||||
</MudTabPanel>
|
||||
</MudTabs>
|
||||
}
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
|
||||
Reference in New Issue
Block a user