Class: PoolForm

PoolForm(setup, view)

Represents a form controller for a pool of questions.

Constructor

new PoolForm(setup, view)

Parameters:
Name Type Description
setup Object

The setup configuration for the form.

Properties
Name Type Attributes Default Description
startQuestion string <optional>
''

The ID of the first question.

questions Array.<QuestionModel> <optional>
[]

The list of questions to be used in the form.

events EventsHandlers <optional>
{}

The event handlers for the form.

values Object <optional>
{}

The default values for the form fields.

autoSaveAnswers Boolean <optional>
false

The default values for the form fields.

view Object

The view object for the form.

Source:

Methods

(async) back() → {*}

Triggers the back event and goes to the current.back question.

Source:
Throws:

When the back event or the error event thrown by goTo is rejected.

Returns:

The result of calling goTo with the current.back question ID.

Type
*

getFirstQuestion() → (nullable) {QuestionModel}

Returns the first question object on the this.questions array list.

Source:
Returns:
Type
QuestionModel

getQuestion(id) → (nullable) {QuestionModel}

Returns the question object with the specified ID.

Parameters:
Name Type Description
id string

The ID of the question.

Source:
Returns:
Type
QuestionModel

getValue(keyPath) → {*}

Retrieves the value at the given key path from the values object.

Parameters:
Name Type Description
keyPath string

The dot-separated path to the desired value.

Source:
Returns:

The value at the given key path.

Type
*

(async) goTo(questionID)

Goes to the question with the given ID and triggers its trigger method.

Parameters:
Name Type Description
questionID *

The ID of the question to go to.

Source:
Throws:

When the trigger method of the question is rejected or the given question ID is not valid.

(async) goToView(viewPath, paramsopt)

Goes to the view with the given path and optional parameters.

Parameters:
Name Type Attributes Description
viewPath string

The path to the view to go to.

params * <optional>

Optional parameters to pass to the view.

Source:

(async) next() → {*}

Triggers the next event and goes to the current.next question.

Source:
Throws:

When the next event or the error event thrown by goTo is rejected.

Returns:

The result of calling goTo with the current.next question ID.

Type
*

setQuestion(setupopt)

Adds a new question to the list of questions.

Parameters:
Name Type Attributes Description
setup QuestionModel <optional>

The setup configuration for the question.

Source:

setValue(keyPath, value, overrideopt)

Sets the value at the given key path in the values object.

Parameters:
Name Type Attributes Default Description
keyPath string

The dot-separated path to the desired value.

value *

The new value to set at the given key path.

override boolean <optional>
false

Whether to override the existing value(s) at the given key path with the new value.

Source:

(async) start()

Triggers the start event and goes to the startQuestion question.

Source:
Throws:

When the start event or the error event thrown by goTo is rejected.

(async) startPool() → {Object}

Starts the form and triggers the "start" event.

Source:
Throws:
  • If an error occurs during form execution.
Type
Error
Returns:
  • The form data which is the result of the form filled.
Type
Object