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