2 * Entity Selector Popup
5 class EntitySelectorPopup {
9 this.selectButton = this.$refs.select;
11 window.EntitySelectorPopup = this;
12 this.selectorEl = this.$refs.selector;
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.getSelector().focusSearch();
29 this.elem.components.popup.hide();
33 return this.selectorEl.components['entity-selector'];
36 onSelectButtonClick() {
38 if (this.selection !== null && this.callback) this.callback(this.selection);
41 onSelectionConfirm(entity) {
43 this.getSelector().reset();
44 if (this.callback && entity) this.callback(entity);
47 onSelectionChange(entity) {
48 this.selection = entity;
49 if (entity === null) {
50 this.selectButton.setAttribute('disabled', 'true');
52 this.selectButton.removeAttribute('disabled');
57 export default EntitySelectorPopup;