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.
252 lines
9.3 KiB
Plaintext
252 lines
9.3 KiB
Plaintext
@page "/teams/printout"
|
|
@attribute [Authorize]
|
|
@using Microsoft.EntityFrameworkCore
|
|
@using WebApp.Models
|
|
@using WebApp.Components.Shared.Components
|
|
@using Core.Utility
|
|
@inject IConfiguration Configuration
|
|
@inject AppDbContext Context
|
|
|
|
<PageHeader
|
|
Title="@($"{Configuration["ChapterSettings:Shortname"]} TSA Teams {Configuration["ChapterSettings:CompetitionYear"]}")"
|
|
Description="Yearly theme: Unity Through Community" />
|
|
|
|
<Legend></Legend>
|
|
@if (_teams == null)
|
|
{
|
|
<p><em>Loading...</em></p>
|
|
}
|
|
else
|
|
{
|
|
<MudContainer Class="mt-3 mb-1 nobrk">
|
|
|
|
<MudTable Items="_teams">
|
|
<HeaderContent>
|
|
<MudTh>Team</MudTh>
|
|
<MudTh></MudTh>
|
|
@for (var i = 0; i <= _maxTeamSize; i++)
|
|
{
|
|
<MudTh></MudTh>
|
|
}
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
|
|
<MudTd>
|
|
@context.ToString()
|
|
</MudTd>
|
|
<MudTd>
|
|
<EventAttributes EventDefinition="context.Event"></EventAttributes>
|
|
</MudTd>
|
|
|
|
@{
|
|
var students
|
|
= context.Students
|
|
.OrderByDescending(s => s == context.Captain)
|
|
.ThenBy(s => s.EventRankings.Find(e => e.EventDefinition == context.Event)?.Rank ?? int.MaxValue)
|
|
.ThenByDescending(e => e.Grade)
|
|
.ThenBy(e => e.FirstName)
|
|
.ToArray();
|
|
}
|
|
|
|
@for (var i = 0; i <= _maxTeamSize; i++)
|
|
{
|
|
var student = i < students.Length ? students[i] : null;
|
|
if (student != null)
|
|
{
|
|
var rank = student.EventRankings
|
|
.Find(e => e.EventDefinition == context.Event)?.Rank ?? int.MaxValue;
|
|
|
|
<MudTd Class="@(EventRankClass(rank))">
|
|
@TeamStudentNameFormatter.FormatStudentName(
|
|
student,
|
|
context,
|
|
new TeamStudentNameFormatter.FormatOptions
|
|
{
|
|
CaptainIndicator = TeamStudentNameFormatter.CaptainIndicatorStyle.Captain
|
|
})
|
|
</MudTd>
|
|
}
|
|
else
|
|
{
|
|
<MudTd></MudTd>
|
|
}
|
|
}
|
|
<MudTd>
|
|
@if (context.Event.EventFormat == EventFormat.Team)
|
|
{
|
|
@if (context.Students.Count < context.Event.MinTeamSize)
|
|
{
|
|
<span>Min Team Size: @context.Event.MinTeamSize</span>
|
|
}
|
|
|
|
@if (context.Students.Count > context.Event.MaxTeamSize)
|
|
{
|
|
<span>Max Team Size: @context.Event.MaxTeamSize</span>
|
|
}
|
|
}
|
|
else if (context.Event.EventFormat == EventFormat.Individual
|
|
&& context.Students.Count > context.Event.ChapterEligibilityCountState)
|
|
{
|
|
<span>Max Team Count State: @context.Event.ChapterEligibilityCountState</span>
|
|
}
|
|
</MudTd>
|
|
</RowTemplate>
|
|
</MudTable>
|
|
|
|
</MudContainer>
|
|
|
|
<MudContainer Class="mt-3 mb-1 nobrk pagebreak">
|
|
|
|
<MudTable Items="_students">
|
|
<HeaderContent>
|
|
<MudTh>Student</MudTh>
|
|
<MudTh>Effort</MudTh>
|
|
@for (var i = 0; i <= 5; i++)
|
|
{
|
|
<MudTh></MudTh>
|
|
}
|
|
<MudTh></MudTh>
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
|
|
<MudTd>@context.Name</MudTd>
|
|
<MudTd>@context.Teams.Sum(e => e.Event.LevelOfEffort)</MudTd>
|
|
@{
|
|
var teams = context.Teams
|
|
.OrderBy(e =>
|
|
context.EventRankings.Find(ser => ser.EventDefinition == e.Event)?.Rank ?? int.MaxValue
|
|
).ToArray();
|
|
}
|
|
@for (var i = 0; i <= 5; i++)
|
|
{
|
|
var team = i < teams.Length ? teams[i] : null;
|
|
|
|
@if (team != null)
|
|
{
|
|
var rank = context.EventRankings
|
|
.Find(e => e.EventDefinition == team.Event)?.Rank ?? int.MaxValue;
|
|
<MudTh Class="@(EventRankClass(rank))">
|
|
@team.ToString()
|
|
<EventAttributes EventDefinition="team.Event"></EventAttributes>
|
|
|
|
@if (rank == int.MaxValue)
|
|
{
|
|
<span>❔</span>
|
|
}
|
|
</MudTh>
|
|
}
|
|
else
|
|
{
|
|
<MudTh></MudTh>
|
|
}
|
|
|
|
}
|
|
<MudTd>
|
|
@if (!context.Teams.Select(e => e.Event).Any(re => re.OnSiteActivity))
|
|
{
|
|
<span>No On-Site Activity</span>
|
|
}
|
|
@if (!context.Teams.Select(e => e.Event).Any(re => re.RegionalEvent))
|
|
{
|
|
<span>No Regional Event</span>
|
|
}
|
|
</MudTd>
|
|
</RowTemplate>
|
|
</MudTable>
|
|
|
|
</MudContainer>
|
|
|
|
|
|
<MudContainer Class="mt-3 mb-1 nobrk pagebreak">
|
|
|
|
<MudTable Items="_students">
|
|
<HeaderContent>
|
|
<MudTh>Student</MudTh>
|
|
<MudTh>Grade, TSA Year</MudTh>
|
|
<MudTh>Level of Effort</MudTh>
|
|
</HeaderContent>
|
|
<RowTemplate>
|
|
|
|
<MudTd>@context.Name</MudTd>
|
|
<MudTd>@AppIcons.GetOrdinal(context.Grade), @context.TsaYear</MudTd>
|
|
<MudTd>@context.Teams.Sum(e => e.Event.LevelOfEffort)
|
|
@if (!context.Teams.Select(e => e.Event).Any(re => re.OnSiteActivity))
|
|
{
|
|
<span>No On-Site Activity</span>
|
|
}
|
|
@if (!context.Teams.Select(e => e.Event).Any(re => re.RegionalEvent))
|
|
{
|
|
<span>No Regional Event</span>
|
|
}
|
|
</MudTd>
|
|
</RowTemplate>
|
|
<ChildRowContent>
|
|
<MudTr>
|
|
<MudTable Items="@context.Teams.OrderBy(e =>
|
|
context.EventRankings.Find(ser => ser.EventDefinition == e.Event)?.Rank ?? int.MaxValue
|
|
)" Context="team">
|
|
<RowTemplate>
|
|
@{ var rank = context.EventRankings
|
|
.Find(e => e.EventDefinition == team.Event)?.Rank ?? int.MaxValue; }
|
|
<MudTd Class="@(EventRankClass(rank))">
|
|
@team.ToString()
|
|
@AppIcons.EventEffort(team.Event)
|
|
@AppIcons.EventAttributes(team.Event)
|
|
|
|
@if (rank == int.MaxValue)
|
|
{
|
|
<span>❔</span>
|
|
}
|
|
</MudTd>
|
|
<MudTd>@TeamStudentNameFormatter.FormatStudentList(
|
|
new Team { Students = team.Students.Where(e => e != context).ToList(), Event = team.Event },
|
|
new TeamStudentNameFormatter.FormatOptions
|
|
{
|
|
Ordering = TeamStudentNameFormatter.OrderingStyle.None
|
|
})</MudTd>
|
|
<MudTd></MudTd>
|
|
</RowTemplate>
|
|
</MudTable>
|
|
</MudTr>
|
|
</ChildRowContent>
|
|
</MudTable>
|
|
|
|
</MudContainer>
|
|
}
|
|
@code {
|
|
private Team[]? _teams;
|
|
private int _maxTeamSize;
|
|
private Student[]? _students;
|
|
private bool _rankColorEnabled = false;
|
|
|
|
private string EventRankClass(int rank)
|
|
{
|
|
if (!_rankColorEnabled)
|
|
return "";
|
|
return "event-rank-" + rank;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_teams
|
|
= await Context.Teams
|
|
.AsNoTracking()
|
|
.Include(e => e.Event)
|
|
.Include(e => e.Students)
|
|
.OrderByEventFormatFirst()
|
|
.ThenBy(e => e.Event.Name)
|
|
.ThenBy(e => e.Identifier ?? "")
|
|
.ToArrayAsync();
|
|
|
|
_maxTeamSize = _teams.Max(t => t.Students.Count);
|
|
_students =
|
|
await Context.Students
|
|
.AsNoTracking()
|
|
.Include(e => e.Teams)
|
|
.ThenInclude(e => e.Captain)
|
|
.Include(e => e.EventRankings)
|
|
.ThenInclude(e => e.EventDefinition)
|
|
.OrderBy(e => e.FirstName).ToArrayAsync();
|
|
}
|
|
}
|