-
Notifications
You must be signed in to change notification settings - Fork 19
Name Generator: Roster List
Provides a way to easily add nodes from an existing roster list when the list is small enough to browse.
All possible nodes are visible. Nodes are added to the network by clicking on them, toggling their selected state.
Nodes are deleted from this interface by clicking on them again, toggling their selected state off.
Nodes can be sorted in ascending or descending order, according to the fields specified in options, by toggling the sort buttons.
Visible nodes can be filtered to more easily get to a node by typing in the text field.
This section describes parts of the protocol specific to the Roster List interface. The protocol (and specifically a stage prompt) shares some of the basic attributes with the standard Name Generator, which are not discussed again here.
For a more complete example, see a demo protocol.
The data to drive search results can be provided within the "externalData"
object of the protocol. That data can then be referenced in the "dataSource"
property of an interview prompt. External data items must define a "type"
that refers to an entry in the "node"
definition of the variable registry.
In this snippet of an example protocol file, we have included a "NameGeneratorList"
stage with one prompt that references the "schoolPupils"
data source. Each school pupil is a "person"
(i.e., variableRegistry.node.person
).
{
"name": "Demo Protocol",
"externalData": {
"schoolPupils": {
"nodes": [
{
"type": "person",
"name": "F. Anita",
"nickname": "Annie",
"age": "23"
},
{
"type": "person",
"name": "H. Barry",
"nickname": "Baz",
"age": "31"
}
]
}
},
"stages": [
{
"type": "NameGeneratorList",
"prompts": [
{
"id": "7cl1",
"text": "Which classmates would you also think of as friends?",
"dataSource": "schoolPupils"
}
]
}
]
}
To change the behavior of sorting, use values in "sortOptions"
:
-
sortOrder
: which attribute to sort by initially; can be sorted in"ASC"
(ascending) or"DESC"
(descending) order. -
sortProperties
: a list of attributes in the data set that can be sorted on.
To change the display of nodes on an interface, use the "cardOptions"
object:
-
displayLabel
: the primary label to display on the node -
additionalProperties
: an array of objects that define supplemental information to display on a search result.
Example:
{
"prompts": [
{
"id": "7cl1",
"text": "Which classmates would you also think of as friends?",
"additionalAttributes": {
"close_friend": true
},
"dataSource": "schoolPupils",
"cardOptions": {
"displayLabel": "nickname",
"additionalProperties": [
{
"label": "Name",
"variable": "name"
},
{
"label": "Age",
"variable": "age"
}
]
},
"sortOptions": {
"sortOrder": {
"name": "ASC"
},
"sortableProperties": [
{
"label": "Pupil Name",
"variable": "name"
},
{
"label": "Pupil Age",
"variable": "age"
}
]
},
"subject": {
"entity": "node",
"type": "person"
}
}
]
}
This interface builds on the Name Generator Interface API. That interface describes the prompts property.
In addition to all prompt properties specified in the name generator API, this interface defines the following parameters within a prompt:
Property | Possible Values | Purpose |
---|---|---|
dataSource Required |
A key in the "externalData" registry. |
This key identifies a data source to be searched and, subsequently, from which to create nodes |
cardOptions Required |
An object containing the following structures | |
cardOptions.displayLabel Required |
A field name that exists in the data (identified by dataSource ) |
This parameter defines the main display lable for nodes and search results in the interface |
cardOptions.additionalProperties Optional Default: []
|
Array consisting of zero or more objects, each with a "label" and "variable" key that refer to a type (identified by dataSource ) in the variable registry. |
This defines additional labels and values to display on a node (e.g., to disambiguate between nodes sharing the same displayLabel) |
sortOptions Optional Default: {}
|
An object containing the following structures | |
sortOptions.sortOrder Optional Default: cardOptions.displayLabel in descending order |
object with a key that refers to a type defined in the external data and a value of "ASC" or "DESC"
|
Defines initial sort field and direction |
sortOptions.sortableProperties Optional Default: []
|
Array consisting of zero or more objects, each with a "label" and "variable" key that refer to a field (identified by dataSource ) in the data. |
This defines which fields are sortable. Contrast this with fields that should be displayed (additionalProperties , above). |
See examples above.