2020-12-31 12:25:20 -05:00
|
|
|
import {onChildEvent} from "../services/dom";
|
|
|
|
|
|
|
|
class UserSelect {
|
|
|
|
|
|
|
|
setup() {
|
|
|
|
this.input = this.$refs.input;
|
|
|
|
this.userInfoContainer = this.$refs.userInfo;
|
|
|
|
|
|
|
|
this.hide = this.$el.components.dropdown.hide;
|
|
|
|
|
|
|
|
onChildEvent(this.$el, 'a.dropdown-search-item', 'click', this.selectUser.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
selectUser(event, userEl) {
|
2021-03-21 11:04:32 -04:00
|
|
|
event.preventDefault();
|
2020-12-31 12:25:20 -05:00
|
|
|
const id = userEl.getAttribute('data-id');
|
|
|
|
this.input.value = id;
|
|
|
|
this.userInfoContainer.innerHTML = userEl.innerHTML;
|
2021-03-21 11:04:32 -04:00
|
|
|
this.input.dispatchEvent(new Event('change', {bubbles: true}));
|
2020-12-31 12:25:20 -05:00
|
|
|
this.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export default UserSelect;
|