FlowStep
Expression Extends:
class FlowStep extends aggregate(FlowStepModel, Helper, Commentable)
Helper class representing a flow step object. Required values include:
- id
- title
- description
- content_type
- image
- inputs
- paths
Constructor Summary
Public Constructor | ||
public |
constructor(response: Object, flow: Flow) Constructor for FlowStep |
Member Summary
Public Members | ||
public get |
Gets the existing id for this FlowStep (in _options) |
|
public set |
Set the existing id for this FlowStep (id) |
|
public get |
Get Fields used only for this step |
|
public |
|
|
public |
|
|
public get |
|
Private Members | ||
private |
|
Method Summary
Public Methods | ||
public |
Save fields for later |
|
public |
Get value from key |
|
public |
getNextStep(steps: Array<any>): * Get Next Step based on an array of steps and the conditions belonging to it |
|
public |
Get Path given the name of the path |
|
public |
Go to a node given the path name |
|
public |
Has Fields |
|
public |
Has Steps |
|
public |
Initializes the fields for insertion |
|
public |
isAutoSave(path: Object): Boolean Is AutoSave will return whether or not the path has capture on or off |
|
public |
isFieldRequired(id: String): Boolean Indicates whether a field is required based on the flowstep.input array |
|
public |
Is run after a successful save (FlowStep Scope). |
|
public |
postInsights(action: String): Promise<any> Post Insight on this flow step |
|
public |
Save makes a server call to update/insert the current fields. |
|
public |
Set value to main key |
|
public |
validateRequiredFields(path: any) Validate Required Fields for a path. |
Public Constructors
public constructor(response: Object, flow: Flow) source
Constructor for FlowStep
Params:
Name | Type | Attribute | Description |
response | Object |
|
Expects all required fields needed for FlowStepModel |
response.id | Number | The id of the step |
|
response.title | Object | The title of the step |
|
response.description | Object | Description, if any, that explain how to answer the step |
|
response.content_type | String | The format of the step (e.g. single choice, multiple choice) |
|
response.choices | Array | An array of inputs available to the user |
|
response.paths | Array | An array of next steps available to the user |
|
response.send_on_capture | Boolean | Save now or later |
|
flow | Flow |
|
Required to link up fields to the flow. |
Public Members
Private Members
Public Methods
public get(key: String): Any source
Get value from key
Params:
Name | Type | Attribute | Description |
key | String | Key must be 'input_id' |
Return:
Any | value This is the user response given the key |
public getNextStep(steps: Array<any>): * source
Get Next Step based on an array of steps and the conditions belonging to it
Params:
Name | Type | Attribute | Description |
steps | Array<any> |
Return:
* | null or a FlowStep |
public getPath(name: String): Object source
Get Path given the name of the path
Params:
Name | Type | Attribute | Description |
name | String | The name of the path |
public go(name: String): Promise<FlowStep> source
Go to a node given the path name
Params:
Name | Type | Attribute | Description |
name | String | Name of the button |
Test:
- [unit] FlowStep.getLongestDistance should return the distance
- [unit] FlowStep.go to path with incorrect condition statements
- [unit] FlowStep.go to path should change _toSave
- [unit] FlowStep.go to path should have labels for range or sliders
- [unit] FlowStep.go to path should have min and max values for numeric text validations
- [unit] FlowStep.go to path should throw error with empty required field
- [unit] FlowStep.go to path with incorrect condition statements on flow.set
- [unit] FlowStep.go to path with incorrect condition statements on flowstep.set text
- [unit] FlowStep.go to path with incorrect condition statements on flow.set text
- [unit] FlowStep.go to path ignoring case on flow.set text
- [unit] FlowStep.go should exist
- [unit] FlowStep.go should exist that return a promise
public hasSteps(path: Object): Boolean source
Has Steps
Params:
Name | Type | Attribute | Description |
path | Object | Path object |
public isAutoSave(path: Object): Boolean source
Is AutoSave will return whether or not the path has capture on or off
Params:
Name | Type | Attribute | Description |
path | Object | Path object |
public isFieldRequired(id: String): Boolean source
Indicates whether a field is required based on the flowstep.input array
Params:
Name | Type | Attribute | Description |
id | String | The input id |
public onSave(results: Object): Object source
Is run after a successful save (FlowStep Scope).
Params:
Name | Type | Attribute | Description |
results | Object | results of the save event |
public postInsights(action: String): Promise<any> source
Post Insight on this flow step
Params:
Name | Type | Attribute | Description |
action | String | The action that is being tracked |
Example:
flowstep.postInsights('collect') = (response) => {
// do something with the save response
return response;
}
public save(): Promise source
Save makes a server call to update/insert the current fields. This requires that the array is [{input_id: <input_id>, value: <value>},...]
public validateRequiredFields(path: any) source
Validate Required Fields for a path. If the path has fields to be captured and are empty, throw an error indicating which path and what fields.
Params:
Name | Type | Attribute | Description |
path | any | The Path the flow step has taken to see if related inputs are required. |