30 lines
648 B
JavaScript
30 lines
648 B
JavaScript
/**
|
|
* Represents the actual input element on the creator tool
|
|
* A field may have multiple inputs if it allows multiple values
|
|
*/
|
|
export class FieldInput {
|
|
constructor(field, parentElem) {
|
|
this.field = field;
|
|
this.id = "field-" + field.key;
|
|
|
|
if (!field.isHidden)
|
|
parentElem.innerHTML += `
|
|
<label for="${field.key}">${field.displayName}</label>
|
|
<p class="description">${field.description ?? ""}</p>
|
|
${field.getInputHtml(this.id)}
|
|
`;
|
|
}
|
|
|
|
isValid() {
|
|
return this.field.isValidInput(this.id);
|
|
}
|
|
|
|
getValue() {
|
|
return this.field.getInputValue(this.id);
|
|
}
|
|
|
|
toString() {
|
|
return this.field.inputToString(this.id);
|
|
}
|
|
}
|