Display current odometer when incrementing.
This commit is contained in:
@@ -12,7 +12,7 @@ namespace CarCareTracker.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class StaticHelper
|
public static class StaticHelper
|
||||||
{
|
{
|
||||||
public const string VersionNumber = "1.4.5";
|
public const string VersionNumber = "1.4.6";
|
||||||
public const string DbName = "data/cartracker.db";
|
public const string DbName = "data/cartracker.db";
|
||||||
public const string UserConfigPath = "data/config/userConfig.json";
|
public const string UserConfigPath = "data/config/userConfig.json";
|
||||||
public const string LegacyUserConfigPath = "config/userConfig.json";
|
public const string LegacyUserConfigPath = "config/userConfig.json";
|
||||||
|
|||||||
@@ -619,36 +619,37 @@ function getAndValidateSelectedRecurringReminder() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function getLastOdometerReadingAndIncrement(odometerFieldName) {
|
function getLastOdometerReadingAndIncrement(odometerFieldName) {
|
||||||
Swal.fire({
|
$.get(`/Vehicle/GetMaxMileage?vehicleId=${GetVehicleId().vehicleId}`, function (currentOdometer) {
|
||||||
title: 'Increment Last Reported Odometer Reading',
|
let additionalHtml = isNaN(currentOdometer) || currentOdometer == 0 ? '' : `<span>Current Odometer: ${currentOdometer}</span><br/>`;
|
||||||
html: `
|
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)">
|
<input type="text" inputmode="decimal" id="inputOdometerIncrement" class="swal2-input" placeholder="Increment" onkeydown="handleSwalEnter(event)">
|
||||||
`,
|
`,
|
||||||
confirmButtonText: 'Add',
|
confirmButtonText: 'Add',
|
||||||
focusConfirm: false,
|
focusConfirm: false,
|
||||||
preConfirm: () => {
|
preConfirm: () => {
|
||||||
const odometerIncrement = parseInt(globalParseFloat($("#inputOdometerIncrement").val()));
|
const odometerIncrement = parseInt(globalParseFloat($("#inputOdometerIncrement").val()));
|
||||||
if (isNaN(odometerIncrement) || odometerIncrement <= 0) {
|
if (isNaN(odometerIncrement) || odometerIncrement < 0) {
|
||||||
Swal.showValidationMessage(`Please enter a non-zero amount to increment`);
|
Swal.showValidationMessage(`Please enter a positive amount to increment or 0 to use current odometer`);
|
||||||
}
|
}
|
||||||
return { odometerIncrement }
|
return { odometerIncrement }
|
||||||
},
|
},
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
if (result.isConfirmed) {
|
if (result.isConfirmed) {
|
||||||
var amountToIncrement = result.value.odometerIncrement;
|
var amountToIncrement = result.value.odometerIncrement;
|
||||||
$.get(`/Vehicle/GetMaxMileage?vehicleId=${GetVehicleId().vehicleId}`, function (data) {
|
var newAmount = currentOdometer + amountToIncrement;
|
||||||
var newAmount = data + amountToIncrement;
|
if (!isNaN(newAmount)) {
|
||||||
if (!isNaN(newAmount)) {
|
var odometerField = $(`#${odometerFieldName}`);
|
||||||
var odometerField = $(`#${odometerFieldName}`);
|
if (odometerField.length > 0) {
|
||||||
if (odometerField.length > 0) {
|
odometerField.val(newAmount);
|
||||||
odometerField.val(newAmount);
|
} else {
|
||||||
|
errorToast(genericErrorMessage());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
errorToast(genericErrorMessage());
|
errorToast(genericErrorMessage());
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
errorToast(genericErrorMessage());
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user