mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
validate function for autocomplete
This commit is contained in:
parent
7eeb3ca137
commit
a74ec62abe
@ -8,18 +8,26 @@ class AutocompleteControl extends BaseControl {
|
|||||||
this.setupAwesomplete();
|
this.setupAwesomplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
setupAwesomplete() {
|
async setupAwesomplete() {
|
||||||
this.awesomplete = new Awesomplete(this.input, {
|
this.awesomplete = new Awesomplete(this.input, {
|
||||||
minChars: 0,
|
minChars: 0,
|
||||||
maxItems: 99
|
maxItems: 99
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.list = await this.getList();
|
||||||
|
|
||||||
// rebuild the list on input
|
// rebuild the list on input
|
||||||
this.input.addEventListener('input', async (event) => {
|
this.input.addEventListener('input', (event) => {
|
||||||
let list = await this.getList();
|
this.awesomplete.list = this.list;
|
||||||
this.awesomplete.list = list;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validate(value) {
|
||||||
|
if (this.list.includes(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = AutocompleteControl;
|
module.exports = AutocompleteControl;
|
Loading…
Reference in New Issue
Block a user