Skip to content

Commit

Permalink
fix: added the error message for section inside section (#959)
Browse files Browse the repository at this point in the history
  • Loading branch information
gokulrajtm authored Dec 5, 2024
1 parent 46be9e2 commit 277a49f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/crayons-core/src/utils/draggable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { debounce, cloneNodeWithEvents } from './index';
import { parseBoolean } from './list-utils';

//Global Variables
let dragElement;
Expand Down Expand Up @@ -126,8 +127,7 @@ export class Draggable {
const hasSectionsInFieldOptions =
dragElement.dataProvider?.type === 'DROPDOWN' &&
dragElement.dataProvider?.field_options &&
dragElement.dataProvider?.field_options.has_sections;

parseBoolean(dragElement.dataProvider?.field_options?.has_sections);
// Check if the section already has the maximum number of fields
const isSectionFieldLimitExceeded =
this.dragContainer?.children?.length > 15;
Expand Down
7 changes: 7 additions & 0 deletions packages/crayons-core/src/utils/list-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,10 @@ export function doKeyDownOperations(
selected: false,
};
}

export const parseBoolean = (value: any) => {
if (typeof value === 'string') {
return value === 'true';
}
return !!value;
};
2 changes: 1 addition & 1 deletion packages/crayons-i18n/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
"deleteSection": "Delete Section",
"disableChoiceOption": "This option is used to create a section and cannot be edited",
"errorMessages" : {
"DROPDOWN" : "Dropdown fields cannot be added into sections",
"DROPDOWN" : "This field cannot be moved into sections",
"MULTI_SELECT" : "Multi Select Dropdown fields cannot be added into sections",
"DEPENDENT_FIELD" : "Dependent fields cannot be added into sections",
"RELATIONSHIP" : "Lookup fields cannot be added into sections",
Expand Down

0 comments on commit 277a49f

Please sign in to comment.