EditListPage Component ReferenceThe Trips page (page ID trip) maintains a user-editable database of trips. Each trip saves the same settings as the Quick Setup page and the weight and balance cards. It is defined in common/page/trips.js and is optional. An app includes it by importing the file for its side effect and listing trip in its nav layout (all the aircraft apps do):
import './common/page/trips.js'; // must be after quickSetup
The import must come after the app's Quick Setup page is imported, because the page reads the Quick Setup page's tripIds() method when it is defined.
The page is an <EditListPage> on the data selector input trip_trips. Each option is a trip. Selecting a trip restores the saved values into the app, so the other pages show the trip. Pressing "+" saves the current app values as a new trip named <departure> to <destination> (or Trip), made unique with a numeric suffix. The "−" button confirms and deletes the trip. The trip name can be edited; it must be non-empty and unique.
The page does not know the aircraft. It borrows the content from the app's other pages through page methods and state variables:
quick) methodstripIds() returns the IDs of the state variables saved with a trip (for example, dep_airportId, dest_airportId, enrt_altitudeH, the wb_ fuel and seat loads and seat name variables).renderAirportCard('trip'), renderEnrouteCard('trip') and renderAlternateCard('trip') return the cards displayed for the trip. The Enroute card omits the wind row when its argument is not quick.wb) methods renderFuelCard('trip') and renderPayloadCard('trip').ctl.page('trip').saveAsTrip().dep_airportId and dest_airportId (used to name a new trip), enrt_flightRules, wb_fuelUsedMode, wb_routeDistMode, and the pages ac, wb, dep, dest, enrt and alt, whose state variables are inputs of the page's "Compute precedent pages" computation.trips.css hides the Quick Setup page's "Save as trip" and "Reverse" buttons and winds when they are displayed on the Trips page.trip_trips is an input state variable with the default save mode, so the trip list and the data saved with each trip are saved with the app state, on the device and in the cloud. The page's setSavedState() validates the saved trips and, if they are corrupt, discards all trips with a notice.
While the Trips page is open, any change of a saved state variable updates the selected trip's data. While the page is not active, a change that makes the app state differ from the selected trip deselects the trip (setting trip_trips to ''). The comparison ignores trip_name, the automatically computed fuel used and route distance when their mode is auto, and the alternate (alt_) values for a VFR trip. The People page renames people stored in a trip's wb_*Name entries.
The page's init() registers trip_name and the input state variables named by tripIds() with trip_trips.sVars(). See the Data Selector Input State Variable Reference.
createTrip()import {createTrip} from 'common/page/trips.js';
createTrip()
Saves the current values as a new trip with a unique name, selects it, and returns the name. This is the function the page's "+" button calls.
saveAsTrip()ctl.page('trip').saveAsTrip()
Calls createTrip() and returns the new trip's name. The Quick Setup page calls this from its "Save as trip" button.
All the state variables have the prefix trip_.
| State variable | Type | Description |
|---|---|---|
trip_trips |
dataSelectorInput |
The list of trips and the selected trip. The first option is the empty "no selection" option. |
trip_name |
textInput |
The selected trip's name, at most 25 characters. |