Proper history tracking

This commit is contained in:
Ian Gulliver
2019-07-11 22:30:53 +00:00
parent d906e6a933
commit 0485580b89
4 changed files with 93 additions and 10 deletions

View File

@@ -8,9 +8,12 @@ class EditorNode extends EditorEntryBase {
this.input_.type = 'text';
this.input_.placeholder = 'node name';
this.listen(this.input_, 'keydown', (e) => this.onInputKeyDown(e));
this.listen(this.input_, 'input', (e) => this.onInput());
this.listen(this.input_, 'input', (e) => this.onInput(e));
this.listen(this.input_, 'blur', (e) => this.onBlur(e));
this.elem_.appendChild(this.input_);
this.lastSnapshotLabel_ = null;
if (label) {
this.setLabel(label);
}
@@ -35,6 +38,7 @@ class EditorNode extends EditorEntryBase {
setLabel(label) {
this.input_.value = label;
this.lastSnapshotLabel_ = label;
this.onInput();
}
@@ -58,7 +62,15 @@ class EditorNode extends EditorEntryBase {
}
onInput() {
this.input_.setAttribute('data-arch-refresh', '');
this.elem_.setAttribute('data-arch-refresh', '');
}
onBlur() {
if (this.getLabel() != this.lastSnapshotLabel_) {
console.log('changed');
this.lastSnapshotLabel_ = this.getLabel();
this.elem_.setAttribute('data-arch-snapshot', '');
}
}
onInputKeyDown(e) {