2 * Entity Selector Popup
5 class EntitySelectorPopup {
9 this.selectButton = this.$refs.select;
10 window.EntitySelectorPopup = this;
13 this.selection = null;
15 this.selectButton.addEventListener('click', this.onSelectButtonClick.bind(this));
16 window.$events.listen('entity-select-change', this.onSelectionChange.bind(this));
17 window.$events.listen('entity-select-confirm', this.onSelectionConfirm.bind(this));
21 this.callback = callback;
22 this.elem.components.popup.show();
26 this.elem.components.popup.hide();
29 onSelectButtonClick() {
31 if (this.selection !== null && this.callback) this.callback(this.selection);
34 onSelectionConfirm(entity) {
36 if (this.callback && entity) this.callback(entity);
39 onSelectionChange(entity) {
40 this.selection = entity;
41 if (entity === null) {
42 this.selectButton.setAttribute('disabled', 'true');
44 this.selectButton.removeAttribute('disabled');
49 export default EntitySelectorPopup;