f8c22690d4
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.
82 lines
3.2 KiB
Plaintext
82 lines
3.2 KiB
Plaintext
@using Core.Calculation
|
|
@using WebApp.Models
|
|
@using Core.Utility
|
|
|
|
<MudStack>
|
|
<MudText Typo="Typo.h6">@TimeSlotName</MudText>
|
|
@foreach (var team in Teams.OrderByEventFormatFirst().ThenBy(e => e.ToString()))
|
|
{
|
|
var scheduledTeamIds = ScheduledTeams.Select(t => t.Id).ToHashSet();
|
|
var removed = !scheduledTeamIds.Contains(team.Id);
|
|
|
|
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center" Class="d-flex align-center">
|
|
<MudStack Row="true" Spacing="1" AlignItems="AlignItems.Center">
|
|
<MudIcon Icon="@Icons.Material.Filled.Clear"
|
|
Size="Size.Small"
|
|
Class="@(removed ? "" : "d-none")"
|
|
OnClick="@(() => OnToggleTeam.InvokeAsync(team))"
|
|
Style="cursor: pointer;">
|
|
</MudIcon>
|
|
@{
|
|
var teamMembers = TeamStudentNameFormatter.FormatStudentList(
|
|
team,
|
|
new TeamStudentNameFormatter.FormatOptions
|
|
{
|
|
Ordering = TeamStudentNameFormatter.OrderingStyle.None
|
|
});
|
|
}
|
|
<MudTooltip Text="@teamMembers">
|
|
<div @onclick="@(() => OnToggleTeam.InvokeAsync(team))" style="cursor: pointer; display: inline-block;">
|
|
<MudChip T="string"
|
|
Size="Size.Small"
|
|
Color="Color.Default">
|
|
@team
|
|
</MudChip>
|
|
</div>
|
|
</MudTooltip>
|
|
</MudStack>
|
|
<MudStack Row="true" Spacing="1" Wrap="Wrap.Wrap" AlignItems="AlignItems.Center">
|
|
@foreach (var student in team.Students)
|
|
{
|
|
var overlap = StudentHasOverlaps(student);
|
|
var chipColor = overlap ? Color.Warning : Color.Default;
|
|
var formattedName = TeamStudentNameFormatter.FormatStudentName(
|
|
student,
|
|
team,
|
|
new TeamStudentNameFormatter.FormatOptions
|
|
{
|
|
MarkOverlaps = true,
|
|
HasOverlaps = StudentHasOverlaps,
|
|
MarkAbsent = true,
|
|
AbsentStudents = AbsentStudents.ToList()
|
|
});
|
|
|
|
<MudChip T="string" Size="Size.Small" Color="@chipColor" Variant="Variant.Outlined">
|
|
@formattedName
|
|
</MudChip>
|
|
}
|
|
</MudStack>
|
|
</MudStack>
|
|
}
|
|
</MudStack>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public string TimeSlotName { get; set; } = string.Empty;
|
|
|
|
[Parameter]
|
|
public IEnumerable<Team> Teams { get; set; } = [];
|
|
|
|
[Parameter]
|
|
public IEnumerable<Team> ScheduledTeams { get; set; } = [];
|
|
|
|
[Parameter]
|
|
public IEnumerable<Student> AbsentStudents { get; set; } = [];
|
|
|
|
[Parameter]
|
|
public Func<Student, bool> StudentHasOverlaps { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback<Team> OnToggleTeam { get; set; }
|
|
}
|