X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/58cadce052f5cc3c9ce2bc12f88a93cac310699a..refs/pull/5429/head:/resources/js/components/page-picker.js diff --git a/resources/js/components/page-picker.js b/resources/js/components/page-picker.js index 130972fdd..5ab511595 100644 --- a/resources/js/components/page-picker.js +++ b/resources/js/components/page-picker.js @@ -1,7 +1,7 @@ import {Component} from './component'; function toggleElem(elem, show) { - elem.style.display = show ? null : 'none'; + elem.toggleAttribute('hidden', !show); } export class PagePicker extends Component { @@ -14,6 +14,8 @@ export class PagePicker extends Component { this.defaultDisplay = this.$refs.defaultDisplay; this.buttonSep = this.$refs.buttonSeperator; + this.selectorEndpoint = this.$opts.selectorEndpoint; + this.value = this.input.value; this.setupListeners(); } @@ -21,6 +23,7 @@ export class PagePicker extends Component { setupListeners() { this.selectButton.addEventListener('click', this.showPopup.bind(this)); this.display.parentElement.addEventListener('click', this.showPopup.bind(this)); + this.display.addEventListener('click', e => e.stopPropagation()); this.resetButton.addEventListener('click', () => { this.setValue('', ''); @@ -32,6 +35,11 @@ export class PagePicker extends Component { const selectorPopup = window.$components.first('entity-selector-popup'); selectorPopup.show(entity => { this.setValue(entity.id, entity.name); + }, { + initialValue: '', + searchEndpoint: this.selectorEndpoint, + entityTypes: 'page', + entityPermission: 'view', }); }