Added local flight duration

This commit is contained in:
2025-12-18 06:27:22 -05:00
parent f65c54109e
commit f572fb75f5
6 changed files with 33 additions and 5 deletions

View File

@@ -409,6 +409,10 @@
<option value="DEPARTURE">Departure to Other Airport</option>
</select>
</div>
<div class="form-group">
<label for="local_duration">Duration (minutes)</label>
<input type="number" id="local_duration" name="duration" min="5" max="480" value="45" placeholder="Duration in minutes" tabindex="7">
</div>
<div class="form-group" id="departure-destination-group" style="display: none;">
<label for="local_out_to" id="departure-destination-label">Destination Airport</label>
<input type="text" id="local_out_to" name="out_to" placeholder="ICAO Code or Airport Name" oninput="handleLocalOutToAirportLookup(this.value)" tabindex="3">
@@ -487,6 +491,10 @@
<option value="DEPARTURE">Departure</option>
</select>
</div>
<div class="form-group">
<label for="local_edit_duration">Duration (minutes)</label>
<input type="number" id="local_edit_duration" name="duration" min="5" max="480">
</div>
<div class="form-group">
<label for="local_edit_departure_dt">Departure Time</label>
<div style="display: flex; gap: 0.5rem;">
@@ -1890,7 +1898,16 @@
acType = flight.type;
typeIcon = '';
fromDisplay = `<i>${flight.flight_type === 'CIRCUITS' ? 'Circuits' : flight.flight_type === 'LOCAL' ? 'Local Flight' : 'Departure'}</i>`;
eta = flight.departure_dt ? formatTimeOnly(flight.departure_dt) : '-';
// Calculate ETA: use departed_dt (actual departure) if available, otherwise etd (planned departure)
// Then add duration to get ETA
let departureTime = flight.departed_dt || flight.etd;
let etaTime = departureTime;
if (departureTime && flight.duration) {
const departTime = new Date(departureTime);
etaTime = new Date(departTime.getTime() + flight.duration * 60000).toISOString(); // duration is in minutes
}
eta = etaTime ? formatTimeOnly(etaTime) : '-';
pob = flight.pob || '-';
fuel = '-';
@@ -3255,6 +3272,7 @@
document.getElementById('local_edit_callsign').value = flight.callsign || '';
document.getElementById('local_edit_pob').value = flight.pob;
document.getElementById('local_edit_flight_type').value = flight.flight_type;
document.getElementById('local_edit_duration').value = flight.duration || 45;
document.getElementById('local_edit_notes').value = flight.notes || '';
// Parse and populate departure time if exists
@@ -3588,7 +3606,7 @@
// Only include non-empty values
if (typeof value === 'number' || (typeof value === 'string' && value.trim() !== '')) {
if (key === 'pob') {
if (key === 'pob' || key === 'duration') {
updateData[key] = parseInt(value);
} else if (value.trim) {
updateData[key] = value.trim();
@@ -3649,7 +3667,7 @@
// Only include non-empty values
if (typeof value === 'number' || (typeof value === 'string' && value.trim() !== '')) {
if (key === 'pob') {
if (key === 'pob' || key === 'duration') {
flightData[key] = parseInt(value);
} else if (value.trim) {
flightData[key] = value.trim();