git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4623 ed5197a5-7fde-0310-b194-c3ffbd925b24
		
			
				
	
	
		
			39 lines
		
	
	
		
			906 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			906 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import {LitElement, html} from './lit-all.min.js';
 | |
| import * as tfrpc from '/static/tfrpc.js';
 | |
| 
 | |
| /*
 | |
| ** Provide a list of IDs, and this lets the user pick one.
 | |
| */
 | |
| class TfIdentityPickerElement extends LitElement {
 | |
| 	static get properties() {
 | |
| 		return {
 | |
| 			ids: {type: Array},
 | |
| 			selected: {type: String},
 | |
| 			users: {type: Object},
 | |
| 		};
 | |
| 	}
 | |
| 
 | |
| 	constructor() {
 | |
| 		super();
 | |
| 		this.ids = [];
 | |
| 		this.users = {};
 | |
| 	}
 | |
| 
 | |
| 	changed(event) {
 | |
| 		this.selected = event.srcElement.value;
 | |
| 		this.dispatchEvent(new Event('change', {
 | |
| 			srcElement: this,
 | |
| 		}));
 | |
| 	}
 | |
| 
 | |
| 	render() {
 | |
| 		return html`
 | |
| 			<select @change=${this.changed} style="max-width: 100%">
 | |
| 				${(this.ids ?? []).map(id => html`<option ?selected=${id == this.selected} value=${id}>${this.users[id]?.name ? (this.users[id]?.name + ' - ') : undefined}<small>${id}</small></option>`)}
 | |
| 			</select>
 | |
| 		`;
 | |
| 	}
 | |
| }
 | |
| 
 | |
| customElements.define('tf-id-picker', TfIdentityPickerElement);
 |