Mobile enhancements

This commit is contained in:
Eric Gullickson
2025-07-27 21:26:41 -05:00
parent ea055f1c38
commit b8d6b76b30

View File

@@ -1,31 +1,67 @@
// Initialize gas record modal for mobile (using shared mobile framework) // Initialize gas record modal for mobile (using shared mobile framework)
function initializeGasRecordMobile() { function initializeGasRecordMobile() {
initMobileModal({ try {
modalId: '#gasRecordModal', console.log('Initializing gas record mobile - isMobile:', typeof isMobileDevice === 'function' ? isMobileDevice() : 'function not found');
dateInputId: '#gasRecordDate',
tagSelectorId: '#gasRecordTag',
modeToggleId: '#fuelEntryModeToggle',
simpleModeDefault: true
});
// Handle desktop initialization if (typeof initMobileModal === 'function') {
if (!isMobileDevice()) { initMobileModal({
initDatePicker($('#gasRecordDate')); modalId: '#gasRecordModal',
initTagSelector($("#gasRecordTag")); dateInputId: '#gasRecordDate',
tagSelectorId: '#gasRecordTag',
modeToggleId: '#fuelEntryModeToggle',
simpleModeDefault: true
});
} else {
console.error('initMobileModal function not found');
}
// Handle desktop initialization
if (typeof isMobileDevice === 'function' && !isMobileDevice()) {
console.log('Initializing desktop components');
initDatePicker($('#gasRecordDate'));
initTagSelector($("#gasRecordTag"));
}
} catch (e) {
console.error('Error in initializeGasRecordMobile:', e);
// Fallback to basic initialization
if (typeof isMobileDevice !== 'function' || !isMobileDevice()) {
try {
initDatePicker($('#gasRecordDate'));
initTagSelector($("#gasRecordTag"));
} catch (fallbackError) {
console.error('Fallback initialization also failed:', fallbackError);
}
}
} }
} }
function showAddGasRecordModal() { function showAddGasRecordModal() {
$.get(`/Vehicle/GetAddGasRecordPartialView?vehicleId=${GetVehicleId().vehicleId}`, function (data) { try {
if (data) { var vehicleInfo = GetVehicleId();
$("#gasRecordModalContent").html(data); console.log('Getting gas record modal for vehicle:', vehicleInfo.vehicleId);
// Initialize mobile experience using shared framework $.get(`/Vehicle/GetAddGasRecordPartialView?vehicleId=${vehicleInfo.vehicleId}`, function (data) {
initializeGasRecordMobile(); if (data) {
$("#gasRecordModalContent").html(data);
$('#gasRecordModal').modal('show'); // Initialize mobile experience using shared framework
} console.log('Initializing mobile gas record modal');
}); initializeGasRecordMobile();
console.log('Showing gas record modal');
$('#gasRecordModal').modal('show');
} else {
console.error('No data received from GetAddGasRecordPartialView');
errorToast('Failed to load gas record form');
}
}).fail(function(xhr, status, error) {
console.error('AJAX request failed:', status, error);
errorToast('Failed to load gas record form: ' + error);
});
} catch (e) {
console.error('Error in showAddGasRecordModal:', e);
errorToast('Error opening gas record form: ' + e.message);
}
} }
function showEditGasRecordModal(gasRecordId, nocache) { function showEditGasRecordModal(gasRecordId, nocache) {
if (!nocache) { if (!nocache) {