Mobile enhancements
This commit is contained in:
@@ -1,31 +1,67 @@
|
||||
// Initialize gas record modal for mobile (using shared mobile framework)
|
||||
function initializeGasRecordMobile() {
|
||||
initMobileModal({
|
||||
modalId: '#gasRecordModal',
|
||||
dateInputId: '#gasRecordDate',
|
||||
tagSelectorId: '#gasRecordTag',
|
||||
modeToggleId: '#fuelEntryModeToggle',
|
||||
simpleModeDefault: true
|
||||
});
|
||||
|
||||
// Handle desktop initialization
|
||||
if (!isMobileDevice()) {
|
||||
initDatePicker($('#gasRecordDate'));
|
||||
initTagSelector($("#gasRecordTag"));
|
||||
try {
|
||||
console.log('Initializing gas record mobile - isMobile:', typeof isMobileDevice === 'function' ? isMobileDevice() : 'function not found');
|
||||
|
||||
if (typeof initMobileModal === 'function') {
|
||||
initMobileModal({
|
||||
modalId: '#gasRecordModal',
|
||||
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() {
|
||||
$.get(`/Vehicle/GetAddGasRecordPartialView?vehicleId=${GetVehicleId().vehicleId}`, function (data) {
|
||||
if (data) {
|
||||
$("#gasRecordModalContent").html(data);
|
||||
|
||||
// Initialize mobile experience using shared framework
|
||||
initializeGasRecordMobile();
|
||||
|
||||
$('#gasRecordModal').modal('show');
|
||||
}
|
||||
});
|
||||
try {
|
||||
var vehicleInfo = GetVehicleId();
|
||||
console.log('Getting gas record modal for vehicle:', vehicleInfo.vehicleId);
|
||||
|
||||
$.get(`/Vehicle/GetAddGasRecordPartialView?vehicleId=${vehicleInfo.vehicleId}`, function (data) {
|
||||
if (data) {
|
||||
$("#gasRecordModalContent").html(data);
|
||||
|
||||
// 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) {
|
||||
if (!nocache) {
|
||||
|
||||
Reference in New Issue
Block a user