Merge pull request #453 from hargata/Hargata/bring.back.modal

Allow users to bring back modal window they accidentally closed.
This commit is contained in:
Hargata Softworks
2024-04-02 07:39:25 -06:00
committed by GitHub

View File

@@ -706,9 +706,56 @@ $(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');
}
}
}
function selectAllRows() {
clearSelectedRows();
$('.vehicleDetailTabContainer .table tbody tr:visible').addClass('table-active');