Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x 125x | import { css, html, TemplateResult } from 'lit';
import { Select, SelectOption } from './Select';
import { property } from 'lit/decorators.js';
import { getScrollParent } from '../../utils';
export interface WorkspaceOption extends SelectOption {
name: string;
id: string;
type: string;
}
export class WorkspaceSelect extends Select<WorkspaceOption> {
static get styles() {
return css`
${super.styles}
/* Workspace chooser is embedded in the account menu, not a
standalone form widget — suppress the focus border + halo
on both the select itself and the dropdown popup. */
:host {
--temba-select-focus-border: transparent;
--temba-select-focus-halo: none;
--temba-options-focus-border: transparent;
--temba-options-focus-halo: none;
}
`;
}
@property({ type: String })
endpoint = '/api/internal/orgs.json';
@property({ type: String })
nameKey = 'name';
@property({ type: String })
valueKey = 'id';
@property({ type: String })
placeholder: string = 'Choose Workspace';
@property({ type: Boolean })
sorted: boolean = true;
@property({ type: Object })
workspace: WorkspaceOption;
constructor() {
super();
this.shouldExclude = (option: WorkspaceOption) => {
const selected = this.values[0];
return option.id === selected?.id;
};
this.searchable = true;
}
public firstUpdated(changed: Map<string, any>) {
super.firstUpdated(changed);
this.allowAnchor = !!getScrollParent(this);
}
public prepareOptionsDefault(options: WorkspaceOption[]): WorkspaceOption[] {
options.forEach((option) => {
option.type = 'workspace';
});
return options;
}
public renderOptionDefault(option: WorkspaceOption): TemplateResult {
if (!option) {
return html``;
}
return html`<temba-user name=${option.name} showname></temba-user>`;
}
}
|