From 6e42dbc4fa33e4ee7fd4a712088852879653f050 Mon Sep 17 00:00:00 2001 From: gowtham-balaganesh Date: Mon, 18 Nov 2024 23:14:22 +0530 Subject: [PATCH] Form builder Dynamic section changes - bug fixes (#953) * fix: delete button is not shown for some of the conversation properties * fix: don't show tooltip for default fields --- .../components/fb-field-dropdown.tsx | 8 ++-- .../form-builder/components/field-editor.tsx | 43 +++++++++++-------- .../components/form-builder/form-builder.tsx | 3 +- .../custom-objects/src/utils/utils.ts | 7 +++ 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/packages/crayons-extended/custom-objects/src/components/form-builder/components/fb-field-dropdown.tsx b/packages/crayons-extended/custom-objects/src/components/form-builder/components/fb-field-dropdown.tsx index e80e830f8..9c637a18f 100644 --- a/packages/crayons-extended/custom-objects/src/components/form-builder/components/fb-field-dropdown.tsx +++ b/packages/crayons-extended/custom-objects/src/components/form-builder/components/fb-field-dropdown.tsx @@ -401,11 +401,11 @@ export class FbFieldDropdown { dpSource.length > 0 ? dpSource .map((dataItem, index) => { - const isNewChoice = !hasCustomProperty(dataItem, 'id'); + const isNewChoice = !hasCustomProperty(dataItem, 'id'), + hasSection = !!dataItem?.choice_options?.section_name; const isChoiceDisabled = - !isNewChoice && - (this.disabled || !!dataItem?.choice_options?.section_name); - if (isChoiceDisabled) { + !isNewChoice && (this.disabled || hasSection); + if (hasSection) { return (
)} - {!this.expanded && - !this.isPrimaryField && - !this.isDeleting && - !this.isDefaultNonCustomField && - !this.editSectionField && ( - - - - )} + {showDeleteBtn && ( + + + + )} {/* {!this.expanded && this.isDefaultNonCustomField && ( diff --git a/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx b/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx index ea61c1ca4..a763b46d0 100644 --- a/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx +++ b/packages/crayons-extended/custom-objects/src/components/form-builder/form-builder.tsx @@ -30,6 +30,7 @@ import presetSchema from './assets/form-builder-preset.json'; import formMapper from './assets/form-mapper.json'; import { debounce } from '../../utils/utils'; import { TranslationController } from '../../global/Translation'; +import { parseBoolean } from '../../utils/utils'; @Component({ tag: 'fw-form-builder', @@ -691,7 +692,7 @@ export class FormBuilder { return fields.reduce((results, field) => { // Check if the field label matches the search text if (field.label.toLowerCase().includes(strSearchableText)) { - if (field?.field_options?.is_section_field) { + if (parseBoolean(field?.field_options?.is_section_field)) { field.isSectionFieldMatch = true; } results.push(field); diff --git a/packages/crayons-extended/custom-objects/src/utils/utils.ts b/packages/crayons-extended/custom-objects/src/utils/utils.ts index 28f631793..36d2ee035 100644 --- a/packages/crayons-extended/custom-objects/src/utils/utils.ts +++ b/packages/crayons-extended/custom-objects/src/utils/utils.ts @@ -33,3 +33,10 @@ export const debounce = (fn, context, timeout = 1000) => { }, timeout); }; }; + +export const parseBoolean = (value: any) => { + if (typeof value === 'string') { + return value === 'true'; + } + return !!value; +};