-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #472 from nyaruka/add-workspace-select
Add WorkspaceSelect
- Loading branch information
Showing
14 changed files
with
119 additions
and
27 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { css, CSSResultArray, 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(): CSSResultArray { | ||
return [ | ||
super.styles, | ||
css` | ||
:host { | ||
border: 0px solid blue; | ||
} | ||
` | ||
]; | ||
} | ||
|
||
@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>`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters