Added context menu to plan records.
This commit is contained in:
@@ -151,6 +151,10 @@ namespace CarCareTracker.Controllers
|
||||
[HttpPost]
|
||||
public IActionResult UpdatePlanRecordProgress(int planRecordId, PlanProgress planProgress, int odometer = 0)
|
||||
{
|
||||
if (planRecordId == default)
|
||||
{
|
||||
return Json(false);
|
||||
}
|
||||
var existingRecord = _planRecordDataAccess.GetPlanRecordById(planRecordId);
|
||||
existingRecord.Progress = planProgress;
|
||||
existingRecord.DateModified = DateTime.Now;
|
||||
|
||||
@@ -506,6 +506,7 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
var existingRecord = _serviceRecordDataAccess.GetServiceRecordById(recordId);
|
||||
existingRecord.Id = default;
|
||||
existingRecord.RequisitionHistory = new List<SupplyUsageHistory>();
|
||||
result = _serviceRecordDataAccess.SaveServiceRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
@@ -513,6 +514,7 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
var existingRecord = _collisionRecordDataAccess.GetCollisionRecordById(recordId);
|
||||
existingRecord.Id = default;
|
||||
existingRecord.RequisitionHistory = new List<SupplyUsageHistory>();
|
||||
result = _collisionRecordDataAccess.SaveCollisionRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
@@ -520,6 +522,7 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
var existingRecord = _upgradeRecordDataAccess.GetUpgradeRecordById(recordId);
|
||||
existingRecord.Id = default;
|
||||
existingRecord.RequisitionHistory = new List<SupplyUsageHistory>();
|
||||
result = _upgradeRecordDataAccess.SaveUpgradeRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
@@ -541,6 +544,7 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
var existingRecord = _supplyRecordDataAccess.GetSupplyRecordById(recordId);
|
||||
existingRecord.Id = default;
|
||||
existingRecord.RequisitionHistory = new List<SupplyUsageHistory>();
|
||||
result = _supplyRecordDataAccess.SaveSupplyRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
@@ -565,6 +569,15 @@ namespace CarCareTracker.Controllers
|
||||
result = _reminderRecordDataAccess.SaveReminderRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
case ImportMode.PlanRecord:
|
||||
{
|
||||
var existingRecord = _planRecordDataAccess.GetPlanRecordById(recordId);
|
||||
existingRecord.Id = default;
|
||||
existingRecord.ReminderRecordId = default;
|
||||
existingRecord.RequisitionHistory = new List<SupplyUsageHistory>();
|
||||
result = _planRecordDataAccess.SavePlanRecordToVehicle(existingRecord);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (result)
|
||||
@@ -589,6 +602,7 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
var existingRecord = _serviceRecordDataAccess.GetServiceRecordById(recordId);
|
||||
existingRecord.Id = default;
|
||||
existingRecord.RequisitionHistory = new List<SupplyUsageHistory>();
|
||||
foreach (int vehicleId in vehicleIds)
|
||||
{
|
||||
existingRecord.VehicleId = vehicleId;
|
||||
@@ -600,6 +614,7 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
var existingRecord = _collisionRecordDataAccess.GetCollisionRecordById(recordId);
|
||||
existingRecord.Id = default;
|
||||
existingRecord.RequisitionHistory = new List<SupplyUsageHistory>();
|
||||
foreach (int vehicleId in vehicleIds)
|
||||
{
|
||||
existingRecord.VehicleId = vehicleId;
|
||||
@@ -611,6 +626,7 @@ namespace CarCareTracker.Controllers
|
||||
{
|
||||
var existingRecord = _upgradeRecordDataAccess.GetUpgradeRecordById(recordId);
|
||||
existingRecord.Id = default;
|
||||
existingRecord.RequisitionHistory = new List<SupplyUsageHistory>();
|
||||
foreach (int vehicleId in vehicleIds)
|
||||
{
|
||||
existingRecord.VehicleId = vehicleId;
|
||||
@@ -684,6 +700,19 @@ namespace CarCareTracker.Controllers
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ImportMode.PlanRecord:
|
||||
{
|
||||
var existingRecord = _planRecordDataAccess.GetPlanRecordById(recordId);
|
||||
existingRecord.Id = default;
|
||||
existingRecord.ReminderRecordId = default;
|
||||
existingRecord.RequisitionHistory = new List<SupplyUsageHistory>();
|
||||
foreach (int vehicleId in vehicleIds)
|
||||
{
|
||||
existingRecord.VehicleId = vehicleId;
|
||||
result = _planRecordDataAccess.SavePlanRecordToVehicle(existingRecord);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (result)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@model PlanRecord
|
||||
<div class="taskCard @(Model.Progress == PlanProgress.Done ? "nodrag" : "") text-dark user-select-none mt-2 mb-2" draggable="@(Model.Progress == PlanProgress.Done ? "false" : "true")" ondragstart="dragStart(event, @Model.Id)" onclick="@(Model.Progress == PlanProgress.Done ? $"deletePlanRecord({Model.Id}, true)" : $"showEditPlanRecordModal({Model.Id})")">
|
||||
<div class="taskCard @(Model.Progress == PlanProgress.Done ? "nodrag" : "") text-dark user-select-none mt-2 mb-2" draggable="@(Model.Progress == PlanProgress.Done ? "false" : "true")" ondragstart="dragStart(event, @Model.Id)" onclick="@(Model.Progress == PlanProgress.Done ? $"deletePlanRecord({Model.Id}, true)" : $"showEditPlanRecordModal({Model.Id})")" oncontextmenu="@($"showPlanTableContextMenu(this, {Model.Id}, '{Model.Progress}')")" onmouseup="stopEvent()" ontouchstart="detectPlanItemLongTouch(this, @Model.Id, '@Model.Progress')" ontouchend="detectPlanItemTouchEndPremature(this)">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-8 text-truncate">
|
||||
|
||||
@@ -117,3 +117,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul class="table-context-menu dropdown-menu" style="display:none;">
|
||||
<li><h6 class="dropdown-header context-menu-move move-header">@translator.Translate(userLanguage, "Move To")</h6></li>
|
||||
<li><a class="dropdown-item context-menu-move move-planned" href="#"><div class="d-flex justify-content-between"><span class="me-5">@translator.Translate(userLanguage, "Planned")</span><i class="bi bi-list-task"></i></div></a></li>
|
||||
<li><a class="dropdown-item context-menu-move move-doing" href="#"><div class="d-flex justify-content-between"><span class="me-5">@translator.Translate(userLanguage, "Doing")</span><i class="bi bi-tools"></i></div></a></li>
|
||||
<li><a class="dropdown-item context-menu-move move-testing" href="#"><div class="d-flex justify-content-between"><span class="me-5">@translator.Translate(userLanguage, "Testing")</span><i class="bi bi-eyeglasses"></i></div></a></li>
|
||||
<li><a class="dropdown-item context-menu-move move-done" href="#"><div class="d-flex justify-content-between"><span class="me-5">@translator.Translate(userLanguage, "Done")</span><i class="bi bi-check2-all"></i></div></a></li>
|
||||
<li><hr class="context-menu-move move-header dropdown-divider"></li>
|
||||
<li><a class="dropdown-item context-menu-move move-header context-menu-duplicate" href="#"><div class="d-flex justify-content-between"><span class="me-5">@translator.Translate(userLanguage, "Duplicate")</span><i class="bi bi-copy"></i></div></a></li>
|
||||
<li><a class="dropdown-item context-menu-move move-header context-menu-duplicate-vehicle" href="#"><div class="d-flex justify-content-between"><span class="me-5">@translator.Translate(userLanguage, "Duplicate To Vehicle")</span><i class="bi bi-copy"></i></div></a></li>
|
||||
<li><a class="dropdown-item context-menu-move move-header text-danger context-menu-delete" href="#"><div class="d-flex justify-content-between"><span class="me-5">@translator.Translate(userLanguage, "Delete")</span><i class="bi bi-trash"></i></div></a></li>
|
||||
</ul>
|
||||
@@ -269,6 +269,10 @@ function dragStart(event, planRecordId) {
|
||||
}
|
||||
function dragOver(event) {
|
||||
event.preventDefault();
|
||||
if (planTouchTimer) {
|
||||
clearTimeout(planTouchTimer);
|
||||
planTouchTimer = null;
|
||||
}
|
||||
}
|
||||
function dropBox(event, newProgress) {
|
||||
var targetSwimLane = $(event.target).hasClass("swimlane") ? event.target : $(event.target).parents(".swimlane")[0];
|
||||
@@ -350,3 +354,104 @@ function hideOrderSupplyModal() {
|
||||
$("#planRecordTemplateSupplyOrderModal").modal('hide');
|
||||
showPlanRecordTemplatesModal();
|
||||
}
|
||||
function configurePlanTableContextMenu(planRecordId, currentSwimLane) {
|
||||
//clear any bound actions
|
||||
$(".context-menu-move").off('click');
|
||||
//bind context menu actions
|
||||
$(".context-menu-delete").on('click', () => {
|
||||
deletePlanRecord(planRecordId, true);
|
||||
});
|
||||
let planRecordIdArray = [planRecordId];
|
||||
$(".context-menu-duplicate").on('click', () => {
|
||||
duplicateRecords(planRecordIdArray, 'PlanRecord');
|
||||
});
|
||||
$(".context-menu-duplicate-vehicle").on('click', () => {
|
||||
duplicateRecordsToOtherVehicles(planRecordIdArray, 'PlanRecord');
|
||||
});
|
||||
$(".context-menu-move.move-planned").on('click', () => {
|
||||
draggedId = planRecordId;
|
||||
updatePlanRecordProgress('Backlog');
|
||||
draggedId = 0;
|
||||
});
|
||||
$(".context-menu-move.move-doing").on('click', () => {
|
||||
draggedId = planRecordId;
|
||||
updatePlanRecordProgress('InProgress');
|
||||
});
|
||||
$(".context-menu-move.move-testing").on('click', () => {
|
||||
draggedId = planRecordId;
|
||||
updatePlanRecordProgress('Testing');
|
||||
});
|
||||
$(".context-menu-move.move-done").on('click', () => {
|
||||
draggedId = planRecordId;
|
||||
updatePlanRecordProgress('Done');
|
||||
});
|
||||
//hide all move buttons
|
||||
$(".context-menu-move").hide();
|
||||
$(".context-menu-delete").show(); //delete is always visible.
|
||||
switch (currentSwimLane) {
|
||||
case 'Backlog':
|
||||
$(".context-menu-move.move-header").show();
|
||||
$(".context-menu-move.move-doing").show();
|
||||
$(".context-menu-move.move-testing").show();
|
||||
$(".context-menu-move.move-done").show();
|
||||
break;
|
||||
case 'InProgress':
|
||||
$(".context-menu-move.move-header").show();
|
||||
$(".context-menu-move.move-planned").show();
|
||||
$(".context-menu-move.move-testing").show();
|
||||
$(".context-menu-move.move-done").show();
|
||||
break;
|
||||
case 'Testing':
|
||||
$(".context-menu-move.move-header").show();
|
||||
$(".context-menu-move.move-planned").show();
|
||||
$(".context-menu-move.move-doing").show();
|
||||
$(".context-menu-move.move-done").show();
|
||||
break;
|
||||
case 'Done':
|
||||
break;
|
||||
}
|
||||
}
|
||||
function showPlanTableContextMenu(e, planRecordId, currentSwimLane) {
|
||||
if (event != undefined) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (getDeviceIsTouchOnly()) {
|
||||
return;
|
||||
}
|
||||
if (planRecordId == 0) {
|
||||
return;
|
||||
}
|
||||
$(".table-context-menu").fadeIn("fast");
|
||||
$(".table-context-menu").css({
|
||||
left: getMenuPosition(event.clientX, 'width', 'scrollLeft'),
|
||||
top: getMenuPosition(event.clientY, 'height', 'scrollTop')
|
||||
});
|
||||
configurePlanTableContextMenu(planRecordId, currentSwimLane);
|
||||
}
|
||||
function showPlanTableContextMenuForMobile(e, xPosition, yPosition, planRecordId, currentSwimLane) {
|
||||
$(".table-context-menu").fadeIn("fast");
|
||||
$(".table-context-menu").css({
|
||||
left: getMenuPosition(xPosition, 'width', 'scrollLeft'),
|
||||
top: getMenuPosition(yPosition, 'height', 'scrollTop')
|
||||
});
|
||||
configurePlanTableContextMenu(planRecordId, currentSwimLane);
|
||||
if (planTouchTimer) {
|
||||
clearTimeout(planTouchTimer);
|
||||
planTouchTimer = null;
|
||||
}
|
||||
}
|
||||
var planTouchTimer;
|
||||
var planTouchDuration = 3000;
|
||||
function detectPlanItemLongTouch(sender, planRecordId, currentSwimLane) {
|
||||
var touchX = event.touches[0].clientX;
|
||||
var touchY = event.touches[0].clientY;
|
||||
if (!planTouchTimer) {
|
||||
planTouchTimer = setTimeout(function () { showPlanTableContextMenuForMobile(sender, touchX, touchY, planRecordId, currentSwimLane); detectPlanItemTouchEndPremature(sender); }, planTouchDuration);
|
||||
}
|
||||
}
|
||||
function detectPlanItemTouchEndPremature(sender) {
|
||||
if (planTouchTimer) {
|
||||
clearTimeout(planTouchTimer);
|
||||
planTouchTimer = null;
|
||||
}
|
||||
}
|
||||
@@ -825,6 +825,10 @@ function duplicateRecords(ids, source) {
|
||||
friendlySource = "Fuel Records";
|
||||
refreshDataCallBack = getVehicleGasRecords;
|
||||
break;
|
||||
case "PlanRecord":
|
||||
friendlySource = "Plan";
|
||||
refreshDataCallBack = getVehiclePlanRecords;
|
||||
break;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
@@ -894,6 +898,10 @@ function duplicateRecordsToOtherVehicles(ids, source) {
|
||||
friendlySource = "Fuel Records";
|
||||
refreshDataCallBack = getVehicleGasRecords;
|
||||
break;
|
||||
case "PlanRecord":
|
||||
friendlySource = "Plan";
|
||||
refreshDataCallBack = getVehiclePlanRecords;
|
||||
break;
|
||||
}
|
||||
|
||||
$.get(`/Home/GetVehicleSelector?vehicleId=${GetVehicleId().vehicleId}`, function (data) {
|
||||
|
||||
@@ -552,6 +552,7 @@ function adjustRecordsOdometer(ids, source) {
|
||||
confirmButtonColor: "#dc3545"
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
saveScrollPosition();
|
||||
$.post('/Vehicle/AdjustRecordsOdometer', { recordIds: ids, vehicleId: GetVehicleId().vehicleId, importMode: source }, function (data) {
|
||||
if (data) {
|
||||
successToast(`${ids.length} Record(s) Updated`);
|
||||
|
||||
Reference in New Issue
Block a user