Skip to content

Commit

Permalink
Merge pull request #217 from hargata/Hargata/tags.other.tab
Browse files Browse the repository at this point in the history
add tagging functionality to notes, odometer, and tax tabs
  • Loading branch information
hargata authored Feb 2, 2024
2 parents 0b1e3f4 + abb4460 commit 7bdd3d9
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 12 deletions.
9 changes: 6 additions & 3 deletions Controllers/VehicleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,8 @@ private void UpdateRecurringTaxes(int vehicleId)
IsRecurring = true,
Notes = recurringFee.Notes,
RecurringInterval = recurringFee.RecurringInterval,
Files = recurringFee.Files
Files = recurringFee.Files,
Tags = recurringFee.Tags
};
_taxRecordDataAccess.SaveTaxRecordToVehicle(recurringFee);
_taxRecordDataAccess.SaveTaxRecordToVehicle(newRecurringFee);
Expand Down Expand Up @@ -831,7 +832,8 @@ public IActionResult GetTaxRecordForEditById(int taxRecordId)
VehicleId = result.VehicleId,
IsRecurring = result.IsRecurring,
RecurringInterval = result.RecurringInterval,
Files = result.Files
Files = result.Files,
Tags = result.Tags
};
return PartialView("_TaxRecordModal", convertedResult);
}
Expand Down Expand Up @@ -1711,7 +1713,8 @@ public IActionResult GetOdometerRecordForEditById(int odometerRecordId)
Mileage = result.Mileage,
Notes = result.Notes,
VehicleId = result.VehicleId,
Files = result.Files
Files = result.Files,
Tags = result.Tags
};
return PartialView("_OdometerRecordModal", convertedResult);
}
Expand Down
9 changes: 6 additions & 3 deletions Helper/StaticHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public static ServiceRecord GenericToServiceRecord(GenericRecord input)
Cost = input.Cost,
Mileage = input.Mileage,
Files = input.Files,
Notes = input.Notes
Notes = input.Notes,
Tags = input.Tags
};
}
public static CollisionRecord GenericToRepairRecord(GenericRecord input)
Expand All @@ -124,7 +125,8 @@ public static CollisionRecord GenericToRepairRecord(GenericRecord input)
Cost = input.Cost,
Mileage = input.Mileage,
Files = input.Files,
Notes = input.Notes
Notes = input.Notes,
Tags = input.Tags
};
}
public static UpgradeRecord GenericToUpgradeRecord(GenericRecord input)
Expand All @@ -137,7 +139,8 @@ public static UpgradeRecord GenericToUpgradeRecord(GenericRecord input)
Cost = input.Cost,
Mileage = input.Mileage,
Files = input.Files,
Notes = input.Notes
Notes = input.Notes,
Tags = input.Tags
};
}

Expand Down
1 change: 1 addition & 0 deletions Models/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public class Note
public string Description { get; set; }
public string NoteText { get; set; }
public bool Pinned { get; set; }
public List<string> Tags { get; set; } = new List<string>();
}
}
1 change: 1 addition & 0 deletions Models/OdometerRecord/OdometerRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class OdometerRecord
public DateTime Date { get; set; }
public int Mileage { get; set; }
public string Notes { get; set; }
public List<string> Tags { get; set; } = new List<string>();
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
}
}
3 changes: 2 additions & 1 deletion Models/OdometerRecord/OdometerRecordInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class OdometerRecordInput
public int Mileage { get; set; }
public string Notes { get; set; }
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
public OdometerRecord ToOdometerRecord() { return new OdometerRecord { Id = Id, VehicleId = VehicleId, Date = DateTime.Parse(Date), Mileage = Mileage, Notes = Notes, Files = Files }; }
public List<string> Tags { get; set; } = new List<string>();
public OdometerRecord ToOdometerRecord() { return new OdometerRecord { Id = Id, VehicleId = VehicleId, Date = DateTime.Parse(Date), Mileage = Mileage, Notes = Notes, Files = Files, Tags = Tags }; }
}
}
1 change: 1 addition & 0 deletions Models/TaxRecord/TaxRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public class TaxRecord
public bool IsRecurring { get; set; } = false;
public ReminderMonthInterval RecurringInterval { get; set; } = ReminderMonthInterval.OneYear;
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
public List<string> Tags { get; set; } = new List<string>();
}
}
5 changes: 4 additions & 1 deletion Models/TaxRecord/TaxRecordInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class TaxRecordInput
public bool IsRecurring { get; set; } = false;
public ReminderMonthInterval RecurringInterval { get; set; } = ReminderMonthInterval.ThreeMonths;
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
public List<string> Tags { get; set; } = new List<string>();
public TaxRecord ToTaxRecord() { return new TaxRecord {
Id = Id,
VehicleId = VehicleId,
Expand All @@ -20,6 +21,8 @@ public class TaxRecordInput
Notes = Notes,
IsRecurring = IsRecurring,
RecurringInterval = RecurringInterval,
Files = Files }; }
Files = Files,
Tags = Tags
}; }
}
}
9 changes: 9 additions & 0 deletions Views/Vehicle/_NoteModal.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
<label for="noteTextArea">Notes<a class="link-underline link-underline-opacity-0" onclick="showLinks(this)"><i class="bi bi-markdown ms-2"></i></a></label>
<textarea class="form-control vehicleNoteContainer" id="noteTextArea">@Model.NoteText</textarea>
</div>
<div class="col-12">
<label for="noteRecordTag">Tags(optional)</label>
<select multiple class="form-select" id="noteRecordTag">
@foreach (string tag in Model.Tags)
{
<!option value="@tag">@tag</!option>
}
</select>
</div>
</div>
</div>
</form>
Expand Down
15 changes: 14 additions & 1 deletion Views/Vehicle/_Notes.cshtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
@model List<Note>
@{
var recordTags = Model.SelectMany(x => x.Tags).Distinct();
}
<div class="row">
<div class="d-flex justify-content-between">
<div class="d-flex align-items-center flex-wrap">
<span class="ms-2 badge bg-success">@($"# of Notes: {Model.Count()}")</span>
@foreach (string recordTag in recordTags)
{
<span onclick="filterTable('notes-tab-pane', this)" class="user-select-none ms-2 rounded-pill badge bg-secondary tagfilter" style="cursor:pointer;">@recordTag</span>
}
<datalist id="tagList">
@foreach (string recordTag in recordTags)
{
<!option value="@recordTag"></!option>
}
</datalist>
</div>
<div>
<button onclick="showAddNoteModal()" class="btn btn-primary btn-md mt-1 mb-1"><i class="bi bi-pencil-square me-2"></i>Add Note</button>
Expand All @@ -26,7 +39,7 @@
<tbody>
@foreach (Note note in Model)
{
<tr class="d-flex" style="cursor:pointer;" onclick="showEditNoteModal(@note.Id)">
<tr class="d-flex" style="cursor:pointer;" onclick="showEditNoteModal(@note.Id)" data-tags='@string.Join(" ", note.Tags)'>
@if (note.Pinned)
{
<td class="col-3"><i class='bi bi-pin-fill me-2'></i>@note.Description</td>
Expand Down
7 changes: 7 additions & 0 deletions Views/Vehicle/_OdometerRecordModal.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
</div>
<label for="odometerRecordMileage">Odometer</label>
<input type="number" id="odometerRecordMileage" class="form-control" placeholder="Odometer reading" value="@(isNew ? "" : Model.Mileage)">
<label for="odometerRecordTag">Tags(optional)</label>
<select multiple class="form-select" id="odometerRecordTag">
@foreach (string tag in Model.Tags)
{
<!option value="@tag">@tag</!option>
}
</select>
</div>
<div class="col-md-6 col-12">
<label for="odometerRecordNotes">Notes(optional)<a class="link-underline link-underline-opacity-0" onclick="showLinks(this)"><i class="bi bi-markdown ms-2"></i></a></label>
Expand Down
13 changes: 12 additions & 1 deletion Views/Vehicle/_OdometerRecords.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,23 @@
@{
var enableCsvImports = config.GetUserConfig(User).EnableCsvImports;
var hideZero = config.GetUserConfig(User).HideZero;
var recordTags = Model.SelectMany(x => x.Tags).Distinct();
}
@model List<OdometerRecord>
<div class="row">
<div class="d-flex justify-content-between">
<div class="d-flex align-items-center flex-wrap">
<span class="ms-2 badge bg-success">@($"# of Odometer Records: {Model.Count()}")</span>
@foreach (string recordTag in recordTags)
{
<span onclick="filterTable('odometer-tab-pane', this)" class="user-select-none ms-2 rounded-pill badge bg-secondary tagfilter" style="cursor:pointer;">@recordTag</span>
}
<datalist id="tagList">
@foreach (string recordTag in recordTags)
{
<!option value="@recordTag"></!option>
}
</datalist>
</div>
<div>
@if (enableCsvImports)
Expand Down Expand Up @@ -51,7 +62,7 @@
<tbody>
@foreach (OdometerRecord odometerRecord in Model)
{
<tr class="d-flex" style="cursor:pointer;" onclick="showEditOdometerRecordModal(@odometerRecord.Id)">
<tr class="d-flex" style="cursor:pointer;" onclick="showEditOdometerRecordModal(@odometerRecord.Id)" data-tags='@string.Join(" ", odometerRecord.Tags)'>
<td class="col-2 col-xl-1">@odometerRecord.Date.ToShortDateString()</td>
<td class="col-3">@odometerRecord.Mileage</td>
<td class="col-7 col-xl-8 text-truncate">@CarCareTracker.Helper.StaticHelper.TruncateStrings(odometerRecord.Notes, 75)</td>
Expand Down
7 changes: 7 additions & 0 deletions Views/Vehicle/_TaxRecordModal.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
<input type="text" id="taxRecordDescription" class="form-control" placeholder="Description of tax paid(i.e. Registration)" value="@Model.Description">
<label for="taxRecordCost">Cost</label>
<input type="text" id="taxRecordCost" class="form-control" placeholder="Cost of tax paid" value="@(isNew? "" : Model.Cost)">
<label for="taxRecordTag">Tags(optional)</label>
<select multiple class="form-select" id="taxRecordTag">
@foreach (string tag in Model.Tags)
{
<!option value="@tag">@tag</!option>
}
</select>
</div>
<div class="col-md-6 col-12">
<label for="taxRecordNotes">Notes(optional)<a class="link-underline link-underline-opacity-0" onclick="showLinks(this)"><i class="bi bi-markdown ms-2"></i></a></label>
Expand Down
13 changes: 12 additions & 1 deletion Views/Vehicle/_TaxRecords.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
@{
var enableCsvImports = config.GetUserConfig(User).EnableCsvImports;
var hideZero = config.GetUserConfig(User).HideZero;
var recordTags = Model.SelectMany(x => x.Tags).Distinct();
}
@model List<TaxRecord>
<div class="row">
<div class="d-flex justify-content-between">
<div class="d-flex align-items-center flex-wrap">
<span class="ms-2 badge bg-success">@($"# of Tax Records: {Model.Count()}")</span>
<span class="ms-2 badge bg-primary">@($"Total: {Model.Sum(x => x.Cost).ToString("C")}")</span>
@foreach (string recordTag in recordTags)
{
<span onclick="filterTable('tax-tab-pane', this)" class="user-select-none ms-2 rounded-pill badge bg-secondary tagfilter" style="cursor:pointer;">@recordTag</span>
}
<datalist id="tagList">
@foreach (string recordTag in recordTags)
{
<!option value="@recordTag"></!option>
}
</datalist>
</div>
<div>
@if (enableCsvImports)
Expand Down Expand Up @@ -53,7 +64,7 @@
<tbody>
@foreach (TaxRecord taxRecord in Model)
{
<tr class="d-flex" style="cursor:pointer;" onclick="showEditTaxRecordModal(@taxRecord.Id)">
<tr class="d-flex" style="cursor:pointer;" onclick="showEditTaxRecordModal(@taxRecord.Id)" data-tags='@string.Join(" ", taxRecord.Tags)'>
<td class="col-3 col-xl-1">@taxRecord.Date.ToShortDateString()</td>
<td class="col-4 col-xl-6">@taxRecord.Description</td>
<td class="col-2">@((hideZero && taxRecord.Cost == default) ? "---" : taxRecord.Cost.ToString("C"))</td>
Expand Down
6 changes: 5 additions & 1 deletion wwwroot/js/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
$.get('/Vehicle/GetAddNotePartialView', function (data) {
if (data) {
$("#noteModalContent").html(data);
initTagSelector($("#noteRecordTag"));
$('#noteModal').modal('show');
}
});
Expand All @@ -10,6 +11,7 @@ function showEditNoteModal(noteId) {
$.get(`/Vehicle/GetNoteForEditById?noteId=${noteId}`, function (data) {
if (data) {
$("#noteModalContent").html(data);
initTagSelector($("#noteRecordTag"));
$('#noteModal').modal('show');
$('#noteModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
Expand Down Expand Up @@ -73,6 +75,7 @@ function getAndValidateNoteValues() {
var vehicleId = GetVehicleId().vehicleId;
var noteId = getNoteModelData().id;
var noteIsPinned = $("#noteIsPinned").is(":checked");
var noteTags = $("#noteRecordTag").val();
//validation
var hasError = false;
if (noteDescription.trim() == '') { //eliminates whitespace.
Expand All @@ -93,6 +96,7 @@ function getAndValidateNoteValues() {
vehicleId: vehicleId,
description: noteDescription,
noteText: noteText,
pinned: noteIsPinned
pinned: noteIsPinned,
tags: noteTags
}
}
4 changes: 4 additions & 0 deletions wwwroot/js/odometerrecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$("#odometerRecordModalContent").html(data);
//initiate datepicker
initDatePicker($('#odometerRecordDate'));
initTagSelector($("#odometerRecordTag"));
$('#odometerRecordModal').modal('show');
}
});
Expand All @@ -14,6 +15,7 @@ function showEditOdometerRecordModal(odometerRecordId) {
$("#odometerRecordModalContent").html(data);
//initiate datepicker
initDatePicker($('#odometerRecordDate'));
initTagSelector($("#odometerRecordTag"));
$('#odometerRecordModal').modal('show');
$('#odometerRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
Expand Down Expand Up @@ -78,6 +80,7 @@ function getAndValidateOdometerRecordValues() {
var serviceDate = $("#odometerRecordDate").val();
var serviceMileage = parseInt(globalParseFloat($("#odometerRecordMileage").val())).toString();
var serviceNotes = $("#odometerRecordNotes").val();
var serviceTags = $("#odometerRecordTag").val();
var vehicleId = GetVehicleId().vehicleId;
var odometerRecordId = getOdometerRecordModelData().id;
//validation
Expand All @@ -101,6 +104,7 @@ function getAndValidateOdometerRecordValues() {
date: serviceDate,
mileage: serviceMileage,
notes: serviceNotes,
tags: serviceTags,
files: uploadedFiles
}
}
4 changes: 4 additions & 0 deletions wwwroot/js/taxrecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$("#taxRecordModalContent").html(data);
//initiate datepicker
initDatePicker($('#taxRecordDate'));
initTagSelector($("#taxRecordTag"));
$('#taxRecordModal').modal('show');
}
});
Expand All @@ -14,6 +15,7 @@ function showEditTaxRecordModal(taxRecordId) {
$("#taxRecordModalContent").html(data);
//initiate datepicker
initDatePicker($('#taxRecordDate'));
initTagSelector($("#taxRecordTag"));
$('#taxRecordModal').modal('show');
$('#taxRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
Expand Down Expand Up @@ -91,6 +93,7 @@ function getAndValidateTaxRecordValues() {
var taxRecordId = getTaxRecordModelData().id;
var taxIsRecurring = $("#taxIsRecurring").is(":checked");
var taxRecurringMonth = $("#taxRecurringMonth").val();
var taxTags = $("#taxRecordTag").val();
var addReminderRecord = $("#addReminderCheck").is(":checked");
//validation
var hasError = false;
Expand Down Expand Up @@ -122,6 +125,7 @@ function getAndValidateTaxRecordValues() {
notes: taxNotes,
isRecurring: taxIsRecurring,
recurringInterval: taxRecurringMonth,
tags: taxTags,
files: uploadedFiles,
addReminderRecord: addReminderRecord
}
Expand Down

0 comments on commit 7bdd3d9

Please sign in to comment.