@using Core.Calculation @using WebApp.Models @using Core.Utility @TimeSlotName @foreach (var team in Teams.OrderByEventFormatFirst().ThenBy(e => e.ToString())) { var scheduledTeamIds = ScheduledTeams.Select(t => t.Id).ToHashSet(); var removed = !scheduledTeamIds.Contains(team.Id); @{ var teamMembers = TeamStudentNameFormatter.FormatStudentList( team, new TeamStudentNameFormatter.FormatOptions { Ordering = TeamStudentNameFormatter.OrderingStyle.None }); } OnToggleTeam.InvokeAsync(team))" style="cursor: pointer; display: inline-block;"> @team @{ var nonExcludedStudentCount = GetNonExcludedStudentCount(team); } @foreach (var student in team.Students) { var overlap = StudentHasOverlaps(student); var chipColor = overlap ? Color.Warning : Color.Default; var isExcluded = IsStudentExcluded(team.Id, TimeSlotIndex, student.Id); var formattedName = TeamStudentNameFormatter.FormatStudentName( student, team, new TeamStudentNameFormatter.FormatOptions { MarkOverlaps = true, HasOverlaps = StudentHasOverlaps, MarkAbsent = true, AbsentStudents = AbsentStudents.ToList() }); @if (nonExcludedStudentCount > 1) { @formattedName } else { @formattedName } } } @code { [Parameter] public string TimeSlotName { get; set; } = string.Empty; [Parameter] public int TimeSlotIndex { get; set; } [Parameter] public IEnumerable Teams { get; set; } = []; [Parameter] public IEnumerable ScheduledTeams { get; set; } = []; [Parameter] public IEnumerable AbsentStudents { get; set; } = []; [Parameter] public Func StudentHasOverlaps { get; set; } = null!; [Parameter] public Dictionary<(int teamId, int timeSlotIndex, int studentId), bool> ExcludedStudents { get; set; } = new(); [Parameter] public EventCallback OnToggleTeam { get; set; } [Parameter] public EventCallback<(int teamId, int timeSlotIndex, int studentId)> OnToggleStudentExclusion { get; set; } private bool IsStudentExcluded(int teamId, int timeSlotIndex, int studentId) { var key = (teamId, timeSlotIndex, studentId); return ExcludedStudents.ContainsKey(key) && ExcludedStudents[key]; } private int GetNonExcludedStudentCount(Team team) { return team.Students.Count(s => !IsStudentExcluded(team.Id, TimeSlotIndex, s.Id)); } }