Constructor
new classInputField(type, parentDom, params, angular) → {void}
Constructor
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type |
string | range, text, checkbox | ||||||||||||||||||||||||||||||||||||||||||||
parentDom |
HTMLElement | DOM element of parent; | ||||||||||||||||||||||||||||||||||||||||||||
params |
Object | parameters of the input field
Properties
|
||||||||||||||||||||||||||||||||||||||||||||
angular |
Object | "self" variable inside thingsboard widget js |
- Source:
Returns:
Nothing
- Type
- void
Methods
addInputField(isMultiField) → {void}
Create new input field DOM
also creates first element of multi-field
Parameters:
| Name | Type | Description |
|---|---|---|
isMultiField |
true | false | set field as part of a multifield |
- Source:
Returns:
Nothing
- Type
- void
checkAndUpdateSummary() → {void}
if there is a total field (array) this updates it
is also called by single field for pattern check
- Source:
Returns:
Nothing
- Type
- void
checkPattern(input, value) → {true|false}
Checks, if there is a pattern for the input value and checks it against it
only for text fields
Parameters:
| Name | Type | Description |
|---|---|---|
input |
HTMLElement | element that contains the value; needed to activate shake on wrong input |
value |
string | this is the string that will be checked agains this.params.pattern |
- Source:
Returns:
- true for correct pattern, false if check is unsuccesfull
- Type
- true | false
disableSendButton() → {void}
disables the send button
- Source:
Returns:
Nothing
- Type
- void
enableSendButton() → {void}
enables the send button
- Source:
Returns:
Nothing
- Type
- void
getDefaultValue(attributeKey) → {Promise}
get default value from server attribute (which is last set value)
does no conversion blunt value
Parameters:
| Name | Type | Description |
|---|---|---|
attributeKey |
Array | array with keys to retrieve values from |
- Source:
Returns:
- a promise with requested attributes
example of returned data:
[{
"lastUpdateTs": 1644836402754,
"key": "startMission_startPos",
"value": "-500"
}]
- Type
- Promise
getValue() → {Object}
get value-key pair of this attribute
public function that gets called from angular inside widget code
- Source:
Returns:
- {key:'', value:''}
- Type
- Object
glueRemoveToLastSubElement()
puts a remove button to the last element of a multifield
only the last element has a remove button
- Source:
render() → {void}
Render DOM of the input field
if field is a multifield, create "add" button
- Source:
Returns:
Nothing
- Type
- void
setValue()
Set value of the input field
gets called after server attributes are called
- Source:
shake(domElement) → {void}
Shake animation for textfield
used when user inputs wrong values (according to pattern setting)
Parameters:
| Name | Type | Description |
|---|---|---|
domElement |
HTMLElement | the element that should be shaken |
- Source:
Returns:
Nothing
- Type
- void
updateLabel(label, value) → {void}
update the label from current value
used excpecially on slider
Parameters:
| Name | Type | Description |
|---|---|---|
label |
HTMLElement | the |
value |
string | the value which may have replacer |
- Source:
Returns:
Nothing
- Type
- void