add multi select dropdown

This commit is contained in:
Simon Larsen 2022-07-30 21:20:40 +01:00
parent 79268309ee
commit 9fc298ba1a
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
5 changed files with 9 additions and 6 deletions

View File

@ -290,7 +290,7 @@ export default class APIKeyPermission extends BaseModel {
Permission.CanEditProjectApiKey,
],
})
@TableColumn({ required: true, type: TableColumnType.Array })
@TableColumn({ required: false, type: TableColumnType.Array })
@ManyToMany(() => {
return Label;
})

View File

@ -23,6 +23,7 @@ export interface ComponentProps {
value?: string | undefined;
onFocus?: (() => void) | undefined;
onBlur?: (() => void) | undefined;
isMultiSelect?: boolean;
}
const Dropdown: FunctionComponent<ComponentProps> = (
@ -68,6 +69,7 @@ const Dropdown: FunctionComponent<ComponentProps> = (
onBlur={() => {
props.onBlur && props.onBlur();
}}
isMulti={props.isMultiSelect}
value={selectedValue}
onFocus={() => {
props.onFocus && props.onFocus();

View File

@ -147,7 +147,7 @@ const BasicForm: Function = <T extends Object>(
</Field>
)}
{field.fieldType === FormFieldSchemaType.Dropdown && (
{(field.fieldType === FormFieldSchemaType.Dropdown || field.fieldType === FormFieldSchemaType.MultiSelectDropdown) && (
<Field name={fieldName}>
{({ form }: any) => {
return (
@ -167,6 +167,7 @@ const BasicForm: Function = <T extends Object>(
true
);
}}
isMultiSelect={field.fieldType === FormFieldSchemaType.MultiSelectDropdown}
options={field.dropdownOptions || []}
placeholder={field.placeholder || ''}
initialValue={

View File

@ -13,8 +13,7 @@ enum FormFieldSchemaType {
LongText,
Color,
Dropdown,
MultiSelectDropdown,
MultiSelectModelDropdown,
MultiSelectDropdown,
}
export default FormFieldSchemaType;

View File

@ -111,8 +111,9 @@ const APIKeyView: FunctionComponent<PageComponentProps> = (
field: {
labels: true,
},
title: 'Labels',
fieldType: FormFieldSchemaType.MultiSelectModelDropdown,
title: 'Labels (Optional)',
description: 'Labels on which this permissions will apply on. This is optional and an advanced feature.',
fieldType: FormFieldSchemaType.MultiSelectDropdown,
dropdownModal: {
type: Label,
labelField: "name",