2 * Entity Selector Popup
5 class EntitySelectorPopup {
9 this.selectButton = this.$refs.select;
10 this.searchInput = this.$refs.searchInput;
12 window.EntitySelectorPopup = this;
15 this.selection = null;
17 this.selectButton.addEventListener('click', this.onSelectButtonClick.bind(this));
18 window.$events.listen('entity-select-change', this.onSelectionChange.bind(this));
19 window.$events.listen('entity-select-confirm', this.onSelectionConfirm.bind(this));
23 this.callback = callback;
24 this.elem.components.popup.show();
25 this.searchInput.focus();
29 this.elem.components.popup.hide();
32 onSelectButtonClick() {
34 if (this.selection !== null && this.callback) this.callback(this.selection);
37 onSelectionConfirm(entity) {
39 if (this.callback && entity) this.callback(entity);
42 onSelectionChange(entity) {
43 this.selection = entity;
44 if (entity === null) {
45 this.selectButton.setAttribute('disabled', 'true');
47 this.selectButton.removeAttribute('disabled');
52 export default EntitySelectorPopup;