Cache the record the user was viewing if they didn't save, delete, or move it.

This commit is contained in:
DESKTOP-GENO133\IvanPlex
2024-04-02 21:51:02 -06:00
parent bfc0b58728
commit d05afe41d6
20 changed files with 128 additions and 19 deletions

View File

@@ -9,7 +9,19 @@
}
});
}
function showEditCollisionRecordModal(collisionRecordId) {
function showEditCollisionRecordModal(collisionRecordId, nocache) {
if (!nocache) {
var existingContent = $("#collisionRecordModalContent").html();
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getCollisionRecordModelData().id;
if (existingId == collisionRecordId) {
$('#collisionRecordModal').modal('show');
$('.cached-banner').show();
return;
}
}
}
$.get(`/Vehicle/GetCollisionRecordForEditById?collisionRecordId=${collisionRecordId}`, function (data) {
if (data) {
$("#collisionRecordModalContent").html(data);

View File

@@ -9,7 +9,19 @@
}
});
}
function showEditGasRecordModal(gasRecordId) {
function showEditGasRecordModal(gasRecordId, nocache) {
if (!nocache) {
var existingContent = $("#gasRecordModalContent").html();
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getGasRecordModelData().id;
if (existingId == gasRecordId) {
$('#gasRecordModal').modal('show');
$('.cached-banner').show();
return;
}
}
}
$.get(`/Vehicle/GetGasRecordForEditById?gasRecordId=${gasRecordId}`, function (data) {
if (data) {
$("#gasRecordModalContent").html(data);

View File

@@ -7,7 +7,19 @@
}
});
}
function showEditNoteModal(noteId) {
function showEditNoteModal(noteId, nocache) {
if (!nocache) {
var existingContent = $("#noteModalContent").html();
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getNoteModelData().id;
if (existingId == noteId) {
$('#noteModal').modal('show');
$('.cached-banner').show();
return;
}
}
}
$.get(`/Vehicle/GetNoteForEditById?noteId=${noteId}`, function (data) {
if (data) {
$("#noteModalContent").html(data);

View File

@@ -9,7 +9,19 @@
}
});
}
function showEditOdometerRecordModal(odometerRecordId) {
function showEditOdometerRecordModal(odometerRecordId, nocache) {
if (!nocache) {
var existingContent = $("#odometerRecordModalContent").html();
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getOdometerRecordModelData().id;
if (existingId == odometerRecordId) {
$('#odometerRecordModal').modal('show');
$('.cached-banner').show();
return;
}
}
}
$.get(`/Vehicle/GetOdometerRecordForEditById?odometerRecordId=${odometerRecordId}`, function (data) {
if (data) {
$("#odometerRecordModalContent").html(data);

View File

@@ -8,7 +8,19 @@
}
});
}
function showEditPlanRecordModal(planRecordId) {
function showEditPlanRecordModal(planRecordId, nocache) {
if (!nocache) {
var existingContent = $("#planRecordModalContent").html();
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getPlanRecordModelData().id;
if (existingId == planRecordId) {
$('#planRecordModal').modal('show');
$('.cached-banner').show();
return;
}
}
}
$.get(`/Vehicle/GetPlanRecordForEditById?planRecordId=${planRecordId}`, function (data) {
if (data) {
$("#planRecordModalContent").html(data);

View File

@@ -9,7 +9,19 @@
}
});
}
function showEditServiceRecordModal(serviceRecordId) {
function showEditServiceRecordModal(serviceRecordId, nocache) {
if (!nocache) {
var existingContent = $("#serviceRecordModalContent").html();
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getServiceRecordModelData().id;
if (existingId == serviceRecordId) {
$('#serviceRecordModal').modal('show');
$('.cached-banner').show();
return;
}
}
}
$.get(`/Vehicle/GetServiceRecordForEditById?serviceRecordId=${serviceRecordId}`, function (data) {
if (data) {
$("#serviceRecordModalContent").html(data);

View File

@@ -753,6 +753,7 @@ function showModalForCurrentTab() {
var modalContent = $(`#${modalName} .modal-content`);
if (modalContent.html().trim() != '' && $(".modal.fade.show").length == 0) {
$(`#${modalName}`).modal('show');
$('.cached-banner').show();
}
}
}

View File

@@ -9,7 +9,19 @@
}
});
}
function showEditSupplyRecordModal(supplyRecordId) {
function showEditSupplyRecordModal(supplyRecordId, nocache) {
if (!nocache) {
var existingContent = $("#supplyRecordModalContent").html();
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getSupplyRecordModelData().id;
if (existingId == supplyRecordId) {
$('#supplyRecordModal').modal('show');
$('.cached-banner').show();
return;
}
}
}
$.get(`/Vehicle/GetSupplyRecordForEditById?supplyRecordId=${supplyRecordId}`, function (data) {
if (data) {
$("#supplyRecordModalContent").html(data);

View File

@@ -9,7 +9,19 @@
}
});
}
function showEditTaxRecordModal(taxRecordId) {
function showEditTaxRecordModal(taxRecordId, nocache) {
if (!nocache) {
var existingContent = $("#taxRecordModalContent").html();
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getTaxRecordModelData().id;
if (existingId == taxRecordId) {
$('#taxRecordModal').modal('show');
$('.cached-banner').show();
return;
}
}
}
$.get(`/Vehicle/GetTaxRecordForEditById?taxRecordId=${taxRecordId}`, function (data) {
if (data) {
$("#taxRecordModalContent").html(data);

View File

@@ -9,7 +9,19 @@
}
});
}
function showEditUpgradeRecordModal(upgradeRecordId) {
function showEditUpgradeRecordModal(upgradeRecordId, nocache) {
if (!nocache) {
var existingContent = $("#upgradeRecordModalContent").html();
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getUpgradeRecordModelData().id;
if (existingId == upgradeRecordId) {
$('#upgradeRecordModal').modal('show');
$('.cached-banner').show();
return;
}
}
}
$.get(`/Vehicle/GetUpgradeRecordForEditById?upgradeRecordId=${upgradeRecordId}`, function (data) {
if (data) {
$("#upgradeRecordModalContent").html(data);