Skip to content

Commit 9d6c059

Browse files
renemadsenclaude
andcommitted
fix(visual-editor): bridge DB field type to hardcoded translation key
The previous commit used translateService.instant(dbType.type) directly, but DB type strings like "ShowPdf" don't match the translation keys like "ShowPDF". Now bridge via the enum member name: look up the DB type by id, then find the hardcoded entry whose enum name matches (case-insensitive), and use its name as the translation key. Falls back to the raw DB type string for unknown types. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b701184 commit 9d6c059

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from 'src/app/common/models';
1010
import {
1111
eformVisualEditorElementColors,
12+
eformVisualEditorElementTypes,
1213
} from '../../../../const';
1314
import { LocaleService, EFormService } from 'src/app/common/services';
1415
import {TranslateService} from '@ngx-translate/core';
@@ -83,10 +84,15 @@ export class VisualEditorFieldComponent implements OnInit, OnDestroy {
8384
return '';
8485
}
8586
const dbType = this.dbFieldTypes.find(x => x.id === fieldType);
86-
if (dbType) {
87-
return this.translateService.instant(dbType.type);
87+
if (!dbType) {
88+
return '';
8889
}
89-
return '';
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;
9096
}
9197

9298
ngOnInit() {

0 commit comments

Comments
 (0)