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.handleConfirmedSelection.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() {
37 this.handleConfirmedSelection(this.selection);
40 onSelectionChange(entity) {
41 this.selection = entity;
42 if (entity === null) {
43 this.selectButton.setAttribute('disabled', 'true');
45 this.selectButton.removeAttribute('disabled');
49 handleConfirmedSelection(entity) {
51 this.getSelector().reset();
52 if (this.callback && entity) this.callback(entity);
56 export default EntitySelectorPopup;