diff --git a/Web/DAL/DataService.cs b/Web/DAL/DataService.cs index ff1b3de..90e5533 100644 --- a/Web/DAL/DataService.cs +++ b/Web/DAL/DataService.cs @@ -663,6 +663,10 @@ namespace MileageTraker.Web.DAL { fuelLogs = fuelLogs.Where(l => l.Log == null); } + if (!string.IsNullOrEmpty(query.TagNumber)) + { + fuelLogs = fuelLogs.Where(l => l.TagNumber == query.TagNumber); + } return fuelLogs; } @@ -842,8 +846,10 @@ namespace MileageTraker.Web.DAL var start = new DateTime(query.Year.Value, query.Month.Value, 1); var monthRange = query.MonthRange.HasValue ? query.MonthRange.Value : 1; var end = start.AddMonths(monthRange); - vehicleServices = vehicleServices.Where(l => l.InvoiceDate >= start && l.InvoiceDate < end); + vehicleServices = vehicleServices.Where(vs => vs.InvoiceDate >= start && vs.InvoiceDate < end); } + if (!string.IsNullOrEmpty(query.VehicleId)) + vehicleServices = vehicleServices.Where(vs => vs.Vehicle.VehicleId == query.VehicleId); return vehicleServices; } diff --git a/Web/Scripts/Shared/Site.js b/Web/Scripts/Shared/Site.js index e494f2c..094384b 100644 --- a/Web/Scripts/Shared/Site.js +++ b/Web/Scripts/Shared/Site.js @@ -151,6 +151,8 @@ var matchCountFunc = function() { } else { $link.append(" 0"); } + $link + .append(' '); } }); }; @@ -233,8 +235,15 @@ function addButtonIcons () { .prepend(' '); } + +function addTargetBlankIcon() { + $("a[target='_blank']:not(:has(i:last-child))") + .append(' '); +} + $(function () { addButtonIcons(); + addTargetBlankIcon(); }); // Convert MVC3 WebGrid paging to Bootstrap diff --git a/Web/ViewModels/FuelLog/FuelLogQueryViewModel.cs b/Web/ViewModels/FuelLog/FuelLogQueryViewModel.cs index 16fe71d..5843262 100644 --- a/Web/ViewModels/FuelLog/FuelLogQueryViewModel.cs +++ b/Web/ViewModels/FuelLog/FuelLogQueryViewModel.cs @@ -3,5 +3,19 @@ namespace MileageTraker.Web.ViewModels.FuelLog public class FuelLogQueryViewModel : DateQueryViewModel { public bool Unmatched { get; set; } + + public string TagNumber { get; set; } + + public override string ToString() + { + if (string.IsNullOrEmpty(TagNumber)) + return base.ToString(); + return base.ToString() + "_" + TagNumber.Replace(' ', '-'); + } + + public override bool HasParameters() + { + return base.HasParameters() || !string.IsNullOrEmpty(TagNumber); + } } } \ No newline at end of file diff --git a/Web/ViewModels/FuelLog/FuelLogResultsViewModel.cs b/Web/ViewModels/FuelLog/FuelLogResultsViewModel.cs index fb79035..0e68079 100644 --- a/Web/ViewModels/FuelLog/FuelLogResultsViewModel.cs +++ b/Web/ViewModels/FuelLog/FuelLogResultsViewModel.cs @@ -22,6 +22,7 @@ namespace MileageTraker.Web.ViewModels.FuelLog public string Month { get; set; } public string MonthRange { get; set; } public bool Unmatched { get; set; } + public string TagNumber { get; set; } public FuelLogResultsViewModel( IEnumerable fuelLogs, @@ -34,6 +35,7 @@ namespace MileageTraker.Web.ViewModels.FuelLog Month = query.Month.HasValue ? query.Month.Value.ToString(CultureInfo.InvariantCulture) : string.Empty; MonthRange = query.MonthRange.HasValue ? query.MonthRange.Value.ToString(CultureInfo.InvariantCulture) : string.Empty; Unmatched = query.Unmatched; + TagNumber = query.TagNumber; } } } \ No newline at end of file diff --git a/Web/ViewModels/VehicleService/VehicleServiceQueryViewModel.cs b/Web/ViewModels/VehicleService/VehicleServiceQueryViewModel.cs index 859dd3c..9ac1e92 100644 --- a/Web/ViewModels/VehicleService/VehicleServiceQueryViewModel.cs +++ b/Web/ViewModels/VehicleService/VehicleServiceQueryViewModel.cs @@ -2,5 +2,18 @@ namespace MileageTraker.Web.ViewModels.VehicleService { public class VehicleServiceQueryViewModel : DateQueryViewModel { + public string VehicleId { get; set; } + + public override string ToString() + { + if (string.IsNullOrEmpty(VehicleId)) + return base.ToString(); + return base.ToString() + "_" + VehicleId.Replace(' ', '-'); + } + + public override bool HasParameters() + { + return base.HasParameters() || !string.IsNullOrEmpty(VehicleId); + } } } \ No newline at end of file diff --git a/Web/ViewModels/VehicleService/VehicleServiceResultsViewModel.cs b/Web/ViewModels/VehicleService/VehicleServiceResultsViewModel.cs index a5dc36d..66b7c7f 100644 --- a/Web/ViewModels/VehicleService/VehicleServiceResultsViewModel.cs +++ b/Web/ViewModels/VehicleService/VehicleServiceResultsViewModel.cs @@ -23,6 +23,7 @@ namespace MileageTraker.Web.ViewModels.VehicleService public string Year { get; set; } public string Month { get; set; } public string MonthRange { get; set; } + public string VehicleId { get; set; } public VehicleServiceResultsViewModel( IEnumerable serviceItems, @@ -36,6 +37,7 @@ namespace MileageTraker.Web.ViewModels.VehicleService Year = query.Year.HasValue ? query.Year.Value.ToString(CultureInfo.InvariantCulture) : string.Empty; Month = query.Month.HasValue ? query.Month.Value.ToString(CultureInfo.InvariantCulture) : string.Empty; MonthRange = query.MonthRange.HasValue ? query.MonthRange.Value.ToString(CultureInfo.InvariantCulture) : string.Empty; + VehicleId = query.VehicleId; } } } diff --git a/Web/Views/FuelLog/Index.cshtml b/Web/Views/FuelLog/Index.cshtml index 5b10df3..6c5d6f0 100644 --- a/Web/Views/FuelLog/Index.cshtml +++ b/Web/Views/FuelLog/Index.cshtml @@ -5,7 +5,7 @@ @{ ViewBag.Title = "Fuel Logs"; var grid = new WebGrid(Model.FuelLogs, rowsPerPage: 45); - var queryParams = new {FiscalYear = Model.Year, Model.Month, Model.Unmatched}; + var queryParams = new {FiscalYear = Model.Year, Model.Month, Model.Unmatched, Model.TagNumber}; } @section Scripts { @@ -21,7 +21,7 @@ @Html.Partial("_StatusMessage") -
+
@using (Html.BeginForm("Index", "FuelLog", FormMethod.Get, new { id = "filter", @class = "form" })) { @Html.EditorForModel() diff --git a/Web/Views/Shared/EditorTemplates/FuelLogResultsViewModel.cshtml b/Web/Views/Shared/EditorTemplates/FuelLogResultsViewModel.cshtml index a468305..089d727 100644 --- a/Web/Views/Shared/EditorTemplates/FuelLogResultsViewModel.cshtml +++ b/Web/Views/Shared/EditorTemplates/FuelLogResultsViewModel.cshtml @@ -3,7 +3,7 @@ @model MileageTraker.Web.ViewModels.FuelLog.FuelLogResultsViewModel
-
+
@Html.Label("Year", "Year") @Html.DropDownList("Year", new SelectList(Model.AvailableYearMonths.Keys, Model.Year), "Select Year", new { @class = "input-small" })
@@ -15,7 +15,11 @@ @Html.Label("MonthRange", "Range") @Html.DropDownList("MonthRange", new SelectList(Enumerable.Range(1,12), Model.MonthRange), new { @class = "input-mini" })
-
+
+ @Html.Label("TagNumber", "Tag Number") + @Html.TextBoxFor(m => m.TagNumber, new {@class="search-query input-mini", placeholder="Vehicle"}) +
+
@Html.Label("Unmatched", "Unmatched Only", new{style = "padding-top:22px"})
diff --git a/Web/Views/Shared/EditorTemplates/VehicleServiceResultsViewModel.cshtml b/Web/Views/Shared/EditorTemplates/VehicleServiceResultsViewModel.cshtml index 52cd093..931d972 100644 --- a/Web/Views/Shared/EditorTemplates/VehicleServiceResultsViewModel.cshtml +++ b/Web/Views/Shared/EditorTemplates/VehicleServiceResultsViewModel.cshtml @@ -3,11 +3,11 @@ @model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceResultsViewModel
-
+
@Html.Label("Year", "Year") @Html.DropDownList("Year", new SelectList(Model.AvailableYearMonths.Keys, Model.Year), "Select Year", new { @class = "input-small" })
-
+
@Html.Label("Month", "Month") @Html.DropDownList("Month", new SelectList(Model.SelectedYearMonths, Model.Month), "All Months", new { @class = "input-small" })
@@ -15,6 +15,10 @@ @Html.Label("MonthRange", "Range") @Html.DropDownList("MonthRange", new SelectList(Enumerable.Range(1,12), Model.MonthRange), new { @class = "input-mini" })
+
+ @Html.Label("VehicleId", "Vehicle Id") + @Html.TextBoxFor(m => m.VehicleId, new {@class="search-query input-mini", placeholder="Vehicle"}) +
diff --git a/Web/Views/VehicleService/Index.cshtml b/Web/Views/VehicleService/Index.cshtml index 02e8abb..82e1e91 100644 --- a/Web/Views/VehicleService/Index.cshtml +++ b/Web/Views/VehicleService/Index.cshtml @@ -3,7 +3,7 @@ @{ ViewBag.Title = "Vehicle Service"; var grid = new WebGrid(Model.ServiceItems, rowsPerPage: 45); - var queryParams = new { Model.Year, Model.Month, Model.MonthRange }; + var queryParams = new { Model.Year, Model.Month, Model.MonthRange, Model.VehicleId }; } @section Scripts { @@ -19,7 +19,7 @@ @Html.Partial("_StatusMessage") -
+
@using (Html.BeginForm("Index", "VehicleService", FormMethod.Get, new { id = "filter", @class = "form" })) { @Html.EditorForModel()