UNPKG

dual-data-picker

Version:

## Settings editableDiv : true This use div instead input. Usefull to eliminate autocomplete feature.

69 lines (54 loc) 1.59 kB
import Option from './../models/option.js'; export default class Repository { constructor(app) { this.app = app; this._search = ""; this._data = []; } loadDataFromSelect() { try { let options = this.app.Select.options; for (let option of options) { let selected = false; if (option.selected) { selected = true; } this.data = new Option({ value : option.value, label : option.label, selected : selected }); } } catch(e) { console.error("loadDataFromSelect", e); } } set data(v) { this._data.push(v); } get data() { return this.filter(this._data); } set search(v) { this._search = v; } get search() { return this._search; } filter(data) { let out = []; let searchString = this.search; if (searchString != "") { this.app.SearchEngine.searchString = searchString; this.app.SearchEngine.data = data; console.log("search", this.app.SearchEngine); out = this.app.SearchEngine.search(); console.log("search out", out, this.app.SearchEngine); return out; } else { return data; } } }