Skip to content

Commit

Permalink
AAE-30066 Render sections in runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgny committed Jan 13, 2025
1 parent 1b3a29f commit 908657a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
*ngFor="let column of currentRootElement?.columns"
[style.width.%]="getColumnWith(currentRootElement)">
<div class="adf-grid-list-column-view-item" *ngFor="let field of column?.fields">
<adf-form-field *ngIf="field" [field]="field" />
<ng-container *ngIf="field.type === 'container-section'; else formField">
to be implemented
</ng-container>
<ng-template #formField>
<adf-form-field [field]="field"></adf-form-field>
</ng-template>
</div>
</div>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -58,23 +59,27 @@ 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);
}

static isReactiveType(type: string): boolean {
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 908657a

Please sign in to comment.