2
0
mirror of https://github.com/frappe/books.git synced 2024-09-21 03:39:02 +00:00
books/client/view/controls/link.js

26 lines
774 B
JavaScript
Raw Normal View History

2018-01-23 12:26:40 +00:00
const frappe = require('frappejs');
const BaseControl = require('./base');
const Awesomplete = require('awesomplete');
class LinkControl extends BaseControl {
make() {
super.make();
2018-01-23 12:31:09 +00:00
this.input.setAttribute('type', 'text');
this.awesomplete = new Awesomplete(this.input, {
autoFirst: true,
minChars: 0,
maxItems: 99
});
2018-01-23 12:26:40 +00:00
2018-01-23 12:31:09 +00:00
// rebuild the list on input
this.input.addEventListener('input', async (event) => {
this.awesomplete.list = (await frappe.db.get_all({
doctype: this.options,
filters: { keywords: ["like", this.input.value] },
limit: 50
})).map(d => d.name);
});
2018-01-23 12:26:40 +00:00
}
};
module.exports = LinkControl;