Bug #576 Cambiar los bindings del textfield

This commit is contained in:
gerard 2018-08-02 15:31:01 +02:00
parent 781fc1b70b
commit dd22309e7c
1 changed files with 7 additions and 24 deletions

View File

@ -22,34 +22,18 @@ export default class Textfield extends Input {
this.rightIcons = tClone[0]; this.rightIcons = tClone[0];
}, null, 'rightIcons'); }, null, 'rightIcons');
} }
this.input.addEventListener('keyup', e => { this.input.addEventListener('keyup', e => {
if (e.key == "Escape") { if (e.key == "Escape") {
this._cancel(); this.input.blur();
} }
}); });
this.input.addEventListener('focus', () => this.saveOldValue()); this.input.addEventListener('change', e => {
this.input.addEventListener('keyup', e => { if (this.onChange) {
if (e.key == "Enter") { this.onChange();
this._accept();
} }
}); });
} }
_accept() {
if (this.accept) {
this.input.blur();
this.accept();
}
}
_cancel() {
this.input.blur();
this.input.value = this.oldValue;
this.value = this.input.value;
this.$.$apply();
if (this.cancel) {
this.cancel();
}
}
saveOldValue() { saveOldValue() {
this.oldValue = this.input.value; this.oldValue = this.input.value;
} }
@ -111,8 +95,7 @@ ngModule.component('vnTextfield', {
rule: '@?', rule: '@?',
type: '@?', type: '@?',
vnTabIndex: '@?', vnTabIndex: '@?',
accept: '&', unclearable: '<?',
cancel: '&', onChange: '&'
unclearable: '<?'
} }
}); });