EditListPage Component ReferenceThe People page (page ID ppl) maintains a user-editable database of frequent occupants: a name, a note, and a weight. It is defined in common/page/people.js and is optional. An app includes it by importing the file for its side effect (all the aircraft apps do) and listing ppl in its nav layout. The weight and balance page uses it to fill in seat weights. Apps that use the database must supply a weight and balance page that calls the methods below.
import './common/page/people.js';
The page is an <EditListPage> on the data selector input ppl_people. Each option of ppl_people is a person, named Last, First (or just the first or last name, or Person, Person 2, ... if neither is entered). The input state variables of the page (ppl_firstName, ppl_lastName, ppl_note, ppl_weight) are registered with ppl_people.sVars() in the page's init(), so each person's values are stored with the option and are restored when the person is selected.
ppl_people is an input state variable with the default save mode, so the list and each person's data are saved with the app state, on the device and in the cloud. The individual input state variables are not saved themselves (save:'none').
The "+" button of the list calls createPerson() to add a new person with blank names and the default weight (170 lb, 3 digits, or kg). The "−" button confirms and then removes the person. Editing the first or last name renames the person. The name is capitalized, and the change is rejected with a notice if it would duplicate an existing person's name. When a person is renamed, the page also updates:
wb_*Name (the seat assignments of the apps' weight and balance pages) that holds the old name, andwb_*Name entries saved with each trip in trip_trips, if the Trips page exists.The page's open() method clears the selection.
pplPageimport {pplPage} from 'common/page/people.js';
The page object returned by ctl.createPage(). Apps normally get it with ctl.page('ppl') instead.
createPerson()import {createPerson} from 'common/page/people.js';
createPerson()
Creates a new person with blank names, a note, the default weight, and a unique name (Person, Person 2, ...), and selects it. This is the same function the page's "+" button calls. It returns the value of ppl_name, but nothing in the page sets that state variable, so the return value is not the new name; callers should not rely on it.
getSelection()ctl.page('ppl').getSelection()
Opens the People page as a popup page and returns a promise. The promise resolves, when the popup is closed, with an object {name, note, weight}: the selected person's name (empty if none), note, and weight in pounds (0 if none is selected).
getInfo()ctl.page('ppl').getInfo(name)
nameppl_people option value).Returns an object containing the person's saved state variable data, with the ppl_ prefix removed from each key, or null if there is no such person. The weight is stored by its unit state variables, so the object has weight_lb and weight_kg entries. A caller finds the weight by looking for a key that starts with weight_.
All the state variables have the prefix ppl_.
| State variable | Type | Description |
|---|---|---|
ppl_people |
dataSelectorInput |
The list of people and the selected person. |
ppl_firstName |
textInput |
First name, at most 20 characters. |
ppl_lastName |
textInput |
Last name, at most 20 characters. |
ppl_note |
textInput |
A note, at most 30 characters. |
ppl_weight |
unitInput |
Weight, lb or kg, default 170 lb. |
ppl_name |
textOutput |
Declared by the page but never set. |
ppl_resolve |
modelObject |
The pending getSelection() promise resolver. |