updated cached view to only show when there are unsaved changes present.

This commit is contained in:
DESKTOP-GENO133\IvanPlex 2024-04-05 07:10:09 -06:00
parent 44e3d19844
commit 2a2cb3bd0c
19 changed files with 36 additions and 63 deletions

View File

@ -8,7 +8,7 @@
var userLanguage = userConfig.UserLanguage;
}
<div class="modal-header">
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Repair Record") : translator.Translate(userLanguage, "Edit Repair Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditCollisionRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Cached")</small></h5>
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Repair Record") : translator.Translate(userLanguage, "Edit Repair Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditCollisionRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Unsaved Changes")</small></h5>
<button type="button" class="btn-close" onclick="hideAddCollisionRecordModal()" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@ -37,7 +37,7 @@
}
}
<div class="modal-header">
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Gas Record") : translator.Translate(userLanguage, "Edit Gas Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditGasRecordModal({Model.GasRecord.Id}, true)" )'>@translator.Translate(userLanguage, "Cached")</small></h5>
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Gas Record") : translator.Translate(userLanguage, "Edit Gas Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditGasRecordModal({Model.GasRecord.Id}, true)" )'>@translator.Translate(userLanguage, "Unsaved Changes")</small></h5>
<button type="button" class="btn-close" onclick="hideAddGasRecordModal()" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@ -8,7 +8,7 @@
var userLanguage = userConfig.UserLanguage;
}
<div class="modal-header">
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Note") : translator.Translate(userLanguage, "Edit Note"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditNoteModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Cached")</small></h5>
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Note") : translator.Translate(userLanguage, "Edit Note"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditNoteModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Unsaved Changes")</small></h5>
<button type="button" class="btn-close" onclick="hideAddNoteModal()" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@ -8,7 +8,7 @@
var userLanguage = userConfig.UserLanguage;
}
<div class="modal-header">
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Odometer Record") : translator.Translate(userLanguage, "Edit Odometer Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditOdometerRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Cached")</small></h5>
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Odometer Record") : translator.Translate(userLanguage, "Edit Odometer Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditOdometerRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Unsaved Changes")</small></h5>
<button type="button" class="btn-close" onclick="hideAddOdometerRecordModal()" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@ -8,7 +8,7 @@
var userLanguage = userConfig.UserLanguage;
}
<div class="modal-header">
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Plan Record") : translator.Translate(userLanguage, "Edit Plan Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditPlanRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Cached")</small></h5>
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Plan Record") : translator.Translate(userLanguage, "Edit Plan Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditPlanRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Unsaved Changes")</small></h5>
<button type="button" class="btn-close" onclick="hideAddPlanRecordModal()" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@ -8,7 +8,7 @@
var userLanguage = userConfig.UserLanguage;
}
<div class="modal-header">
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Service Record") : translator.Translate(userLanguage, "Edit Service Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditServiceRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Cached")</small></h5>
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Service Record") : translator.Translate(userLanguage, "Edit Service Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditServiceRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Unsaved Changes")</small></h5>
<button type="button" class="btn-close" onclick="hideAddServiceRecordModal()" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@ -8,7 +8,7 @@
var userLanguage = userConfig.UserLanguage;
}
<div class="modal-header">
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Supply Record") : translator.Translate(userLanguage, "Edit Supply Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditSupplyRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Cached")</small></h5>
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Supply Record") : translator.Translate(userLanguage, "Edit Supply Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditSupplyRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Unsaved Changes")</small></h5>
<button type="button" class="btn-close" onclick="hideAddSupplyRecordModal()" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@ -8,7 +8,7 @@
var userLanguage = userConfig.UserLanguage;
}
<div class="modal-header">
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Tax Record") : translator.Translate(userLanguage, "Edit Tax Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditTaxRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Cached")</small></h5>
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Tax Record") : translator.Translate(userLanguage, "Edit Tax Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditTaxRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Unsaved Changes")</small></h5>
<button type="button" class="btn-close" onclick="hideAddTaxRecordModal()" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@ -8,7 +8,7 @@
var userLanguage = userConfig.UserLanguage;
}
<div class="modal-header">
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Upgrade Record") : translator.Translate(userLanguage, "Edit Upgrade Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditUpgradeRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Cached")</small></h5>
<h5 class="modal-title">@(isNew ? translator.Translate(userLanguage, "Add New Upgrade Record") : translator.Translate(userLanguage, "Edit Upgrade Record"))<small style="display:none; @(isNew ? "" : "cursor:pointer;")" class="cached-banner ms-2 text-body-secondary" onclick='@(isNew ? "" : $"showEditUpgradeRecordModal({Model.Id}, true)" )'>@translator.Translate(userLanguage, "Unsaved Changes")</small></h5>
<button type="button" class="btn-close" onclick="hideAddUpgradeRecordModal()" aria-label="Close"></button>
</div>
<div class="modal-body">

View File

@ -15,7 +15,7 @@ function showEditCollisionRecordModal(collisionRecordId, nocache) {
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getCollisionRecordModelData().id;
if (existingId == collisionRecordId) {
if (existingId == collisionRecordId && $('[data-changed=true]').length > 0) {
$('#collisionRecordModal').modal('show');
$('.cached-banner').show();
return;
@ -29,6 +29,7 @@ function showEditCollisionRecordModal(collisionRecordId, nocache) {
initDatePicker($('#collisionRecordDate'));
initTagSelector($("#collisionRecordTag"));
$('#collisionRecordModal').modal('show');
bindModalInputChanges('collisionRecordModal');
$('#collisionRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("collisionRecordNotes");

View File

@ -15,7 +15,7 @@ function showEditGasRecordModal(gasRecordId, nocache) {
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getGasRecordModelData().id;
if (existingId == gasRecordId) {
if (existingId == gasRecordId && $('[data-changed=true]').length > 0) {
$('#gasRecordModal').modal('show');
$('.cached-banner').show();
return;
@ -29,6 +29,7 @@ function showEditGasRecordModal(gasRecordId, nocache) {
initDatePicker($('#gasRecordDate'));
initTagSelector($("#gasRecordTag"));
$('#gasRecordModal').modal('show');
bindModalInputChanges('gasRecordModal');
$('#gasRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("gasRecordNotes");

View File

@ -13,7 +13,7 @@ function showEditNoteModal(noteId, nocache) {
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getNoteModelData().id;
if (existingId == noteId) {
if (existingId == noteId && $('[data-changed=true]').length > 0) {
$('#noteModal').modal('show');
$('.cached-banner').show();
return;
@ -25,6 +25,7 @@ function showEditNoteModal(noteId, nocache) {
$("#noteModalContent").html(data);
initTagSelector($("#noteRecordTag"));
$('#noteModal').modal('show');
bindModalInputChanges('noteModal');
$('#noteModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("noteTextArea");

View File

@ -15,7 +15,7 @@ function showEditOdometerRecordModal(odometerRecordId, nocache) {
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getOdometerRecordModelData().id;
if (existingId == odometerRecordId) {
if (existingId == odometerRecordId && $('[data-changed=true]').length > 0) {
$('#odometerRecordModal').modal('show');
$('.cached-banner').show();
return;
@ -29,6 +29,7 @@ function showEditOdometerRecordModal(odometerRecordId, nocache) {
initDatePicker($('#odometerRecordDate'));
initTagSelector($("#odometerRecordTag"));
$('#odometerRecordModal').modal('show');
bindModalInputChanges('odometerRecordModal');
$('#odometerRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("odometerRecordNotes");

View File

@ -14,7 +14,7 @@ function showEditPlanRecordModal(planRecordId, nocache) {
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getPlanRecordModelData().id;
if (existingId == planRecordId) {
if (existingId == planRecordId && $('[data-changed=true]').length > 0) {
$('#planRecordModal').modal('show');
$('.cached-banner').show();
return;
@ -27,6 +27,7 @@ function showEditPlanRecordModal(planRecordId, nocache) {
//initiate datepicker
initDatePicker($('#planRecordDate'));
$('#planRecordModal').modal('show');
bindModalInputChanges('planRecordModal');
$('#planRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("planRecordNotes");

View File

@ -15,7 +15,7 @@ function showEditServiceRecordModal(serviceRecordId, nocache) {
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getServiceRecordModelData().id;
if (existingId == serviceRecordId) {
if (existingId == serviceRecordId && $('[data-changed=true]').length > 0) {
$('#serviceRecordModal').modal('show');
$('.cached-banner').show();
return;
@ -29,6 +29,7 @@ function showEditServiceRecordModal(serviceRecordId, nocache) {
initDatePicker($('#serviceRecordDate'));
initTagSelector($("#serviceRecordTag"));
$('#serviceRecordModal').modal('show');
bindModalInputChanges('serviceRecordModal');
$('#serviceRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("serviceRecordNotes");

View File

@ -706,57 +706,12 @@ $(window).on('keydown', function (e) {
e.preventDefault();
e.stopPropagation();
selectAllRows();
} else if ((e.ctrlKey || e.metaKey) && e.which == 90) {
e.preventDefault();
e.stopPropagation();
showModalForCurrentTab();
}
}
});
function getCurrentTab() {
return $(".tab-pane.active.show").attr('id');
}
function showModalForCurrentTab() {
var currentTab = getCurrentTab();
var modalName = "";
switch (currentTab) {
case "servicerecord-tab-pane":
modalName = "serviceRecordModal";
break;
case "gas-tab-pane":
modalName = "gasRecordModal";
break;
case "tax-tab-pane":
modalName = "taxRecordModal";
break;
case "notes-tab-pane":
modalName = "noteModal";
break;
case "accident-tab-pane":
modalName = "collisionRecordModal";
break;
case "upgrade-tab-pane":
modalName = "upgradeRecordModal";
break;
case "supply-tab-pane":
modalName = "supplyRecordModal";
break;
case "plan-tab-pane":
modalName = "planRecordModal";
break;
case "odometer-tab-pane":
modalName = "odometerRecordModal";
break;
}
if (modalName != '') {
//check if modal has content and no other modal is currently showing.
var modalContent = $(`#${modalName} .modal-content`);
if (modalContent.html().trim() != '' && $(".modal.fade.show").length == 0) {
$(`#${modalName}`).modal('show');
$('.cached-banner').show();
}
}
}
function selectAllRows() {
clearSelectedRows();
$('.vehicleDetailTabContainer .table tbody tr:visible').addClass('table-active');
@ -1089,4 +1044,13 @@ function waitForElement(element, callBack, callBackParameter) {
clearInterval(checkExist);
}
}, 100); // check every 100ms
}
function bindModalInputChanges(modalName) {
//bind text inputs
$(`#${modalName} input[type='text'], #${modalName} input[type='number'], #${modalName} textarea`).off('input').on('input', function (e) {
$(e.currentTarget).attr('data-changed', true);
});
$(`#${modalName} select, #${modalName} input[type='checkbox']`).off('input').on('input', function (e) {
$(e.currentTarget).attr('data-changed', true);
});
}

View File

@ -15,7 +15,7 @@ function showEditSupplyRecordModal(supplyRecordId, nocache) {
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getSupplyRecordModelData().id;
if (existingId == supplyRecordId) {
if (existingId == supplyRecordId && $('[data-changed=true]').length > 0) {
$('#supplyRecordModal').modal('show');
$('.cached-banner').show();
return;
@ -29,6 +29,7 @@ function showEditSupplyRecordModal(supplyRecordId, nocache) {
initDatePicker($('#supplyRecordDate'));
initTagSelector($("#supplyRecordTag"));
$('#supplyRecordModal').modal('show');
bindModalInputChanges('supplyRecordModal');
$('#supplyRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("supplyRecordNotes");

View File

@ -15,7 +15,7 @@ function showEditTaxRecordModal(taxRecordId, nocache) {
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getTaxRecordModelData().id;
if (existingId == taxRecordId) {
if (existingId == taxRecordId && $('[data-changed=true]').length > 0) {
$('#taxRecordModal').modal('show');
$('.cached-banner').show();
return;
@ -29,6 +29,7 @@ function showEditTaxRecordModal(taxRecordId, nocache) {
initDatePicker($('#taxRecordDate'));
initTagSelector($("#taxRecordTag"));
$('#taxRecordModal').modal('show');
bindModalInputChanges('taxRecordModal');
$('#taxRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("taxRecordNotes");

View File

@ -15,7 +15,7 @@ function showEditUpgradeRecordModal(upgradeRecordId, nocache) {
if (existingContent.trim() != '') {
//check if id is same.
var existingId = getUpgradeRecordModelData().id;
if (existingId == upgradeRecordId) {
if (existingId == upgradeRecordId && $('[data-changed=true]').length > 0) {
$('#upgradeRecordModal').modal('show');
$('.cached-banner').show();
return;
@ -29,6 +29,7 @@ function showEditUpgradeRecordModal(upgradeRecordId, nocache) {
initDatePicker($('#upgradeRecordDate'));
initTagSelector($("#upgradeRecordTag"));
$('#upgradeRecordModal').modal('show');
bindModalInputChanges('upgradeRecordModal');
$('#upgradeRecordModal').off('shown.bs.modal').on('shown.bs.modal', function () {
if (getGlobalConfig().useMarkDown) {
toggleMarkDownOverlay("upgradeRecordNotes");