Skip to content

Commit e93206c

Browse files
authored
Fix a few minor bugs in backend dynamics (#110)
* Fix logic error It's the target context, not the context that can't be GroupComponent for a ["component"] lookups * OptionId => OptionsId This error causes errors because of the parse time validation. Co-authored-by: Ivar <ivar.nesje@finanstilsynet.no>
1 parent 34db5b3 commit e93206c

3 files changed

Lines changed: 115 additions & 4 deletions

File tree

src/Altinn.App.Core/Internal/Expressions/ExpressionEvaluator.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ public static bool EvaluateBooleanExpression(LayoutEvaluatorState state, Compone
8282
throw new ArgumentException("Cannot lookup component null");
8383
}
8484

85-
if (context.Component is GroupComponent)
85+
var targetContext = state.GetComponentContext(context.Component.PageId, componentId, context.RowIndices);
86+
87+
if (targetContext.Component is GroupComponent)
8688
{
8789
throw new NotImplementedException("Component lookup for components in groups not implemented");
8890
}
8991

90-
var targetContext = state.GetComponentContext(context.Component.PageId, componentId, context.RowIndices);
91-
9292
if (!targetContext.Component.DataModelBindings.TryGetValue("simpleBinding", out var binding))
9393
{
9494
throw new ArgumentException("component lookup requires the target component to have a simpleBinding");

src/Altinn.App.Core/Models/Layout/PageComponentComverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ private BaseComponent ReadComponent(ref Utf8JsonReader reader, JsonSerializerOpt
238238
pageRef = reader.GetString();
239239
break;
240240
// option
241-
case "optionid":
241+
case "optionsid":
242242
optionId = reader.GetString();
243243
break;
244244
case "options":
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"name": "Lookup for hidden component inside repeating group",
3+
"expression": ["component", "single-top-component"],
4+
"expects": "singleTopValue",
5+
"layouts": {
6+
"Page1": {
7+
"$schema": "https://altinncdn.no/schemas/json/layout/layout.schema.v1.json",
8+
"data": {
9+
"layout": [
10+
{
11+
"id": "single-top-component",
12+
"type": "Input",
13+
"dataModelBindings": {
14+
"simpleBinding": "Single.Top"
15+
}
16+
},
17+
{
18+
"id": "bedrifter",
19+
"type": "Group",
20+
"maxCount": 99,
21+
"dataModelBindings": {
22+
"group": "Bedrifter"
23+
},
24+
"children": ["bedriftsNavn", "ansatte"]
25+
},
26+
{
27+
"id": "bedriftsNavn",
28+
"type": "Input",
29+
"dataModelBindings": {
30+
"simpleBinding": "Bedrifter.Navn"
31+
}
32+
},
33+
{
34+
"id": "ansatte",
35+
"type": "Group",
36+
"maxCount": 99,
37+
"dataModelBindings": {
38+
"group": "Bedrifter.Ansatte"
39+
},
40+
"children": ["navn", "alder", "myndig"]
41+
},
42+
{
43+
"id": "navn",
44+
"type": "Input",
45+
"dataModelBindings": {
46+
"simpleBinding": "Bedrifter.Ansatte.Navn"
47+
}
48+
},
49+
{
50+
"id": "alder",
51+
"type": "Input",
52+
"dataModelBindings": {
53+
"simpleBinding": "Bedrifter.Ansatte.Alder"
54+
},
55+
"hidden": [
56+
"if",
57+
["dataModel", "Bedrifter.Ansatte.AlderSkjult"],
58+
true
59+
]
60+
},
61+
{
62+
"id": "myndig",
63+
"type": "Paragraph",
64+
"textResourceBindings": {
65+
"title": "Hurra, den ansatte er myndig!"
66+
}
67+
}
68+
]
69+
}
70+
}
71+
},
72+
"dataModel": {
73+
"Single": {
74+
"Top": "singleTopValue"
75+
},
76+
"Bedrifter": [
77+
{
78+
"Navn": "Hell og lykke AS",
79+
"Ansatte": [
80+
{
81+
"Navn": "Kaare",
82+
"Alder": 24
83+
},
84+
{
85+
"Navn": "Per",
86+
"Alder": 24
87+
}
88+
]
89+
},
90+
{
91+
"Navn": "Nedtur og motgang AS",
92+
"Ansatte": [
93+
{
94+
"Navn": "Arne",
95+
"Alder": 24,
96+
"AlderSkjult": true
97+
},
98+
{
99+
"Navn": "Vidar",
100+
"Alder": 14
101+
}
102+
]
103+
}
104+
]
105+
},
106+
"context": {
107+
"component": "ansatte",
108+
"currentLayout": "Page1",
109+
"rowIndices": [1,0]
110+
}
111+
}

0 commit comments

Comments
 (0)