Add vehicle active/inactive state
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
@using System.Globalization
|
||||
@model DateTime
|
||||
@model DateTime?
|
||||
@{
|
||||
Layout = "~/Views/Shared/DisplayTemplates/_FieldLayout.cshtml";
|
||||
var val =
|
||||
ViewData.ModelMetadata.DisplayFormatString != null
|
||||
?string.Format(ViewData.ModelMetadata.DisplayFormatString, Model)
|
||||
: Model.ToString(CultureInfo.InvariantCulture);
|
||||
Model.HasValue
|
||||
?
|
||||
ViewData.ModelMetadata.DisplayFormatString != null
|
||||
? string.Format(ViewData.ModelMetadata.DisplayFormatString, Model)
|
||||
: Model.Value.ToString(CultureInfo.InvariantCulture)
|
||||
: string.Empty;
|
||||
}
|
||||
@Html.Encode(val)
|
||||
@if (Model == null)
|
||||
{
|
||||
@Html.Encode(@ViewData.ModelMetadata.NullDisplayText)
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.Encode(val)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
@foreach (var prop in ViewData.ModelMetadata.Properties.Where(pm => pm.ShowForDisplay && !pm.HideSurroundingHtml && !pm.ModelType.IsCollection()))
|
||||
@foreach (var prop in ViewData.ModelMetadata.Properties.Where(
|
||||
pm => pm.ShowForDisplay
|
||||
&& !pm.HideSurroundingHtml
|
||||
&& !pm.ModelType.IsCollection()
|
||||
))
|
||||
{
|
||||
@Html.Display(prop.PropertyName)
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
@model DateTime
|
||||
@model DateTime?
|
||||
@{
|
||||
Layout = "~/Views/Shared/EditorTemplates/_FieldLayout.cshtml";
|
||||
var inputSize = (string)ViewData.ModelMetadata.AdditionalValues["InputSize"];
|
||||
var val =
|
||||
Model.HasValue
|
||||
? Model.Value.ToShortDateString()
|
||||
: string.Empty;
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(inputSize))
|
||||
{
|
||||
@Html.TextBox("", (Model != DateTime.MinValue ? Model.ToShortDateString() : string.Empty ), new { @class = inputSize})
|
||||
@Html.TextBox("", (Model != DateTime.MinValue ? val : string.Empty ), new { @class = inputSize})
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.TextBox("", (Model != DateTime.MinValue ? Model.ToShortDateString() : string.Empty ))
|
||||
@Html.TextBox("", (Model != DateTime.MinValue ? val : string.Empty ))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@model MileageTraker.Web.Models.Vehicle
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Vehicle Details";
|
||||
ViewBag.Title = "Vehicle Details " + (!Model.InactiveDate.HasValue ? "(Active)" : "(Inactive)");
|
||||
}
|
||||
|
||||
@section Styles {
|
||||
@@ -20,5 +20,13 @@
|
||||
|
||||
<div class="center-content btn-toolbar">
|
||||
@Html.ActionLink("Edit", "Edit", new { id = Model.VehicleId }, new { @class = "btn" })
|
||||
@if (!Model.InactiveDate.HasValue)
|
||||
{
|
||||
@Html.ActionLink("Set Inactive", "SetInactive", new {id = Model.VehicleId}, new {@class = "btn"})
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.ActionLink("Reactivate", "SetActive", new {id = Model.VehicleId}, new {@class = "btn"})
|
||||
}
|
||||
@Html.ActionLink("Logs", "Index", "Log", new { Model.VehicleId}, new { @class = "btn" })
|
||||
</div>
|
||||
@@ -1,7 +1,7 @@
|
||||
@model IEnumerable<MileageTraker.Web.Models.Vehicle>
|
||||
@model MileageTraker.Web.ViewModels.Vehicle.VehicleResultsViewModel
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Vehicles";
|
||||
ViewBag.Title = "Vehicles " + (!Model.Inactive ? "(Active)" : "(Inactive)");
|
||||
}
|
||||
|
||||
@section Styles {
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
<div class="btn-toolbar">
|
||||
@Html.ActionLink("Add Another Vehicle", "Create", null, new{@class="btn"})
|
||||
@Html.ActionLink("Export", "Export", null, new { @class = "btn" })
|
||||
@Html.ActionLink("Export All", "Export", null, new { @class = "btn" })
|
||||
@Html.ActionLink(Model.Inactive ? "Show Active" : "Show Inactive", "Index", new {inactive = !Model.Inactive}, new { @class = "btn" })
|
||||
</div>
|
||||
<table class="table table-striped table-bordered table-hover table-condensed">
|
||||
<tr>
|
||||
@@ -51,7 +52,7 @@
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
@foreach (var item in Model.Vehicles) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayTextFor(m => item.Key)
|
||||
|
||||
Reference in New Issue
Block a user