diff --git a/Controllers/VehicleController.cs b/Controllers/VehicleController.cs index d6245e1..ae48f54 100644 --- a/Controllers/VehicleController.cs +++ b/Controllers/VehicleController.cs @@ -589,7 +589,8 @@ namespace CarCareTracker.Controllers Gallons = result.Gallons, IsFillToFull = result.IsFillToFull, MissedFuelUp = result.MissedFuelUp, - Notes = result.Notes + Notes = result.Notes, + Tags = result.Tags }; var vehicleData = _dataAccess.GetVehicleById(convertedResult.VehicleId); var vehicleIsElectric = vehicleData.IsElectric; diff --git a/Helper/GasHelper.cs b/Helper/GasHelper.cs index 4dce396..6dc6c1b 100644 --- a/Helper/GasHelper.cs +++ b/Helper/GasHelper.cs @@ -68,7 +68,8 @@ namespace CarCareTracker.Helper CostPerGallon = convertedConsumption > 0.00M ? currentObject.Cost / convertedConsumption : 0, IsFillToFull = currentObject.IsFillToFull, MissedFuelUp = currentObject.MissedFuelUp, - Notes = currentObject.Notes + Notes = currentObject.Notes, + Tags = currentObject.Tags }; if (currentObject.MissedFuelUp) { @@ -120,7 +121,8 @@ namespace CarCareTracker.Helper CostPerGallon = convertedConsumption > 0.00M ? currentObject.Cost / convertedConsumption : 0, IsFillToFull = currentObject.IsFillToFull, MissedFuelUp = currentObject.MissedFuelUp, - Notes = currentObject.Notes + Notes = currentObject.Notes, + Tags = currentObject.Tags }); } previousMileage = currentObject.Mileage; diff --git a/Models/GasRecord/GasRecord.cs b/Models/GasRecord/GasRecord.cs index 336c60e..6fe085a 100644 --- a/Models/GasRecord/GasRecord.cs +++ b/Models/GasRecord/GasRecord.cs @@ -18,5 +18,6 @@ public bool MissedFuelUp { get; set; } = false; public string Notes { get; set; } public List Files { get; set; } = new List(); + public List Tags { get; set; } = new List(); } } diff --git a/Models/GasRecord/GasRecordInput.cs b/Models/GasRecord/GasRecordInput.cs index 37fe265..72ec723 100644 --- a/Models/GasRecord/GasRecordInput.cs +++ b/Models/GasRecord/GasRecordInput.cs @@ -18,6 +18,7 @@ public bool MissedFuelUp { get; set; } = false; public string Notes { get; set; } public List Files { get; set; } = new List(); + public List Tags { get; set; } = new List(); public GasRecord ToGasRecord() { return new GasRecord { Id = Id, Cost = Cost, @@ -28,7 +29,8 @@ Files = Files, IsFillToFull = IsFillToFull, MissedFuelUp = MissedFuelUp, - Notes = Notes + Notes = Notes, + Tags = Tags }; } } } diff --git a/Models/GasRecord/GasRecordViewModel.cs b/Models/GasRecord/GasRecordViewModel.cs index 1eee41f..b9825f4 100644 --- a/Models/GasRecord/GasRecordViewModel.cs +++ b/Models/GasRecord/GasRecordViewModel.cs @@ -21,5 +21,6 @@ public bool IsFillToFull { get; set; } public bool MissedFuelUp { get; set; } public string Notes { get; set; } + public List Tags { get; set; } = new List(); } } diff --git a/Views/Vehicle/_Gas.cshtml b/Views/Vehicle/_Gas.cshtml index c2c7d0a..fb0c839 100644 --- a/Views/Vehicle/_Gas.cshtml +++ b/Views/Vehicle/_Gas.cshtml @@ -12,6 +12,7 @@ var gasCostFormat = useThreeDecimals ? "C3" : "C2"; var useKwh = Model.UseKwh; var useHours = Model.UseHours; + var recordTags = Model.GasRecords.SelectMany(x => x.Tags).Distinct(); string preferredFuelEconomyUnit = userConfig.PreferredGasMileageUnit; string preferredGasUnit = userConfig.PreferredGasUnit; string consumptionUnit; @@ -41,7 +42,7 @@
- @($"# of Gas Records: {Model.GasRecords.Count()}") + @($"# of Gas Records: {Model.GasRecords.Count()}") @if (Model.GasRecords.Where(x => x.MilesPerGallon > 0).Any()) { @($"Average Fuel Economy: {gasHelper.GetAverageGasMileage(Model.GasRecords, useMPG)}") @@ -56,7 +57,17 @@ } } @($"Total Fuel Consumed: {Model.GasRecords.Sum(x => x.Gallons).ToString("F")}") - @($"Total Cost: {Model.GasRecords.Sum(x => x.Cost).ToString(gasCostFormat)}") + @($"Total Cost: {Model.GasRecords.Sum(x => x.Cost).ToString(gasCostFormat)}") + @foreach (string recordTag in recordTags) + { + @recordTag + } + + @foreach (string recordTag in recordTags) + { + + } +
@if (enableCsvImports) { @@ -98,12 +109,12 @@ @foreach (GasRecordViewModel gasRecord in Model.GasRecords) { - + @gasRecord.Date @gasRecord.Mileage @gasRecord.Gallons.ToString("F") @(gasRecord.MilesPerGallon == 0 ? "---" : gasRecord.MilesPerGallon.ToString("F")) - @((hideZero && gasRecord.Cost == default) ? "---" : gasRecord.Cost.ToString(gasCostFormat)) + @((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 759f90b..8d5049a 100644 --- a/Views/Vehicle/_GasModal.cshtml +++ b/Views/Vehicle/_GasModal.cshtml @@ -76,6 +76,13 @@ { } + +
diff --git a/wwwroot/js/gasrecord.js b/wwwroot/js/gasrecord.js index 49ce0ff..0fbeef7 100644 --- a/wwwroot/js/gasrecord.js +++ b/wwwroot/js/gasrecord.js @@ -4,6 +4,7 @@ $("#gasRecordModalContent").html(data); //initiate datepicker initDatePicker($('#gasRecordDate')); + initTagSelector($("#gasRecordTag")); $('#gasRecordModal').modal('show'); } }); @@ -14,6 +15,7 @@ function showEditGasRecordModal(gasRecordId) { $("#gasRecordModalContent").html(data); //initiate datepicker initDatePicker($('#gasRecordDate')); + initTagSelector($("#gasRecordTag")); $('#gasRecordModal').modal('show'); $('#gasRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () { if (getGlobalConfig().useMarkDown) { @@ -80,6 +82,7 @@ function getAndValidateGasRecordValues() { var gasIsFillToFull = $("#gasIsFillToFull").is(":checked"); var gasIsMissed = $("#gasIsMissed").is(":checked"); var gasNotes = $("#gasRecordNotes").val(); + var gasTags = $("#gasRecordTag").val(); var vehicleId = GetVehicleId().vehicleId; var gasRecordId = getGasRecordModelData().id; //validation @@ -128,6 +131,7 @@ function getAndValidateGasRecordValues() { gallons: gasGallons, cost: gasCost, files: uploadedFiles, + tags: gasTags, isFillToFull: gasIsFillToFull, missedFuelUp: gasIsMissed, notes: gasNotes