]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/page-picker.js
Add optional OIDC avatar fetching from the “picture” claim
[bookstack] / resources / js / components / page-picker.js
index 130972fdd63ebc8aaed1cf4572a728d25a505904..5ab51159570350f00a31abdf5fb581923a1a42cd 100644 (file)
@@ -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',
         });
     }