Manual Reference Source Test
public class | source

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(key: String): Any

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

Is AutoSave will return whether or not the path has capture on or off

public

Indicates whether a field is required based on the flowstep.input array

public

onSave(results: Object): Object

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(key: String, value: Any, existingId: Number)

Set value to main key

public

Validate Required Fields for a path.

Public Constructors

public constructor(response: Object, flow: Flow) source

Constructor for FlowStep

Params:

NameTypeAttributeDescription
response Object
  • nullable: false

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
  • nullable: true

Required to link up fields to the flow.

Public Members

public get existingId: Number source

Gets the existing id for this FlowStep (in _options)

public set existingId: Number source

Set the existing id for this FlowStep (id)

public get fields: Object source

Get Fields used only for this step

public flow: Flow source

public inputs: FlowInput[] source

public get type: String source

Private Members

private _options: Object source

Public Methods

public addFieldsToSave() source

Save fields for later

public get(key: String): Any source

Get value from key

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
steps Array<any>

Return:

*

null or a FlowStep

public getPath(name: String): Object source

Get Path given the name of the path

Params:

NameTypeAttributeDescription
name String

The name of the path

Return:

Object

The path object with conditions, steps, and capture

Test:

public hasFields(): Boolean source

Has Fields

Return:

Boolean

True if the step has fields, otherwise false

Test:

public hasSteps(path: Object): Boolean source

Has Steps

Params:

NameTypeAttributeDescription
path Object

Path object

Return:

Boolean

True if the path has steps

Test:

public initFields() source

Initializes the fields for insertion

Test:

public isAutoSave(path: Object): Boolean source

Is AutoSave will return whether or not the path has capture on or off

Params:

NameTypeAttributeDescription
path Object

Path object

Return:

Boolean

True if autosave / capture is on for the path

Test:

public isFieldRequired(id: String): Boolean source

Indicates whether a field is required based on the flowstep.input array

Params:

NameTypeAttributeDescription
id String

The input id

Return:

Boolean

Returns true if the input is required else false

public onSave(results: Object): Object source

Is run after a successful save (FlowStep Scope).

Params:

NameTypeAttributeDescription
results Object

results of the save event

Return:

Object

returns the results

public postInsights(action: String): Promise<any> source

Post Insight on this flow step

Params:

NameTypeAttributeDescription
action String

The action that is being tracked

Return:

Promise<any>

returns the results

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>},...]

Return:

Promise

A Promise returning success or failure from FlowService

Test:

public set(key: String, value: Any, existingId: Number) source

Set value to main key

Params:

NameTypeAttributeDescription
key String

Key must be 'input_id'

value Any

This must be the expected value for this question type.

existingId Number
  • nullable: true

The existing id to update an object to

Test:

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:

NameTypeAttributeDescription
path any

The Path the flow step has taken to see if related inputs are required.