39 lines
996 B
JavaScript
39 lines
996 B
JavaScript
import UI from "../ui.js";
|
|
|
|
class Form extends UI {
|
|
constructor(width, height) {
|
|
super(document.createElement("div"), width, height);
|
|
|
|
this.element.classList.add("form");
|
|
this._lines = [];
|
|
this._linesById = Object.create(null);
|
|
}
|
|
addLine(id, label, editor) {
|
|
let line = document.createElement("table");
|
|
let row = document.createElement("tr");
|
|
let labelCell = document.createElement("td");
|
|
let editorCell = document.createElement("td");
|
|
|
|
labelCell.innerText = label;
|
|
editorCell.appendChild(editor.element);
|
|
|
|
row.appendChild(labelCell);
|
|
row.appendChild(editorCell);
|
|
line.appendChild(row);
|
|
|
|
let obj = {
|
|
id: id,
|
|
label: label,
|
|
editor: editor,
|
|
visible: true,
|
|
line: line
|
|
};
|
|
|
|
this._lines.push(obj);
|
|
this._linesById[id] = obj;
|
|
|
|
this.element.appendChild(line);
|
|
}
|
|
}
|
|
|
|
export default Form; |