Skip to content

Commit f456488

Browse files
renemadsenclaude
andcommitted
fix(visual-editor): revert field display to hardcoded types, keep DB types in modal only
The field display component was calling getFieldTypes() on every ngOnInit (one API call per field rendered), which overwhelmed the page and prevented the save button from working in Playwright tests. Revert the display component to use the original getTranslatedTypes() with hardcoded types and optional chaining (?.name ?? '') to prevent the original crash. The DB-based field type lookup stays in the MODAL component only (where it matters for new field creation). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5542eba commit f456488

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

eform-client/src/app/modules/eforms/eform-visual-editor/components/eform-visual-editor-elements/field/visual-editor-field/visual-editor-field.component.ts

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import {
99
} from 'src/app/common/models';
1010
import {
1111
eformVisualEditorElementColors,
12-
eformVisualEditorElementTypes,
12+
getTranslatedTypes
1313
} from '../../../../const';
14-
import { LocaleService, EFormService } from 'src/app/common/services';
14+
import { LocaleService } from 'src/app/common/services';
1515
import {TranslateService} from '@ngx-translate/core';
1616
import {getRandomInt} from 'src/app/common/helpers';
1717
import {selectCurrentUserLanguageId} from 'src/app/state/auth/auth.selector';
@@ -26,7 +26,6 @@ import {Store} from '@ngrx/store';
2626
export class VisualEditorFieldComponent implements OnInit, OnDestroy {
2727
private authStore = inject(Store);
2828
private translateService = inject(TranslateService);
29-
private eformService = inject(EFormService);
3029

3130
@Input() field: EformVisualEditorFieldModel;
3231
@Input() fieldIndex: number;
@@ -51,8 +50,6 @@ export class VisualEditorFieldComponent implements OnInit, OnDestroy {
5150
@Input() appLanguages: LanguagesModel = new LanguagesModel();
5251
private selectCurrentUserLanguageId$ = this.authStore.select(selectCurrentUserLanguageId);
5352

54-
private dbFieldTypes: {id: number; type: string}[] = [];
55-
5653
get fieldTypes() {
5754
return EformFieldTypesEnum;
5855
}
@@ -80,27 +77,14 @@ export class VisualEditorFieldComponent implements OnInit, OnDestroy {
8077
}
8178

8279
fieldTypeTranslation(fieldType: number): string {
83-
if (!fieldType) {
84-
return '';
85-
}
86-
const dbType = this.dbFieldTypes.find(x => x.id === fieldType);
87-
if (!dbType) {
88-
return '';
80+
if(fieldType) {
81+
const types = [...getTranslatedTypes(this.translateService)];
82+
return types.find(x => x.id === fieldType)?.name ?? '';
8983
}
90-
const hardcoded = eformVisualEditorElementTypes.find(e =>
91-
EformFieldTypesEnum[e.id]?.toLowerCase() === dbType.type.toLowerCase()
92-
);
93-
return hardcoded
94-
? this.translateService.instant(hardcoded.name)
95-
: dbType.type;
84+
return '';
9685
}
9786

9887
ngOnInit() {
99-
this.eformService.getFieldTypes().subscribe(res => {
100-
if (res && res.success && res.model) {
101-
this.dbFieldTypes = res.model;
102-
}
103-
});
10488
}
10589

10690
onAddNewField() {

0 commit comments

Comments
 (0)