asks for odometer reading when task is marked as done.
This commit is contained in:
@@ -1250,7 +1250,7 @@ namespace CarCareTracker.Controllers
|
||||
return PartialView("_PlanRecordModal", new PlanRecordInput());
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult UpdatePlanRecordProgress(int planRecordId, PlanProgress planProgress)
|
||||
public IActionResult UpdatePlanRecordProgress(int planRecordId, PlanProgress planProgress, int odometer = 0)
|
||||
{
|
||||
var existingRecord = _planRecordDataAccess.GetPlanRecordById(planRecordId);
|
||||
existingRecord.Progress = planProgress;
|
||||
@@ -1265,10 +1265,11 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
VehicleId = existingRecord.VehicleId,
|
||||
Date = DateTime.Now,
|
||||
Mileage = 0,
|
||||
Mileage = odometer,
|
||||
Description = existingRecord.Description,
|
||||
Cost = existingRecord.Cost,
|
||||
Notes = existingRecord.Notes
|
||||
Notes = existingRecord.Notes,
|
||||
Files = existingRecord.Files
|
||||
};
|
||||
_serviceRecordDataAccess.SaveServiceRecordToVehicle(newRecord);
|
||||
} else if (existingRecord.ImportMode == ImportMode.RepairRecord)
|
||||
@@ -1277,10 +1278,11 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
VehicleId = existingRecord.VehicleId,
|
||||
Date = DateTime.Now,
|
||||
Mileage = 0,
|
||||
Mileage = odometer,
|
||||
Description = existingRecord.Description,
|
||||
Cost = existingRecord.Cost,
|
||||
Notes = existingRecord.Notes
|
||||
Notes = existingRecord.Notes,
|
||||
Files = existingRecord.Files
|
||||
};
|
||||
_collisionRecordDataAccess.SaveCollisionRecordToVehicle(newRecord);
|
||||
} else if (existingRecord.ImportMode == ImportMode.UpgradeRecord)
|
||||
@@ -1289,10 +1291,11 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
VehicleId = existingRecord.VehicleId,
|
||||
Date = DateTime.Now,
|
||||
Mileage = 0,
|
||||
Mileage = odometer,
|
||||
Description = existingRecord.Description,
|
||||
Cost = existingRecord.Cost,
|
||||
Notes = existingRecord.Notes
|
||||
Notes = existingRecord.Notes,
|
||||
Files = existingRecord.Files
|
||||
};
|
||||
_upgradeRecordDataAccess.SaveUpgradeRecordToVehicle(newRecord);
|
||||
}
|
||||
|
||||
@@ -132,15 +132,47 @@ function dropBox(event, newProgress) {
|
||||
}
|
||||
function updatePlanRecordProgress(newProgress) {
|
||||
if (draggedId > 0) {
|
||||
$.post('/Vehicle/UpdatePlanRecordProgress', { planRecordId: draggedId, planProgress: newProgress }, function (data) {
|
||||
if (data) {
|
||||
successToast("Plan Progress Updated");
|
||||
var vehicleId = GetVehicleId().vehicleId;
|
||||
getVehiclePlanRecords(vehicleId);
|
||||
} else {
|
||||
errorToast("An error has occurred, please try again later.");
|
||||
}
|
||||
});
|
||||
if (newProgress == 'Done') {
|
||||
//if user is marking the task as done, we will want them to enter the mileage so that we can auto-convert it.
|
||||
Swal.fire({
|
||||
title: 'Mark Task as Done?',
|
||||
html: `<p>To confirm, please enter the current odometer reading on your vehicle, as we also need the current odometer to auto convert the task into the relevant record.</p>
|
||||
<input type="text" id="inputOdometer" class="swal2-input" placeholder="Odometer Reading">
|
||||
`,
|
||||
confirmButtonText: 'Confirm',
|
||||
focusConfirm: false,
|
||||
preConfirm: () => {
|
||||
const odometer = $("#inputOdometer").val();
|
||||
if (!odometer || isNaN(odometer)) {
|
||||
Swal.showValidationMessage(`Please enter an odometer reading`)
|
||||
}
|
||||
return { odometer }
|
||||
},
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
$.post('/Vehicle/UpdatePlanRecordProgress', { planRecordId: draggedId, planProgress: newProgress, odometer: result.value.odometer }, function (data) {
|
||||
if (data) {
|
||||
successToast("Plan Progress Updated");
|
||||
var vehicleId = GetVehicleId().vehicleId;
|
||||
getVehiclePlanRecords(vehicleId);
|
||||
} else {
|
||||
errorToast("An error has occurred, please try again later.");
|
||||
}
|
||||
});
|
||||
}
|
||||
draggedId = 0;
|
||||
});
|
||||
} else {
|
||||
$.post('/Vehicle/UpdatePlanRecordProgress', { planRecordId: draggedId, planProgress: newProgress }, function (data) {
|
||||
if (data) {
|
||||
successToast("Plan Progress Updated");
|
||||
var vehicleId = GetVehicleId().vehicleId;
|
||||
getVehiclePlanRecords(vehicleId);
|
||||
} else {
|
||||
errorToast("An error has occurred, please try again later.");
|
||||
}
|
||||
});
|
||||
draggedId = 0;
|
||||
}
|
||||
}
|
||||
draggedId = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user