From 908657aa0f49dfa10fefe6ef2a0bbda01a4d0706 Mon Sep 17 00:00:00 2001 From: Tomasz Gnyp Date: Mon, 13 Jan 2025 10:57:00 +0100 Subject: [PATCH] AAE-30066 Render sections in runtime --- .../form/components/form-renderer.component.html | 7 ++++++- .../components/widgets/core/form-field-types.ts | 13 +++++++++---- .../components/widgets/core/form-field.model.ts | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/core/src/lib/form/components/form-renderer.component.html b/lib/core/src/lib/form/components/form-renderer.component.html index 706b27c578d..f7179d26884 100644 --- a/lib/core/src/lib/form/components/form-renderer.component.html +++ b/lib/core/src/lib/form/components/form-renderer.component.html @@ -40,7 +40,12 @@ *ngFor="let column of currentRootElement?.columns" [style.width.%]="getColumnWith(currentRootElement)">
- + + to be implemented + + + +
diff --git a/lib/core/src/lib/form/components/widgets/core/form-field-types.ts b/lib/core/src/lib/form/components/widgets/core/form-field-types.ts index 3bda51016de..a5384a0a1d0 100644 --- a/lib/core/src/lib/form/components/widgets/core/form-field-types.ts +++ b/lib/core/src/lib/form/components/widgets/core/form-field-types.ts @@ -20,6 +20,7 @@ export class FormFieldTypes { static CONTAINER: string = 'container'; static GROUP: string = 'group'; + static SECTION: string = 'section'; static DYNAMIC_TABLE: string = 'dynamic-table'; static TEXT: string = 'text'; static STRING: string = 'string'; @@ -58,11 +59,11 @@ export class FormFieldTypes { static CONSTANT_VALUE_TYPES: string[] = [FormFieldTypes.DISPLAY_EXTERNAL_PROPERTY]; - static isReadOnlyType(type: string) { + static isReadOnlyType(type: string): boolean { return FormFieldTypes.READONLY_TYPES.includes(type); } - static isValidatableType(type: string) { + static isValidatableType(type: string): boolean { return FormFieldTypes.VALIDATABLE_TYPES.includes(type); } @@ -70,11 +71,15 @@ export class FormFieldTypes { return FormFieldTypes.REACTIVE_TYPES.includes(type); } - static isConstantValueType(type: string) { + static isConstantValueType(type: string): boolean { return FormFieldTypes.CONSTANT_VALUE_TYPES.includes(type); } - static isContainerType(type: string) { + static isContainerType(type: string): boolean { return type === FormFieldTypes.CONTAINER || type === FormFieldTypes.GROUP; } + + static isSectionType(type: string): boolean { + return type === FormFieldTypes.SECTION; + } } diff --git a/lib/core/src/lib/form/components/widgets/core/form-field.model.ts b/lib/core/src/lib/form/components/widgets/core/form-field.model.ts index 463d044d24a..840903cbf81 100644 --- a/lib/core/src/lib/form/components/widgets/core/form-field.model.ts +++ b/lib/core/src/lib/form/components/widgets/core/form-field.model.ts @@ -234,7 +234,7 @@ export class FormFieldModel extends FormWidgetModel { } } - if (FormFieldTypes.isContainerType(this.type)) { + if (FormFieldTypes.isContainerType(this.type) || FormFieldTypes.isSectionType(this.type)) { this.containerFactory(json, form); } } @@ -292,7 +292,7 @@ export class FormFieldModel extends FormWidgetModel { if (json.fields) { for (const currentField in json.fields) { if (Object.prototype.hasOwnProperty.call(json.fields, currentField)) { - const col = new ContainerColumnModel(); + const col = new ContainerColumnModel(); // TODO: Make sure this model is suitable for the section col.fields = (json.fields[currentField] || []).map((field) => new FormFieldModel(form, field)); col.rowspan = json.fields[currentField].length;