Enhance MeetingSchedule and MeetingHistoryDetailDialog with load into planner functionality
This commit adds a new feature to the MeetingSchedule and MeetingHistoryDetailDialog components, allowing users to load meeting details into the planner. The LoadMeetingIntoPlanner method is implemented in both components, which retrieves team and student data, calculates absent students, and saves the state to localStorage before navigating to the planner. Additionally, a confirmation dialog is introduced in the SaveMeetingHistoryDialog to handle overwriting existing meeting histories, improving user experience and data management in the meeting scheduling feature.
This commit is contained in:
@@ -9,6 +9,9 @@
|
||||
@inject IDialogService DialogService
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IConfiguration Configuration
|
||||
@inject IMeetingScheduleDataService DataService
|
||||
@inject IMeetingScheduleStateService StateService
|
||||
@inject NavigationManager NavigationManager
|
||||
@implements IAsyncDisposable
|
||||
|
||||
<PageHeader Title="Team Meeting Schedule History">
|
||||
@@ -40,6 +43,7 @@
|
||||
Breakpoint="Breakpoint.Sm">
|
||||
<ColGroup>
|
||||
<col style="width: 100px;" />
|
||||
<col style="width: 50px;" />
|
||||
@foreach (var team in _allTeams)
|
||||
{
|
||||
<col style="width: 40px;" />
|
||||
@@ -51,6 +55,9 @@
|
||||
Date
|
||||
</MudText>
|
||||
</MudTh>
|
||||
<MudTh Style="padding: 4px 8px; border-right: 2px solid var(--mud-palette-divider);">
|
||||
<MudText Typo="Typo.caption">Actions</MudText>
|
||||
</MudTh>
|
||||
@{
|
||||
var teamIndex = 0;
|
||||
}
|
||||
@@ -77,6 +84,15 @@
|
||||
@context.MeetingDate.ToString("MM/dd/yy")
|
||||
</MudButton>
|
||||
</MudTd>
|
||||
<MudTd Style="padding: 4px 8px; border-right: 2px solid var(--mud-palette-divider);">
|
||||
<MudTooltip Text="Load into Planner">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Upload"
|
||||
Size="Size.Small"
|
||||
Color="Color.Secondary"
|
||||
OnClick="@(() => LoadMeetingIntoPlanner(context))"
|
||||
Variant="Variant.Text" />
|
||||
</MudTooltip>
|
||||
</MudTd>
|
||||
@{
|
||||
var rowTeamIndex = 0;
|
||||
}
|
||||
@@ -99,6 +115,7 @@
|
||||
<MudTd Style="padding: 4px 8px; border-right: 2px solid var(--mud-palette-divider); font-weight: bold;">
|
||||
Times Met
|
||||
</MudTd>
|
||||
<MudTd Style="padding: 4px 8px; border-right: 2px solid var(--mud-palette-divider);"></MudTd>
|
||||
@{
|
||||
var footerTeamIndex = 0;
|
||||
}
|
||||
@@ -268,6 +285,56 @@
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadMeetingIntoPlanner(TeamMeetingHistory history)
|
||||
{
|
||||
if (_isDisposed) return;
|
||||
|
||||
try
|
||||
{
|
||||
// Get all teams and students from database
|
||||
var allTeams = await DataService.LoadTeamsAsync();
|
||||
var allStudents = await DataService.LoadStudentsAsync();
|
||||
|
||||
// Match teams from history to all teams by ID for reference equality
|
||||
var historyTeamIds = history.Teams.Select(t => t.Id).ToHashSet();
|
||||
var scheduledTeams = allTeams.Where(t => historyTeamIds.Contains(t.Id));
|
||||
|
||||
// Calculate absent students (all students not in the meeting history's student list)
|
||||
var presentStudentIds = history.Students.Select(s => s.Id).ToHashSet();
|
||||
var absentStudents = allStudents.Where(s => !presentStudentIds.Contains(s.Id));
|
||||
|
||||
// Save state to localStorage
|
||||
await StateService.SaveScheduledTeamsAsync(scheduledTeams);
|
||||
await StateService.SaveAbsentStudentsAsync(absentStudents);
|
||||
// Clear extended teams and excluded students when loading from history
|
||||
await StateService.SaveExtendedTeamsAsync([]);
|
||||
await StateService.SaveExcludedStudentsAsync(new Dictionary<(int teamId, int timeSlotIndex, int studentId), bool>());
|
||||
|
||||
// Navigate to planner
|
||||
NavigationManager.NavigateTo("/meeting-schedule");
|
||||
|
||||
if (!_isDisposed)
|
||||
{
|
||||
Snackbar.Add($"Loaded meeting from {history.MeetingDate:MM/dd/yyyy} into planner", Severity.Success);
|
||||
}
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
// Component was disposed, ignore
|
||||
}
|
||||
catch (JSDisconnectedException)
|
||||
{
|
||||
// JS connection lost, ignore
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
Snackbar.Add($"Error loading meeting into planner: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
if (!_isDisposed)
|
||||
|
||||
Reference in New Issue
Block a user