From 05e5e69d0b9e19f083b134832b5c3b133ef6025b Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Fri, 3 Oct 2025 12:37:11 -0400 Subject: [PATCH] Clean up Team page Add an EventAttributes display --- Core/Entities/Team.cs | 4 +-- WebApp/Components/Layout/NavMenu.razor | 2 +- WebApp/Components/Pages/EventAttributes.razor | 25 ++++++++++++++++ WebApp/Components/Pages/TeamPages/Edit.razor | 17 +++++++++-- WebApp/Components/Pages/TeamPages/Index.razor | 29 ++++++++++++------- WebApp/Models/AppIcons.cs | 10 +++---- 6 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 WebApp/Components/Pages/EventAttributes.razor diff --git a/Core/Entities/Team.cs b/Core/Entities/Team.cs index d0b76f3..ac823b4 100644 --- a/Core/Entities/Team.cs +++ b/Core/Entities/Team.cs @@ -5,9 +5,9 @@ public class Team { public int Id { get; set; } - [Required] - [Display(Name = "Team Name")] + [Display(Name = "Team Number")] public int? Number { get; set; } + public EventDefinition Event { get; diff --git a/WebApp/Components/Layout/NavMenu.razor b/WebApp/Components/Layout/NavMenu.razor index dd2affa..cba3fc1 100644 --- a/WebApp/Components/Layout/NavMenu.razor +++ b/WebApp/Components/Layout/NavMenu.razor @@ -10,7 +10,7 @@ Students - Teams + Teams Print out Handout diff --git a/WebApp/Components/Pages/EventAttributes.razor b/WebApp/Components/Pages/EventAttributes.razor new file mode 100644 index 0000000..e755ca4 --- /dev/null +++ b/WebApp/Components/Pages/EventAttributes.razor @@ -0,0 +1,25 @@ +@using WebApp.Models + +@if(EventDefinition.EventFormat == EventFormat.Individual) { + @AppIcons.IndividualEvent +} +@if (EventDefinition.OnSiteActivity) +{ + @AppIcons.OnSiteActivity +} + +@if (EventDefinition.RegionalEvent) +{ + @AppIcons.RegionalEvent +} + +@if (EventDefinition.Presubmission) +{ + @AppIcons.PresubmissionEvent +} + + +@code { + [Parameter] + public EventDefinition EventDefinition { get; set; } +} diff --git a/WebApp/Components/Pages/TeamPages/Edit.razor b/WebApp/Components/Pages/TeamPages/Edit.razor index 4965b93..bae19fa 100644 --- a/WebApp/Components/Pages/TeamPages/Edit.razor +++ b/WebApp/Components/Pages/TeamPages/Edit.razor @@ -31,12 +31,14 @@ else @student.Name } - + + + Back - Save + Save } @@ -66,6 +68,17 @@ else { NavigationManager.NavigateTo("notfound"); } + + switch (Team!.Event.EventFormat) + { + case EventFormat.Individual when Team.Students.Count == 1: + Team.Captain ??= Team.Students[0]; + Team.TeamId ??= Team.Captain.FirstName; + break; + case EventFormat.Team when Team.Number != null && Team.TeamId == null: + Team.TeamId = Team.Number.ToString(); + break; + } } // To protect from overposting attacks, enable the specific properties you want to bind to. diff --git a/WebApp/Components/Pages/TeamPages/Index.razor b/WebApp/Components/Pages/TeamPages/Index.razor index c53b513..f74b156 100644 --- a/WebApp/Components/Pages/TeamPages/Index.razor +++ b/WebApp/Components/Pages/TeamPages/Index.razor @@ -16,28 +16,37 @@ - - + + + @context.Item.ToString() + + + + + + + @foreach (var student in context.Item.Students .OrderBy(e => e.EventRankings - .Find(er => er.EventDefinition == context.Item.Event)?.Rank ?? 10) + .Find(er => er.EventDefinition == context.Item.Event)?.Rank ?? 10) .ThenBy(s => s.Grade + s.TsaYear)) { - var eventRank = + var eventRank = student.EventRankings - .Find(e => e.EventDefinition == context.Item.Event)?.Rank; + .Find(e => e.EventDefinition == context.Item.Event)?.Rank; var color = AppIcons.RankedEventColor(eventRank ?? 0); + var captain = context.Item.Captain != null && context.Item.Captain.Equals(student); - @student.FirstName + @student.FirstName @if(captain){ *} } - + @* @context.Item.Grade (@context.Item.TsaYear) @@ -48,15 +57,15 @@ - Details + Details - Edit + Edit + OnClick="() => DeleteTeam(context.Item!)"/> diff --git a/WebApp/Models/AppIcons.cs b/WebApp/Models/AppIcons.cs index 2246729..444be82 100644 --- a/WebApp/Models/AppIcons.cs +++ b/WebApp/Models/AppIcons.cs @@ -24,11 +24,11 @@ namespace WebApp.Models } /*https://unicodeplus.com/search*/ - public static string OnSiteActivity = "𝔸"; - public static string RegionalEvent = "ℝ"; - public static string IndividualEvent = "ⅈ"; - public static string PresubmissionEvent = "↩"; - public static string PresentationEvent = "ⓟ"; + public static string OnSiteActivity = "ⓐ"; + public static string RegionalEvent = "ⓡ"; + public static string IndividualEvent = "ⓘ"; + public static string PresubmissionEvent = "ⓟ"; + public static string PresentationEvent = ""; public static string QuestionMark = "❔"; public static string EventEffort(EventDefinition eventDefinition)