SimpleInputBrick Class
The SimpleInputBrick prototype. Provides a control for a simple text input. Can be potentially extended to serve more specific purposes. To instantiate, call new on the SimpleInputBrick prototype.
Imports RAMP Modules:
Uses RAMP Templates:
templates/bricks_template.json
Item Index
Methods
Properties
Events
Methods
clear
()
SimpleInputBrick
chainable
Clears the Brick by setting inputValue to "" and userEntered to false.
Returns:
itself
disable
-
disable
-
force
Disables or re-enables the Brick.
Parameters:
Returns:
itself
displayNotice
-
notice
-
[noticeTemplate]
Display a (error) notice on the brick.
Parameters:
Returns:
itself
getData
-
[wrap]
Returns SimpleInputBrick's data.
Parameters:
-
[wrap]
Boolean optionalindicates of the payload should be wrapped with a Brick's id; useful when collection information from several Bricks at once.
Returns:
A wrapper object around two properties: inputValue and userEntered
isUserEntered
()
Boolean
Checks if the input value was entered by the user or not.
Returns:
true if the input value was entered by the user; false, otherwise
isValid
()
Boolean
Checks if the SimpleInputBrick is valid. It's considered valid if the input value is not an empty String.
Returns:
true if valid; false if not
new
-
id
-
config
Initializes the SimpleInputBrick by generating a specified template and setting defaults. This Brick fires a CHANGE event on every change inside the input field.
Parameters:
-
id
Stringspecified id of the Brick
-
config
Objecta configuration object for the Brick
-
[header]
String optionala Brick header
-
[instructions]
String optionala configuration object for the Brick
-
[required]
Array | Object optionalcollection of rules specifying what external conditions must be valid for the Brick to be enabled
-
[isEnabled]
Boolean optionalspecifies if the brick is disabled from the start
-
[freezeStates]
Array optionala set of rules specifying states Brick should be frozen
-
[baseTemplate]
String optionala base template name to be used
-
[noticeTemplate]
String optionala notice template name to be used
-
[containerClass]
String optionala CSS class of the specific brick container
-
[customContainerClass]
String optionalany other optional CSS class to be added to the brick container
-
[template]
String optionala name of the specific Brick template
-
[label]
String optionalan input field label. Invisible. Defaults to the Brick's header
-
[placeholder]
String optionala placeholder to be displayed inside the input field
-
notify
-
eventName
-
data
Notifies a listener of a Brick event.
Parameters:
Returns:
itself
on
-
eventName
-
listener
Sets a listener on the Brick for a specified eventName.
Parameters:
Returns:
itself
setData
-
data
Sets SimpleInputBrick's data. First calls setInputValue and calls set data on the Brick prototype.
Parameters:
-
data
Objecta wrapper object for the data to be set.
Returns:
itself
setInputValue
-
value
-
userEntered
Sets the current value of the input field.
Parameters:
Returns:
itself
setState
-
state
Sets the state of the Brick. Depending on the state, update the visual styles of the input field. Then call the Brick prototype setState function.
Parameters:
-
state
Stringa name of the state to set
Returns:
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: {}
containerClass
String
private
A CSS class of the SimpleInputBrick container node.
Default: "simpleinput-brick-container"
customContainerClass
String
private
Any other custom CSS class to be added to the Brick container node.
Default: ""
freezeStates
Array
private
A set of rules specifying states Brick should be frozen.
Default: []
Example:
[
Bricks.Brick.state.SUCCESS,
Bricks.Brick.state.ERROR
],
isEnabled
Boolean
Specifies if the brick is enabled from creation. If false, the Brick is disabled after initialization.
Default: true
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
A name of the default SimpleInputBrick template.
Default: "default_simpleinput_brick_template"
userEntered
Boolean
private
Indicates if the user entered text into the input field or it was entered programmatically
Default: false
Events
Bricks.Brick.event.CHANGE
Published whenever a Brick undergoes some change.
Event Payload:
-
data
Objectanything, usually result of calling getData() on the Brick