Debug: Tilføj console.log for at tracke entry loading i wizard
This commit is contained in:
parent
1c12014c5a
commit
d704a2f780
@ -385,6 +385,7 @@
|
||||
|
||||
// Load a specific time entry
|
||||
async function loadSpecificEntry(timeId) {
|
||||
console.log('🎯 Loading specific entry:', timeId);
|
||||
document.getElementById('loading-state').classList.remove('d-none');
|
||||
document.getElementById('time-entry-container').classList.add('d-none');
|
||||
document.getElementById('completion-state').classList.add('d-none');
|
||||
@ -397,6 +398,7 @@
|
||||
}
|
||||
|
||||
const entry = await response.json();
|
||||
console.log('📥 Loaded entry:', entry.id, 'Status:', entry.status, 'Date:', entry.worked_date);
|
||||
|
||||
currentEntry = entry;
|
||||
currentCaseId = entry.case_id;
|
||||
@ -404,19 +406,26 @@
|
||||
// Only fetch other case entries if this entry is pending
|
||||
// Otherwise just show this single entry
|
||||
if (entry.status === 'pending' && entry.case_id) {
|
||||
console.log('🔍 Fetching other pending entries for case:', entry.case_id);
|
||||
const caseResponse = await fetch(`/api/v1/timetracking/wizard/case/${entry.case_id}/entries`);
|
||||
if (caseResponse.ok) {
|
||||
const caseEntries = await caseResponse.json();
|
||||
console.log('📋 Got', caseEntries.length, 'pending entries for case');
|
||||
// Make sure our entry is in the list (it should be since it's pending)
|
||||
window.currentCaseEntries = caseEntries;
|
||||
} else {
|
||||
console.log('⚠️ Could not fetch case entries, showing single entry');
|
||||
window.currentCaseEntries = [entry];
|
||||
}
|
||||
} else {
|
||||
console.log('ℹ️ Entry is not pending or has no case - showing single entry only');
|
||||
// Entry is not pending - just show this one entry
|
||||
window.currentCaseEntries = [entry];
|
||||
}
|
||||
|
||||
console.log('✨ Current entry to display:', currentEntry.id);
|
||||
console.log('📦 All entries:', window.currentCaseEntries.map(e => e.id));
|
||||
|
||||
// Show the entry
|
||||
displayCaseEntries({
|
||||
time_entry: entry,
|
||||
@ -431,7 +440,7 @@
|
||||
document.getElementById('time-entry-container').classList.remove('d-none');
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading specific entry:', error);
|
||||
console.error('❌ Error loading specific entry:', error);
|
||||
showToast('Kunne ikke indlæse tidsregistrering', 'danger');
|
||||
// Fall back to loading next entry
|
||||
setTimeout(() => loadNextEntry(), 1000);
|
||||
@ -498,6 +507,9 @@
|
||||
const entries = window.currentCaseEntries || [];
|
||||
const container = document.getElementById('time-entries-list');
|
||||
|
||||
console.log('🖼️ displayCaseEntries called with', entries.length, 'entries');
|
||||
console.log('🎯 currentEntry.id:', currentEntry?.id);
|
||||
|
||||
if (entries.length === 0) {
|
||||
container.innerHTML = '<div class="alert alert-info">Ingen pending tidsregistreringer</div>';
|
||||
return;
|
||||
@ -507,10 +519,14 @@
|
||||
let entry;
|
||||
if (currentEntry && currentEntry.id) {
|
||||
entry = entries.find(e => e.id === currentEntry.id) || entries[0];
|
||||
console.log('🔎 Looking for entry', currentEntry.id, '- Found:', entry.id);
|
||||
} else {
|
||||
entry = entries[0];
|
||||
console.log('ℹ️ No currentEntry set, using first entry:', entry.id);
|
||||
}
|
||||
|
||||
console.log('✅ Displaying entry:', entry.id, 'Date:', entry.worked_date);
|
||||
|
||||
// Update header
|
||||
document.getElementById('case-header-title').textContent = entry.case_title || 'Ingen case';
|
||||
document.getElementById('case-header-customer').textContent = entry.customer_name || '-';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user