From 023e6c289a9bbcde88fb7c3eadc00897fe56e9b0 Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Thu, 25 Dec 2025 21:53:15 -0500 Subject: [PATCH] Use PageHeader throughout the system --- .../Components/Features/Events/Create.razor | 21 ++++---- .../Components/Features/Events/Details.razor | 32 ++++++------- WebApp/Components/Features/Events/Edit.razor | 26 ++++++---- .../Components/Features/Events/Printout.razor | 8 ++-- .../Features/MeetingSchedule/Index.razor | 5 +- .../Components/Features/Students/Create.razor | 21 ++++---- .../Features/Students/Details.razor | 33 ++++++------- .../Components/Features/Students/Edit.razor | 36 +++++++------- .../Features/Students/EventRanking.razor | 7 +-- .../Features/Students/Registration.razor | 23 +++++---- .../Features/Teams/Assignment.razor | 18 +++---- WebApp/Components/Features/Teams/Create.razor | 43 ++++++++++------- WebApp/Components/Features/Teams/Edit.razor | 48 +++++++++++-------- WebApp/Components/Features/Teams/Goals.razor | 8 ++-- .../Components/Features/Teams/Handout.razor | 10 ++-- .../Components/Features/Teams/Printout.razor | 8 ++-- WebApp/Components/Pages/ChapterSettings.razor | 7 +-- .../Components/Pages/ValidationSettings.razor | 7 +-- .../Shared/Components/PageHeader.razor | 2 +- 19 files changed, 199 insertions(+), 164 deletions(-) diff --git a/WebApp/Components/Features/Events/Create.razor b/WebApp/Components/Features/Events/Create.razor index 528be1a..9f8fece 100644 --- a/WebApp/Components/Features/Events/Create.razor +++ b/WebApp/Components/Features/Events/Create.razor @@ -1,16 +1,21 @@ @page "/events/create" @attribute [Authorize] +@using WebApp.Components.Shared.Components @inject AppDbContext context @inject NavigationManager NavigationManager -Create Event - TSA Chapter Organizer + + + Create + Cancel + + -Create -Event - - - - + @@ -44,8 +49,6 @@ - Back - Save diff --git a/WebApp/Components/Features/Events/Details.razor b/WebApp/Components/Features/Events/Details.razor index b90fb1f..d1008eb 100644 --- a/WebApp/Components/Features/Events/Details.razor +++ b/WebApp/Components/Features/Events/Details.razor @@ -1,22 +1,28 @@ @page "/events/details" @attribute [Authorize] @using Microsoft.EntityFrameworkCore +@using WebApp.Components.Shared.Components @inject AppDbContext context @inject NavigationManager NavigationManager -Event Details - TSA Chapter Organizer - -Details -Event Definition - - @if (eventdefinition is null) { Loading... + return; } -else -{ - + + + + Edit + Back to List + + + + Name @@ -79,13 +85,7 @@ else @eventdefinition.Description - - -
- Edit - Back to List -
-} +
@code { private EventDefinition? eventdefinition; diff --git a/WebApp/Components/Features/Events/Edit.razor b/WebApp/Components/Features/Events/Edit.razor index 9b2cde0..a3770c5 100644 --- a/WebApp/Components/Features/Events/Edit.razor +++ b/WebApp/Components/Features/Events/Edit.razor @@ -1,17 +1,28 @@ @page "/events/edit" @attribute [Authorize] @using Microsoft.EntityFrameworkCore +@using WebApp.Components.Shared.Components @inject AppDbContext context @inject NavigationManager NavigationManager -Edit Event - TSA Chapter Organizer +@if (EventDefinition is null) +{ +

Loading...

+ return; +} -Edit -Event - + + + Save + Cancel + + - - + @@ -45,11 +56,8 @@ - Back - Save - @code { [SupplyParameterFromQuery] private int Id { get; set; } diff --git a/WebApp/Components/Features/Events/Printout.razor b/WebApp/Components/Features/Events/Printout.razor index d92a43e..0fd4d13 100644 --- a/WebApp/Components/Features/Events/Printout.razor +++ b/WebApp/Components/Features/Events/Printout.razor @@ -1,13 +1,13 @@ @using Microsoft.EntityFrameworkCore +@using WebApp.Components.Shared.Components @attribute [Authorize] @page "/events/printout" @inject IConfiguration Configuration @inject AppDbContext Context -TSA Events @Configuration["ChapterSettings:CompetitionYear"] - -TSA Events @Configuration["ChapterSettings:CompetitionYear"] -Yearly theme: Unity Through Community + @if (_events == null) { diff --git a/WebApp/Components/Features/MeetingSchedule/Index.razor b/WebApp/Components/Features/MeetingSchedule/Index.razor index dd6b754..9b8d733 100644 --- a/WebApp/Components/Features/MeetingSchedule/Index.razor +++ b/WebApp/Components/Features/MeetingSchedule/Index.razor @@ -3,14 +3,13 @@ @using System.Text @using Core.Calculation @using Microsoft.EntityFrameworkCore +@using WebApp.Components.Shared.Components @inject IConfiguration Configuration @inject AppDbContext Context @inject ClipboardService ClipboardService @inject LocalStorageService LocalStorage -@Configuration["ChapterSettings:Shortname"] TSA Schedule @Configuration["ChapterSettings:CompetitionYear"] - -@Configuration["ChapterSettings:Shortname"] TSA Schedule @Configuration["ChapterSettings:CompetitionYear"] + diff --git a/WebApp/Components/Features/Students/Create.razor b/WebApp/Components/Features/Students/Create.razor index 628d351..bade1ee 100644 --- a/WebApp/Components/Features/Students/Create.razor +++ b/WebApp/Components/Features/Students/Create.razor @@ -1,16 +1,21 @@ @page "/students/create" @attribute [Authorize] +@using WebApp.Components.Shared.Components @inject AppDbContext Context @inject NavigationManager NavigationManager -Create Student - TSA Chapter Organizer + + + Create + Cancel + + -Create -Student - - - - + @@ -25,8 +30,6 @@ - Back - Save @code { diff --git a/WebApp/Components/Features/Students/Details.razor b/WebApp/Components/Features/Students/Details.razor index 6d48d0a..5f07b35 100644 --- a/WebApp/Components/Features/Students/Details.razor +++ b/WebApp/Components/Features/Students/Details.razor @@ -1,24 +1,27 @@ @page "/students/details" @attribute [Authorize] @using Microsoft.EntityFrameworkCore -@using Core.Entities -@using Data +@using WebApp.Components.Shared.Components @inject AppDbContext context @inject NavigationManager NavigationManager -Student Details - TSA Chapter Organizer - -Details -Student - - @if (student is null) { Loading... + return; } -else -{ - + + + + Edit + Back to List + + + + First Name @@ -61,13 +64,7 @@ else @student.OfficerRole - - -
- Edit - Back to List -
-} +
@code { private Student? student; diff --git a/WebApp/Components/Features/Students/Edit.razor b/WebApp/Components/Features/Students/Edit.razor index 84d5fd5..0116d6c 100644 --- a/WebApp/Components/Features/Students/Edit.razor +++ b/WebApp/Components/Features/Students/Edit.razor @@ -1,25 +1,30 @@ @page "/students/edit" @attribute [Authorize] @using Microsoft.EntityFrameworkCore +@using WebApp.Components.Shared.Components @inject AppDbContext Context @inject NavigationManager NavigationManager -Edit Student - TSA Chapter Organizer - -Edit -Student@(@Student == null ? "" : $" ({Student.Name})") - - - @if (Student is null) {

Loading...

+ return; } -else -{ - /* https://www.mudblazor.com/components/form */ - /* https://medium.com/@husainalbar/applying-mudblazor-for-crud-operations-in-our-blazor-project-a343037a52ef */ - + + + + Save + Cancel + + + +@* https://www.mudblazor.com/components/form *@ +@* https://medium.com/@husainalbar/applying-mudblazor-for-crud-operations-in-our-blazor-project-a343037a52ef *@ + @@ -45,10 +50,7 @@ else - Back - Save - -} + @code { [SupplyParameterFromQuery] @@ -74,7 +76,7 @@ else // For more information, see https://learn.microsoft.com/aspnet/core/blazor/forms/#mitigate-overposting-attacks. private async Task UpdateStudent() { - if (Student.OfficerRole == 0) + if (Student?.OfficerRole == 0) Student.OfficerRole = null; Context.Attach(Student!).State = EntityState.Modified; diff --git a/WebApp/Components/Features/Students/EventRanking.razor b/WebApp/Components/Features/Students/EventRanking.razor index b5c698b..6da004e 100644 --- a/WebApp/Components/Features/Students/EventRanking.razor +++ b/WebApp/Components/Features/Students/EventRanking.razor @@ -2,14 +2,15 @@ @attribute [Authorize] @using Microsoft.EntityFrameworkCore @using WebApp.Models +@using WebApp.Components.Shared.Components @using Core.Validation @inject AppDbContext Context @inject ValidationService ValidationService @rendermode InteractiveServer -Student Event Ranks - TSA Chapter Organizer - - Student Event Ranks + @if (_students == null) { diff --git a/WebApp/Components/Features/Students/Registration.razor b/WebApp/Components/Features/Students/Registration.razor index 5bd5bea..b442977 100644 --- a/WebApp/Components/Features/Students/Registration.razor +++ b/WebApp/Components/Features/Students/Registration.razor @@ -2,23 +2,22 @@ @attribute [Authorize] @using Microsoft.EntityFrameworkCore @using WebApp.Models +@using WebApp.Components.Shared.Components @using Core.Validation @inject AppDbContext Context @inject WebApp.LocalStorageService LocalStorage @inject ValidationService ValidationService -Registration - TSA Chapter Organizer - -Registration - - - - @(_showRegionalOnly ? "Showing Regional Only" : "Show Regional Only") - - + + + + @(_showRegionalOnly ? "Showing Regional Only" : "Show Regional Only") + + + = Team Captain diff --git a/WebApp/Components/Features/Teams/Assignment.razor b/WebApp/Components/Features/Teams/Assignment.razor index 182d0af..4486218 100644 --- a/WebApp/Components/Features/Teams/Assignment.razor +++ b/WebApp/Components/Features/Teams/Assignment.razor @@ -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 -Event Assignment - TSA Chapter Organizer - -Assignment - - - Optimized team assignments based on the student event rankings - Edit Student Event Rankings - + + + + Edit Student Event Rankings + + + diff --git a/WebApp/Components/Features/Teams/Create.razor b/WebApp/Components/Features/Teams/Create.razor index feb8d82..688dd6a 100644 --- a/WebApp/Components/Features/Teams/Create.razor +++ b/WebApp/Components/Features/Teams/Create.razor @@ -1,14 +1,26 @@ @page "/teams/create" @attribute [Authorize] @using Microsoft.EntityFrameworkCore +@using WebApp.Components.Shared.Components @inject AppDbContext Context @inject NavigationManager NavigationManager -Create Team - TSA Chapter Organizer +@if (_events is null) +{ +

Loading...

+ return; +} -Create -Team - + + + Add + Cancel + + @@ -23,17 +35,18 @@ } - @if (_existingTeams?.Count == 1) + @switch (_existingTeams?.Count) { - - A team for @Team.Event.Name already exists. This will be team 2, and the existing team will become team 1. - - } - else if (_existingTeams?.Count >= 2) - { - - Two teams for @Team.Event.Name already exist. Cannot create a third team. - + case 1: + + A team for @Team.Event.Name already exists. This will be team 2, and the existing team will become team 1. + + break; + case >= 2: + + Two teams for @Team.Event.Name already exist. Cannot create a third team. + + break; } @@ -55,8 +68,6 @@ { @_errorMessage } - Back - Add @code { diff --git a/WebApp/Components/Features/Teams/Edit.razor b/WebApp/Components/Features/Teams/Edit.razor index 3048b6e..3719c07 100644 --- a/WebApp/Components/Features/Teams/Edit.razor +++ b/WebApp/Components/Features/Teams/Edit.razor @@ -1,21 +1,27 @@ @page "/teams/edit" @attribute [Authorize] @using Microsoft.EntityFrameworkCore +@using WebApp.Components.Shared.Components @inject AppDbContext Context @inject NavigationManager NavigationManager -Edit Team - TSA Chapter Organizer - -Edit -Team @(Team.ToString()) - @if (Team is null) {

Loading...

+ return; } -else -{ - + + + + Save + Cancel + + + + @@ -33,10 +39,7 @@ else
- Back - Save -
-} + @code { [SupplyParameterFromQuery] @@ -45,7 +48,7 @@ else [SupplyParameterFromForm] private Team? Team { get; set; } - private IEnumerable _selectedStudents = []; + private IEnumerable? _selectedStudents = []; private List _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; diff --git a/WebApp/Components/Features/Teams/Goals.razor b/WebApp/Components/Features/Teams/Goals.razor index 12a9193..09d8171 100644 --- a/WebApp/Components/Features/Teams/Goals.razor +++ b/WebApp/Components/Features/Teams/Goals.razor @@ -2,13 +2,13 @@ @attribute [Authorize] @using Microsoft.EntityFrameworkCore @using WebApp.Models +@using WebApp.Components.Shared.Components @inject IConfiguration Configuration @inject AppDbContext Context -@Configuration["ChapterSettings:Shortname"] TSA Student Goals @Configuration["ChapterSettings:CompetitionYear"] - -@Configuration["ChapterSettings:Shortname"] TSA Student Goals @Configuration["ChapterSettings:CompetitionYear"] -Set Your Goals for Success + @if (_students == null) { diff --git a/WebApp/Components/Features/Teams/Handout.razor b/WebApp/Components/Features/Teams/Handout.razor index f35257d..1e82e16 100644 --- a/WebApp/Components/Features/Teams/Handout.razor +++ b/WebApp/Components/Features/Teams/Handout.razor @@ -2,15 +2,15 @@ @attribute [Authorize] @using Microsoft.EntityFrameworkCore @using WebApp.Models +@using WebApp.Components.Shared.Components @inject IConfiguration Configuration @inject AppDbContext Context -@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"] + -@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"] -Yearly theme: Unity Through Community - -@if (_teams == null) +@if (_teams == null || _students == null) {

Loading...

} diff --git a/WebApp/Components/Features/Teams/Printout.razor b/WebApp/Components/Features/Teams/Printout.razor index b2f56d9..5533fad 100644 --- a/WebApp/Components/Features/Teams/Printout.razor +++ b/WebApp/Components/Features/Teams/Printout.razor @@ -2,13 +2,13 @@ @attribute [Authorize] @using Microsoft.EntityFrameworkCore @using WebApp.Models +@using WebApp.Components.Shared.Components @inject IConfiguration Configuration @inject AppDbContext Context -@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"] - -@Configuration["ChapterSettings:Shortname"] TSA Teams @Configuration["ChapterSettings:CompetitionYear"] -Yearly theme: Unity Through Community + @if (_teams == null) diff --git a/WebApp/Components/Pages/ChapterSettings.razor b/WebApp/Components/Pages/ChapterSettings.razor index ad9b3be..1b3a924 100644 --- a/WebApp/Components/Pages/ChapterSettings.razor +++ b/WebApp/Components/Pages/ChapterSettings.razor @@ -2,17 +2,18 @@ @attribute [Authorize(Roles = AuthRoles.Administrator)] @using WebApp.Authentication @using WebApp.Models +@using WebApp.Components.Shared.Components @using System.Text.Json @inject IWebHostEnvironment Environment @inject IConfiguration Configuration @rendermode InteractiveServer -Chapter Settings + - Chapter Settings - Configure chapter information. Changes take effect on next application restart. @if (_settings != null) { diff --git a/WebApp/Components/Pages/ValidationSettings.razor b/WebApp/Components/Pages/ValidationSettings.razor index 8308252..5f01f89 100644 --- a/WebApp/Components/Pages/ValidationSettings.razor +++ b/WebApp/Components/Pages/ValidationSettings.razor @@ -2,17 +2,18 @@ @attribute [Authorize(Roles = AuthRoles.Administrator)] @using Core.Validation @using WebApp.Authentication +@using WebApp.Components.Shared.Components @using System.Text.Json @inject IWebHostEnvironment Environment @inject IConfiguration Configuration @rendermode InteractiveServer -Validation Settings + - Validation Settings - Configure validation rules and thresholds. Changes take effect on next application restart. @if (_config != null) { diff --git a/WebApp/Components/Shared/Components/PageHeader.razor b/WebApp/Components/Shared/Components/PageHeader.razor index 086091f..bfcdb68 100644 --- a/WebApp/Components/Shared/Components/PageHeader.razor +++ b/WebApp/Components/Shared/Components/PageHeader.razor @@ -57,7 +57,7 @@ @* Description *@ @if (!string.IsNullOrEmpty(Description)) { - @Description + @Description } @* Custom Header Content *@