import {Component} from './component';
function toggleElem(elem, show) {
- elem.style.display = show ? null : 'none';
+ elem.toggleAttribute('hidden', !show);
}
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();
}
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('', '');
const selectorPopup = window.$components.first('entity-selector-popup');
selectorPopup.show(entity => {
this.setValue(entity.id, entity.name);
+ }, '', {
+ searchEndpoint: this.selectorEndpoint,
+ entityTypes: 'page',
+ entityPermission: 'view',
});
}