Skip to content

Commit

Permalink
Merge pull request #49 from reidst/style
Browse files Browse the repository at this point in the history
Style
  • Loading branch information
k-atej authored Dec 11, 2023
2 parents 188c3fd + ce6448c commit e29f008
Show file tree
Hide file tree
Showing 13 changed files with 174 additions and 69 deletions.
2 changes: 2 additions & 0 deletions Models/ListItems.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
Expand All @@ -13,6 +14,7 @@ public class ListItems
[StringLength(255)]
public int? LocationID { get; set; }
[DataType(DataType.Date)]
[DisplayName("Date Added")]
public DateTime TimeDiscovered { get; set; }
[ForeignKey("KewID")]
public Taxa? Plant { get; set; }
Expand Down
11 changes: 5 additions & 6 deletions Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
var randomImage = new Array();
// can add as whatever images as we want
randomImage[0] = "https://images.unsplash.com/photo-1487700160041-babef9c3cb55?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8NHx8cGxhbnQlMjB3aGl0ZXxlbnwwfHwwfHx8MA%3D%3D&w=1000&q=80"
randomImage[1] = "https://images.unsplash.com/photo-1536762131871-17373957273e?q=80&w=2940&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
randomImage[2] = "https://images.unsplash.com/photo-1431263154979-0982327fccbb?q=80&w=2670&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
randomImage[3] = "https://images.unsplash.com/photo-1516613835066-91cb1a42dda5?q=80&w=2940&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
randomImage[4] = "https://images.unsplash.com/photo-1562504979-5aee5dc1cc2c?q=80&w=2940&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
randomImage[5] = "https://images.unsplash.com/photo-1606922604118-c1aff542a1a9?q=80&w=2844&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
randomImage[0] = "https://images.unsplash.com/photo-1536762131871-17373957273e?q=80&w=2940&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
randomImage[1] = "https://images.unsplash.com/photo-1431263154979-0982327fccbb?q=80&w=2670&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
randomImage[2] = "https://images.unsplash.com/photo-1516613835066-91cb1a42dda5?q=80&w=2940&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
randomImage[3] = "https://images.unsplash.com/photo-1562504979-5aee5dc1cc2c?q=80&w=2940&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
randomImage[4] = "https://images.unsplash.com/photo-1606922604118-c1aff542a1a9?q=80&w=2844&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
var number = Math.floor(Math.random() * randomImage.length)
console.log();
Expand Down
6 changes: 5 additions & 1 deletion Pages/ListItems/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
ViewData["Title"] = "Create";
}

<h1>Create</h1>
<br>
<div id="header_box">
<h1 id="search_heading">Create</h1>
</div>
<br>

<h4>ListItems</h4>
<hr />
Expand Down
23 changes: 13 additions & 10 deletions Pages/ListItems/Delete.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,40 @@
ViewData["Title"] = "Delete";
}

<h1>Delete</h1>
<br>
<div id="header_box">
<h1 id="search_heading">Delete</h1>
</div>
<br>

<h3>Are you sure you want to delete this?</h3>
<div>
<h4>ListItems</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.TimeDiscovered)
@Html.DisplayNameFor(model => model.ListItems.TimeDiscovered):
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.TimeDiscovered)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.Plant)
@Html.DisplayNameFor(model => model.ListItems.Plant):
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.Plant.KewID)
@Html.DisplayFor(model => model.ListItems.Plant.Name)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.List)
@Html.DisplayNameFor(model => model.ListItems.List):
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.List.Id)
@Html.DisplayFor(model => model.ListItems.List.Name)
</dd>
<!--
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.Location)
@Html.DisplayNameFor(model => model.ListItems.Location):
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.Location.Id)
</dd>
</dd> -->
</dl>

<form method="post">
Expand Down
4 changes: 2 additions & 2 deletions Pages/ListItems/Delete.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async Task<IActionResult> OnGetAsync(string id)
return NotFound();
}

var listitems = await _context.ListItems.FirstOrDefaultAsync(m => m.KewID == id);
var listitems = await _context.ListItems.Include(l => l.Plant).Include(v => v.List).FirstOrDefaultAsync(m => m.KewID == id);

if (listitems == null)
{
Expand All @@ -49,7 +49,7 @@ public async Task<IActionResult> OnPostAsync(string id)
return NotFound();
}

var listitems = await _context.ListItems.FirstOrDefaultAsync(m => m.KewID == id);
var listitems = await _context.ListItems.Include(t => t.Plant).FirstOrDefaultAsync(m => m.KewID == id);

if (listitems != null)
{
Expand Down
54 changes: 45 additions & 9 deletions Pages/ListItems/Details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
ViewData["Title"] = "Details";
}

<h1>Details</h1>
<br>
<div id="header_box">
<h1 id="search_heading">Details</h1>
</div>
<br>

<div>
<h4>ListItems</h4>
<hr />
<dl class="row">
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.TimeDiscovered)
Expand All @@ -18,26 +20,60 @@
@Html.DisplayFor(model => model.ListItems.TimeDiscovered)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.Plant)
@Html.DisplayNameFor(model => model.ListItems.List)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.Plant.KewID)
@Html.DisplayFor(model => model.ListItems.List.Name)
</dd>
<hr>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.List)
@Html.DisplayNameFor(model => model.ListItems.Plant.Genus.Family.Category)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.Plant.Genus.Family.Category.Description)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.Plant.Genus.Family)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.Plant.Genus.FamilyID)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.Plant.Genus)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.Plant.GenusID)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.Plant.SpecificEpithet)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.Plant.SpecificEpithet)
</dd>
@if (Model.ListItems.Plant.InfraspecificEpithet != null) {
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.Plant.InfraspecificEpithet)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.Plant.InfraspecificEpithet)
</dd>
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.Plant.TaxonRank)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.List.Id)
@Html.DisplayFor(model => model.ListItems.Plant.TaxonRank)
</dd>
}

<!--
<dt class="col-sm-2">
@Html.DisplayNameFor(model => model.ListItems.Location)
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.ListItems.Location.Id)
</dd>
</dd> -->
</dl>
</div>
<div>
@Html.ActionLink("Edit", "Edit", new { /* id = Model.PrimaryKey */ }) |
<a asp-page="./Index" asp-route-itemid="@Model.ListItems.ListID">Back to List</a>
</div>
2 changes: 1 addition & 1 deletion Pages/ListItems/Details.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public async Task<IActionResult> OnGetAsync(string id)
return NotFound();
}

var listitems = await _context.ListItems.FirstOrDefaultAsync(m => m.KewID == id);
var listitems = await _context.ListItems.Include(l => l.Plant).Include(v => v.List).Include(g => g.Plant!.Genus).Include(f => f.Plant!.Genus!.Family).Include(c => c.Plant!.Genus!.Family!.Category).FirstOrDefaultAsync(m => m.KewID == id);
if (listitems == null)
{
return NotFound();
Expand Down
16 changes: 12 additions & 4 deletions Pages/ListItems/Edit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@
ViewData["Title"] = "Edit";
}

<h1>Edit</h1>
<br>
<div id="header_box">
<h1 id="search_heading">Edit</h1>
</div>
<br>

<h4>ListItems</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="ListItems.KewID" />
<input type="hidden" asp-for="ListItems.ListID" />
<div class="form-group">
<div class="form-group" id="hide">
<label asp-for="ListItems.LocationID" class="control-label"></label>
<select asp-for="ListItems.LocationID" class="form-control" asp-items="ViewBag.LocationID"></select>
<span asp-validation-for="ListItems.LocationID" class="text-danger"></span>
Expand All @@ -39,3 +41,9 @@
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

<style>
#hide {
display:none;
}
</style>
43 changes: 32 additions & 11 deletions Pages/ListItems/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
ViewData["Title"] = "Index";
}

<h1>@Model.ListItems[0].List.Name</h1>
@if (Model.ListItems.Count > 0) {

<p>
<a asp-page="/Search/Index">Search for more!</a>
</p>
<br>
<div id="header_box">
<h1 id="search_heading"> @Model.ListItems[0].List.Name</h1>
</div>
<br>
<table class="table">
<thead>
<tr>
Expand All @@ -19,9 +21,6 @@
<th>
@Html.DisplayNameFor(model => model.ListItems[0].Plant.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.ListItems[0].Location)
</th>
<th></th>
</tr>
</thead>
Expand All @@ -34,15 +33,37 @@
<td>
@Html.DisplayFor(modelItem => item.Plant.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Location.Id)
</td>
<td>
<a asp-page="/ListItems/Edit" asp-route-id="@item.Plant.KewID">Edit</a> |
<a asp-page="/Taxa/Details" asp-route-id="@item.Plant.KewID">Details</a> |
<a asp-page="/ListItems/Details" asp-route-id="@item.Plant.KewID">Details</a> |
<a asp-page="/ListItems/Delete" asp-route-id="@item.Plant.KewID">Delete</a>
</td>
</tr>
}
</tbody>
</table>
<p>
<a asp-page="/Search/Index">Search for more!</a>
</p>
<a asp-page="/Lists/Index">Return to My Lists!</a>
}
else{
<br>
<div id="header_box">
<h1 id="search_heading">List is Empty!</h1>
</div>
<br>

<p>
<a asp-page="/Search/Index">Search for Plants!</a>
</p>

<a asp-page="/Lists/Index">Return to My Lists!</a>
}

<style>
#header_box {
margin: auto;
text-align: center;
}
</style>
21 changes: 14 additions & 7 deletions Pages/Lists/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@
@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IdentityUser> UserManager

<h1>Create</h1>

<h4>Lists</h4>
<hr />
<br>
<div id="header_box">
<h1 id="search_heading">Create List</h1>
</div>
<hr>
<div class="row">
<div class="col-md-4">
<div class="col-md-4" id="cont">
<form method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="Lists.Name" class="control-label"></label>
<input asp-for="Lists.Name" class="form-control" />
<span asp-validation-for="Lists.Name" class="text-danger"></span>
</div>
<div class="form-group">
<div class="form-group" id="own">
<label asp-for="Lists.OwnerID" class="control-label"></label>
<input asp-for="Lists.OwnerID" value="@UserManager.GetUserId(User)" readonly />
</div>
Expand All @@ -33,11 +34,17 @@
</form>
</div>
</div>

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

@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}

<style>
#own{
display:none;
}
</style>
Loading

0 comments on commit e29f008

Please sign in to comment.