added tags to general supply record tab.

This commit is contained in:
DESKTOP-GENO133\IvanPlex
2024-02-11 09:48:54 -07:00
parent dfe4e4f1ab
commit f581e55842
7 changed files with 36 additions and 6 deletions

View File

@@ -256,7 +256,8 @@ namespace CarCareTracker.Controllers
PartNumber = x.PartNumber,
PartQuantity = x.Quantity.ToString(),
PartSupplier = x.PartSupplier,
Notes = x.Notes
Notes = x.Notes,
Tags = string.Join(" ", x.Tags)
});
using (var writer = new StreamWriter(fullExportFilePath))
{
@@ -508,7 +509,8 @@ namespace CarCareTracker.Controllers
Quantity = decimal.Parse(importModel.PartQuantity, NumberStyles.Any),
Description = importModel.Description,
Cost = decimal.Parse(importModel.Cost, NumberStyles.Any),
Notes = importModel.Notes
Notes = importModel.Notes,
Tags = string.IsNullOrWhiteSpace(importModel.Tags) ? [] : importModel.Tags.Split(" ").ToList()
};
_supplyRecordDataAccess.SaveSupplyRecordToVehicle(convertedRecord);
}
@@ -1585,7 +1587,8 @@ namespace CarCareTracker.Controllers
PartSupplier = result.PartSupplier,
Notes = result.Notes,
VehicleId = result.VehicleId,
Files = result.Files
Files = result.Files,
Tags = result.Tags
};
return PartialView("_SupplyRecordModal", convertedResult);
}

View File

@@ -35,6 +35,7 @@
public string Description { get; set; }
public string Cost { get; set; }
public string Notes { get; set; }
public string Tags { get; set; }
}
public class ServiceRecordExportModel

View File

@@ -33,5 +33,6 @@
/// </summary>
public string Notes { get; set; }
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
public List<string> Tags { get; set; } = new List<string>();
}
}

View File

@@ -12,6 +12,7 @@
public decimal Cost { get; set; }
public string Notes { get; set; }
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
public List<string> Tags { get; set; } = new List<string>();
public SupplyRecord ToSupplyRecord() { return new SupplyRecord {
Id = Id,
VehicleId = VehicleId,
@@ -22,6 +23,8 @@
Quantity = Quantity,
Description = Description,
Notes = Notes,
Files = Files }; }
Files = Files,
Tags = Tags
}; }
}
}

View File

@@ -38,6 +38,13 @@
<input type="text" inputmode="decimal" id="supplyRecordCost" class="form-control" placeholder="@translator.Translate(userLanguage,"Cost")" value="@(isNew ? "" : Model.Cost)">
</div>
</div>
<label for="supplyRecordTag">@translator.Translate(userLanguage, "Tags(optional)")</label>
<select multiple class="form-select" id="supplyRecordTag">
@foreach (string tag in Model.Tags)
{
<!option value="@tag">@tag</!option>
}
</select>
</div>
<div class="col-md-6 col-12">
<label for="supplyRecordNotes">@translator.Translate(userLanguage,"Notes(optional)")<a class="link-underline link-underline-opacity-0" onclick="showLinks(this)"><i class="bi bi-markdown ms-2"></i></a></label>

View File

@@ -6,6 +6,7 @@
var userLanguage = userConfig.UserLanguage;
var enableCsvImports = userConfig.EnableCsvImports;
var hideZero = userConfig.HideZero;
var recordTags = Model.SelectMany(x => x.Tags).Distinct();
}
@model List<SupplyRecord>
<div class="row">
@@ -13,6 +14,16 @@
<div class="d-flex align-items-center flex-wrap">
<span class="ms-2 badge bg-success">@($"{translator.Translate(userLanguage,"# of Supply Records")}: {Model.Count()}")</span>
<span class="ms-2 badge bg-primary">@($"{translator.Translate(userLanguage,"Total")}: {Model.Sum(x => x.Cost).ToString("C")}")</span>
@foreach (string recordTag in recordTags)
{
<span onclick="filterTable('supply-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)
@@ -59,7 +70,7 @@
<tbody>
@foreach (SupplyRecord supplyRecord in Model)
{
<tr class="d-flex" style="cursor:pointer;" onclick="showEditSupplyRecordModal(@supplyRecord.Id)">
<tr class="d-flex" style="cursor:pointer;" onclick="showEditSupplyRecordModal(@supplyRecord.Id)" data-tags='@string.Join(" ", supplyRecord.Tags)'>
<td class="col-2 col-xl-1">@supplyRecord.Date.ToShortDateString()</td>
<td class="col-2">@supplyRecord.PartNumber</td>
<td class="col-2">@supplyRecord.PartSupplier</td>

View File

@@ -4,6 +4,7 @@
$("#supplyRecordModalContent").html(data);
//initiate datepicker
initDatePicker($('#supplyRecordDate'));
initTagSelector($("#supplyRecordTag"));
$('#supplyRecordModal').modal('show');
}
});
@@ -14,6 +15,7 @@ function showEditSupplyRecordModal(supplyRecordId) {
$("#supplyRecordModalContent").html(data);
//initiate datepicker
initDatePicker($('#supplyRecordDate'));
initTagSelector($("#supplyRecordTag"));
$('#supplyRecordModal').modal('show');
$('#supplyRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
@@ -82,6 +84,7 @@ function getAndValidateSupplyRecordValues() {
var supplyQuantity = $("#supplyRecordQuantity").val();
var supplyCost = $("#supplyRecordCost").val();
var supplyNotes = $("#supplyRecordNotes").val();
var supplyTags = $("#supplyRecordTag").val();
var vehicleId = GetVehicleId().vehicleId;
var supplyRecordId = getSupplyRecordModelData().id;
//validation
@@ -121,6 +124,7 @@ function getAndValidateSupplyRecordValues() {
cost: supplyCost,
notes: supplyNotes,
quantity: supplyQuantity,
files: uploadedFiles
files: uploadedFiles,
tags: supplyTags
}
}