Enhance MeetingHistoryDetailDialog and SaveMeetingHistoryDialog with navigation and editing features
This commit introduces navigation buttons for previous and next meeting histories in the MeetingHistoryDetailDialog, improving user experience by allowing easy access to related meetings. Additionally, the SaveMeetingHistoryDialog is updated to support editing existing meeting histories, with logic to load existing data and prevent duplicate entries for the same date. The integration of TeamToggleSelector and StudentToggleSelector components streamlines team and student selection, enhancing the overall functionality of the meeting history management feature.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
@inject INoteNamingService NoteNamingService
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IDialogService DialogService
|
||||
@inject IMeetingScheduleDataService DataService
|
||||
@implements IAsyncDisposable
|
||||
|
||||
<MudDialog>
|
||||
@@ -25,7 +26,28 @@
|
||||
else
|
||||
{
|
||||
<MudStack Spacing="3">
|
||||
<MudText Typo="Typo.h6">Meeting Details</MudText>
|
||||
@* Navigation Header *@
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center" Spacing="2">
|
||||
<MudTooltip Text="@(_previousMeetingHistory != null ? $"Previous: {_previousMeetingHistory.MeetingDate:MM/dd/yyyy}" : "No previous meeting")">
|
||||
<span>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.ChevronLeft"
|
||||
OnClick="NavigateToPrevious"
|
||||
Disabled="@(_previousMeetingHistory == null || IsActionDisabled)"
|
||||
Color="Color.Primary"
|
||||
Size="Size.Medium" />
|
||||
</span>
|
||||
</MudTooltip>
|
||||
<MudText Typo="Typo.h6" Class="flex-grow-1" Style="text-align: center;">@_meetingHistory.MeetingDate.ToString("MM/dd/yyyy")</MudText>
|
||||
<MudTooltip Text="@(_nextMeetingHistory != null ? $"Next: {_nextMeetingHistory.MeetingDate:MM/dd/yyyy}" : "No next meeting")">
|
||||
<span>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.ChevronRight"
|
||||
OnClick="NavigateToNext"
|
||||
Disabled="@(_nextMeetingHistory == null || IsActionDisabled)"
|
||||
Color="Color.Primary"
|
||||
Size="Size.Medium" />
|
||||
</span>
|
||||
</MudTooltip>
|
||||
</MudStack>
|
||||
|
||||
<MudPaper Elevation="1" Class="pa-3">
|
||||
<MudStack Spacing="2">
|
||||
@@ -106,6 +128,13 @@
|
||||
Delete
|
||||
</MudButton>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Text"
|
||||
Color="Color.Primary"
|
||||
OnClick="OpenEditDialog"
|
||||
Disabled="@IsActionDisabled"
|
||||
StartIcon="@Icons.Material.Filled.Edit">
|
||||
Edit
|
||||
</MudButton>
|
||||
<MudButton OnClick="Close" Disabled="@IsActionDisabled">Close</MudButton>
|
||||
}
|
||||
else
|
||||
@@ -127,9 +156,13 @@
|
||||
private Note? _meetingNote;
|
||||
private bool _isLoading = true;
|
||||
private bool _isDeleting = false;
|
||||
private Team[] _allTeams = [];
|
||||
private Student[] _allStudents = [];
|
||||
private CancellationTokenSource? _cancellationTokenSource;
|
||||
private bool _isDisposed = false;
|
||||
private bool IsActionDisabled => _isLoading || _isDeleting;
|
||||
private TeamMeetingHistory? _previousMeetingHistory;
|
||||
private TeamMeetingHistory? _nextMeetingHistory;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
@@ -138,6 +171,9 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
// Load all teams and students for the edit dialog
|
||||
_allTeams = await DataService.LoadTeamsAsync();
|
||||
_allStudents = await DataService.LoadStudentsAsync();
|
||||
await LoadMeetingHistory();
|
||||
}
|
||||
|
||||
@@ -153,6 +189,9 @@
|
||||
if (_meetingHistory != null)
|
||||
{
|
||||
_meetingNote = await TeamMeetingHistoryService.GetMeetingNoteAsync(_meetingHistory.MeetingDate);
|
||||
|
||||
// Load all meeting histories to find previous/next
|
||||
await LoadNavigationMeetings();
|
||||
}
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
@@ -180,6 +219,91 @@
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadNavigationMeetings()
|
||||
{
|
||||
if (_isDisposed || _meetingHistory == null) return;
|
||||
|
||||
try
|
||||
{
|
||||
// Get all meeting histories ordered by date
|
||||
var allMeetings = (await TeamMeetingHistoryService.GetMeetingHistoriesAsync())
|
||||
.OrderBy(m => m.MeetingDate)
|
||||
.ThenBy(m => m.Id)
|
||||
.ToList();
|
||||
|
||||
var currentIndex = allMeetings.FindIndex(m => m.Id == _meetingHistory.Id);
|
||||
|
||||
if (currentIndex >= 0)
|
||||
{
|
||||
_previousMeetingHistory = currentIndex > 0 ? allMeetings[currentIndex - 1] : null;
|
||||
_nextMeetingHistory = currentIndex < allMeetings.Count - 1 ? allMeetings[currentIndex + 1] : null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_previousMeetingHistory = null;
|
||||
_nextMeetingHistory = null;
|
||||
}
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
// Component was disposed, ignore
|
||||
}
|
||||
catch (JSDisconnectedException)
|
||||
{
|
||||
// JS connection lost, ignore
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
// Log error but don't show snackbar - navigation is not critical
|
||||
System.Diagnostics.Debug.WriteLine($"Error loading navigation meetings: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task NavigateToPrevious()
|
||||
{
|
||||
if (_previousMeetingHistory == null || _isDisposed) return;
|
||||
|
||||
// Close current dialog and open new one with previous meeting ID
|
||||
var parameters = new DialogParameters
|
||||
{
|
||||
["MeetingHistoryId"] = _previousMeetingHistory.Id
|
||||
};
|
||||
|
||||
var options = new DialogOptions
|
||||
{
|
||||
MaxWidth = MaxWidth.Medium,
|
||||
FullWidth = true,
|
||||
CloseButton = true
|
||||
};
|
||||
|
||||
MudDialog.Close();
|
||||
await DialogService.ShowAsync<MeetingHistoryDetailDialog>("Meeting History", parameters, options);
|
||||
}
|
||||
|
||||
private async Task NavigateToNext()
|
||||
{
|
||||
if (_nextMeetingHistory == null || _isDisposed) return;
|
||||
|
||||
// Close current dialog and open new one with next meeting ID
|
||||
var parameters = new DialogParameters
|
||||
{
|
||||
["MeetingHistoryId"] = _nextMeetingHistory.Id
|
||||
};
|
||||
|
||||
var options = new DialogOptions
|
||||
{
|
||||
MaxWidth = MaxWidth.Medium,
|
||||
FullWidth = true,
|
||||
CloseButton = true
|
||||
};
|
||||
|
||||
MudDialog.Close();
|
||||
await DialogService.ShowAsync<MeetingHistoryDetailDialog>("Meeting History", parameters, options);
|
||||
}
|
||||
|
||||
private async Task ConfirmDelete()
|
||||
{
|
||||
if (_isDisposed || _isDeleting || _meetingHistory == null) return;
|
||||
@@ -255,6 +379,36 @@
|
||||
await LoadMeetingHistory();
|
||||
}
|
||||
|
||||
private async Task OpenEditDialog()
|
||||
{
|
||||
if (_meetingHistory == null || _isDisposed) return;
|
||||
|
||||
var parameters = new DialogParameters
|
||||
{
|
||||
["MeetingHistoryId"] = _meetingHistory.Id,
|
||||
["AllTeams"] = _allTeams,
|
||||
["AllStudents"] = _allStudents,
|
||||
["ScheduledTeams"] = new List<Team>(), // Not used when editing
|
||||
["AbsentStudents"] = new List<Student>() // Not used when editing
|
||||
};
|
||||
|
||||
var options = new DialogOptions
|
||||
{
|
||||
MaxWidth = MaxWidth.Medium,
|
||||
FullWidth = true,
|
||||
CloseButton = true
|
||||
};
|
||||
|
||||
var dialog = await DialogService.ShowAsync<SaveMeetingHistoryDialog>("Edit Meeting History", parameters, options);
|
||||
var result = await dialog.Result;
|
||||
|
||||
// Refresh meeting history if dialog was saved
|
||||
if (!result.Canceled && !_isDisposed)
|
||||
{
|
||||
await LoadMeetingHistory();
|
||||
}
|
||||
}
|
||||
|
||||
private List<Student> GetAllStudentsFromTeams()
|
||||
{
|
||||
if (_meetingHistory == null)
|
||||
|
||||
Reference in New Issue
Block a user