Update model and add invalidated cycle

This commit is contained in:
Misode
2020-05-25 14:45:10 +02:00
parent 79a5742dad
commit 56f3766a13
9 changed files with 73 additions and 20 deletions

View File

@@ -12,12 +12,14 @@ export class EnumNode extends AbstractNode<string> {
}
updateModel(el: Element, path: Path, model: DataModel) {
model.set(path, el.querySelector('select')?.value)
}
render(path: Path, value: string, view: TreeView) {
const id = view.register(el => (el as HTMLInputElement).value = value)
return this.wrap(path, view, `<span>${path.last()}</span>
<select value="${value}">
${this.options.map(o => `<option>${o}</option>`)}
<select data-id=${id}>
${this.options.map(o => `<option value="${o}">${o}</option>`).join('')}
</select>`)
}
}