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