2022-09-06 19:26:43 -04:00
|
|
|
import {LitElement, html} from './lit-all.min.js';
|
|
|
|
import * as tfrpc from '/static/tfrpc.js';
|
2024-01-11 23:23:31 -05:00
|
|
|
import {styles} from './tf-styles.js';
|
2022-09-06 19:26:43 -04:00
|
|
|
|
|
|
|
/*
|
2022-11-16 19:30:58 -05:00
|
|
|
* Provide a list of IDs, and this lets the user pick one.
|
2022-09-06 19:26:43 -04:00
|
|
|
*/
|
|
|
|
class TfIdentityPickerElement extends LitElement {
|
|
|
|
static get properties() {
|
|
|
|
return {
|
|
|
|
ids: {type: Array},
|
|
|
|
selected: {type: String},
|
2023-11-08 18:51:54 -05:00
|
|
|
users: {type: Object},
|
2023-03-29 18:02:12 -04:00
|
|
|
};
|
2022-09-06 19:26:43 -04:00
|
|
|
}
|
|
|
|
|
2024-01-11 23:23:31 -05:00
|
|
|
static styles = styles;
|
|
|
|
|
2022-09-06 19:26:43 -04:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.ids = [];
|
2023-11-08 18:51:54 -05:00
|
|
|
this.users = {};
|
2022-09-06 19:26:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
changed(event) {
|
|
|
|
this.selected = event.srcElement.value;
|
2022-11-16 19:30:58 -05:00
|
|
|
this.dispatchEvent(
|
|
|
|
new Event('change', {
|
|
|
|
srcElement: this,
|
|
|
|
})
|
|
|
|
);
|
2022-09-06 19:26:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return html`
|
2024-01-14 21:01:36 -05:00
|
|
|
<select
|
|
|
|
class="w3-select w3-dark-grey w3-padding w3-border"
|
|
|
|
@change=${this.changed}
|
|
|
|
style="max-width: 100%; overflow: hidden"
|
|
|
|
>
|
2023-11-08 18:51:54 -05:00
|
|
|
${(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>`
|
|
|
|
)}
|
2022-09-06 19:26:43 -04:00
|
|
|
</select>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-02 20:30:48 -04:00
|
|
|
customElements.define('tf-id-picker', TfIdentityPickerElement);
|