diff --git a/Helper/ConfigHelper.cs b/Helper/ConfigHelper.cs index 89bdd0e..437684f 100644 --- a/Helper/ConfigHelper.cs +++ b/Helper/ConfigHelper.cs @@ -140,6 +140,7 @@ namespace CarCareTracker.Helper PreferredGasUnit = _config[nameof(UserConfig.PreferredGasUnit)], UserLanguage = _config[nameof(UserConfig.UserLanguage)], EnableShopSupplies = bool.Parse(_config[nameof(UserConfig.EnableShopSupplies)]), + EnableExtraFieldColumns = bool.Parse(_config[nameof(UserConfig.EnableExtraFieldColumns)]), VisibleTabs = _config.GetSection("VisibleTabs").Get>(), DefaultTab = (ImportMode)int.Parse(_config[nameof(UserConfig.DefaultTab)]) }; diff --git a/Helper/GasHelper.cs b/Helper/GasHelper.cs index a71b5d5..d564cf2 100644 --- a/Helper/GasHelper.cs +++ b/Helper/GasHelper.cs @@ -71,7 +71,8 @@ namespace CarCareTracker.Helper IsFillToFull = currentObject.IsFillToFull, MissedFuelUp = currentObject.MissedFuelUp, Notes = currentObject.Notes, - Tags = currentObject.Tags + Tags = currentObject.Tags, + ExtraFields = currentObject.ExtraFields }; if (currentObject.MissedFuelUp) { @@ -124,7 +125,8 @@ namespace CarCareTracker.Helper IsFillToFull = currentObject.IsFillToFull, MissedFuelUp = currentObject.MissedFuelUp, Notes = currentObject.Notes, - Tags = currentObject.Tags + Tags = currentObject.Tags, + ExtraFields = currentObject.ExtraFields }); } previousMileage = currentObject.Mileage; diff --git a/Helper/StaticHelper.cs b/Helper/StaticHelper.cs index 098b4dc..e54cbd8 100644 --- a/Helper/StaticHelper.cs +++ b/Helper/StaticHelper.cs @@ -182,11 +182,20 @@ namespace CarCareTracker.Helper { return templateExtraFields; } - //append the fields. + var recordFieldNames = recordExtraFields.Select(x => x.Name); + //update isrequired setting foreach (ExtraField extraField in recordExtraFields) { extraField.IsRequired = templateExtraFields.Where(x => x.Name == extraField.Name).First().IsRequired; } + //append extra fields + foreach(ExtraField extraField in templateExtraFields) + { + if (!recordFieldNames.Contains(extraField.Name)) + { + recordExtraFields.Add(extraField); + } + } return recordExtraFields; } diff --git a/Models/GasRecord/GasRecordViewModel.cs b/Models/GasRecord/GasRecordViewModel.cs index 6086114..a4b3f30 100644 --- a/Models/GasRecord/GasRecordViewModel.cs +++ b/Models/GasRecord/GasRecordViewModel.cs @@ -22,6 +22,7 @@ public bool MissedFuelUp { get; set; } public string Notes { get; set; } public List Tags { get; set; } = new List(); + public List ExtraFields { get; set; } = new List(); public bool IncludeInAverage { get { return MilesPerGallon > 0 || (!IsFillToFull && !MissedFuelUp); } } } } diff --git a/Models/UserConfig.cs b/Models/UserConfig.cs index 5805f87..fb1d503 100644 --- a/Models/UserConfig.cs +++ b/Models/UserConfig.cs @@ -14,6 +14,7 @@ public bool EnableAutoReminderRefresh { get; set; } public bool EnableAutoOdometerInsert { get; set; } public bool EnableShopSupplies { get; set; } + public bool EnableExtraFieldColumns { get; set; } public string PreferredGasUnit { get; set; } = string.Empty; public string PreferredGasMileageUnit { get; set; } = string.Empty; public string UserNameHash { get; set; } diff --git a/Views/Home/_Settings.cshtml b/Views/Home/_Settings.cshtml index a730a66..d74d0a1 100644 --- a/Views/Home/_Settings.cshtml +++ b/Views/Home/_Settings.cshtml @@ -53,6 +53,10 @@ +
+ + +
@@ -287,6 +291,7 @@ enableAutoReminderRefresh: $("#enableAutoReminderRefresh").is(":checked"), enableAutoOdometerInsert: $("#enableAutoOdometerInsert").is(":checked"), enableShopSupplies: $("#enableShopSupplies").is(":checked"), + enableExtraFieldColumns: $("#enableExtraFieldColumns").is(":checked"), preferredGasUnit: $("#preferredGasUnit").val(), preferredGasMileageUnit: $("#preferredFuelMileageUnit").val(), userLanguage: $("#defaultLanguage").val(), diff --git a/Views/Vehicle/_CollisionRecords.cshtml b/Views/Vehicle/_CollisionRecords.cshtml index cd57214..7d6b98d 100644 --- a/Views/Vehicle/_CollisionRecords.cshtml +++ b/Views/Vehicle/_CollisionRecords.cshtml @@ -7,6 +7,11 @@ var hideZero = userConfig.HideZero; var recordTags = Model.SelectMany(x => x.Tags).Distinct(); var userLanguage = userConfig.UserLanguage; + var extraFields = new List(); + if (userConfig.EnableExtraFieldColumns) + { + extraFields = Model.SelectMany(x => x.ExtraFields).Select(y => y.Name).Distinct().ToList(); + } } @model List
@@ -38,6 +43,48 @@
  • @translator.Translate(userLanguage,"Export to CSV")
  • @translator.Translate(userLanguage,"Print")
  • +
  • +
  • + + + + + + @foreach (string extraFieldColumn in extraFields) + { + var elementId = Guid.NewGuid(); + + }
    } @@ -58,22 +105,30 @@ - - - - - + + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } @foreach (CollisionRecord collisionRecord in Model) { - - - - - + + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } } diff --git a/Views/Vehicle/_Gas.cshtml b/Views/Vehicle/_Gas.cshtml index 3f8abd3..8c3bd00 100644 --- a/Views/Vehicle/_Gas.cshtml +++ b/Views/Vehicle/_Gas.cshtml @@ -29,7 +29,8 @@ { consumptionUnit = "imp gal"; fuelEconomyUnit = useHours ? "h/g" : "mpg"; - } else if (useUKMPG) + } + else if (useUKMPG) { fuelEconomyUnit = useHours ? "l/100h" : "l/100mi."; consumptionUnit = "l"; @@ -40,26 +41,32 @@ consumptionUnit = useMPG ? "US gal" : "l"; fuelEconomyUnit = useHours ? (useMPG ? "h/g" : "l/100h") : (useMPG ? "mpg" : "l/100km"); } + var extraFields = new List(); + if (userConfig.EnableExtraFieldColumns) + { + extraFields = Model.GasRecords.SelectMany(x => x.ExtraFields).Select(y => y.Name).Distinct().ToList(); + } }
    - @($"{translator.Translate(userLanguage,"# of Gas Records")}: {Model.GasRecords.Count()}") + @($"{translator.Translate(userLanguage, "# of Gas Records")}: {Model.GasRecords.Count()}") @if (Model.GasRecords.Where(x => x.MilesPerGallon > 0).Any()) { - @($"{translator.Translate(userLanguage,"Average Fuel Economy")}: {gasHelper.GetAverageGasMileage(Model.GasRecords, useMPG)}") + @($"{translator.Translate(userLanguage, "Average Fuel Economy")}: {gasHelper.GetAverageGasMileage(Model.GasRecords, useMPG)}") if (useMPG) { - @($"{translator.Translate(userLanguage,"Min Fuel Economy")}: {Model.GasRecords.Where(y => y.MilesPerGallon > 0)?.Min(x => x.MilesPerGallon).ToString("F") ?? "0"}") - @($"{translator.Translate(userLanguage,"Max Fuel Economy")}: {Model.GasRecords.Max(x => x.MilesPerGallon).ToString("F") ?? "0"}") - } else + @($"{translator.Translate(userLanguage, "Min Fuel Economy")}: {Model.GasRecords.Where(y => y.MilesPerGallon > 0)?.Min(x => x.MilesPerGallon).ToString("F") ?? "0"}") + @($"{translator.Translate(userLanguage, "Max Fuel Economy")}: {Model.GasRecords.Max(x => x.MilesPerGallon).ToString("F") ?? "0"}") + } + else { - @($"{translator.Translate(userLanguage,"Min Fuel Economy")}: {Model.GasRecords.Max(x => x.MilesPerGallon).ToString("F") ?? "0"}") - @($"{translator.Translate(userLanguage,"Max Fuel Economy")}: {Model.GasRecords.Where(y => y.MilesPerGallon > 0)?.Min(x => x.MilesPerGallon).ToString("F") ?? "0"}") + @($"{translator.Translate(userLanguage, "Min Fuel Economy")}: {Model.GasRecords.Max(x => x.MilesPerGallon).ToString("F") ?? "0"}") + @($"{translator.Translate(userLanguage, "Max Fuel Economy")}: {Model.GasRecords.Where(y => y.MilesPerGallon > 0)?.Min(x => x.MilesPerGallon).ToString("F") ?? "0"}") } } - @($"{translator.Translate(userLanguage,"Total Fuel Consumed")}: {Model.GasRecords.Sum(x => x.Gallons).ToString("F")}") - @($"{translator.Translate(userLanguage,"Total Cost")}: {Model.GasRecords.Sum(x => x.Cost).ToString(gasCostFormat)}") + @($"{translator.Translate(userLanguage, "Total Fuel Consumed")}: {Model.GasRecords.Sum(x => x.Gallons).ToString("F")}") + @($"{translator.Translate(userLanguage, "Total Cost")}: {Model.GasRecords.Sum(x => x.Cost).ToString(gasCostFormat)}") @foreach (string recordTag in recordTags) { @recordTag @@ -74,19 +81,75 @@ @if (enableCsvImports) {
    - +
    - } else { - + } + else + { + }
    @@ -100,26 +163,34 @@
    @translator.Translate(userLanguage,"Date")@translator.Translate(userLanguage,"Odometer")@translator.Translate(userLanguage,"Description")@translator.Translate(userLanguage,"Cost")@translator.Translate(userLanguage,"Notes")@translator.Translate(userLanguage, "Date")@translator.Translate(userLanguage, "Odometer")@translator.Translate(userLanguage, "Description")@translator.Translate(userLanguage, "Cost")@translator.Translate(userLanguage, "Notes")
    @collisionRecord.Date.ToShortDateString()@collisionRecord.Mileage@collisionRecord.Description@((hideZero && collisionRecord.Cost == default) ? "---" : collisionRecord.Cost.ToString("C"))@CarCareTracker.Helper.StaticHelper.TruncateStrings(collisionRecord.Notes)@collisionRecord.Date.ToShortDateString()@collisionRecord.Mileage@collisionRecord.Description@((hideZero && collisionRecord.Cost == default) ? "---" : collisionRecord.Cost.ToString("C"))@CarCareTracker.Helper.StaticHelper.TruncateStrings(collisionRecord.Notes)
    - - - - - - - + + + + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } @foreach (GasRecordViewModel gasRecord in Model.GasRecords) { - - - - - - - + + + + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } } @@ -131,7 +202,6 @@ @@ -149,8 +219,8 @@ { @:convertFuelMileageUnits(decodeHTMLEntities('@fuelEconomyUnit'), decodeHTMLEntities('@preferredFuelEconomyUnit'), false); } - @if (!string.IsNullOrWhiteSpace(preferredGasUnit)) - { + @if (!string.IsNullOrWhiteSpace(preferredGasUnit)) + { @:convertGasConsumptionUnits(decodeHTMLEntities('@consumptionUnit'), decodeHTMLEntities('@preferredGasUnit'), false); } diff --git a/Views/Vehicle/_OdometerRecords.cshtml b/Views/Vehicle/_OdometerRecords.cshtml index dc19d2f..a5c6145 100644 --- a/Views/Vehicle/_OdometerRecords.cshtml +++ b/Views/Vehicle/_OdometerRecords.cshtml @@ -7,6 +7,11 @@ var hideZero = userConfig.HideZero; var recordTags = Model.SelectMany(x => x.Tags).Distinct(); var userLanguage = userConfig.UserLanguage; + var extraFields = new List(); + if (userConfig.EnableExtraFieldColumns) + { + extraFields = Model.SelectMany(x => x.ExtraFields).Select(y => y.Name).Distinct().ToList(); + } } @model List
    @@ -37,6 +42,36 @@
  • @translator.Translate(userLanguage, "Export to CSV")
  • @translator.Translate(userLanguage, "Print")
  • +
  • +
  • + + + + @foreach (string extraFieldColumn in extraFields) + { + var elementId = Guid.NewGuid(); + + }
    } @@ -57,18 +92,26 @@
    @translator.Translate(userLanguage,"Date Refueled")@($"{translator.Translate(userLanguage, "Odometer")}({distanceUnit})")@($"Δ({distanceUnit})")@($"{translator.Translate(userLanguage,"Consumption")}({consumptionUnit})")@($"{@translator.Translate(userLanguage,"Fuel Economy")}({fuelEconomyUnit})")@translator.Translate(userLanguage,"Cost")@translator.Translate(userLanguage,"Unit Cost")@translator.Translate(userLanguage, "Date Refueled")@($"{translator.Translate(userLanguage, "Odometer")}({distanceUnit})")@($"Δ({distanceUnit})")@($"{translator.Translate(userLanguage, "Consumption")}({consumptionUnit})")@($"{@translator.Translate(userLanguage, "Fuel Economy")}({fuelEconomyUnit})")@translator.Translate(userLanguage, "Cost")@translator.Translate(userLanguage, "Unit Cost")
    @gasRecord.Date@gasRecord.Mileage@(gasRecord.DeltaMileage == default ? "---" : gasRecord.DeltaMileage)@gasRecord.Gallons.ToString("F")@(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F"))@((hideZero && gasRecord.Cost == default) ? "---" : gasRecord.Cost.ToString(gasCostFormat))@((hideZero && gasRecord.CostPerGallon == default) ? "---" : gasRecord.CostPerGallon.ToString(gasCostFormat))@gasRecord.Date@gasRecord.Mileage@(gasRecord.DeltaMileage == default ? "---" : gasRecord.DeltaMileage)@gasRecord.Gallons.ToString("F")@(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F"))@((hideZero && gasRecord.Cost == default) ? "---" : gasRecord.Cost.ToString(gasCostFormat))@((hideZero && gasRecord.CostPerGallon == default) ? "---" : gasRecord.CostPerGallon.ToString(gasCostFormat))
    - - - + + + + @foreach (string extraFieldColumn in extraFields) + { + + } @foreach (OdometerRecord odometerRecord in Model) { - - - + + + + @foreach (string extraFieldColumn in extraFields) + { + + } } diff --git a/Views/Vehicle/_ServiceRecords.cshtml b/Views/Vehicle/_ServiceRecords.cshtml index 4e1f8a5..3057eca 100644 --- a/Views/Vehicle/_ServiceRecords.cshtml +++ b/Views/Vehicle/_ServiceRecords.cshtml @@ -7,14 +7,19 @@ var hideZero = userConfig.HideZero; var userLanguage = userConfig.UserLanguage; var recordTags = Model.SelectMany(x => x.Tags).Distinct(); + var extraFields = new List(); + if (userConfig.EnableExtraFieldColumns) + { + extraFields = Model.SelectMany(x => x.ExtraFields).Select(y => y.Name).Distinct().ToList(); + } } @model List
    - @($"{translator.Translate(userLanguage,"# of Service Records")}: {Model.Count()}") - @($"{translator.Translate(userLanguage,"Total")}: {Model.Sum(x => x.Cost).ToString("C")}") - @foreach(string recordTag in recordTags) + @($"{translator.Translate(userLanguage, "# of Service Records")}: {Model.Count()}") + @($"{translator.Translate(userLanguage, "Total")}: {Model.Sum(x => x.Cost).ToString("C")}") + @foreach (string recordTag in recordTags) { @recordTag } @@ -29,21 +34,63 @@ @if (enableCsvImports) {
    - +
    } else { - + }
    @@ -58,22 +105,30 @@
    @translator.Translate(userLanguage, "Date")@translator.Translate(userLanguage, "Odometer")@translator.Translate(userLanguage, "Notes")@translator.Translate(userLanguage, "Date")@translator.Translate(userLanguage, "Odometer")@translator.Translate(userLanguage, "Notes")
    @odometerRecord.Date.ToShortDateString()@odometerRecord.Mileage@CarCareTracker.Helper.StaticHelper.TruncateStrings(odometerRecord.Notes, 75)@odometerRecord.Date.ToShortDateString()@odometerRecord.Mileage@CarCareTracker.Helper.StaticHelper.TruncateStrings(odometerRecord.Notes, 75)
    - - - - - + + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } @foreach (ServiceRecord serviceRecord in Model) { - - - - - + + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } } @@ -85,7 +140,6 @@ @@ -101,4 +155,4 @@
  • @translator.Translate(userLanguage, "Duplicate")
  • @translator.Translate(userLanguage, "Delete")
  • - \ No newline at end of file + diff --git a/Views/Vehicle/_SupplyRecords.cshtml b/Views/Vehicle/_SupplyRecords.cshtml index ab20a38..2974876 100644 --- a/Views/Vehicle/_SupplyRecords.cshtml +++ b/Views/Vehicle/_SupplyRecords.cshtml @@ -7,6 +7,11 @@ var enableCsvImports = userConfig.EnableCsvImports; var hideZero = userConfig.HideZero; var recordTags = Model.SelectMany(x => x.Tags).Distinct(); + var extraFields = new List(); + if (userConfig.EnableExtraFieldColumns) + { + extraFields = Model.SelectMany(x => x.ExtraFields).Select(y => y.Name).Distinct().ToList(); + } } @model List
    @@ -38,6 +43,60 @@
  • @translator.Translate(userLanguage,"Export to CSV")
  • @translator.Translate(userLanguage,"Print")
  • +
  • +
  • + + + + + + + + @foreach (string extraFieldColumn in extraFields) + { + var elementId = Guid.NewGuid(); + + }
    } @@ -58,26 +117,34 @@
    @translator.Translate(userLanguage,"Date")@translator.Translate(userLanguage, "Odometer")@translator.Translate(userLanguage, "Description")@translator.Translate(userLanguage, "Cost")@translator.Translate(userLanguage, "Notes")@translator.Translate(userLanguage, "Date")@translator.Translate(userLanguage, "Odometer")@translator.Translate(userLanguage, "Description")@translator.Translate(userLanguage, "Cost")@translator.Translate(userLanguage, "Notes")
    @serviceRecord.Date.ToShortDateString()@serviceRecord.Mileage@serviceRecord.Description@((hideZero && serviceRecord.Cost == default) ? "---" : serviceRecord.Cost.ToString("C"))@CarCareTracker.Helper.StaticHelper.TruncateStrings(serviceRecord.Notes)@serviceRecord.Date.ToShortDateString()@serviceRecord.Mileage@serviceRecord.Description@((hideZero && serviceRecord.Cost == default) ? "---" : serviceRecord.Cost.ToString("C"))@CarCareTracker.Helper.StaticHelper.TruncateStrings(serviceRecord.Notes)
    - - - - - - - + + + + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } @foreach (SupplyRecord supplyRecord in Model) { - - - - - - - + + + + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } } diff --git a/Views/Vehicle/_TaxRecords.cshtml b/Views/Vehicle/_TaxRecords.cshtml index ae21988..40ebcb9 100644 --- a/Views/Vehicle/_TaxRecords.cshtml +++ b/Views/Vehicle/_TaxRecords.cshtml @@ -7,6 +7,11 @@ var enableCsvImports = userConfig.EnableCsvImports; var hideZero = userConfig.HideZero; var recordTags = Model.SelectMany(x => x.Tags).Distinct(); + var extraFields = new List(); + if (userConfig.EnableExtraFieldColumns) + { + extraFields = Model.SelectMany(x => x.ExtraFields).Select(y => y.Name).Distinct().ToList(); + } } @model List
    @@ -38,6 +43,42 @@
  • @translator.Translate(userLanguage, "Export to CSV")
  • @translator.Translate(userLanguage, "Print")
  • +
  • +
  • + + + + + @foreach (string extraFieldColumn in extraFields) + { + var elementId = Guid.NewGuid(); + + }
    } @@ -58,20 +99,28 @@
    @translator.Translate(userLanguage,"Date")@translator.Translate(userLanguage, "Part #")@translator.Translate(userLanguage, "Supplier")@translator.Translate(userLanguage, "Description")@translator.Translate(userLanguage, "Quantity")@translator.Translate(userLanguage, "Cost")@translator.Translate(userLanguage, "Notes")@translator.Translate(userLanguage, "Date")@translator.Translate(userLanguage, "Part #")@translator.Translate(userLanguage, "Supplier")@translator.Translate(userLanguage, "Description")@translator.Translate(userLanguage, "Quantity")@translator.Translate(userLanguage, "Cost")@translator.Translate(userLanguage, "Notes")
    @supplyRecord.Date.ToShortDateString()@supplyRecord.PartNumber@supplyRecord.PartSupplier@supplyRecord.Description@supplyRecord.Quantity@((hideZero && supplyRecord.Cost == default) ? "---" : supplyRecord.Cost.ToString("C"))@CarCareTracker.Helper.StaticHelper.TruncateStrings(supplyRecord.Notes)@supplyRecord.Date.ToShortDateString()@supplyRecord.PartNumber@supplyRecord.PartSupplier@supplyRecord.Description@supplyRecord.Quantity@((hideZero && supplyRecord.Cost == default) ? "---" : supplyRecord.Cost.ToString("C"))@CarCareTracker.Helper.StaticHelper.TruncateStrings(supplyRecord.Notes)
    - - - - + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } @foreach (TaxRecord taxRecord in Model) { - - - - + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } } diff --git a/Views/Vehicle/_UpgradeRecords.cshtml b/Views/Vehicle/_UpgradeRecords.cshtml index 3565775..2361ad6 100644 --- a/Views/Vehicle/_UpgradeRecords.cshtml +++ b/Views/Vehicle/_UpgradeRecords.cshtml @@ -7,6 +7,11 @@ var enableCsvImports = userConfig.EnableCsvImports; var hideZero = userConfig.HideZero; var recordTags = Model.SelectMany(x => x.Tags).Distinct(); + var extraFields = new List(); + if (userConfig.EnableExtraFieldColumns) + { + extraFields = Model.SelectMany(x => x.ExtraFields).Select(y => y.Name).Distinct().ToList(); + } } @model List
    @@ -38,6 +43,48 @@
  • @translator.Translate(userLanguage, "Export to CSV")
  • @translator.Translate(userLanguage, "Print")
  • +
  • +
  • + + + + + + @foreach (string extraFieldColumn in extraFields) + { + var elementId = Guid.NewGuid(); + + }
    } @@ -58,22 +105,30 @@
    @translator.Translate(userLanguage, "Date")@translator.Translate(userLanguage, "Description")@translator.Translate(userLanguage, "Cost")@translator.Translate(userLanguage, "Notes")@translator.Translate(userLanguage, "Date")@translator.Translate(userLanguage, "Description")@translator.Translate(userLanguage, "Cost")@translator.Translate(userLanguage, "Notes")
    @taxRecord.Date.ToShortDateString()@taxRecord.Description@((hideZero && taxRecord.Cost == default) ? "---" : taxRecord.Cost.ToString("C"))@CarCareTracker.Helper.StaticHelper.TruncateStrings(taxRecord.Notes)@taxRecord.Date.ToShortDateString()@taxRecord.Description@((hideZero && taxRecord.Cost == default) ? "---" : taxRecord.Cost.ToString("C"))@CarCareTracker.Helper.StaticHelper.TruncateStrings(taxRecord.Notes)
    - - - - - + + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } @foreach (UpgradeRecord upgradeRecord in Model) { - - - - - + + + + + + @foreach (string extraFieldColumn in extraFields) + { + + } } diff --git a/appsettings.json b/appsettings.json index bbe7c1b..d8112be 100644 --- a/appsettings.json +++ b/appsettings.json @@ -15,6 +15,7 @@ "EnableAutoReminderRefresh": false, "EnableAutoOdometerInsert": false, "EnableShopSupplies": false, + "EnableExtraFieldColumns": false, "UseUKMPG": false, "UseThreeDecimalGasCost": true, "UseMarkDownOnSavedNotes": false, diff --git a/wwwroot/js/shared.js b/wwwroot/js/shared.js index 361b1ca..f9e317b 100644 --- a/wwwroot/js/shared.js +++ b/wwwroot/js/shared.js @@ -864,4 +864,24 @@ function replenishSupplies() { } } }); +} +function showTableColumns(e, isExtraField) { + //logic for extra field since we dont hardcode the data-column type + if (isExtraField) { + var showColumn = $(e).is(':checked'); + var columnName = $(e).parent().find('.form-check-label').text(); + if (showColumn) { + $(`[data-column='${columnName}']`).show(); + } else { + $(`[data-column='${columnName}']`).hide(); + } + } else { + var showColumn = $(e).is(':checked'); + var columnName = $(e).attr('data-column-toggle'); + if (showColumn) { + $(`[data-column='${columnName}']`).show(); + } else { + $(`[data-column='${columnName}']`).hide(); + } + } } \ No newline at end of file
    @translator.Translate(userLanguage, "Date")@translator.Translate(userLanguage, "Odometer")@translator.Translate(userLanguage, "Description")@translator.Translate(userLanguage, "Cost")@translator.Translate(userLanguage, "Notes")@translator.Translate(userLanguage, "Date")@translator.Translate(userLanguage, "Odometer")@translator.Translate(userLanguage, "Description")@translator.Translate(userLanguage, "Cost")@translator.Translate(userLanguage, "Notes")
    @upgradeRecord.Date.ToShortDateString()@upgradeRecord.Mileage@upgradeRecord.Description@((hideZero && upgradeRecord.Cost == default) ? "---" : upgradeRecord.Cost.ToString("C"))@CarCareTracker.Helper.StaticHelper.TruncateStrings(upgradeRecord.Notes)@upgradeRecord.Date.ToShortDateString()@upgradeRecord.Mileage@upgradeRecord.Description@((hideZero && upgradeRecord.Cost == default) ? "---" : upgradeRecord.Cost.ToString("C"))@CarCareTracker.Helper.StaticHelper.TruncateStrings(upgradeRecord.Notes)