From a52ac6a41bb9a692705dd07ae17830ab3711741f Mon Sep 17 00:00:00 2001 From: "DESKTOP-GENO133\\IvanPlex" Date: Tue, 6 Feb 2024 15:54:32 -0700 Subject: [PATCH] Front end for creating plan records from templates. --- Controllers/VehicleController.cs | 8 ++ Views/Vehicle/_PlanRecordModal.cshtml | 11 ++- Views/Vehicle/_PlanRecordTemplateModal.cshtml | 87 +++++++++++++++++++ Views/Vehicle/_PlanRecords.cshtml | 2 +- wwwroot/js/planrecord.js | 73 ++++++++++++++++ 5 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 Views/Vehicle/_PlanRecordTemplateModal.cshtml diff --git a/Controllers/VehicleController.cs b/Controllers/VehicleController.cs index 6ac5c58..fdada44 100644 --- a/Controllers/VehicleController.cs +++ b/Controllers/VehicleController.cs @@ -1613,6 +1613,7 @@ namespace CarCareTracker.Controllers var result = _planRecordTemplateDataAccess.SavePlanRecordTemplateToVehicle(planRecord); return Json(new OperationResponse { Success = result, Message = result ? "Template Added" : StaticHelper.GenericErrorMessage }); } + [TypeFilter(typeof(CollaboratorFilter))] [HttpGet] public IActionResult GetPlanRecordTemplatesForVehicleId(int vehicleId) { @@ -1620,6 +1621,12 @@ namespace CarCareTracker.Controllers return PartialView("_PlanRecordTemplateModal", result); } [HttpPost] + public IActionResult DeletePlanRecordTemplateById(int planRecordTemplateId) + { + var result = _planRecordTemplateDataAccess.DeletePlanRecordTemplateById(planRecordTemplateId); + return Json(result); + } + [HttpPost] public IActionResult ConvertPlanRecordTemplateToPlanRecord(int planRecordTemplateId) { var existingRecord = _planRecordTemplateDataAccess.GetPlanRecordTemplateById(planRecordTemplateId); @@ -1639,6 +1646,7 @@ namespace CarCareTracker.Controllers //populate createdDate existingRecord.DateCreated = DateTime.Now.ToString("G"); existingRecord.DateModified = DateTime.Now.ToString("G"); + existingRecord.Id = default; var result = _planRecordDataAccess.SavePlanRecordToVehicle(existingRecord.ToPlanRecord()); if (result && existingRecord.Supplies.Any()) { diff --git a/Views/Vehicle/_PlanRecordModal.cshtml b/Views/Vehicle/_PlanRecordModal.cshtml index a88c0af..b924d03 100644 --- a/Views/Vehicle/_PlanRecordModal.cshtml +++ b/Views/Vehicle/_PlanRecordModal.cshtml @@ -82,7 +82,16 @@ @if (isNew) { - +
+ + + +
} else if (!isNew) { diff --git a/Views/Vehicle/_PlanRecordTemplateModal.cshtml b/Views/Vehicle/_PlanRecordTemplateModal.cshtml new file mode 100644 index 0000000..198e17d --- /dev/null +++ b/Views/Vehicle/_PlanRecordTemplateModal.cshtml @@ -0,0 +1,87 @@ +@using CarCareTracker.Helper +@inject IConfigHelper config +@inject ITranslationHelper translator +@{ + var userConfig = config.GetUserConfig(User); + var userLanguage = userConfig.UserLanguage; +} +@model List + + + \ No newline at end of file diff --git a/Views/Vehicle/_PlanRecords.cshtml b/Views/Vehicle/_PlanRecords.cshtml index 4ddd231..b01cba8 100644 --- a/Views/Vehicle/_PlanRecords.cshtml +++ b/Views/Vehicle/_PlanRecords.cshtml @@ -102,7 +102,7 @@ -