diff --git a/Views/Vehicle/_TaxRecordModal.cshtml b/Views/Vehicle/_TaxRecordModal.cshtml
index 026b7af..fbef7f9 100644
--- a/Views/Vehicle/_TaxRecordModal.cshtml
+++ b/Views/Vehicle/_TaxRecordModal.cshtml
@@ -8,7 +8,7 @@
var userLanguage = userConfig.UserLanguage;
}
diff --git a/Views/Vehicle/_UpgradeRecordModal.cshtml b/Views/Vehicle/_UpgradeRecordModal.cshtml
index 97573fb..523f55c 100644
--- a/Views/Vehicle/_UpgradeRecordModal.cshtml
+++ b/Views/Vehicle/_UpgradeRecordModal.cshtml
@@ -8,7 +8,7 @@
var userLanguage = userConfig.UserLanguage;
}
diff --git a/wwwroot/js/collisionrecord.js b/wwwroot/js/collisionrecord.js
index 2c6a3da..3431a5e 100644
--- a/wwwroot/js/collisionrecord.js
+++ b/wwwroot/js/collisionrecord.js
@@ -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");
diff --git a/wwwroot/js/gasrecord.js b/wwwroot/js/gasrecord.js
index 01b4aff..67de342 100644
--- a/wwwroot/js/gasrecord.js
+++ b/wwwroot/js/gasrecord.js
@@ -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");
diff --git a/wwwroot/js/note.js b/wwwroot/js/note.js
index 0d3f7f9..0ad93f0 100644
--- a/wwwroot/js/note.js
+++ b/wwwroot/js/note.js
@@ -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");
diff --git a/wwwroot/js/odometerrecord.js b/wwwroot/js/odometerrecord.js
index d384fae..e7bf559 100644
--- a/wwwroot/js/odometerrecord.js
+++ b/wwwroot/js/odometerrecord.js
@@ -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");
diff --git a/wwwroot/js/planrecord.js b/wwwroot/js/planrecord.js
index 87ee450..2cdf3d2 100644
--- a/wwwroot/js/planrecord.js
+++ b/wwwroot/js/planrecord.js
@@ -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");
diff --git a/wwwroot/js/servicerecord.js b/wwwroot/js/servicerecord.js
index c7a1b02..d42a10b 100644
--- a/wwwroot/js/servicerecord.js
+++ b/wwwroot/js/servicerecord.js
@@ -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");
diff --git a/wwwroot/js/shared.js b/wwwroot/js/shared.js
index bcedc5d..efa9d12 100644
--- a/wwwroot/js/shared.js
+++ b/wwwroot/js/shared.js
@@ -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);
+ });
}
\ No newline at end of file
diff --git a/wwwroot/js/supplyrecord.js b/wwwroot/js/supplyrecord.js
index cd168d3..a64e28a 100644
--- a/wwwroot/js/supplyrecord.js
+++ b/wwwroot/js/supplyrecord.js
@@ -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");
diff --git a/wwwroot/js/taxrecord.js b/wwwroot/js/taxrecord.js
index 1277433..4fca8f0 100644
--- a/wwwroot/js/taxrecord.js
+++ b/wwwroot/js/taxrecord.js
@@ -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");
diff --git a/wwwroot/js/upgraderecord.js b/wwwroot/js/upgraderecord.js
index 9c144ae..6245cef 100644
--- a/wwwroot/js/upgraderecord.js
+++ b/wwwroot/js/upgraderecord.js
@@ -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");