Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team layout updates + add member bugfix #143

Merged
merged 2 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ServerCore/ModelBases/EventSpecificPageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public async Task BindModelAsync(ModelBindingContext bindingContext)
{
bindingContext.Result = ModelBindingResult.Success(Enum.Parse(typeof(EventRole), eventRoleAsString));
}
else
{
throw new Exception("Invalid route parameter '" + eventRoleAsString + "'. Please check your URL to make sure you are using the correct path. (code: InvalidRoleId)");
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ServerCore/Pages/Hints/Create.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/{eventId}/Hints/Create/{puzzleId}"
@page "/{eventId}/{eventRole}/Hints/Create/{puzzleId}"
@model ServerCore.Pages.Hints.CreateModel

@{
Expand Down
2 changes: 1 addition & 1 deletion ServerCore/Pages/Hints/Delete.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/{eventId}/Hints/Delete/{puzzleId}"
@page "/{eventId}/{eventRole}/Hints/Delete/{puzzleId}"
@model ServerCore.Pages.Hints.DeleteModel

@{
Expand Down
2 changes: 1 addition & 1 deletion ServerCore/Pages/Hints/Details.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/{eventId}/Hints/Details/{puzzleId}"
@page "/{eventId}/{eventRole}/Hints/Details/{puzzleId}"
@model ServerCore.Pages.Hints.DetailsModel

@{
Expand Down
2 changes: 1 addition & 1 deletion ServerCore/Pages/Hints/Edit.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/{eventId}/Hints/Edit/{puzzleId}"
@page "/{eventId}/{eventRole}/Hints/Edit/{puzzleId}"
@model ServerCore.Pages.Hints.EditModel

@{
Expand Down
2 changes: 1 addition & 1 deletion ServerCore/Pages/Hints/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/{eventId}/Hints/{puzzleID}"
@page "/{eventId}/{eventRole}/Hints/{puzzleID}"
@model ServerCore.Pages.Hints.IndexModel

@{
Expand Down
8 changes: 4 additions & 4 deletions ServerCore/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
<span class="icon-bar"></span>
</button>
<a asp-page="/." class="navbar-brand" data-toggle="dropdown">
Admin
@Event.Name - Admin
</a>
<!-- Get this to work & add it to the other header bars
<ul class="dropdown-menu">
Expand Down Expand Up @@ -220,7 +220,7 @@
<span class="icon-bar"></span>
</button>
<a asp-page="/Index" class="navbar-brand">
Author
@Event.Name - Author
</a>
</div>
<div class="navbar-collapse collapse">
Expand Down Expand Up @@ -263,14 +263,14 @@
<span class="icon-bar"></span>
</button>
<a asp-page="/Index" class="navbar-brand">
Player
@Event.Name
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a asp-page="/Events/Details" asp-route-id="@Event.ID" asp-route-eventRole="@ModelBases.EventRole.play">Event</a></li>
<li><a asp-page="/Puzzles/Index" asp-route-eventId="@Event.ID" asp-route-eventRole="@ModelBases.EventRole.play">Puzzles</a></li>
<li><a asp-page="/Teams/Index" asp-route-eventId="@Event.ID" asp-route-eventRole="@ModelBases.EventRole.play">Team</a></li>
<li><a asp-page="/Teams/Details" asp-route-eventId="@Event.ID" asp-route-eventRole="@ModelBases.EventRole.play">Team</a></li>
<li><a asp-page="/Events/Standings" asp-route-eventId="@Event.ID" asp-route-eventRole="@ModelBases.EventRole.play">Standings</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Expand Down
2 changes: 1 addition & 1 deletion ServerCore/Pages/Submissions/AuthorIndex.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/{eventId}/AuthorSubmissions"
@page "/{eventId}/{eventRole}/AuthorSubmissions"
@model ServerCore.Pages.Submissions.AuthorIndexModel
@{
ViewData["Title"] = "AuthorIndex";
Expand Down
21 changes: 8 additions & 13 deletions ServerCore/Pages/Teams/AddMember.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
Layout = "_teamLayout.cshtml";
}

<h2>Add a team member</h2>
<h2>@Html.DisplayFor(model => model.Team.Name) - Add Member</h2>

<h4>Select a user to add to team "@Model.MyTeam.Name"</h4>
<div>
<a asp-page="./Members" asp-route-id="@Model.Team.ID">Cancel</a>
</div>

<h4>Select a user to add to this team:</h4>

<table class="table">
<thead>
Expand Down Expand Up @@ -39,18 +43,9 @@
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
<a asp-page-handler="AddMember" asp-route-teamId="@Model.MyTeam.ID" asp-route-userId="@item.ID">Add</a>
<a asp-page-handler="AddMember" asp-route-teamId="@Model.Team.ID" asp-route-userId="@item.ID">Add</a>
</td>
</tr>
}
</tbody>
</table>

<div>
TEMPORARY - use this to add a random user so you can use this page. TODO: Remove once users have their own add page
<a asp-page-handler="AddUser" asp-route-teamId="@Model.MyTeam.ID">TEMP add user</a>
</div>

<div>
<a asp-page="Members" asp-route-id="@Model.MyTeam.ID">Back to team member list</a>
</div>
</table>
23 changes: 3 additions & 20 deletions ServerCore/Pages/Teams/AddMember.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class AddMemberModel : EventSpecificPageModel
{
private readonly ServerCore.DataModel.PuzzleServerContext _context;

public Team MyTeam { get; set; }
public Team Team { get; set; }

public IList<PuzzleUser> Users { get; set; }

Expand All @@ -26,8 +26,8 @@ public AddMemberModel(ServerCore.DataModel.PuzzleServerContext context)

public async Task<IActionResult> OnGetAsync(int teamId)
{
MyTeam = await _context.Teams.FirstOrDefaultAsync(m => m.ID == teamId);
if (MyTeam == null)
Team = await _context.Teams.FirstOrDefaultAsync(m => m.ID == teamId);
if (Team == null)
{
return NotFound("Could not find team with ID '" + teamId + "'. Check to make sure you're accessing this page in the context of a team.");
}
Expand Down Expand Up @@ -67,22 +67,5 @@ public async Task<IActionResult> OnGetAddMemberAsync(int teamId, int userId)
await _context.SaveChangesAsync();
return RedirectToPage("./Members", new { id = teamId });
}

// TEMPORARY - can't test member add without this function to add random users
// TODO (@Jenna) - delete once users have an add page
public async Task<IActionResult> OnGetAddUserAsync(int teamId)
{
PuzzleUser User = new PuzzleUser();
User.Name = "MyName" + new Random().Next(1, 99);
User.EmployeeAlias = "null";
User.Email = User.Name + "@domain.com";
User.PhoneNumber = "null";
User.TShirtSize = "null";
User.VisibleToOthers = true;
_context.PuzzleUsers.Add(User);

await _context.SaveChangesAsync();
return RedirectToPage("./AddMember", new { teamId });
}
}
}
2 changes: 1 addition & 1 deletion ServerCore/Pages/Teams/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ViewData["Title"] = "Create";
}

<h2>Create</h2>
<h2>Create a new team</h2>

<h4>Team</h4>
<hr />
Expand Down
5 changes: 4 additions & 1 deletion ServerCore/Pages/Teams/Delete.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
Layout = "_teamLayout.cshtml";
}

<h2>Delete</h2>
<h2>@Html.DisplayFor(model => model.Team.Name) - Delete</h2>
<div>
<a asp-page="./Details" asp-route-id="@Model.Team.ID">Cancel</a>
</div>

<h3>Are you sure you want to delete this?</h3>
<div>
Expand Down
14 changes: 8 additions & 6 deletions ServerCore/Pages/Teams/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
Layout = "_teamLayout.cshtml";
}

<h2>Details</h2>
<h2>@Html.DisplayFor(model => model.Team.Name) - Details</h2>

<div>
<h4>Team</h4>
@if(Model.EventRole != ModelBases.EventRole.author)
{
<div>
<a asp-page="./Edit" asp-route-id="@Model.Team.ID">Edit</a> |
<a asp-page="./Delete">Delete</a>
</div>
}
<hr />
<dl class="dl-horizontal">
<dt>
Expand Down Expand Up @@ -50,7 +56,3 @@
</dd>
</dl>
</div>
<div>
<a asp-page="./Edit" asp-route-id="@Model.Team.ID">Edit</a> |
<a asp-page="./Index">Back to List</a>
</div>
17 changes: 14 additions & 3 deletions ServerCore/Pages/Teams/Details.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using ServerCore.DataModel;
Expand All @@ -9,21 +10,31 @@ namespace ServerCore.Pages.Teams
public class DetailsModel : EventSpecificPageModel
{
private readonly PuzzleServerContext _context;
private readonly UserManager<IdentityUser> userManager;

public DetailsModel(PuzzleServerContext context)
public DetailsModel(PuzzleServerContext context, UserManager<IdentityUser> manager)
{
_context = context;
userManager = manager;
}

public Team Team { get; set; }

public async Task<IActionResult> OnGetAsync(int id)
public async Task<IActionResult> OnGetAsync(int id=-1)
{
if (id == -1)
{
if (EventRole != ModelBases.EventRole.play)
{
return NotFound("Missing team id");
}
id = 1;// TODO - fix to get the user's team loggedInUser.teamId;
}
Team = await _context.Teams.FirstOrDefaultAsync(m => m.ID == id);

if (Team == null)
{
return NotFound();
return NotFound("No team found with id '" + id + "'.");
}
return Page();
}
Expand Down
9 changes: 4 additions & 5 deletions ServerCore/Pages/Teams/Edit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
Layout = "_teamLayout.cshtml";
}

<h2>Edit</h2>
<h2>@Html.DisplayFor(model => model.Team.Name) - Edit</h2>
<div>
<a asp-page="./Details" asp-route-id="@Model.Team.ID">Cancel</a>
</div>

<h4>Team</h4>
<hr />
Expand Down Expand Up @@ -51,10 +54,6 @@
</div>
</div>

<div>
<a asp-page="./Index">Back to List</a>
</div>

@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
2 changes: 1 addition & 1 deletion ServerCore/Pages/Teams/Hints.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/{eventId}/Teams/Hints"
@page "/{eventId}/{eventRole}/Teams/Hints"
@model ServerCore.Pages.Teams.HintsModel

@{
Expand Down
15 changes: 9 additions & 6 deletions ServerCore/Pages/Teams/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@
@Html.DisplayFor(modelItem => item.SecondaryPhoneNumber)
</td>
<td>
<a asp-page="./Edit" asp-route-id="@item.ID">Edit</a> |
<a asp-page="./Details" asp-route-id="@item.ID">Details</a> |
<a asp-page="./Delete" asp-route-id="@item.ID">Delete</a> |
<a asp-page="./Play" asp-route-id="@item.ID">Play</a> |
<a asp-page="./Status" asp-route-id="@item.ID">Status</a> |
<a asp-page="./Members" asp-route-id="@item.ID">Members</a>
<a asp-page="./Status" asp-route-id="@item.ID">Status</a>
@if (Model.EventRole == ModelBases.EventRole.admin)
{
<div>
|
<a asp-page="./Details" asp-route-id="@item.ID">View</a> |
<a asp-page="./Members" asp-route-id="@item.ID">Members</a>
</div>
}
</td>
</tr>
}
Expand Down
14 changes: 4 additions & 10 deletions ServerCore/Pages/Teams/Members.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
Layout = "_teamLayout.cshtml";
}

<h2>Team Members</h2>
<h2>@Html.DisplayFor(model => model.Team.Name) - Members</h2>

<h4>Team: @Model.Team.Name</h4>
<h4>ID: @Model.Team.ID</h4>
<div>
<a asp-page="./AddMember" asp-route-teamId="@Model.Team.ID">Add a member</a>
</div>

<table class="table">
<thead>
Expand Down Expand Up @@ -50,10 +51,3 @@

<p>@Model.Emails</p>

<div>
<a asp-page="./AddMember" asp-route-teamId="@Model.Team.ID">Add a member</a>
</div>

<div>
<a asp-page="./Index">Back to team list</a>
</div>
2 changes: 1 addition & 1 deletion ServerCore/Pages/Teams/Members.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<IActionResult> OnGetAsync(int id)
StringBuilder emailList = new StringBuilder("");
foreach (TeamMembers Member in Members)
{
emailList.Append(Member.Member.Email + "; ");
//TODO - figure out why this isn't working: emailList.Append(Member.Member.Email + "; ");
}
Emails = emailList.ToString();

Expand Down
2 changes: 1 addition & 1 deletion ServerCore/Pages/Teams/Status.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Layout = "_teamLayout.cshtml";
}

<h2>Puzzle Status for @Model.Team.Name</h2>
<h2>@Html.DisplayFor(model => model.Team.Name) - Status</h2>

<table class="table">
<thead>
Expand Down
29 changes: 22 additions & 7 deletions ServerCore/Pages/Teams/_teamLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,28 @@

@{ Layout = "../Shared/_Layout.cshtml"; }

Current team ID: @Model.Team.ID ||
<a asp-page="./Index">Back to team list</a> ||
<a asp-page="./Edit" asp-route-id="@Model.Team.ID">Edit</a> |
<a asp-page="./Details" asp-route-id="@Model.Team.ID">Details</a> |
<a asp-page="./Delete" asp-route-id="@Model.Team.ID">Delete</a> |
<a asp-page="./Status" asp-route-id="@Model.Team.ID">Status</a> |
<a asp-page="./Members" asp-route-id="@Model.Team.ID">Members</a>
@if (Model.EventRole == ModelBases.EventRole.admin)
{
<div>
<a asp-page="./Index">Back to team list</a> ||
<a asp-page="./Details" asp-route-id="@Model.Team.ID">Details</a> |
<a asp-page="./Members" asp-route-id="@Model.Team.ID">Members</a> |
<a asp-page="./Status" asp-route-id="@Model.Team.ID">Status</a>
</div>
}
@if (Model.EventRole == ModelBases.EventRole.author)
{
<div>
<a asp-page="./Index">Back to team list</a>
</div>
}
@if (Model.EventRole == ModelBases.EventRole.play)
{
<div>
<a asp-page="./Details" asp-route-id="@Model.Team.ID">Details</a> |
<a asp-page="./Members" asp-route-id="@Model.Team.ID">Members</a>
</div>
}

<body>
<div>
Expand Down