Files
chapter-organizer/WebApp/Components/Features/Teams/TeamMeetingHistoryDialog.razor
T
poprhythm 84eaf338a9 Enhance TeamMeetingHistoryDialog to display team members' attendance
This commit updates the TeamMeetingHistoryDialog component to show the attendance status of team members during meetings. It replaces the previous status display with a list of team members, indicating their presence or absence using MudBlazor chips. Additionally, the TeamMeetingHistoryService is modified to include student data for accurate attendance tracking. These changes improve the clarity and usability of the meeting history dialog, enhancing the overall user experience in managing team meetings.
2026-01-27 20:10:40 -05:00

152 lines
5.1 KiB
Plaintext

@namespace WebApp.Components.Features.Teams
@using Core.Entities
@using WebApp.Services
@using Microsoft.AspNetCore.Components
@using WebApp.Models
@using WebApp.Components.Shared.Components
@using Core.Utility
@inject ITeamMeetingHistoryService TeamMeetingHistoryService
@implements IAsyncDisposable
<MudDialog>
<TitleContent>
<MudText Typo="Typo.h6">@TeamName Meeting History</MudText>
</TitleContent>
<DialogContent>
@if (_isLoading)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-4" />
}
else if (!_meetingHistories.Any())
{
<MudAlert Severity="Severity.Info">No meeting history found for this team.</MudAlert>
}
else
{
<MudTable Items="_meetingHistories" Hover="true" Dense="true">
<HeaderContent>
<MudTh>Date</MudTh>
<MudTh>Team Members</MudTh>
</HeaderContent>
<RowTemplate>
@{
var team = context.Teams.FirstOrDefault(t => t.Id == TeamId);
var presentStudentIds = context.Students.Select(s => s.Id).ToHashSet();
var absentStudents = team?.Students.Where(s => !presentStudentIds.Contains(s.Id)).ToList() ?? [];
}
<MudTd>@context.MeetingDate.ToString("MM/dd/yyyy")</MudTd>
<MudTd>
@if (team != null)
{
<MudStack Row="true" Spacing="1" Wrap="Wrap.Wrap" AlignItems="AlignItems.Center">
@foreach (var student in team.Students)
{
var isAbsent = absentStudents.Contains(student);
var formattedName = TeamStudentNameFormatter.FormatStudentName(
student,
team,
new TeamStudentNameFormatter.FormatOptions
{
MarkAbsent = true,
AbsentStudents = absentStudents
});
<MudChip T="string"
Size="Size.Small"
Color="Color.Default"
Variant="@AppIcons.StudentChipVariant()"
Style="@(isAbsent ? "opacity: 0.5;" : "")">
<span>@formattedName</span>
</MudChip>
}
</MudStack>
}
</MudTd>
</RowTemplate>
</MudTable>
}
</DialogContent>
<DialogActions>
<MudSpacer />
<MudButton OnClick="Close">Close</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter]
IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter]
public int TeamId { get; set; }
[Parameter]
public string TeamName { get; set; } = string.Empty;
private List<TeamMeetingHistory> _meetingHistories = [];
private bool _isLoading = true;
private CancellationTokenSource? _cancellationTokenSource;
private bool _isDisposed = false;
protected override void OnInitialized()
{
_cancellationTokenSource = new CancellationTokenSource();
}
protected override async Task OnInitializedAsync()
{
await LoadMeetingHistories();
}
private async Task LoadMeetingHistories()
{
if (_isDisposed) return;
try
{
var cancellationToken = _cancellationTokenSource?.Token ?? CancellationToken.None;
var histories = await TeamMeetingHistoryService.GetMeetingHistoriesForTeamAsync(TeamId);
_meetingHistories = histories.ToList();
}
catch (TaskCanceledException)
{
// Component was disposed, ignore
}
catch (JSDisconnectedException)
{
// JS connection lost, ignore
}
catch (Exception ex)
{
if (!_isDisposed)
{
System.Diagnostics.Debug.WriteLine($"Error loading meeting histories: {ex.Message}");
}
}
finally
{
if (!_isDisposed)
{
_isLoading = false;
StateHasChanged();
}
}
}
private void Close()
{
if (_isDisposed) return;
MudDialog.Close();
}
public async ValueTask DisposeAsync()
{
if (!_isDisposed)
{
_isDisposed = true;
_cancellationTokenSource?.Cancel();
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = null;
}
await ValueTask.CompletedTask;
}
}