1 import {onChildEvent} from "../services/dom";
2 import {Component} from "./component";
4 export class UserSelect extends Component {
7 this.container = this.$el;
8 this.input = this.$refs.input;
9 this.userInfoContainer = this.$refs.userInfo;
11 this.initialValue = this.input.value;
12 this.initialContent = this.userInfoContainer.innerHTML;
14 onChildEvent(this.container, 'a.dropdown-search-item', 'click', this.selectUser.bind(this));
17 selectUser(event, userEl) {
18 event.preventDefault();
19 this.input.value = userEl.getAttribute('data-id');
20 this.userInfoContainer.innerHTML = userEl.innerHTML;
21 this.input.dispatchEvent(new Event('change', {bubbles: true}));
26 this.input.value = this.initialValue;
27 this.userInfoContainer.innerHTML = this.initialContent;
28 this.input.dispatchEvent(new Event('change', {bubbles: true}));
33 /** @var {Dropdown} **/
34 const dropdown = window.$components.firstOnElement(this.container, 'dropdown');