Files
chapter-organizer/WebApp/Components/Features/MeetingSchedule/UnscheduledStudentsList.razor
T
poprhythm f8c22690d4 Add student name formatting utilities and refactor team student name handling
This commit introduces two new utility classes: StudentNameFormatter and TeamStudentNameFormatter, which provide methods for formatting student names with options for indicating absence and overlaps. The Team class has been updated to remove the StudentsFirstNames property, and various components across the WebApp have been refactored to utilize the new formatting utilities. This enhances the maintainability and readability of the code while improving the presentation of student names in the UI.
2026-01-11 21:43:00 -05:00

79 lines
3.4 KiB
Plaintext

@using Core.Calculation
@using Core.Utility
@if (UnscheduledStudents.Any())
{
<MudText Typo="Typo.body1" HtmlTag="strong">Unscheduled</MudText>
<MudStack>
@foreach (var student in UnscheduledStudents)
{
<MudItem>
@{
var formattedName = StudentNameFormatter.FormatStudentName(
student,
new StudentNameFormatter.FormatOptions
{
IsAbsent = AbsentStudents.Contains(student)
});
}
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
<MudStack Row="true" Spacing="1" AlignItems="AlignItems.Center">
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined" Class="font-style-italic">
@formattedName
</MudChip>
</MudStack>
<MudStack Row="true" Spacing="1" Wrap="Wrap.Wrap" AlignItems="AlignItems.Center">
@foreach (var unassignedTeam in UnassignedTeams(student))
{
var isPossibleAddition = PossibleAdditions.Contains(unassignedTeam, new TeamIdComparer());
var scheduledTeamIds = ScheduledTeams.Select(t => t.Id).ToHashSet();
var isScheduled = scheduledTeamIds.Contains(unassignedTeam.Id);
var chipColor = isPossibleAddition ? Color.Success : Color.Default;
var teamMembers = TeamStudentNameFormatter.FormatStudentList(
unassignedTeam,
new TeamStudentNameFormatter.FormatOptions
{
Ordering = TeamStudentNameFormatter.OrderingStyle.None
});
<MudTooltip Text="@teamMembers">
<div @onclick="@(() => OnToggleTeam.InvokeAsync(unassignedTeam))" style="cursor: pointer; display: inline-block;">
<MudChip T="string"
Size="Size.Small"
Color="@chipColor">
@if (isScheduled)
{
<MudIcon Icon="@Icons.Material.Filled.Check" Size="Size.Small" Style="margin-right: 4px;" />
}
@unassignedTeam
</MudChip>
</div>
</MudTooltip>
}
</MudStack>
</MudStack>
</MudItem>
}
</MudStack>
}
@code {
[Parameter]
public IEnumerable<Student> UnscheduledStudents { get; set; } = [];
[Parameter]
public IEnumerable<Student> AbsentStudents { get; set; } = [];
[Parameter]
public IEnumerable<Team> ScheduledTeams { get; set; } = [];
[Parameter]
public IEnumerable<Team> PossibleAdditions { get; set; } = [];
[Parameter]
public Func<Student, IEnumerable<Team>> UnassignedTeams { get; set; } = null!;
[Parameter]
public EventCallback<Team> OnToggleTeam { get; set; }
}