Skip to content

Commit

Permalink
fix: add multiselect to compatibility layer
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Aug 17, 2023
1 parent 01e6ea0 commit eba904e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 20 additions & 1 deletion module-legacy/instance_skel_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ export type SomeCompanionInputField =
| CompanionInputFieldTextWithVariablesInput
| CompanionInputFieldDropdown
| CompanionInputFieldMultiDropdown
| CompanionInputFieldMultiselect
| CompanionInputFieldNumber
| CompanionInputFieldCheckbox
export interface CompanionInputField {
id: string
type: 'text' | 'textinput' | 'textwithvariables' | 'dropdown' | 'colorpicker' | 'number' | 'checkbox'
type: 'text' | 'textinput' | 'textwithvariables' | 'dropdown' | 'colorpicker' | 'number' | 'checkbox' | 'multiselect'
label: string
tooltip?: string
isVisible?: (options: any /*CompanionActionEvent | CompanionFeedbackEvent*/) => boolean // TODO - this varies based on where it is used, and in this current structure is not possible to type without breaking every module
Expand Down Expand Up @@ -152,6 +153,7 @@ export interface CompanionInputFieldDropdown extends CompanionInputFieldDropdown
regex?: string
}
export interface CompanionInputFieldMultiDropdown extends CompanionInputFieldDropdownBase {
type: 'dropdown'
multiple: true
default: ConfigValue[]

Expand All @@ -172,6 +174,23 @@ export interface CompanionInputFieldDropdownBase extends CompanionInputField {
/** The minimum number of entries the dropdown must have before it allows searching */
minChoicesForSearch?: number
}

export interface CompanionInputFieldMultiselect extends CompanionInputFieldDropdownBase {
type: 'multiselect'
default: ConfigValue[]

required?: boolean

choices: DropdownChoice[]

/** The minimum number of selected values */
minSelection?: number
/** The maximum number of selected values */
maxSelection?: number

/** The minimum number of entries the dropdown must have before it allows searching */
minChoicesForSearch?: number
}
export interface CompanionInputFieldCheckbox extends CompanionInputField {
type: 'checkbox'
default: boolean
Expand Down
3 changes: 2 additions & 1 deletion module-legacy/src/fakeSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ export function convertInputField(input: SomeCompanionInputField): Complete<Modu
default: input.default,
})
case 'dropdown':
if (input.multiple) {
case 'multiselect':
if (input.multiple || input.type === 'multiselect') {
return literal<Complete<ModuleApi.CompanionInputFieldMultiDropdown>>({
...convertInputFieldBase(input),
type: 'multidropdown',
Expand Down

0 comments on commit eba904e

Please sign in to comment.