From 3c1ce805281dd86e216b7d33005937b5b27b2622 Mon Sep 17 00:00:00 2001 From: "DESKTOP-T0O5CDB\\DESK-555BD" Date: Tue, 19 Nov 2024 10:43:34 -0700 Subject: [PATCH] Added user setting for fixing gas consumption to two decimal places. --- Helper/ConfigHelper.cs | 1 + Models/UserConfig.cs | 1 + Views/Home/_Settings.cshtml | 4 ++++ Views/Vehicle/_Gas.cshtml | 4 +++- Views/Vehicle/_GasModal.cshtml | 8 +++++--- appsettings.json | 1 + wwwroot/defaults/en_US.json | 2 +- wwwroot/js/settings.js | 1 + 8 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Helper/ConfigHelper.cs b/Helper/ConfigHelper.cs index c54ef1c..0c1dbf0 100644 --- a/Helper/ConfigHelper.cs +++ b/Helper/ConfigHelper.cs @@ -195,6 +195,7 @@ namespace CarCareTracker.Helper UseUKMPG = bool.Parse(_config[nameof(UserConfig.UseUKMPG)]), UseMarkDownOnSavedNotes = bool.Parse(_config[nameof(UserConfig.UseMarkDownOnSavedNotes)]), UseThreeDecimalGasCost = bool.Parse(_config[nameof(UserConfig.UseThreeDecimalGasCost)]), + UseThreeDecimalGasConsumption = bool.Parse(_config[nameof(UserConfig.UseThreeDecimalGasConsumption)]), EnableAutoReminderRefresh = bool.Parse(_config[nameof(UserConfig.EnableAutoReminderRefresh)]), EnableAutoOdometerInsert = bool.Parse(_config[nameof(UserConfig.EnableAutoOdometerInsert)]), PreferredGasMileageUnit = _config[nameof(UserConfig.PreferredGasMileageUnit)], diff --git a/Models/UserConfig.cs b/Models/UserConfig.cs index 8dfcfab..1598bda 100644 --- a/Models/UserConfig.cs +++ b/Models/UserConfig.cs @@ -13,6 +13,7 @@ public bool HideZero { get; set; } public bool UseUKMPG {get;set;} public bool UseThreeDecimalGasCost { get; set; } + public bool UseThreeDecimalGasConsumption { get; set; } public bool UseMarkDownOnSavedNotes { get; set; } public bool EnableAutoReminderRefresh { get; set; } public bool EnableAutoOdometerInsert { get; set; } diff --git a/Views/Home/_Settings.cshtml b/Views/Home/_Settings.cshtml index b27733b..d0e1670 100644 --- a/Views/Home/_Settings.cshtml +++ b/Views/Home/_Settings.cshtml @@ -49,6 +49,10 @@ +
+ + +
diff --git a/Views/Vehicle/_Gas.cshtml b/Views/Vehicle/_Gas.cshtml index 5cc3173..5fcebf7 100644 --- a/Views/Vehicle/_Gas.cshtml +++ b/Views/Vehicle/_Gas.cshtml @@ -10,7 +10,9 @@ var useUKMPG = userConfig.UseUKMPG; var hideZero = userConfig.HideZero; var useThreeDecimals = userConfig.UseThreeDecimalGasCost; + var useThreeDecimalsConsumption = userConfig.UseThreeDecimalGasConsumption; var gasCostFormat = useThreeDecimals ? "C3" : "C2"; + var gasConsumptionFormat = useThreeDecimalsConsumption ? "F3" : "F2"; var userLanguage = userConfig.UserLanguage; var useKwh = Model.UseKwh; var useHours = Model.UseHours; @@ -192,7 +194,7 @@ @gasRecord.Date @(gasRecord.Mileage == default ? "---" : gasRecord.Mileage.ToString()) @(gasRecord.DeltaMileage == default ? "---" : gasRecord.DeltaMileage) - @gasRecord.Gallons.ToString("F") + @gasRecord.Gallons.ToString(gasConsumptionFormat) @(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F")) @((hideZero && gasRecord.Cost == default) ? "---" : gasRecord.Cost.ToString(gasCostFormat)) @((hideZero && gasRecord.CostPerGallon == default) ? "---" : gasRecord.CostPerGallon.ToString(gasCostFormat)) diff --git a/Views/Vehicle/_GasModal.cshtml b/Views/Vehicle/_GasModal.cshtml index b6c44e5..9fd493c 100644 --- a/Views/Vehicle/_GasModal.cshtml +++ b/Views/Vehicle/_GasModal.cshtml @@ -7,6 +7,8 @@ var useMPG = userConfig.UseMPG; var useUKMPG = userConfig.UseUKMPG; var userLanguage = userConfig.UserLanguage; + var useThreeDecimals = userConfig.UseThreeDecimalGasCost; + var useThreeDecimalsConsumption = userConfig.UseThreeDecimalGasConsumption; var useKwh = Model.UseKwh; var useHours = Model.UseHours; var isNew = Model.GasRecord.Id == 0; @@ -62,7 +64,7 @@ }
- +
@@ -75,7 +77,7 @@ @if (isNew) {
- +
+ }