(text, name, maxLength = 3000, minLength = 0, optional = false, hint, subtype, value, placeholder)
| 100 | } |
| 101 | |
| 102 | addTextarea(text, name, maxLength = 3000, minLength = 0, optional = false, hint, subtype, value, placeholder) { |
| 103 | if (this.template.dialog.elements.length === 5) |
| 104 | throw new Error('You can not add more than 5 elements'); |
| 105 | |
| 106 | if (!text || !name) |
| 107 | throw new Error('Text and name are requeired for addTextarea method'); |
| 108 | |
| 109 | if (text.length > 24) |
| 110 | throw new Error('Text needs to be less or equal to 24 characters'); |
| 111 | |
| 112 | if (name.length > 300) |
| 113 | throw new Error('Name needs to be less or equal to 300 characters'); |
| 114 | |
| 115 | if (!(/^\+?(0|[1-9]\d*)$/.test(maxLength)) || maxLength > 3000 || maxLength == 0) |
| 116 | throw new Error('Max length needs to be a valid number and less or equal to 3000'); |
| 117 | |
| 118 | if (!(/^\+?(0|[1-9]\d*)$/.test(minLength)) || minLength >= 3000) |
| 119 | throw new Error('Min length needs to be a valid number and less or equal to 3000'); |
| 120 | |
| 121 | if (optional && typeof optional !== 'boolean') |
| 122 | throw new Error('Optional needs to be a boolean'); |
| 123 | |
| 124 | if (hint && (typeof hint !== 'string' || hint.length > 150)) |
| 125 | throw new Error('Hint needs to be a valid string and less or equal to 150 characters'); |
| 126 | |
| 127 | if (subtype && (['text', 'email', 'number', 'tel', 'url'].indexOf(subtype) === -1 || typeof subtype !== 'string' || typeof subtype === 'boolean')) |
| 128 | throw new Error('The value of the subtype can be email, number, tel, url or text'); |
| 129 | |
| 130 | |
| 131 | if (value && (typeof value !== 'string' || value.length > 3000)) |
| 132 | throw new Error('Value needs to be a valid string and less or equal to 3000 characters'); |
| 133 | |
| 134 | if (placeholder && (typeof placeholder !== 'string' || placeholder.length > 150)) |
| 135 | throw new Error('Placeholder needs to be a valid string and less or equal to 150 characters'); |
| 136 | |
| 137 | let textareaElement = { |
| 138 | label: text, |
| 139 | name: name, |
| 140 | type: 'textarea', |
| 141 | max_length: maxLength, |
| 142 | min_length: minLength, |
| 143 | optional: optional |
| 144 | }; |
| 145 | |
| 146 | if (hint) |
| 147 | textareaElement.hint = hint; |
| 148 | |
| 149 | if (subtype) |
| 150 | textareaElement.subtype = subtype; |
| 151 | |
| 152 | if (value) |
| 153 | textareaElement.value = value; |
| 154 | |
| 155 | if (placeholder) |
| 156 | textareaElement.placeholder = placeholder; |
| 157 | |
| 158 | this.template.dialog.elements.push(textareaElement); |
| 159 |
no outgoing calls
no test coverage detected