@using Core.Entities
@using WebApp.Services
@using MudBlazor
@inject INotesService NotesService
@inject IDialogService DialogService
@if (_isLoading)
{
}
else if (!_history.Any())
{
No history available for this note.
}
else
{
Date/Time
User
Change Type
Title
Actions
@context.ModifiedAt.ToString("g")
@(context.ModifiedBy ?? "Unknown")
@context.ChangeType
@context.Title
View
}
Close
@code {
[CascadingParameter]
IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public int NoteId { get; set; }
private List _history = [];
private bool _isLoading = true;
protected override async Task OnInitializedAsync()
{
await LoadHistory();
}
private async Task LoadHistory()
{
try
{
_history = (await NotesService.GetNoteHistoryAsync(NoteId)).ToList();
}
catch (Exception ex)
{
// Error handling - could show snackbar if we had access
}
finally
{
_isLoading = false;
}
}
private Color GetChangeTypeColor(string changeType)
{
return changeType switch
{
"Created" => Color.Success,
"Updated" => Color.Info,
"Deleted" => Color.Error,
"Soft Deleted" => Color.Error,
"Restored" => Color.Success,
_ => Color.Default
};
}
private async Task ViewVersion(NoteHistory history)
{
var parameters = new DialogParameters
{
["History"] = history
};
var options = new DialogOptions
{
MaxWidth = MaxWidth.Medium,
FullWidth = true,
CloseButton = true
};
await DialogService.ShowAsync("View Version", parameters, options);
}
private void Close()
{
MudDialog.Close();
}
}