class UserSelect extends DataSelect { get type() { return "user"; } get filters() { return { deleted: 0 }; } constructor(element) { super(element); //Add a data listener for the session user. //This is because we display an additional " (me)" for the session user option. TimeCards.dataManager.addDataListener("user", { is_session_user: true }, this.onUserUpdate.bind(this)); } setOptionInformation(option, userId, user) { option.value = userId; option.innerText = user.full_name + (userId == this.sessionUserId ? " (me)" : ""); //TODO: Localize this. } onUserUpdate(userId, user) { var firstUpdate = this.sessionUserId == undefined; this.sessionUserId = userId; //Update the option information on the first user update. This is because this listener is called after the one of the data select. if (firstUpdate) { this.setOptionInformation(this.options[this.sessionUserId], this.sessionUserId, user); } } } UIKit.registerViewType(UserSelect);