Repository navigation
Lookup ids (FieldTypes/Languages) are assumed fixed; visual editor SingleSelect options vanish when ids are not 1..N #8141
Description
Symptom
On a freshly installed environment, the visual editor's New field modal with Type = SingleSelect ("Rullemenu") does not render the options section: the Options textarea, the "Add options" button and the per-language options table are missing. Older installations render it correctly.
Root cause
Lookup rows are seeded with whatever AUTO_INCREMENT hands out, and code compares against fixed numeric ids.
-
The seeder ignores the intended id.
eform-sdkSqlController.FieldTypeAdd(int Id, ...)discardsIdand insertsnew FieldType { Type, Description }.Language.AddDefaultLanguagesalso inserts without an id. -
Ids stop being 1..N on some servers. On a server with
auto_increment_increment=3(e.g. a Galera cluster), the seeded ids become3, 6, 9, …:FieldType id on a contiguous install id with increment 3 Text 1 3 Picture 5 15 SingleSelect 8 24 MultiSelect 10 30 FieldGroup 17 51 Languages shift the same way: Danish 1 → 3, English 2 → 6.
-
The earlier visual-editor fix was partial (b701184 … 881b113). It remapped the Type dropdown to DB ids. Everything that reads
field.fieldTypeback still compares againstEformFieldTypesEnum, e.g.visual-editor-field-modal.component.html:2[ngSwitch]="recursionModel.field.fieldType"with*ngSwitchCase="eformFieldTypesEnum.SingleSelect"(= 8). The stored value is 24, so nothing matches. -
Some shifted ids collide with other enum values, which makes the wrong panels or flags apply:
- Text (3) equals enum
None. - Picture (15) equals enum
EntitySelect.
- Text (3) equals enum
Affected code (known so far)
eform-angular-frontend (visual editor)
visual-editor-field-modal.component.html: allngSwitchCases (Number, Date, NumberStepper, SaveButton, ShowPdf, SingleSelect, MultiSelect, EntitySearch, EntitySelect, ShowPicture)visual-editor-field-modal.component.ts:mandatoryIsNotNeed(L82-92) and the EntitySearch/EntitySelect reset inupdateFieldTypeeform-visual-editor-container.component.ts:130, 318-320and.html:137: FieldGroup checksvisual-editor-field.component.ts:94and.html:44, 80, 92visual-editor-checklist.component.html:86
eform-angular-frontend (backend and app)
SitesService.cs:186: falls back to language id 1auth-state.service.ts:45:currentLanguageId = 1
eform-sdk
Core.cs:5804, 5825:FieldTypeId != 3 && FieldTypeId != 18, meant to skip None and SaveButton
eform-angular-items-planning-plugin
ItemsPlanningReportService.cs:265, 473:FieldTypeId == 5(Picture)PlanningImportService: maps the|-separated name segments toLanguagesids 1..3, so the Excel import throwsSequence contains no elements(found while fixing)
eform-angular-workflow-plugin
WorkflowCasesService.cs:184:FieldTypeId == 5, used withFirstAsync, so it throwsWorkflowCasesService.cs:630:FieldTypeId == 8
eform-backendconfiguration-plugin
BackendConfigurationAreaRulePlanningsServiceHelper.cs:LanguageId == 1/2/3BackendConfigurationAreaRulesServiceHelper.cs:94- calendar
task-create-edit-modal:danishLanguageId = 1andEformFieldTypesEnum
eform-service-backendconfiguration-plugin
SearchListJob.cs:1871, 1897, 1901:.First(x => x.LanguageId == 1)inGenerateDocumentList. Correction: that method has no callers, so it never ran; it is dead code and has been removedFloatingLayerCaseCompletedHandler.cs:79: reads the Danish option text byLanguageId == 1and gets null. Correction: the value is currently only consumed by commented-out code, so there is no visible symptom today
Plan
Constraint: existing databases must not be renumbered or migrated. The fix is code-only.
-
Tests first. Add tests that seed or run with shifted lookup ids (
auto_increment_increment=3, or ids deliberately offset from the enum values) and assert that:- The visual editor field modal renders the correct panel for every field type, and its mandatory-flag logic matches.
- The SDK, plugin backends and service jobs resolve field types by
Typename and languages byLanguageCode.
These tests must fail on the current code.
-
Make the code id-agnostic.
- Resolve field types by
FieldType.Typeand languages byLanguageCode. - In the visual editor, normalise DB
FieldTypeId⇄EformFieldTypesEnumonce, at the API/UI boundary, so the existing enum comparisons stay valid.
- Resolve field types by
-
Keep the shifted-id tests in CI as a regression guard.
Fix (PRs)
- fix(visual-editor): speak EformFieldTypesEnum on the wire, map DB ids by name #8143
- fix: skip None/SaveButton columns by field type name, not ids 3/18 eform-sdk-dotnet#4958
- fix: resolve field types and languages by name, not by numeric id eform-angular-items-planning-plugin#2142
- fix: resolve Picture/SingleSelect fields by type name, not numeric id eform-angular-workflow-plugin#1447
- fix: resolve languages by LanguageCode instead of positional ids eform-backendconfiguration-plugin#1436
- fix: resolve the Danish language by LanguageCode, not LanguageId 1 eform-service-backendconfiguration-plugin#599
No seeder change and no data migration. Known leftovers that are out of scope are listed in each PR under "Known, out of scope".
Activity
test: expose shifted language ids as static properties (Sonar S2339)
fix(auth-state): resolve short and regional locales before picking th…
test: share the planning import setup between the shifted-id import t…