undefined

API Docs for: 5.4.1
Show:

DropDownBrick Class

Extends Brick
Module: Bricks
Parent Module: Utils

The DropDownBrick prototype. Provides a dropdown control to choose an item from. To instantiate, call new on the DropDownBrick prototype.

Imports RAMP Modules:

Util
TmplHelper
Array
Dictionary

Uses RAMP Templates:

templates/bricks_template.json

Methods

clear

() DropDownBrick chainable

Inherited from Brick but overwritten in src/js/RAMP/Utils/bricks.js:2196

Clears the DropDownBrick by setting the selected option to "" and userSelected to false.

Returns:

DropDownBrick:

itself

disable

(
  • disable
  • force
)
Brick chainable

Disables or re-enables the Brick.

Parameters:

  • disable Boolean

    true to disable; false to enable

  • force Boolean

    if true, disables the brick even if it's frozen

Returns:

Brick:

itself

displayNotice

(
  • notice
  • [noticeTemplate]
)
Brick chainable

Display a (error) notice on the brick.

Parameters:

  • notice Object

    object with notice data to be passed to the template

  • [noticeTemplate] String optional

    notice template name

Returns:

Brick:

itself

getData

(
  • [wrap]
)
Object

Inherited from Brick but overwritten in src/js/RAMP/Utils/bricks.js:2253

Returns DropDownBrick's data.

Parameters:

  • [wrap] Boolean optional

    indicates of the payload should be wrapped with a Brick's id; useful when collection information from several Bricks at once.

Returns:

Object:

A wrapper object around two properties: inputValue and userEntered

isUserSelected

() DropDownBrick chainable

Checks if the option was selected by the user or not.

Returns:

DropDownBrick:

itself

isValid

() Boolean

Inherited from Brick but overwritten in src/js/RAMP/Utils/bricks.js:2211

Checks if the DropDownBrick is valid. It's considered valid if the selected option's value is not "".

Returns:

Boolean:

true if valid; false if not

new

(
  • id
  • config
)
chainable

Inherited from Brick but overwritten in src/js/RAMP/Utils/bricks.js:2071

Initializes the DropDownBrick by generating a specified template and setting defaults. This Brick fires a CHANGE event on every change inside the dropdown.

Parameters:

  • id String

    specified id of the Brick

  • config Object

    a configuration object for the Brick

    • [header] String optional

      a Brick header

    • [instructions] String optional

      a configuration object for the Brick

    • [required] Array | Object optional

      collection of rules specifying what external conditions must be valid for the Brick to be enabled

    • [isEnabled] Boolean optional

      specifies if the brick is disabled from the start

    • [freezeStates] Array optional

      a set of rules specifying states Brick should be frozen

    • [baseTemplate] String optional

      a base template name to be used

    • [noticeTemplate] String optional

      a notice template name to be used

    • [containerClass] String optional

      a CSS class of the specific brick container

    • [customContainerClass] String optional

      any other optional CSS class to be added to the brick container

    • [template] String optional

      a name of the specific Brick template

notify

(
  • eventName
  • data
)
Brick private chainable

Notifies a listener of a Brick event.

Parameters:

  • eventName String

    an eventName that should be reported

  • data Object

    a payload object to be passed along with the @event

Returns:

Brick:

itself

on

(
  • eventName
  • listener
)
Brick chainable

Sets a listener on the Brick for a specified eventName.

Parameters:

  • eventName String

    an eventName to listen for

  • listener Function

    a callback function to be called

Returns:

Brick:

itself

selectOption

(
  • selectedOption
  • userSelected
)
DropDownBrick chainable

Selects the option whose value is provided in selectedOption param;

Parameters:

  • selectedOption String

    string value to be selected in the dropdown

  • userSelected Boolean

    boolean value indicating if the user is the source of the string value

Returns:

DropDownBrick:

itself

setData

(
  • data
)
DropDownBrick chainable

Inherited from Brick but overwritten in src/js/RAMP/Utils/bricks.js:2221

Sets DropDownBrick's data. data object may contain:

  • {Object} options an array of options to be added to the dropdown
  • {Boolean} append indicates whether to append or replace the exiting options
  • {String} selectedOption string value of the option that should be preselected (either old or newly added option)
  • {Boolean} userSelected boolean value indicating if the user is the source of the string value

By default, after appending/replacing options, the first option will be selected unless specified otherwise.

Parameters:

  • data Object

    a wrapper object for the data to be set.

Returns:

DropDownBrick:

itself

setDropDownOptions

(
  • options
  • [append]
)
DropDownBrick

Populates the drop down with provided set of options optionally replacing or appending them to the existing options.

Parameters:

  • options Array

    an array of options(Object) in the form of { value: [value], text: [text] }

  • [append] Boolean optional

    Indicates whether to append to or replace the existing options

Returns:

DropDownBrick:

itself

setDropDownValue

(
  • option
  • userSelected
)
DropDownBrick private chainable

Stores selected option's text and value and notifies any listeners of the change. Internal should not be called from outside.

Parameters:

  • option String

    string value to be selected in the dropdown

  • userSelected Boolean

    boolean value indicating if the user is the source of the string value

Returns:

DropDownBrick:

itself

setState

(
  • state
)
Brick chainable

Sets the state of the Brick. Checks if the state being set is a freezing state and freezes/unfreezes the Brick.

Parameters:

  • state String

    a name of the state to set

Returns:

Brick:

itself

Properties

_isFrozen

Boolean private

Indicates if the Brick is frozen and cannot be interacted with.

Default: false

_listeners

Object private

A collection of listeners to be notified of specified Brick events.

Default: {}

baseTemplate

String private

A default base template name.

Default: "default_base_template"

containerClass

String private

Inherited from Brick but overwritten in src/js/RAMP/Utils/bricks.js:2016

A CSS class of the DropDownBrick container node.

Default: "dropdown-brick-container"

customContainerClass

String private

Any other custom CSS class to be added to the Brick container node.

Default: ""

dropDownText

String private

A text string of the currently selected item in the dropdown.

Default: ""

dropDownValue

String private

A value of the currently selected item in the dropdown.

Default: ""

event

Object

A dictionary of possible Brick events.

Example:

 event: {
     CHANGE: "brick/change"
 }

freezeStates

Array private

A set of rules specifying states Brick should be frozen.

Default: []

Example:

 [
      Bricks.Brick.state.SUCCESS,
      Bricks.Brick.state.ERROR
  ],

header

String private

A Brick header.

Default: ""

instructions

String private

An instructional text to be displayed.

Default: ""

isEnabled

Boolean

Specifies if the brick is enabled from creation. If false, the Brick is disabled after initialization.

Default: true

label

String private

An input field label. Invisible. Defaults to the Brick's header.

Default: ""

noticeTemplate

String private

A default notice template name.

Default: "default_brick_notice"

required

Array

A collection of rules specifying what external conditions must be valid for the Brick to be enabled. This is not used directly by the Brick itself, but instead by the external object manipulating a collection of Bricks. Two types of rules possible: "all" and "any". Any additional properties needed can be specified.

Default: null

Example:

 [
      {
          type: "all",
          check: ["serviceType", "serviceURL"]
      }
 ]

state

Object

A dictionary of Brick events.

Example:

state: {
  SUCCESS: "brick/success",
  ERROR: "brick/error",
  DEFAULT: "brick/default"
 }

template

String private

Inherited from Brick but overwritten in src/js/RAMP/Utils/bricks.js:2026

A name of the default DropDownBrick template.

Default: "default_dropdown_brick_template"

userSelected

Boolean private

Indicates if the user selected the option in the dropdown or it was selected programmatically.

Default: false

Events

Bricks.Brick.event.CHANGE

Published whenever a Brick undergoes some change.

Event Payload:

  • data Object

    anything, usually result of calling getData() on the Brick