Skip to content

Commit

Permalink
Separated out formatted roster into its own partial view and moved it…
Browse files Browse the repository at this point in the history
… to the top of the session details page
  • Loading branch information
morrisonbrett committed Apr 7, 2024
1 parent 5f89c34 commit 7ba58ca
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 117 deletions.
2 changes: 1 addition & 1 deletion pickuphockey/Views/Sessions/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
{
<span class="text-danger">@TempData["Message"]</span>
}
<hr />
@Html.Partial("_UnmarkedReceivedPartial", Model)
@Html.Partial("_UnmarkedSentPartial", Model)
@Html.Partial("_EmergencyInfoPartial", Model.User)
@Html.Partial("_RosterFormatted", Model)
@if (!Model.IsPast)
{
<div class="form-group">
Expand Down
143 changes: 143 additions & 0 deletions pickuphockey/Views/Shared/_RosterFormatted.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
@model pickuphockey.Models.Session
<style>
.team-container-wrapper {
display: flex;
justify-content: center;
margin-bottom: 5px;
flex-wrap: wrap;
}
.team-container {
flex: 1 0 400px;
padding: 20px;
border-radius: 25px;
margin: 10px;
}
.team-name {
font-size: 48px;
font-weight: bold;
text-align: center;
margin-bottom: 10px;
font-family: "Roboto Condensed", sans-serif;
}
.player-list {
display: grid;
grid-template-columns: 1fr;
grid-gap: 10px;
}
.player-item {
padding: 10px 15px;
border-radius: 5px;
font-family: "Roboto Condensed", sans-serif;
font-size: 22px;
}
.light-team {
background-color: #f0f0f0;
color: #333;
}
.light-team .player-item {
background-color: #e0e0e0;
}
.dark-team {
background-color: #333;
color: #fff;
}
.dark-team .player-item {
background-color: #444;
}
.logo {
display: block;
margin-left: auto;
margin-right: auto;
width: 180px;
padding: 10px;
border-radius: 25px;
}
</style>
<script>
function AddLight(name, pos) {
const lightTeamList = document.getElementById("light-list");
const listItem = document.createElement("div");
listItem.className = "player-item";
listItem.textContent = name + ((pos.length > 0) ? ', ' + pos : '');
lightTeamList.appendChild(listItem);
}
function AddDark(name, pos) {
const darkTeamList = document.getElementById("dark-list");
const listItem = document.createElement("div");
listItem.className = "player-item";
listItem.textContent = name + ((pos.length > 0) ? ', ' + pos : '');
darkTeamList.appendChild(listItem);
}
</script>
@if (Model.RegularSetId != null)
{
<div class="team-container-wrapper">
<div class="team-container light-team">
<h1 class="team-name">Rockets</h1>
<img src="~/Content/Rockets_Logo.jpg" class="logo" />
<div id="light-list" class="player-list"></div>
</div>

<div class="team-container dark-team">
<h1 class="team-name">Beauties</h1>
<img src="~/Content/Beauties_Logo.jpg" class="logo" />
<div id="dark-list" , class="player-list"></div>
</div>
</div>
foreach (var item in Model.Regulars.Where(r => r.TeamAssignment == pickuphockey.Models.TeamAssignment.Light).OrderByDescending(r => r.PositionPreference).ThenBy(u => u.User.FirstName))
{
if (!item.SellingOrSoldSpot)
{
<script>
var playerName = "@Html.DisplayFor(modelItem => item.User.FirstName) @Html.DisplayFor(modelItem => item.User.LastName)";
var playerPosition = "@Html.DisplayFor(modelItem => item.PositionPreference)"

AddLight(playerName, playerPosition);
</script>
}
}
foreach (var item in Model.LightSubs)
{
if (!item.ReSellingOrSold)
{
<script>
var playerName = "@Html.DisplayFor(modelItem => item.BuyerUser.FirstName) @Html.DisplayFor(modelItem => item.BuyerUser.LastName)";

AddLight(playerName, '');
</script>
}
}
foreach (var item in Model.Regulars.Where(r => r.TeamAssignment == pickuphockey.Models.TeamAssignment.Dark).OrderByDescending(r => r.PositionPreference).ThenBy(u => u.User.FirstName))
{
if (!item.SellingOrSoldSpot)
{
<script>
var playerName = "@Html.DisplayFor(modelItem => item.User.FirstName) @Html.DisplayFor(modelItem => item.User.LastName)";
var playerPosition = "@Html.DisplayFor(modelItem => item.PositionPreference)"

AddDark(playerName, playerPosition);
</script>
}
}
foreach (var item in Model.DarkSubs)
{
if (!item.ReSellingOrSold)
{
<script>
var playerName = "@Html.DisplayFor(modelItem => item.BuyerUser.FirstName) @Html.DisplayFor(modelItem => item.BuyerUser.LastName)";

AddDark(playerName, '');
</script>
}
}
}
116 changes: 0 additions & 116 deletions pickuphockey/Views/Shared/_RosterPartial.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,8 @@
var isAdmin = User.IsInRole("Admin");
var isSubAdmin = User.IsInRole("SubAdmin");
}
<script>
function AddLight(name, pos) {
const lightTeamList = document.getElementById("light-list");
const listItem = document.createElement("div");
listItem.className = "player-item";
listItem.textContent = name + ((pos.length > 0) ? ', ' + pos : '');
lightTeamList.appendChild(listItem);
}
function AddDark(name, pos) {
const darkTeamList = document.getElementById("dark-list");
const listItem = document.createElement("div");
listItem.className = "player-item";
listItem.textContent = name + ((pos.length > 0) ? ', ' + pos : '');
darkTeamList.appendChild(listItem);
}
</script>
@if (Model.RegularSetId != null)
{
<div class="team-container-wrapper">
<div class="team-container light-team">
<h1 class="team-name">Rockets</h1>
<img src="~/Content/Rockets_Logo.jpg" class="logo" />
<div id="light-list" class="player-list"></div>
</div>

<div class="team-container dark-team">
<h1 class="team-name">Beauties</h1>
<img src="~/Content/Beauties_Logo.jpg" class="logo" />
<div id="dark-list" , class="player-list"></div>
</div>
</div>
<h2>Roster - @Model.RegularSet.Description</h2>
<table class="table">
<tr>
Expand Down Expand Up @@ -64,12 +34,6 @@
var rating = string.Format("{0:0.0}", item.User.Rating);
<span> (</span>@Html.DisplayFor(modelItem => rating)<span>)</span>}<span>, </span>
@Html.DisplayFor(modelItem => item.PositionPreference)
<script>
var playerName = "@Html.DisplayFor(modelItem => item.User.FirstName) @Html.DisplayFor(modelItem => item.User.LastName)";
var playerPosition = "@Html.DisplayFor(modelItem => item.PositionPreference)"
AddLight(playerName, playerPosition);
</script>
<br />
}
}
Expand All @@ -94,11 +58,6 @@
var rating = string.Format("{0:0.0}", item.BuyerUser.Rating);
<span> (</span>@Html.DisplayFor(modelItem => rating)<span>)</span>
}
<script>
var playerName = "@Html.DisplayFor(modelItem => item.BuyerUser.FirstName) @Html.DisplayFor(modelItem => item.BuyerUser.LastName)";
AddLight(playerName, '');
</script>
<br />
}
}
Expand All @@ -125,12 +84,6 @@
var rating = string.Format("{0:0.0}", item.User.Rating);
<span> (</span>@Html.DisplayFor(modelItem => rating)<span>)</span>}<span>, </span>
@Html.DisplayFor(modelItem => item.PositionPreference)
<script>
var playerName = "@Html.DisplayFor(modelItem => item.User.FirstName) @Html.DisplayFor(modelItem => item.User.LastName)";
var playerPosition = "@Html.DisplayFor(modelItem => item.PositionPreference)"
AddDark(playerName, playerPosition);
</script>
<br />
}
}
Expand All @@ -155,11 +108,6 @@
var rating = string.Format("{0:0.0}", item.BuyerUser.Rating);
<span> (</span>@Html.DisplayFor(modelItem => rating)<span>)</span>
}
<script>
var playerName = "@Html.DisplayFor(modelItem => item.BuyerUser.FirstName) @Html.DisplayFor(modelItem => item.BuyerUser.LastName)";
AddDark(playerName, '');
</script>
<br />
}
}
Expand All @@ -174,67 +122,3 @@
}
</table>
}

<style>
.team-container-wrapper {
display: flex;
justify-content: center;
margin-bottom: 5px;
flex-wrap: wrap;
}
.team-container {
flex: 1 0 400px;
padding: 20px;
border-radius: 25px;
margin: 10px;
}
.team-name {
font-size: 48px;
font-weight: bold;
text-align: center;
margin-bottom: 10px;
font-family: "Roboto Condensed", sans-serif;
}
.player-list {
display: grid;
grid-template-columns: 1fr;
grid-gap: 10px;
}
.player-item {
padding: 10px 15px;
border-radius: 5px;
font-family: "Roboto Condensed", sans-serif;
font-size: 22px;
}
.light-team {
background-color: #f0f0f0;
color: #333;
}
.light-team .player-item {
background-color: #e0e0e0;
}
.dark-team {
background-color: #333;
color: #fff;
}
.dark-team .player-item {
background-color: #444;
}
.logo {
display: block;
margin-left: auto;
margin-right: auto;
width: 180px;
padding: 10px;
border-radius: 25px;
}
</style>
1 change: 1 addition & 0 deletions pickuphockey/pickuphockey.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@
<Content Include="Views\Shared\_LockerRoom13Partial.cshtml" />
<Content Include="Views\BuySells\Payment.cshtml" />
<Content Include="Views\Users\RegularSets.cshtml" />
<Content Include="Views\Shared\_RosterFormatted.cshtml" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
Expand Down

0 comments on commit 7ba58ca

Please sign in to comment.