0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-17 13:52:04 +00:00
BookStackApp_BookStack/resources/js/components/user-select.js

29 lines
837 B
JavaScript
Raw Permalink Normal View History

import {onChildEvent} from '../services/dom.ts';
import {Component} from './component';
2020-12-31 17:25:20 +00:00
export class UserSelect extends Component {
2020-12-31 17:25:20 +00:00
setup() {
this.container = this.$el;
2020-12-31 17:25:20 +00:00
this.input = this.$refs.input;
this.userInfoContainer = this.$refs.userInfo;
onChildEvent(this.container, 'a.dropdown-search-item', 'click', this.selectUser.bind(this));
2020-12-31 17:25:20 +00:00
}
selectUser(event, userEl) {
event.preventDefault();
this.input.value = userEl.getAttribute('data-id');
2020-12-31 17:25:20 +00:00
this.userInfoContainer.innerHTML = userEl.innerHTML;
this.input.dispatchEvent(new Event('change', {bubbles: true}));
2020-12-31 17:25:20 +00:00
this.hide();
}
hide() {
/** @var {Dropdown} * */
const dropdown = window.$components.firstOnElement(this.container, 'dropdown');
dropdown.hide();
}
}