]> BookStack Code Mirror - bookstack/blob - resources/js/components/user-select.js
aba43e0a920a5c66b0cdb8097061cec9c039d211
[bookstack] / resources / js / components / user-select.js
1 import {onChildEvent} from "../services/dom";
2
3 class UserSelect {
4
5     setup() {
6         this.input = this.$refs.input;
7         this.userInfoContainer = this.$refs.userInfo;
8
9         this.hide = this.$el.components.dropdown.hide;
10
11         onChildEvent(this.$el, 'a.dropdown-search-item', 'click', this.selectUser.bind(this));
12     }
13
14     selectUser(event, userEl) {
15         event.preventDefault();
16         const id = userEl.getAttribute('data-id');
17         this.input.value = id;
18         this.userInfoContainer.innerHTML = userEl.innerHTML;
19         this.input.dispatchEvent(new Event('change', {bubbles: true}));
20         this.hide();
21     }
22
23 }
24
25 export default UserSelect;