mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
e711290d8b
Had to do some manual fixing of the app.js file due to misplaced comments
29 lines
834 B
JavaScript
29 lines
834 B
JavaScript
import {onChildEvent} from '../services/dom';
|
|
import {Component} from './component';
|
|
|
|
export class UserSelect extends Component {
|
|
|
|
setup() {
|
|
this.container = this.$el;
|
|
this.input = this.$refs.input;
|
|
this.userInfoContainer = this.$refs.userInfo;
|
|
|
|
onChildEvent(this.container, 'a.dropdown-search-item', 'click', this.selectUser.bind(this));
|
|
}
|
|
|
|
selectUser(event, userEl) {
|
|
event.preventDefault();
|
|
this.input.value = userEl.getAttribute('data-id');
|
|
this.userInfoContainer.innerHTML = userEl.innerHTML;
|
|
this.input.dispatchEvent(new Event('change', {bubbles: true}));
|
|
this.hide();
|
|
}
|
|
|
|
hide() {
|
|
/** @var {Dropdown} * */
|
|
const dropdown = window.$components.firstOnElement(this.container, 'dropdown');
|
|
dropdown.hide();
|
|
}
|
|
|
|
}
|