Merge pull request #885 from hargata/Hargata/146.changes
Display current odometer when incrementing.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -4,6 +4,15 @@
|
||||
$("#extraFieldModal").modal('show');
|
||||
});
|
||||
}
|
||||
function showServerConfigModal() {
|
||||
$.get(`/Home/GetServerConfiguration`, function (data) {
|
||||
$("#serverConfigModalContent").html(data);
|
||||
$("#serverConfigModal").modal('show');
|
||||
});
|
||||
}
|
||||
function hideServerConfigModal() {
|
||||
$("#serverConfigModal").modal('hide');
|
||||
}
|
||||
function hideExtraFieldModal() {
|
||||
$("#extraFieldModal").modal('hide');
|
||||
}
|
||||
@@ -85,6 +94,33 @@ function updateSettings() {
|
||||
}
|
||||
})
|
||||
}
|
||||
function sendTestEmail() {
|
||||
Swal.fire({
|
||||
title: 'Send Test Email',
|
||||
html: `
|
||||
<input type="text" id="testEmailRecipient" class="swal2-input" placeholder="Email Address" onkeydown="handleSwalEnter(event)">
|
||||
`,
|
||||
confirmButtonText: 'Send',
|
||||
focusConfirm: false,
|
||||
preConfirm: () => {
|
||||
const emailRecipient = $("#testEmailRecipient").val();
|
||||
if (!emailRecipient || emailRecipient.trim() == '') {
|
||||
Swal.showValidationMessage(`Please enter a valid email address`);
|
||||
}
|
||||
return { emailRecipient }
|
||||
},
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
$.post('/Home/SendTestEmail', { emailAddress: result.value.emailRecipient }, function (data) {
|
||||
if (data.success) {
|
||||
successToast(data.message);
|
||||
} else {
|
||||
errorToast(data.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function makeBackup() {
|
||||
$.get('/Files/MakeBackup', function (data) {
|
||||
window.location.href = data;
|
||||
|
||||
@@ -619,36 +619,37 @@ function getAndValidateSelectedRecurringReminder() {
|
||||
}
|
||||
}
|
||||
function getLastOdometerReadingAndIncrement(odometerFieldName) {
|
||||
Swal.fire({
|
||||
title: 'Increment Last Reported Odometer Reading',
|
||||
html: `
|
||||
$.get(`/Vehicle/GetMaxMileage?vehicleId=${GetVehicleId().vehicleId}`, function (currentOdometer) {
|
||||
let additionalHtml = isNaN(currentOdometer) || currentOdometer == 0 ? '' : `<span>Current Odometer: ${currentOdometer}</span><br/>`;
|
||||
Swal.fire({
|
||||
title: 'Increment Last Reported Odometer Reading',
|
||||
html: `${additionalHtml}
|
||||
<input type="text" inputmode="decimal" id="inputOdometerIncrement" class="swal2-input" placeholder="Increment" onkeydown="handleSwalEnter(event)">
|
||||
`,
|
||||
confirmButtonText: 'Add',
|
||||
focusConfirm: false,
|
||||
preConfirm: () => {
|
||||
const odometerIncrement = parseInt(globalParseFloat($("#inputOdometerIncrement").val()));
|
||||
if (isNaN(odometerIncrement) || odometerIncrement <= 0) {
|
||||
Swal.showValidationMessage(`Please enter a non-zero amount to increment`);
|
||||
}
|
||||
return { odometerIncrement }
|
||||
},
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
var amountToIncrement = result.value.odometerIncrement;
|
||||
$.get(`/Vehicle/GetMaxMileage?vehicleId=${GetVehicleId().vehicleId}`, function (data) {
|
||||
var newAmount = data + amountToIncrement;
|
||||
if (!isNaN(newAmount)) {
|
||||
var odometerField = $(`#${odometerFieldName}`);
|
||||
if (odometerField.length > 0) {
|
||||
odometerField.val(newAmount);
|
||||
confirmButtonText: 'Add',
|
||||
focusConfirm: false,
|
||||
preConfirm: () => {
|
||||
const odometerIncrement = parseInt(globalParseFloat($("#inputOdometerIncrement").val()));
|
||||
if (isNaN(odometerIncrement) || odometerIncrement < 0) {
|
||||
Swal.showValidationMessage(`Please enter a positive amount to increment or 0 to use current odometer`);
|
||||
}
|
||||
return { odometerIncrement }
|
||||
},
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
var amountToIncrement = result.value.odometerIncrement;
|
||||
var newAmount = currentOdometer + amountToIncrement;
|
||||
if (!isNaN(newAmount)) {
|
||||
var odometerField = $(`#${odometerFieldName}`);
|
||||
if (odometerField.length > 0) {
|
||||
odometerField.val(newAmount);
|
||||
} else {
|
||||
errorToast(genericErrorMessage());
|
||||
}
|
||||
} else {
|
||||
errorToast(genericErrorMessage());
|
||||
}
|
||||
} else {
|
||||
errorToast(genericErrorMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user