Skip to content

Commit

Permalink
Issue #0000 chore: multiselect and maxselection for one condition added
Browse files Browse the repository at this point in the history
  • Loading branch information
suvarnakale committed Jul 29, 2024
1 parent c104587 commit 508cbd1
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/components/GeneratedSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const GenerateSchemaAndUiSchema = (
// fieldUiSchema['ui:widget'] = 'select';
// }

if (isMultiSelect && type === 'drop_down') {
if (isMultiSelect && type === 'drop_down' && maxSelections !== 1) {
fieldSchema.type = 'array';
fieldSchema.items = {
type: 'string',
Expand All @@ -149,7 +149,24 @@ export const GenerateSchemaAndUiSchema = (
if (maxSelections) {
fieldSchema.maxItems = maxSelections;
}
fieldUiSchema['ui:widget'] = 'MultiSelectDropdown';
if (maxSelections === 1) {
fieldUiSchema['ui:widget'] = 'select';
} else {
fieldUiSchema['ui:widget'] = 'MultiSelectDropdown';
}
}

if (isMultiSelect && maxSelections === 1 && type === 'drop_down') {
fieldSchema.type = 'string';
fieldSchema.isDropdown = true;
fieldSchema.oneOf = options.map((opt: FieldOption) => ({
const: opt.value,
title:
t(`FORM.${opt.label}`) === `FORM.${opt.label}`
? opt.label
: t(`FORM.${opt.label}`),
}));
fieldUiSchema['ui:widget'] = 'select';
}

if (!isMultiSelect && type === 'drop_down') {
Expand Down

0 comments on commit 508cbd1

Please sign in to comment.