From 2ef281bd0a4cb1eb45d1600f7129a39e2fbb99a3 Mon Sep 17 00:00:00 2001 From: "DESKTOP-GENO133\\IvanPlex" Date: Mon, 8 Jan 2024 11:24:51 -0700 Subject: [PATCH] added setting to hide zero costs with dashes --- Controllers/HomeController.cs | 3 ++- Models/UserConfig.cs | 1 + Views/Home/_Settings.cshtml | 7 ++++++- Views/Vehicle/_CollisionRecords.cshtml | 3 ++- Views/Vehicle/_Gas.cshtml | 5 +++-- Views/Vehicle/_ServiceRecords.cshtml | 3 ++- Views/Vehicle/_TaxRecords.cshtml | 3 ++- appsettings.json | 1 + 8 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index dad44ec..86d2f70 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -45,7 +45,8 @@ namespace CarCareTracker.Controllers UseDarkMode = bool.Parse(_config[nameof(UserConfig.UseDarkMode)]), UseMPG = bool.Parse(_config[nameof(UserConfig.UseMPG)]), UseDescending = bool.Parse(_config[nameof(UserConfig.UseDescending)]), - EnableAuth = bool.Parse(_config[nameof(UserConfig.EnableAuth)]) + EnableAuth = bool.Parse(_config[nameof(UserConfig.EnableAuth)]), + HideZero = bool.Parse(_config[nameof(UserConfig.HideZero)]) }; return PartialView("_Settings", userConfig); } diff --git a/Models/UserConfig.cs b/Models/UserConfig.cs index b3cd48c..2e80932 100644 --- a/Models/UserConfig.cs +++ b/Models/UserConfig.cs @@ -7,6 +7,7 @@ public bool UseMPG { get; set; } public bool UseDescending { get; set; } public bool EnableAuth { get; set; } + public bool HideZero { get; set; } public string UserNameHash { get; set; } public string UserPasswordHash { get; set;} } diff --git a/Views/Home/_Settings.cshtml b/Views/Home/_Settings.cshtml index ee79800..160d24a 100644 --- a/Views/Home/_Settings.cshtml +++ b/Views/Home/_Settings.cshtml @@ -24,6 +24,10 @@ +
+ + +
@@ -76,7 +80,8 @@ useDarkMode: $("#enableDarkMode").is(':checked'), enableCsvImports: $("#enableCsvImports").is(':checked'), useMPG: $("#useMPG").is(':checked'), - useDescending: $("#useDescending").is(':checked') + useDescending: $("#useDescending").is(':checked'), + hideZero: $("#hideZero").is(":checked") } $.post('/Home/WriteToSettings', { userConfig: userConfigObject}, function(data){ if (data) { diff --git a/Views/Vehicle/_CollisionRecords.cshtml b/Views/Vehicle/_CollisionRecords.cshtml index b1e2932..1071ea0 100644 --- a/Views/Vehicle/_CollisionRecords.cshtml +++ b/Views/Vehicle/_CollisionRecords.cshtml @@ -1,6 +1,7 @@ @inject IConfiguration Configuration @{ var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]); + var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); } @model List
@@ -48,7 +49,7 @@ @collisionRecord.Date.ToShortDateString() @collisionRecord.Mileage @collisionRecord.Description - @collisionRecord.Cost.ToString("C") + @((hideZero && collisionRecord.Cost == default) ? "---" : collisionRecord.Cost.ToString("C")) @collisionRecord.Notes } diff --git a/Views/Vehicle/_Gas.cshtml b/Views/Vehicle/_Gas.cshtml index b12294f..a861433 100644 --- a/Views/Vehicle/_Gas.cshtml +++ b/Views/Vehicle/_Gas.cshtml @@ -3,6 +3,7 @@ @{ var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]); var useMPG = bool.Parse(Configuration[nameof(UserConfig.UseMPG)]); + var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); var useKwh = Model.UseKwh; string consumptionUnit; string fuelEconomyUnit; @@ -66,8 +67,8 @@ @gasRecord.Mileage @gasRecord.Gallons.ToString("F") @(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F")) - @gasRecord.Cost.ToString("C3") - @gasRecord.CostPerGallon.ToString("C3") + @((hideZero && gasRecord.Cost == default) ? "---" : gasRecord.Cost.ToString("C3")) + @((hideZero && gasRecord.CostPerGallon == default) ? "---" : gasRecord.CostPerGallon.ToString("C3")) } diff --git a/Views/Vehicle/_ServiceRecords.cshtml b/Views/Vehicle/_ServiceRecords.cshtml index 139ef9d..447648d 100644 --- a/Views/Vehicle/_ServiceRecords.cshtml +++ b/Views/Vehicle/_ServiceRecords.cshtml @@ -1,6 +1,7 @@ @inject IConfiguration Configuration @{ var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]); + var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); } @model List
@@ -48,7 +49,7 @@ @serviceRecord.Date.ToShortDateString() @serviceRecord.Mileage @serviceRecord.Description - @serviceRecord.Cost.ToString("C") + @((hideZero && serviceRecord.Cost == default) ? "---" : serviceRecord.Cost.ToString("C")) @serviceRecord.Notes } diff --git a/Views/Vehicle/_TaxRecords.cshtml b/Views/Vehicle/_TaxRecords.cshtml index 02c6fde..5c795b1 100644 --- a/Views/Vehicle/_TaxRecords.cshtml +++ b/Views/Vehicle/_TaxRecords.cshtml @@ -1,6 +1,7 @@ @inject IConfiguration Configuration @{ var enableCsvImports = bool.Parse(Configuration[nameof(UserConfig.EnableCsvImports)]); + var hideZero = bool.Parse(Configuration[nameof(UserConfig.HideZero)]); } @model List
@@ -46,7 +47,7 @@ @taxRecord.Date.ToShortDateString() @taxRecord.Description - @taxRecord.Cost.ToString("C") + @((hideZero && taxRecord.Cost == default) ? "---" : taxRecord.Cost.ToString("C")) @taxRecord.Notes } diff --git a/appsettings.json b/appsettings.json index 6252e11..bf22a5e 100644 --- a/appsettings.json +++ b/appsettings.json @@ -11,6 +11,7 @@ "UseMPG": true, "UseDescending": false, "EnableAuth": false, + "HideZero": false, "UserNameHash": "", "UserPasswordHash": "" }