make history table cells align in the middle rather than top (included in site.css)

correct bug in file upload where someone clicks upload without choosing a file!
added alternating icon in history table for expanding rows on click, will now show plus when minimised, minus when expanded.
This commit is contained in:
chris.watts90@outlook.com 2017-06-26 15:50:53 +01:00
parent 38cfb67f62
commit 7fbcba58ba
5 changed files with 60 additions and 37 deletions

View File

@ -38,27 +38,30 @@ namespace RaceLapTimer.ApiControllers
Directory.CreateDirectory(uploadDirectory);
}
var file = Request.Files.First();
var newFileName = Guid.NewGuid();
var generatedFileName = string.Format("{0}{1}", newFileName, Path.GetExtension(file.Name)); //0000-0000.....ext
var filename = Path.Combine(uploadDirectory, generatedFileName);
using (var fileStream = new FileStream(filename, FileMode.Create))
if (Request.Files.Any())
{
file.Value.CopyTo(fileStream);
fileStream.Flush();
fileStream.Close();
var file = Request.Files.First();
var newFileName = Guid.NewGuid();
var generatedFileName = string.Format("{0}{1}", newFileName, Path.GetExtension(file.Name)); //0000-0000.....ext
var filename = Path.Combine(uploadDirectory, generatedFileName);
using (var fileStream = new FileStream(filename, FileMode.Create))
{
file.Value.CopyTo(fileStream);
fileStream.Flush();
fileStream.Close();
}
pilot.ImageUrl = "/images/" + generatedFileName;
_provider.UpdatePilot(pilot);
File.Delete(Path.Combine(uploadDirectory, oldImagePath));
}
pilot.ImageUrl = "/images/" + generatedFileName;
_provider.UpdatePilot(pilot);
File.Delete(Path.Combine(uploadDirectory, oldImagePath));
string returnurl = "/pilot/edit/" + pilotId;
return Context.GetRedirect(returnurl);
return Context.GetRedirect(returnurl);
}
private dynamic DeletePilot(dynamic args)

View File

@ -166,7 +166,9 @@
<None Include="www\Views\EditPilot.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="www\Views\History.cshtml" />
<None Include="www\Views\History.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="www\Views\HistoryIndex.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@ -191,7 +193,9 @@
<None Include="www\Views\secure.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="www\Views\SystemIndex.cshtml" />
<None Include="www\Views\SystemIndex.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup />
<ItemGroup>
@ -218,6 +222,9 @@
<Content Include="www\css\login.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="www\css\site.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="www\css\stickyfooter.css">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -4,6 +4,7 @@
ViewBag.Title = "History";
}
<h3>@ViewBag.Title</h3>
<link rel="stylesheet" href="css/site.css"/>
<table class="table table-striped dataTable">
<thead>
@ -17,17 +18,19 @@
</tr>
</thead>
<tbody data-bind="foreach: sessions, visible: sessions().length > 0">
<tr data-toggle="collapse" data-bind="attr: { 'data-target': '#collapse' + id() }">
<td class="text-center" data-bind="text: id"></td>
<td class="col-md-2" data-bind="text: createdDate">June 16, 2017 19:07</td>
<td data-bind="text: title">Race Name 1</td>
<td class="col-md-1" data-bind="text: mode">standard</td>
<td class="text-center col-md-1" >5</td>
<tr data-toggle="collapse" data-bind="attr: { 'data-target': '#collapse' + id() }, click: function(){return $root.toggleIcon('#expIcon'+id())}">
<td class="text-center vertical-center"><span data-bind="text: id"></span></td>
<td class="col-md-2 vertical-center"><span data-bind="text: createdDate"></span></td>
<td class="vertical-center" data-bind="text: title">Race Name 1</td>
<td class="col-md-1 vertical-center" data-bind="text: mode">standard</td>
<td class="text-center col-md-1 vertical-center" >5</td>
<td class="col-md-3 text-center">
<button type="button" class="btn btn-warning" data-bind="click: $root.deleteSession">Delete</button>
<button type="button" class="btn btn-default">Export as PDF</button>
</td>
<td><span class="glyphicon glyphicon-plus"></span></td>
<td class="vertical-center">
<span data-bind="attr:{id:'expIcon'+id()}" class="glyphicon glyphicon-plus"></span>
</td>
</tr>
<tr class="collapse" data-bind="attr:{ id: 'collapse' + id()}">
<td colspan="6">

View File

@ -0,0 +1,3 @@
.table>tbody>tr>td.vertical-center {
vertical-align: middle;
}

View File

@ -13,19 +13,26 @@
var mappedSessions = $.map(allData.data, function (item) { return new RaceSession(item) });
self.sessions(mappedSessions);
});
self.toggleIcon = function(e) {
$(e).toggleClass("glyphicon-plus glyphicon-minus");
}
};
ko.applyBindings(new ViewModel());
function toggleIcon(e) {
$(e.target)
.toggleClass("glyphicon-plus glyphicon-minus");
}
$(".dataTable").on("hidden.bs.collapse",
function toggleIcon(e) {
$(e.target)
.toggleClass("glyphicon-plus glyphicon-minus");
});
$(".dataTable").on("shown.bs.collapse",
function toggleIcon(e) {
$(e.target)
.toggleClass("glyphicon-plus glyphicon-minus");
});
//$(".dataTable").on("hidden.bs.collapse",
// function toggleIcon(e) {
// $(e.target)
// .find("tr.collapse")
// .find("td")
// .toggleClass("glyphicon-plus glyphicon-minus");
// });
//$(".dataTable").on("shown.bs.collapse",
// function toggleIcon(e) {
// $(e.target)
// .find("tr.collapse")
// .find("td")
// .toggleClass("glyphicon-plus glyphicon-minus");
// });