Many more states WIP
This commit is contained in:
+60
-34
@@ -1837,8 +1837,8 @@
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const bookedInToday = bookedInArrivals
|
||||
.filter(arrival => {
|
||||
// Only include arrivals booked in today (created_dt) with BOOKED_IN status
|
||||
if (!arrival.created_dt || arrival.status !== 'BOOKED_IN') return false;
|
||||
// Only include arrivals booked in today (created_dt) with INBOUND, LOCAL, or CIRCUIT status
|
||||
if (!arrival.created_dt || !['INBOUND', 'LOCAL', 'CIRCUIT'].includes(arrival.status)) return false;
|
||||
const bookedDate = arrival.created_dt.split('T')[0];
|
||||
return bookedDate === today;
|
||||
})
|
||||
@@ -1860,7 +1860,7 @@
|
||||
document.getElementById('arrivals-loading').style.display = 'none';
|
||||
}
|
||||
|
||||
// Load departures (LANDED status for PPR, BOOKED_OUT only for local flights)
|
||||
// Load departures (LANDED status for PPR, GROUND/LOCAL for local flights)
|
||||
async function loadDepartures() {
|
||||
document.getElementById('departures-loading').style.display = 'block';
|
||||
document.getElementById('departures-table-content').style.display = 'none';
|
||||
@@ -1868,7 +1868,7 @@
|
||||
|
||||
try {
|
||||
// Load PPR departures, local flight departures, and airport departures simultaneously
|
||||
const [pprResponse, localBookedOutResponse, localOutGroundResponse, localLocalResponse, localCircuitResponse, depBookedOutResponse, depOutGroundResponse, depLocalResponse, arrLocalResponse, arrCircuitResponse] = await Promise.all([
|
||||
const [pprResponse, localBookedOutResponse, localOutGroundResponse, localLocalResponse, localCircuitResponse, depBookedOutResponse, depOutGroundResponse, depLocalResponse] = await Promise.all([
|
||||
authenticatedFetch('/api/v1/pprs/?limit=1000'),
|
||||
authenticatedFetch('/api/v1/local-flights/?status=BOOKED_OUT&limit=1000'),
|
||||
authenticatedFetch('/api/v1/local-flights/?status=GROUND&limit=1000'),
|
||||
@@ -1876,9 +1876,7 @@
|
||||
authenticatedFetch('/api/v1/local-flights/?status=CIRCUIT&limit=1000'),
|
||||
authenticatedFetch('/api/v1/departures/?status=BOOKED_OUT&limit=1000'),
|
||||
authenticatedFetch('/api/v1/departures/?status=GROUND&limit=1000'),
|
||||
authenticatedFetch('/api/v1/departures/?status=LOCAL&limit=1000'),
|
||||
authenticatedFetch('/api/v1/arrivals/?status=LOCAL&limit=1000'),
|
||||
authenticatedFetch('/api/v1/arrivals/?status=CIRCUIT&limit=1000')
|
||||
authenticatedFetch('/api/v1/departures/?status=LOCAL&limit=1000')
|
||||
]);
|
||||
|
||||
if (!pprResponse.ok) {
|
||||
@@ -1893,8 +1891,6 @@
|
||||
const depBookedOut = depBookedOutResponse.ok ? await depBookedOutResponse.json() : [];
|
||||
const depOutGround = depOutGroundResponse.ok ? await depOutGroundResponse.json() : [];
|
||||
const depLocal = depLocalResponse.ok ? await depLocalResponse.json() : [];
|
||||
const arrLocal = arrLocalResponse.ok ? await arrLocalResponse.json() : [];
|
||||
const arrCircuit = arrCircuitResponse.ok ? await arrCircuitResponse.json() : [];
|
||||
|
||||
// Combine local flights
|
||||
const allLocalFlights = [...localBookedOut, ...localOutGround, ...localLocal, ...localCircuit];
|
||||
@@ -1912,7 +1908,7 @@
|
||||
return etdDate === today;
|
||||
});
|
||||
|
||||
// Add local flights (BOOKED_OUT, GROUND, and LOCAL status - ready to go) - only those booked out today
|
||||
// Add local flights (GROUND and LOCAL status - ready to go) - only those booked out today
|
||||
const localDepartures = allLocalFlights
|
||||
.filter(flight => {
|
||||
// Only include flights booked out today (created_dt)
|
||||
@@ -1933,20 +1929,6 @@
|
||||
}));
|
||||
departures.push(...depDepartures);
|
||||
|
||||
// Add arrivals in LOCAL status
|
||||
const arrDepartures = arrLocal.map(flight => ({
|
||||
...flight,
|
||||
isArrival: true // Flag to distinguish from PPR
|
||||
}));
|
||||
departures.push(...arrDepartures);
|
||||
|
||||
// Add arrivals in CIRCUIT status
|
||||
const arrCircuitDepartures = arrCircuit.map(flight => ({
|
||||
...flight,
|
||||
isArrival: true // Flag to distinguish from PPR
|
||||
}));
|
||||
departures.push(...arrCircuitDepartures);
|
||||
|
||||
displayDepartures(departures);
|
||||
} catch (error) {
|
||||
console.error('Error loading departures:', error);
|
||||
@@ -2500,14 +2482,58 @@
|
||||
eta = flight.eta ? formatTimeOnly(flight.eta) : (flight.landed_dt ? formatTimeOnly(flight.landed_dt) : '-');
|
||||
pob = flight.pob || '-';
|
||||
fuel = '-';
|
||||
actionButtons = `
|
||||
<button class="btn btn-success btn-icon" onclick="event.stopPropagation(); currentBookedInArrivalId = ${flight.id}; showTimestampModal('LANDED', ${flight.id}, false, false, true)" title="Mark as Landed">
|
||||
LAND
|
||||
</button>
|
||||
<button class="btn btn-danger btn-icon" onclick="event.stopPropagation(); updateArrivalStatusFromTable(${flight.id}, 'CANCELLED')" title="Cancel Arrival">
|
||||
CANCEL
|
||||
</button>
|
||||
`;
|
||||
|
||||
// Different action buttons based on status
|
||||
if (flight.status === 'INBOUND') {
|
||||
actionButtons = `
|
||||
<button class="btn btn-primary btn-icon" onclick="event.stopPropagation(); updateArrivalStatusFromTable(${flight.id}, 'LOCAL')" title="Mark as Local">
|
||||
LOCAL
|
||||
</button>
|
||||
<button class="btn btn-success btn-icon" onclick="event.stopPropagation(); currentBookedInArrivalId = ${flight.id}; showTimestampModal('LANDED', ${flight.id}, false, false, true)" title="Mark as Landed">
|
||||
LAND
|
||||
</button>
|
||||
<button class="btn btn-danger btn-icon" onclick="event.stopPropagation(); updateArrivalStatusFromTable(${flight.id}, 'CANCELLED')" title="Cancel Arrival">
|
||||
CANCEL
|
||||
</button>
|
||||
`;
|
||||
} else if (flight.status === 'LOCAL') {
|
||||
// Arrival in local area - show circuit and land buttons
|
||||
let circuitButton = `<button class="btn btn-info btn-icon" onclick="event.stopPropagation(); currentArrivalId = ${flight.id}; showCircuitModal()" title="Record Touch & Go">
|
||||
T&G
|
||||
</button>`;
|
||||
actionButtons = `
|
||||
<button class="btn btn-warning btn-icon" onclick="event.stopPropagation(); updateArrivalStatusFromTable(${flight.id}, 'CIRCUIT')" title="Join Circuit">
|
||||
CIRCUIT
|
||||
</button>
|
||||
${circuitButton}
|
||||
<button class="btn btn-success btn-icon" onclick="event.stopPropagation(); currentArrivalId = ${flight.id}; showTimestampModal('LANDED', ${flight.id}, false, false, true)" title="Mark as Landed">
|
||||
LAND
|
||||
</button>
|
||||
`;
|
||||
} else if (flight.status === 'CIRCUIT') {
|
||||
// Arrival in circuit - show local, T&G and land buttons
|
||||
let circuitButton = `<button class="btn btn-info btn-icon" onclick="event.stopPropagation(); currentArrivalId = ${flight.id}; showCircuitModal()" title="Record Touch & Go">
|
||||
T&G
|
||||
</button>`;
|
||||
actionButtons = `
|
||||
<button class="btn btn-primary btn-icon" onclick="event.stopPropagation(); updateArrivalStatusFromTable(${flight.id}, 'LOCAL')" title="Move to Local Area">
|
||||
LOCAL
|
||||
</button>
|
||||
${circuitButton}
|
||||
<button class="btn btn-success btn-icon" onclick="event.stopPropagation(); currentArrivalId = ${flight.id}; showTimestampModal('LANDED', ${flight.id}, false, false, true)" title="Mark as Landed">
|
||||
LAND
|
||||
</button>
|
||||
`;
|
||||
} else {
|
||||
actionButtons = `
|
||||
<button class="btn btn-success btn-icon" onclick="event.stopPropagation(); currentBookedInArrivalId = ${flight.id}; showTimestampModal('LANDED', ${flight.id}, false, false, true)" title="Mark as Landed">
|
||||
LAND
|
||||
</button>
|
||||
<button class="btn btn-danger btn-icon" onclick="event.stopPropagation(); updateArrivalStatusFromTable(${flight.id}, 'CANCELLED')" title="Cancel Arrival">
|
||||
CANCEL
|
||||
</button>
|
||||
`;
|
||||
}
|
||||
} else {
|
||||
// PPR display
|
||||
if (flight.ac_call && flight.ac_call.trim()) {
|
||||
@@ -4581,8 +4607,8 @@
|
||||
// Show/hide quick action buttons based on status
|
||||
const landedBtn = document.getElementById('arrival-btn-landed');
|
||||
const cancelBtn = document.getElementById('arrival-btn-cancel');
|
||||
landedBtn.style.display = arrival.status === 'BOOKED_IN' ? 'block' : 'none';
|
||||
cancelBtn.style.display = arrival.status === 'BOOKED_IN' ? 'block' : 'none';
|
||||
landedBtn.style.display = arrival.status === 'INBOUND' ? 'block' : 'none';
|
||||
cancelBtn.style.display = arrival.status === 'INBOUND' ? 'block' : 'none';
|
||||
|
||||
// Show modal
|
||||
document.getElementById('arrivalEditModal').style.display = 'block';
|
||||
|
||||
Reference in New Issue
Block a user