added setting to hide zero costs with dashes

This commit is contained in:
DESKTOP-GENO133\IvanPlex 2024-01-08 11:24:51 -07:00
parent 859796cfe8
commit 2ef281bd0a
8 changed files with 19 additions and 7 deletions

View File

@ -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);
}

View File

@ -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;}
}

View File

@ -24,6 +24,10 @@
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="useDescending" checked="@Model.UseDescending">
<label class="form-check-label" for="useDescending">Sort lists in Descending Order(Newest to Oldest)</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="hideZero" checked="@Model.HideZero">
<label class="form-check-label" for="hideZero">Replace @(0.ToString("C")) Costs with ---</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input" onChange="enableAuthCheckChanged()" type="checkbox" role="switch" id="enableAuth" checked="@Model.EnableAuth">
<label class="form-check-label" for="enableAuth">Enable Authentication</label>
@ -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) {

View File

@ -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<CollisionRecord>
<div class="row">
@ -48,7 +49,7 @@
<td class="col-1">@collisionRecord.Date.ToShortDateString()</td>
<td class="col-2">@collisionRecord.Mileage</td>
<td class="col-4">@collisionRecord.Description</td>
<td class="col-2">@collisionRecord.Cost.ToString("C")</td>
<td class="col-2">@((hideZero && collisionRecord.Cost == default) ? "---" : collisionRecord.Cost.ToString("C"))</td>
<td class="col-3 text-truncate">@collisionRecord.Notes</td>
</tr>
}

View File

@ -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 @@
<td class="col-2">@gasRecord.Mileage</td>
<td class="col-2">@gasRecord.Gallons.ToString("F")</td>
<td class="col-4">@(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F"))</td>
<td class="col-1">@gasRecord.Cost.ToString("C3")</td>
<td class="col-1">@gasRecord.CostPerGallon.ToString("C3")</td>
<td class="col-1">@((hideZero && gasRecord.Cost == default) ? "---" : gasRecord.Cost.ToString("C3"))</td>
<td class="col-1">@((hideZero && gasRecord.CostPerGallon == default) ? "---" : gasRecord.CostPerGallon.ToString("C3"))</td>
</tr>
}
</tbody>

View File

@ -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<ServiceRecord>
<div class="row">
@ -48,7 +49,7 @@
<td class="col-1">@serviceRecord.Date.ToShortDateString()</td>
<td class="col-2">@serviceRecord.Mileage</td>
<td class="col-4">@serviceRecord.Description</td>
<td class="col-2">@serviceRecord.Cost.ToString("C")</td>
<td class="col-2">@((hideZero && serviceRecord.Cost == default) ? "---" : serviceRecord.Cost.ToString("C"))</td>
<td class="col-3 text-truncate">@serviceRecord.Notes</td>
</tr>
}

View File

@ -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<TaxRecord>
<div class="row">
@ -46,7 +47,7 @@
<tr class="d-flex" style="cursor:pointer;" onclick="showEditTaxRecordModal(@taxRecord.Id)">
<td class="col-1">@taxRecord.Date.ToShortDateString()</td>
<td class="col-6">@taxRecord.Description</td>
<td class="col-2">@taxRecord.Cost.ToString("C")</td>
<td class="col-2">@((hideZero && taxRecord.Cost == default) ? "---" : taxRecord.Cost.ToString("C"))</td>
<td class="col-3 text-truncate">@taxRecord.Notes</td>
</tr>
}

View File

@ -11,6 +11,7 @@
"UseMPG": true,
"UseDescending": false,
"EnableAuth": false,
"HideZero": false,
"UserNameHash": "",
"UserPasswordHash": ""
}