Trips Page Reference

Table of Contents


Introduction

The 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.

What the app must supply

The page does not know the aircraft. It borrows the content from the app's other pages through page methods and state variables:

Persistence and consistency

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.


Exported identifiers

createTrip()

Syntax

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.


Page methods

saveAsTrip()

Syntax

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.


Page state variables

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.