X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b37e84dc101e8ca5c80bcd731adb9cc19b9e08ab..refs/pull/5429/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 69534dea5..29c06e909 100644 --- a/resources/js/components/entity-selector-popup.js +++ b/resources/js/components/entity-selector-popup.js @@ -1,4 +1,4 @@ -import {Component} from "./component"; +import {Component} from './component'; export class EntitySelectorPopup extends Component { @@ -15,18 +15,35 @@ export class EntitySelectorPopup extends Component { window.$events.listen('entity-select-confirm', this.handleConfirmedSelection.bind(this)); } - show(callback) { + /** + * Show the selector popup. + * @param {Function} callback + * @param {EntitySelectorSearchOptions} searchOptions + */ + show(callback, searchOptions = {}) { this.callback = callback; - this.container.components.popup.show(); + this.getSelector().configureSearchOptions(searchOptions); + this.getPopup().show(); + this.getSelector().focusSearch(); } hide() { - this.container.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() { @@ -47,4 +64,5 @@ export class EntitySelectorPopup extends Component { this.getSelector().reset(); if (this.callback && entity) this.callback(entity); } -} \ No newline at end of file + +}