Use PageHeader throughout the system

This commit is contained in:
2025-12-25 21:53:15 -05:00
parent 1e36a5661b
commit 023e6c289a
19 changed files with 199 additions and 164 deletions
@@ -4,20 +4,22 @@
@using Core.Validation
@using Microsoft.EntityFrameworkCore
@using WebApp.Models
@using WebApp.Components.Shared.Components
@using EventAssignment = Core.Calculation.EventAssignment
@inject AppDbContext Context
@inject IDialogService DialogService
@inject NavigationManager NavigationManager
@inject ValidationService ValidationService
<PageTitle>Event Assignment - TSA Chapter Organizer</PageTitle>
<MudText Typo="Typo.h3">Assignment</MudText>
<MudGrid>
<MudItem><MudText>Optimized team assignments based on the student event rankings</MudText></MudItem>
<MudItem><MudButton StartIcon="@Icons.Material.Filled.Edit" Href="students/event-ranking">Edit Student Event Rankings</MudButton></MudItem>
</MudGrid>
<PageHeader
Title="Assignment"
Description="Optimized team assignments based on the student event rankings">
<ActionButtons>
<MudButton StartIcon="@Icons.Material.Filled.Edit" Href="students/event-ranking" Variant="Variant.Outlined">
Edit Student Event Rankings
</MudButton>
</ActionButtons>
</PageHeader>
<MudPaper Class="pa-4 mt-5">
<MudGrid>
+27 -16
View File
@@ -1,14 +1,26 @@
@page "/teams/create"
@attribute [Authorize]
@using Microsoft.EntityFrameworkCore
@using WebApp.Components.Shared.Components
@inject AppDbContext Context
@inject NavigationManager NavigationManager
<PageTitle>Create Team - TSA Chapter Organizer</PageTitle>
@if (_events is null)
{
<p><em>Loading...</em></p>
return;
}
<MudText Typo="Typo.h3">Create</MudText>
<MudText Typo="Typo.h4">Team</MudText>
<MudDivider />
<PageHeader
Title="Create"
Subtitle="Team"
ShowBackButton="true"
BackButtonUrl="/teams">
<ActionButtons>
<MudButton OnClick="AddTeam" Variant="Variant.Filled" Color="Color.Primary">Add</MudButton>
<MudButton Href="/teams" Variant="Variant.Text">Cancel</MudButton>
</ActionButtons>
</PageHeader>
<EditForm method="post" Model="Team" OnValidSubmit="AddTeam" FormName="create" Enhance>
<AntiforgeryToken />
@@ -23,17 +35,18 @@
<MudSelectItem T="EventDefinition" Value="@(evt)"></MudSelectItem>
}
</MudSelect>
@if (_existingTeams?.Count == 1)
@switch (_existingTeams?.Count)
{
<MudAlert Severity="Severity.Info" Class="my-2">
A team for @Team.Event.Name already exists. This will be team 2, and the existing team will become team 1.
</MudAlert>
}
else if (_existingTeams?.Count >= 2)
{
<MudAlert Severity="Severity.Error" Class="my-2">
Two teams for @Team.Event.Name already exist. Cannot create a third team.
</MudAlert>
case 1:
<MudAlert Severity="Severity.Info" Class="my-2">
A team for @Team.Event.Name already exists. This will be team 2, and the existing team will become team 1.
</MudAlert>
break;
case >= 2:
<MudAlert Severity="Severity.Error" Class="my-2">
Two teams for @Team.Event.Name already exist. Cannot create a third team.
</MudAlert>
break;
}
<MudDivider Class="my-4" />
@@ -55,8 +68,6 @@
{
<MudAlert Severity="Severity.Error" Class="mt-3">@_errorMessage</MudAlert>
}
<MudButton StartIcon="@Icons.Material.Filled.ArrowBack" Href="students">Back</MudButton>
<MudButton StartIcon="@Icons.Material.Filled.Add" OnClick="AddTeam">Add</MudButton>
</EditForm>
@code {
+28 -20
View File
@@ -1,21 +1,27 @@
@page "/teams/edit"
@attribute [Authorize]
@using Microsoft.EntityFrameworkCore
@using WebApp.Components.Shared.Components
@inject AppDbContext Context
@inject NavigationManager NavigationManager
<PageTitle>Edit Team - TSA Chapter Organizer</PageTitle>
<MudText Typo="Typo.h3">Edit</MudText>
<MudText Typo="Typo.h4">Team @(Team.ToString())</MudText>
@if (Team is null)
{
<p><em>Loading...</em></p>
return;
}
else
{
<EditForm method="post" Model="Team" OnValidSubmit="UpdateTeam" FormName="edit" Enhance>
<PageHeader Title="Edit Team"
Subtitle=@Team.ToString()
ShowBackButton="true"
BackButtonUrl="/teams">
<ActionButtons>
<MudButton OnClick="UpdateTeam" Variant="Variant.Filled" Color="Color.Primary">Save</MudButton>
<MudButton Href="/teams" Variant="Variant.Text">Cancel</MudButton>
</ActionButtons>
</PageHeader>
<EditForm method="post" Model="Team" OnValidSubmit="UpdateTeam" FormName="edit" Enhance>
<AntiforgeryToken />
<DataAnnotationsValidator/>
<MudGrid>
@@ -33,10 +39,7 @@ else
</MudPaper>
</MudItem>
</MudGrid>
<MudButton StartIcon="@Icons.Material.Filled.ArrowBack" Href="teams">Back</MudButton>
<MudButton StartIcon="@Icons.Material.Filled.Save" OnClick="UpdateTeam">Save</MudButton>
</EditForm>
}
</EditForm>
@code {
[SupplyParameterFromQuery]
@@ -45,7 +48,7 @@ else
[SupplyParameterFromForm]
private Team? Team { get; set; }
private IEnumerable<Student> _selectedStudents = [];
private IEnumerable<Student>? _selectedStudents = [];
private List<Student> _students = [];
protected override async Task OnInitializedAsync()
@@ -55,7 +58,7 @@ else
.Include(e => e.Students)
.FirstOrDefaultAsync(m => m.Id == Id);
_students = await Context.Students.ToListAsync();
_selectedStudents = Team.Students.ToList();
_selectedStudents = Team?.Students.ToList();
if (Team is null)
{
@@ -68,6 +71,10 @@ else
Team.Captain ??= Team.Students[0];
Team.Identifier ??= Team.Captain.FirstName;
break;
case EventFormat.Team:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
@@ -76,14 +83,15 @@ else
private async Task UpdateTeam()
{
//Context.Attach(Team!).Entity = EntityState.Modified;
Team.Students.Clear();
foreach (var s in _selectedStudents)
{
Team.Students.Add(s);
}
Team?.Students.Clear();
if (_selectedStudents != null)
foreach (var s in _selectedStudents)
{
Team?.Students.Add(s);
}
// Update identifier for individual events
if (Team.Event.EventFormat == EventFormat.Individual && Team.Students.Count == 1)
if (Team is { Event.EventFormat: EventFormat.Individual, Students.Count: 1 })
{
Team.Captain ??= Team.Students[0];
Team.Identifier = Team.Captain.FirstName;
+4 -4
View File
@@ -2,13 +2,13 @@
@attribute [Authorize]
@using Microsoft.EntityFrameworkCore
@using WebApp.Models
@using WebApp.Components.Shared.Components
@inject IConfiguration Configuration
@inject AppDbContext Context
<PageTitle>@Configuration["ChapterSettings:Shortname"] TSA Student Goals @Configuration["ChapterSettings:CompetitionYear"]</PageTitle>
<MudText Typo="Typo.h3">@Configuration["ChapterSettings:Shortname"] TSA Student Goals @Configuration["ChapterSettings:CompetitionYear"]</MudText>
<MudText Typo="Typo.h5" Class="mb-4">Set Your Goals for Success</MudText>
<PageHeader
Title="@($"{Configuration["ChapterSettings:Shortname"]} TSA Student Goals {Configuration["ChapterSettings:CompetitionYear"]}")"
Description="Set Your Goals for Success" />
@if (_students == null)
{
@@ -2,15 +2,15 @@
@attribute [Authorize]
@using Microsoft.EntityFrameworkCore
@using WebApp.Models
@using WebApp.Components.Shared.Components
@inject IConfiguration Configuration
@inject AppDbContext Context
<PageTitle>@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"]</PageTitle>
<PageHeader
Title="@($"{Configuration["ChapterSettings:Shortname"]} TSA Teams {Configuration["ChapterSettings:CompetitionYear"]}")"
Description="Yearly theme: Unity Through Community" />
<MudText Typo="Typo.h3">@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"]</MudText>
<MudText Typo="Typo.h5" Class="mb-4">Yearly theme: Unity Through Community</MudText>
@if (_teams == null)
@if (_teams == null || _students == null)
{
<p><em>Loading...</em></p>
}
@@ -2,13 +2,13 @@
@attribute [Authorize]
@using Microsoft.EntityFrameworkCore
@using WebApp.Models
@using WebApp.Components.Shared.Components
@inject IConfiguration Configuration
@inject AppDbContext Context
<PageTitle>@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"]</PageTitle>
<MudText Typo="Typo.h3">@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"]</MudText>
<MudText Typo="Typo.h5" Class="mb-4">Yearly theme: Unity Through Community</MudText>
<PageHeader
Title="@($"{Configuration["ChapterSettings:Shortname"]} TSA Teams {Configuration["ChapterSettings:CompetitionYear"]}")"
Description="Yearly theme: Unity Through Community" />
<Legend></Legend>
@if (_teams == null)