diff --git a/Models/PlanRecord/PlanRecord.cs b/Models/PlanRecord/PlanRecord.cs index 98f724c..5746552 100644 --- a/Models/PlanRecord/PlanRecord.cs +++ b/Models/PlanRecord/PlanRecord.cs @@ -13,5 +13,6 @@ public PlanPriority Priority { get; set; } public PlanProgress Progress { get; set; } public decimal Cost { get; set; } + public List ExtraFields { get; set; } = new List(); } } diff --git a/Models/PlanRecord/PlanRecordInput.cs b/Models/PlanRecord/PlanRecordInput.cs index ff713d9..22f5106 100644 --- a/Models/PlanRecord/PlanRecordInput.cs +++ b/Models/PlanRecord/PlanRecordInput.cs @@ -14,6 +14,7 @@ public PlanPriority Priority { get; set; } public PlanProgress Progress { get; set; } public decimal Cost { get; set; } + public List ExtraFields { get; set; } = new List(); public PlanRecord ToPlanRecord() { return new PlanRecord { Id = Id, VehicleId = VehicleId, @@ -25,7 +26,8 @@ ImportMode = ImportMode, Cost = Cost, Priority = Priority, - Progress = Progress + Progress = Progress, + ExtraFields = ExtraFields }; } } } diff --git a/wwwroot/js/shared.js b/wwwroot/js/shared.js index 3727386..517366e 100644 --- a/wwwroot/js/shared.js +++ b/wwwroot/js/shared.js @@ -386,4 +386,21 @@ function showBulkImportModal(mode) { } function hideBulkImportModal() { $("#bulkImportModal").modal('hide'); +} +function getAndValidateExtraFields() { + var hasError = false; + var outputData = []; + $(".extra-field").map((index, elem) => { + var extraFieldName = $(elem).children("label").text(); + var extraFieldInput = $(elem).children("input"); + var extraFieldValue = extraFieldInput.val(); + if (extraFieldInput.hasClass('extra-field-required') && extraFieldValue.trim() == '') { + hasError = true; + extraFieldInput.addClass("is-invalid"); + } else { + extraFieldInput.removeClass("is-invalid"); + } + outputData.push({ name: extraFieldName, value: extraFieldValue }); + }); + return { hasError: hasError, extraFields: outputData }; } \ No newline at end of file