diff --git a/web/admin.html b/web/admin.html index 2dc2fe2..d2a19a7 100644 --- a/web/admin.html +++ b/web/admin.html @@ -689,10 +689,10 @@ ✓ Confirm - 🛬 Landed + 🛬 Land - 🛫 Departed + 🛫 Depart ❌ Cancel @@ -710,11 +710,11 @@ Aircraft Type * - + Callsign - + Captain * @@ -735,7 +735,7 @@ Fuel Required - + None 100LL JET A1 @@ -744,28 +744,28 @@ Departing To - + ETD (Local Time) - + POB Outbound - + Email - + Phone - + Notes - + @@ -1437,6 +1437,28 @@ const ppr = await response.json(); populateForm(ppr); + + // Show/hide quick action buttons based on current status + if (ppr.status === 'NEW') { + document.getElementById('btn-confirm').style.display = 'inline-block'; + document.getElementById('btn-landed').style.display = 'none'; + document.getElementById('btn-departed').style.display = 'none'; + document.getElementById('btn-cancel').style.display = 'inline-block'; + } else if (ppr.status === 'CONFIRMED') { + document.getElementById('btn-confirm').style.display = 'none'; + document.getElementById('btn-landed').style.display = 'inline-block'; + document.getElementById('btn-departed').style.display = 'none'; + document.getElementById('btn-cancel').style.display = 'inline-block'; + } else if (ppr.status === 'LANDED') { + document.getElementById('btn-confirm').style.display = 'none'; + document.getElementById('btn-landed').style.display = 'none'; + document.getElementById('btn-departed').style.display = 'inline-block'; + document.getElementById('btn-cancel').style.display = 'inline-block'; + } else { + // DEPARTED, CANCELED, DELETED - hide all quick actions + document.querySelector('.quick-actions').style.display = 'none'; + } + await loadJournal(pprId); // Always load journal when opening a PPR document.getElementById('pprModal').style.display = 'block'; @@ -1588,6 +1610,7 @@ closeTimestampModal(); loadPPRs(); // Refresh both tables showNotification(`Status updated to ${updatedStatus}`); + closePPRModal(); // Close PPR modal after successful status update } catch (error) { console.error('Error updating status:', error); showNotification(`Error updating status: ${error.message}`, true); @@ -1656,6 +1679,13 @@ async function updateStatus(status) { if (!currentPPRId || !accessToken) return; + // Show confirmation for cancel actions + if (status === 'CANCELED') { + if (!confirm('Are you sure you want to cancel this PPR? This action cannot be easily undone.')) { + return; + } + } + try { const response = await fetch(`/api/v1/pprs/${currentPPRId}/status`, { method: 'PATCH', @@ -1673,6 +1703,7 @@ await loadJournal(currentPPRId); // Refresh journal loadPPRs(); // Refresh both tables showNotification(`Status updated to ${status}`); + closePPRModal(); // Close modal after successful status update } catch (error) { console.error('Error updating status:', error); showNotification('Error updating status', true);