diff --git a/Web/Content/Site.css b/Web/Content/Site.css index 8c66bfa..a0f8fe9 100644 --- a/Web/Content/Site.css +++ b/Web/Content/Site.css @@ -50,11 +50,23 @@ body { margin-bottom: 10px; } - .employeeName input { - width: 120px; - } - .form-horizontal .control-group.endOdometer { margin-bottom: 0; } + + .employeeName input { + width: 120px; + } +} + +@media (max-width: 767px) { + .dl-horizontal dt { + float: left; + width: 110px; + text-align: right; + } + + .dl-horizontal dd { + margin-left: 120px; + } } \ No newline at end of file diff --git a/Web/Scripts/Shared/Site.js b/Web/Scripts/Shared/Site.js index 681caf4..809342d 100644 --- a/Web/Scripts/Shared/Site.js +++ b/Web/Scripts/Shared/Site.js @@ -58,7 +58,7 @@ $(function () { }); }); - if ($("input#EmployeeName").length > 0) { + if ($("input#EmployeeName").filter(':not(:hidden)').length > 0) { $("input#EmployeeName") .after('') diff --git a/Web/Utility/CustomExtensions.cs b/Web/Utility/CustomExtensions.cs index 08771d2..caff8e2 100644 --- a/Web/Utility/CustomExtensions.cs +++ b/Web/Utility/CustomExtensions.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Linq.Expressions; using System.Reflection; using System.Text; using System.Web.Mvc; @@ -170,5 +171,15 @@ namespace MileageTraker.Web.Utility { return MvcHtmlString.Create(f + s); } + + public static MvcHtmlString DisplayNameFor( + this HtmlHelper htmlHelper, + Expression> expression + ) + { + var metaData = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData); + var value = metaData.DisplayName ?? (metaData.PropertyName ?? ExpressionHelper.GetExpressionText(expression)); + return MvcHtmlString.Create(value); + } } } \ No newline at end of file diff --git a/Web/Views/CreateLog/Confirm.cshtml b/Web/Views/CreateLog/Confirm.cshtml index e5b963b..6b447c2 100644 --- a/Web/Views/CreateLog/Confirm.cshtml +++ b/Web/Views/CreateLog/Confirm.cshtml @@ -1,9 +1,9 @@ +@using MileageTraker.Web.Utility @model MileageTraker.Web.ViewModels.ConfirmCreateLogViewModel @{ ViewBag.Title = "Confirm"; Layout = "~/Views/Shared/_Layout.cshtml"; - var endOdometerStyle = Model.PreviousOdometer != null ? "style=padding-bottom:0px;" : ""; } @section Styles { @@ -17,69 +17,92 @@

Please confirm - entry not complete until confirm clicked

@if (Model.Miles == 0) { -

Warning No mileage being logged - is this a duplicate?

+

Warning No mileage being logged - is this a duplicate?

} -
-
- @Html.LabelFor(model => model.VehicleId) -
-
- @Html.Encode(Model.VehicleId) (@Model.VehicleType) -
-
+
+
+ @Html.DisplayNameFor(m => m.VehicleId) +
+
+ @Html.DisplayTextFor(m => m.VehicleId) + @Html.DisplayTextFor(m => m.VehicleType) +
+
@Html.HiddenFor(m => m.VehicleId) -
-
- @Html.LabelFor(model => model.EndOdometer) -
-
- @Html.Encode(Model.EndOdometer) - @if (Model.PreviousOdometer != null) +
+
+ @Html.DisplayNameFor(m => m.EndOdometer) +
+
+ @Html.DisplayTextFor(m => m.EndOdometer) + @if (Model.PreviousOdometer.HasValue) {
- @Html.Encode(Model.Miles) miles since
- @Html.Encode(Model.PreviousOdometer) on @Html.Encode(Model.PreviousDate.Value.ToShortDateString())
+ + @if (Model.Miles > 0) + { + @Html.DisplayTextFor(m => m.Miles) miles + } + else + { + + @Html.DisplayTextFor(m => m.Miles) miles + + } + since @Html.DisplayTextFor(m => m.PreviousOdometer) + on @Html.Encode(Model.PreviousDate.Value.ToShortDateString()) + } -
-
- + + + @Html.HiddenFor(m => m.EndOdometer) + @Html.DisplayFor(model => model.LogType) @Html.HiddenFor(model => model.LogType.Value) - @Html.DisplayFor(model => model.EmployeeName) - - @Html.DisplayFor(model => model.CityName) - -
-
- @Html.LabelFor(model => model.GasPurchased) -
-
+ @Html.DisplayFor(model => model.EmployeeName) + @Html.HiddenFor(model => model.EmployeeName) + + @Html.DisplayFor(model => model.CityName) + @Html.HiddenFor(model => model.CityName) + +
+
+ @Html.DisplayNameFor(m => m.GasPurchased) +
+
@if (!string.IsNullOrEmpty(Model.GasPurchased)) { - @Model.GasPurchased Gallons + @Html.DisplayTextFor(m => m.GasPurchased) Gallons } else { No Gas Purchased } - -
-
-
-
- @Html.LabelFor(model => model.Date) -
-
- @Html.Encode(Model.Date) - (@Html.Encode(Model.DateHowLongAgo)) - -
-
- - - + + + @Html.HiddenFor(model => model.GasPurchased) + + +
+
+ @Html.DisplayNameFor(m => m.Date) +
+
+ @Html.DisplayTextFor(m => m.Date) + (@Html.DisplayTextFor(m => m.DateHowLongAgo)) +
+
+ @Html.HiddenFor(model => model.Date) + +
+
+ +
+
+ +
+
} diff --git a/Web/Views/CreateLog/Success.cshtml b/Web/Views/CreateLog/Success.cshtml index a05fa7b..7ce7e23 100644 --- a/Web/Views/CreateLog/Success.cshtml +++ b/Web/Views/CreateLog/Success.cshtml @@ -5,24 +5,16 @@ Layout = "~/Views/Shared/_Layout.cshtml"; } -@section Styles -{ - -} - @{ - @:
- @ViewBag.Title +

@ViewBag.Title

- You've successfully created an entry - for @Html.Encode(Model.EmployeeName) - traveling to @Html.Encode(Model.CityName) - on @Html.Encode(Model.Date) - in VehicleId @Html.Encode(Model.VehicleId) + You've successfully created an entry + for @Html.DisplayTextFor(m => m.EmployeeName) + traveling to @Html.DisplayTextFor(m => m.CityName) + on @Html.DisplayTextFor(m => m.Date) + in Vehicle Id @Html.DisplayTextFor(m => m.VehicleId)

- @Html.ActionLink("Create another", "Index", null, new { @class = "btn" }) + @Html.ActionLink("Create another", "Index", null, new { @class = "btn" })

- - @:
} \ No newline at end of file diff --git a/Web/Views/Log/MonthlyEmployeeMileage.cshtml b/Web/Views/Log/MonthlyEmployeeMileage.cshtml index d9a23dd..2aa4561 100644 --- a/Web/Views/Log/MonthlyEmployeeMileage.cshtml +++ b/Web/Views/Log/MonthlyEmployeeMileage.cshtml @@ -1,4 +1,5 @@ -@model MileageTraker.Web.ViewModels.EmployeeMileageViewModel +@using MileageTraker.Web.Utility +@model MileageTraker.Web.ViewModels.EmployeeMileageViewModel @{ ViewBag.Title = "Employee Mileage Report"; } @@ -16,11 +17,11 @@
-
Year
+
@Html.DisplayNameFor(m => m.Query.Year)
@Html.Encode(Model.Query.Year)
-
Month
+
@Html.DisplayNameFor(m => m.Query.Month)
@Html.Encode(Model.Query.Month)
@if (Model.Query.LogType.HasValue) diff --git a/Web/Views/Log/MonthlyVehicleMileage.cshtml b/Web/Views/Log/MonthlyVehicleMileage.cshtml index 3145f39..9aa4f50 100644 --- a/Web/Views/Log/MonthlyVehicleMileage.cshtml +++ b/Web/Views/Log/MonthlyVehicleMileage.cshtml @@ -1,4 +1,4 @@ -@using System.Globalization +@using MileageTraker.Web.Utility @model MileageTraker.Web.ViewModels.VehicleMileageViewModel @{ ViewBag.Title = "Vehicle Mileage Report"; @@ -17,11 +17,11 @@
-
Year
+
@Html.DisplayNameFor(m => m.Query.Year)
@Html.Encode(Model.Query.Year)
-
Month
+
@Html.DisplayNameFor(m => m.Query.Month)
@Html.Encode(Model.Query.Month)
@if (Model.Query.LogType.HasValue) diff --git a/Web/Views/Vehicle/Index.cshtml b/Web/Views/Vehicle/Index.cshtml index b63893f..0649ad2 100644 --- a/Web/Views/Vehicle/Index.cshtml +++ b/Web/Views/Vehicle/Index.cshtml @@ -21,7 +21,7 @@ Key - EthraId + Ethra Id Model Yr @@ -36,7 +36,7 @@ Type - TagNumber + Tag Number Prog @@ -67,8 +67,10 @@ @Html.DisplayTextFor(m => item.CarModel) - - @Html.DisplayTextFor(m => item.Type) + + + @Html.DisplayTextFor(m => item.Type) + @Html.DisplayTextFor(m => item.TagNumber)