little fixes

This commit is contained in:
James Pattinson
2025-10-24 17:53:01 +00:00
parent 1223d9e9f9
commit 9d77e11627

View File

@@ -689,10 +689,10 @@
✓ Confirm ✓ Confirm
</button> </button>
<button id="btn-landed" class="btn btn-warning btn-sm" onclick="showTimestampModal('LANDED')"> <button id="btn-landed" class="btn btn-warning btn-sm" onclick="showTimestampModal('LANDED')">
🛬 Landed 🛬 Land
</button> </button>
<button id="btn-departed" class="btn btn-primary btn-sm" onclick="showTimestampModal('DEPARTED')"> <button id="btn-departed" class="btn btn-primary btn-sm" onclick="showTimestampModal('DEPARTED')">
🛫 Departed 🛫 Depart
</button> </button>
<button id="btn-cancel" class="btn btn-danger btn-sm" onclick="updateStatus('CANCELED')"> <button id="btn-cancel" class="btn btn-danger btn-sm" onclick="updateStatus('CANCELED')">
❌ Cancel ❌ Cancel
@@ -710,11 +710,11 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="ac_type">Aircraft Type *</label> <label for="ac_type">Aircraft Type *</label>
<input type="text" id="ac_type" name="ac_type" required> <input type="text" id="ac_type" name="ac_type" required tabindex="-1">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="ac_call">Callsign</label> <label for="ac_call">Callsign</label>
<input type="text" id="ac_call" name="ac_call" placeholder="If different from registration"> <input type="text" id="ac_call" name="ac_call" placeholder="If different from registration" tabindex="-1">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="captain">Captain *</label> <label for="captain">Captain *</label>
@@ -735,7 +735,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="fuel">Fuel Required</label> <label for="fuel">Fuel Required</label>
<select id="fuel" name="fuel"> <select id="fuel" name="fuel" tabindex="-1">
<option value="">None</option> <option value="">None</option>
<option value="100LL">100LL</option> <option value="100LL">100LL</option>
<option value="JET A1">JET A1</option> <option value="JET A1">JET A1</option>
@@ -744,28 +744,28 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="out_to">Departing To</label> <label for="out_to">Departing To</label>
<input type="text" id="out_to" name="out_to" placeholder="ICAO Code or Airport Name" oninput="handleDepartureAirportLookup(this.value)"> <input type="text" id="out_to" name="out_to" placeholder="ICAO Code or Airport Name" oninput="handleDepartureAirportLookup(this.value)" tabindex="-1">
<div id="departure-airport-lookup-results"></div> <div id="departure-airport-lookup-results"></div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="etd">ETD (Local Time)</label> <label for="etd">ETD (Local Time)</label>
<input type="datetime-local" id="etd" name="etd"> <input type="datetime-local" id="etd" name="etd" tabindex="-1">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="pob_out">POB Outbound</label> <label for="pob_out">POB Outbound</label>
<input type="number" id="pob_out" name="pob_out" min="1"> <input type="number" id="pob_out" name="pob_out" min="1" tabindex="-1">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="email">Email</label> <label for="email">Email</label>
<input type="email" id="email" name="email"> <input type="email" id="email" name="email" tabindex="-1">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="phone">Phone</label> <label for="phone">Phone</label>
<input type="tel" id="phone" name="phone"> <input type="tel" id="phone" name="phone" tabindex="-1">
</div> </div>
<div class="form-group full-width"> <div class="form-group full-width">
<label for="notes">Notes</label> <label for="notes">Notes</label>
<textarea id="notes" name="notes" rows="3"></textarea> <textarea id="notes" name="notes" rows="3" tabindex="-1"></textarea>
</div> </div>
</div> </div>
@@ -1437,6 +1437,28 @@
const ppr = await response.json(); const ppr = await response.json();
populateForm(ppr); 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 await loadJournal(pprId); // Always load journal when opening a PPR
document.getElementById('pprModal').style.display = 'block'; document.getElementById('pprModal').style.display = 'block';
@@ -1588,6 +1610,7 @@
closeTimestampModal(); closeTimestampModal();
loadPPRs(); // Refresh both tables loadPPRs(); // Refresh both tables
showNotification(`Status updated to ${updatedStatus}`); showNotification(`Status updated to ${updatedStatus}`);
closePPRModal(); // Close PPR modal after successful status update
} catch (error) { } catch (error) {
console.error('Error updating status:', error); console.error('Error updating status:', error);
showNotification(`Error updating status: ${error.message}`, true); showNotification(`Error updating status: ${error.message}`, true);
@@ -1656,6 +1679,13 @@
async function updateStatus(status) { async function updateStatus(status) {
if (!currentPPRId || !accessToken) return; 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 { try {
const response = await fetch(`/api/v1/pprs/${currentPPRId}/status`, { const response = await fetch(`/api/v1/pprs/${currentPPRId}/status`, {
method: 'PATCH', method: 'PATCH',
@@ -1673,6 +1703,7 @@
await loadJournal(currentPPRId); // Refresh journal await loadJournal(currentPPRId); // Refresh journal
loadPPRs(); // Refresh both tables loadPPRs(); // Refresh both tables
showNotification(`Status updated to ${status}`); showNotification(`Status updated to ${status}`);
closePPRModal(); // Close modal after successful status update
} catch (error) { } catch (error) {
console.error('Error updating status:', error); console.error('Error updating status:', error);
showNotification('Error updating status', true); showNotification('Error updating status', true);