X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/d20aacb732358457fbc4ea82c5eb3761a5f1a097..refs/pull/4126/head:/resources/js/components/entity-selector-popup.js diff --git a/resources/js/components/entity-selector-popup.js b/resources/js/components/entity-selector-popup.js index e7cb60b1f..d455f7ee7 100644 --- a/resources/js/components/entity-selector-popup.js +++ b/resources/js/components/entity-selector-popup.js @@ -1,14 +1,10 @@ -/** - * Entity Selector Popup - * @extends {Component} - */ -class EntitySelectorPopup { +import {Component} from "./component"; + +export class EntitySelectorPopup extends Component { setup() { - this.elem = this.$el; + this.container = this.$el; this.selectButton = this.$refs.select; - - window.EntitySelectorPopup = this; this.selectorEl = this.$refs.selector; this.callback = null; @@ -21,16 +17,26 @@ class EntitySelectorPopup { show(callback) { this.callback = callback; - this.elem.components.popup.show(); + this.getPopup().show(); this.getSelector().focusSearch(); } hide() { - this.elem.components.popup.hide(); + this.getPopup().hide(); } + /** + * @returns {Popup} + */ + getPopup() { + return window.$components.firstOnElement(this.container, 'popup'); + } + + /** + * @returns {EntitySelector} + */ getSelector() { - return this.selectorEl.components['entity-selector']; + return window.$components.firstOnElement(this.selectorEl, 'entity-selector'); } onSelectButtonClick() { @@ -51,6 +57,4 @@ class EntitySelectorPopup { this.getSelector().reset(); if (this.callback && entity) this.callback(entity); } -} - -export default EntitySelectorPopup; \ No newline at end of file +} \ No newline at end of file