undefined

API Docs for: 5.4.2
Show:

StepItem Class

Creates a step in the choice tree. A step item can contain several bricks in it and can take different states. Each step can advance and retreat by either displaying its selected child or hiding it.

Imports RAMP Modules:

Util
TmplHelper
TmplUtil
Array
Dictionary
Bricks

Uses RAMP Templates:

templates/layer_selector_template.json

Constructor

StepItem

(
  • config
  • []
  • []
  • []
  • []
  • []
  • []
)
StepItem

Parameters:

  • config Object

    a config definition of the step item

    • id String

      step item it; can be anything

    • level Number

      level of this step item

    • content Array

      an array of Brick configuration objects

  • [] String optional

    content brick id

  • [] Brick optional

    type of the content brick

  • [] Object optional

    a brick config object that will be passed to Brick.new() init function

  • [] Array optional

    a set of callbacks set on the create Brick object

  • [] String optional

    a name of the Brick event the callback should react to

  • [] Function optional

    a function to be executed when the specified event is fired

Returns:

StepItem:

A built StepItem object.

Methods

_addContentBrick

(
  • contentItem
)
private

Instantiates and adds a new brick to this step item.

Parameters:

  • contentItem Object

    a config object for a Brick

_doInternalCheck

() private

Checks this step item validity by checking validity of all its Bricks.

_getChildNodes

(
  • except
)
Array private

Returns an array of child step nodes except for steps whose ids are passed in except param.

Parameters:

  • except Array

    an array of child step ids to not include in the result

Returns:

Array:

an array of child step nodes

_getCloseTimelines

(
  • tls
  • skip
  • reset
)
StepItem private chainable

Generates a close timeline for this particular step item and adds it to the global close timeline. Calls the same on the target child.

Parameters:

  • tls Object

    global close timeline

  • skip Boolean

    indicates whether to skip the first child step item

  • reset Boolean

    indicates whether to reset the step item state to DEFAULT

Returns:

StepItem:

itself

_getOpenTimelines

(
  • tls
  • targetChildStepId
  • skip
)
StepItem private chainable

Generates an open timeline for this particular step item and adds it to the global open timeline. Calls the same on the target child.

Parameters:

  • tls Object

    global open timeline

  • targetChildStepId String

    specifies the target child id

  • skip Boolean

    indicates whether to skip the first child step item

Returns:

StepItem:

itself

_internalCheckHelper

(
  • required
  • targetBrick
  • contentBricks
)
private

Checks Brick's requirements. Enables or disabled the target Brick based on validity of its requirements.

Parameters:

  • required Array

    an array of required rules

  • targetBrick Brick

    a Brick with requirements

  • contentBricks Object

    a dictionary of bricks available in this step

_makeCloseTimeline

(
  • skipFirst
  • resetState
)
Object private

Creates timeline for retreat animation - when the part of the choice tree is collapsing, switching to another branch of the tree.

Parameters:

  • skipFirst Boolean

    indicates whether the first child step should be included in the timeline

  • resetState Boolean

    indicates if the child step state should be reset

Returns:

Object:

a constructed close timeline

_makeOpenTimeline

(
  • targetChildStepId
  • skipFirst
)
Object private

Creates timeline for advance animation - when the part of the choice tree is unfolding, (after switching to another branch of the tree).

Parameters:

  • targetChildStepId String

    specifies the target child id

  • skipFirst Boolean

    indicates whether the first child step should be included in the timeline

Returns:

Object:

a constructed open timeline

_makeShiftTimeline

(
  • targetChildStepId
)
Object private

Creates timeline for shift animation - when the selected option for a choice is changing - animating horizontally.

Parameters:

  • targetChildStepId String

    specifies the target childId

Returns:

Object:

a constructed shift timeline

_notifyCurrentStepChange

() private

Emits a CURRENT_STEP_CHANGE event with a payload of id and level of the current step item. This notifies the trunk of the tree and this step is now a current step. The trunk in turn notifies every other step that they are not current steps.

_notifyStateChange

(
  • state
)
StepItem private chainable

Emits a STATE_CHANGE event with a payload of id, level and state of the current step item. Additionally sets state of all the content bricks to corresponding states.

Parameters:

  • state String

    state to set the step item to

Returns:

StepItem:

itself

_toggleBrickNotices

(
  • bricks
  • show
)
Promise private

Toggles the visibility of notices for specified bricks.

Parameters:

  • bricks Array

    an array of Brick items to toggle notices on

  • show Boolean

    a flag indicating whether to show or hide the notices

Returns:

Promise:

a promise that is resolved after animation is completed

_wireBrickUp

(
  • contentItem
  • contentBrick
)
private

Wire up listeners on the given Brick.

Parameters:

  • contentItem Object

    a config object for a Brick

  • contentBrick Object

    an actual Brick instance

(
  • brickIds
)
StepItem chainable

Clears this step by resetting its state to DEFAULT, clearing all content bricks, and hide all brick notices.

Parameters:

  • brickIds Array

    [description]

Returns:

StepItem:

itself

addChild

(
  • stepItem
)
StepItem chainable

Adds a given step item object as a child for this step item.

Parameters:

  • stepItem StepItem

    a stepItem object to be added as a child.

Returns:

StepItem:

itself

advance

(
  • targetChildStepId
  • [targetChildData]
)
StepItem

Advances the current step to the step with the provided id. The target id has to be a child step. Additionally, the tree expands down if the target child has an active child as well, and so on, until no active child is present.

Parameters:

  • targetChildStepId String

    id of the new target step of advance too

  • [targetChildData] Object optional

    data to be passed to the target step as it opens

Returns:

StepItem:

itself

currentStep

(
  • level
  • stepId
)

Makes the step specified by the level and stepId a current step by setting a proper CSS class.

Parameters:

displayBrickNotices

(
  • [data]
)

Set Brick notices, mostly errors.

Parameters:

  • [data] Object optional

    a dictionary of objects containing Brick notices

getContentOuterHeight

() Number

Get outer height of the content node

Returns:

Number:

outer height of the content node

getContentPosition

() Object

Get position of the content node.

Returns:

Object:

jQuery position object of the content node

isCompleted

() Boolean

Checks if the step is completed. It's considered completed if its state is SUCCESS.

Returns:

Boolean:

true if completed; false, otherwise

isValid

() Boolean

Checks if the step is valid. It's considered valid if all its content bricks are valid.

Returns:

Boolean:

true if completed; false, otherwise

retreat

() StepItem chainable

Retreats the current step item by collapsing its active children and resetting their states to default. After, active child step is set to null.

Returns:

StepItem:

itself

setData

(
  • data
)
StepItem chainable

Sets data to the content brick

Parameters:

  • data Object

    a data object

    • [bricksData] Object optional

      dictionary of data where keys are brick ids and values data to be passed to the corresponding bricks

    • [stepData] Object optional

      some data object to be saved in this step

Returns:

StepItem:

itself

setState

(
  • level
  • stepId
  • state
)

Sets the step specified by the level and stepId to a specified state.

Parameters:

  • level Number

    level of the step to set the state on

  • stepId String

    id of the step to set the state on

  • state String

    name of the state to set

Properties

_activeChildStep

Unknown private

A step item of the currently active child of this step item. If there is no active child, it means that a choice or action hasn't been made on this step yet or it's the last step in the branch.

Default: null

_childSteps

Unknown private

A collection of the child step items of this step item. Should not be accessed directly.

Default: {}

_contentNode

Unknown private

Node of the content div.

Default: null

_optionsBackgroundNode

Unknown private

Node of the options background node. It's used to change the state of the child steps - SUCCESS, ERROR, etc.

Default: null

_optionsContainerNode

Unknown private

Node of the options container.

Default: null

_optionsNode

Unknown private

Node of the options div.

Default: null

_parent

Unknown private

A step item of the parent step item if any. Used only for animating background when opening/collapsing (error) notices.

Default: null

_state

Unknown private

The current state of this step item.

Default: StepItem.state.DEFAULT,

_stepData

Unknown private

An object containing some data. This is used like that: when the step is advanced, a data object is provided by external code; this object is then passed to whichever child is being advanced so it can be retrieved later without external code having to store it somewhere.

Default: null

_timeline

Unknown private

A timeline of this step item. Used for animation

_transitionDuration

Unknown private

A default duration value for all single transitions of any elements of this step.

Default: 0.4

content

Array private

An array of Brick configs and other related properties.

Default: null

Example:

[{
   id: "sourceType",
   type: Bricks.ChoiceBrick,
   config: {
       header: i18n.t("addDataset.dataSource"),
       instructions: i18n.t("addDataset.help.dataSource"),
       choices: [
           {
               key: "serviceTypeStep",
               value: i18n.t("addDataset.dataSourceService")
           },
           {
               key: "fileTypeStep",
               value: i18n.t("addDataset.dataSourceFile")
           }
       ]
   },
   on: [
       {
           eventName: Bricks.ChoiceBrick.event.CHANGE,
           //expose: { as: "advance" },
           callback: choiceTreeCallbacks.simpleAdvance
       }
   ]
  }]

contentBricks

Object

A collection of build Bricks that can accessed by their ids.

Default: {}

currentStepClass

String static

Specifies the current step CSS class name.

event

Object static

Event names published by the StepItem

Example:

 {
     CURRENT_STEP_CHANGE: "stepItem/currentStepChange",
     STATE_CHANGE: "stepItem/stateChange"
 }

id

String

Layer id. Upon initialization, id can be overwritten by config.id value.

Default: null

level

Number

Indicates the level of the step, or how far down the tree this step appears.

Default: 0

node

JObject

A node of the StepItem.

Default: null

state

Object static

A collection of possible StepItem states and their names.

Example:

state: {
      SUCCESS: "step-state-success",
      ERROR: "step-state-error",
      DEFAULT: "step-state-default",
      LOADING: "step-state-loading"
  }

template

String

Default template used for building step items.

Default: "default_step_template"

Events

StepItem.event.CURRENT_STEP_CHANGE

Published whenever a StepItem becomes a current step. A current step has a distinct visual style.

Event Payload:

  • event Object
    • level Number

      Level of the StepItem that became a current step

    • id String

      Id of the StepItem that became a current step

StepItem.event.CURRENT_STEP_CHANGE

Published whenever a StepItem changes its state.

Event Payload:

  • event Object
    • level Number

      Level of the StepItem that became a current step

    • id String

      Id of the StepItem that became a current step

    • state String

      name of the state