@inseefr/lunatic 2.6.2 → 2.6.3-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/lib/components/index.js +4 -4
  2. package/lib/components/loop/block-for-loop.js +6 -10
  3. package/lib/components/loop/roster-for-loop/roster-for-loop.js +27 -35
  4. package/lib/components/lunatic-components.js +16 -5
  5. package/lib/components/pairwise-links/pairwise-links.js +27 -30
  6. package/lib/components/table/lunatic-table.js +22 -13
  7. package/lib/components/table/{header.js → table-header.js} +3 -5
  8. package/lib/hooks/use-track-changes.js +50 -0
  9. package/lib/src/components/index.d.ts +2 -2
  10. package/lib/src/components/loop/block-for-loop.d.ts +3 -4
  11. package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +3 -4
  12. package/lib/src/components/lunatic-components.d.ts +5 -3
  13. package/lib/src/components/pairwise-links/pairwise-links.d.ts +1 -2
  14. package/lib/src/components/table/lunatic-table.d.ts +1 -1
  15. package/lib/src/components/table/{header.d.ts → table-header.d.ts} +2 -2
  16. package/lib/src/components/type.d.ts +5 -6
  17. package/lib/src/hooks/use-track-changes.d.ts +9 -0
  18. package/lib/src/use-lunatic/actions.d.ts +3 -16
  19. package/lib/src/use-lunatic/commons/compile-controls.d.ts +3 -2
  20. package/lib/src/use-lunatic/commons/component.d.ts +22 -0
  21. package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +2 -3
  22. package/lib/src/use-lunatic/commons/fill-components/fill-components.d.ts +6 -0
  23. package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +107 -122
  24. package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +112 -0
  25. package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +53 -89
  26. package/lib/src/use-lunatic/commons/get-compatible-vtl-expression.d.ts +1 -0
  27. package/lib/src/use-lunatic/commons/index.d.ts +0 -3
  28. package/lib/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +7 -0
  29. package/lib/src/use-lunatic/commons/variables/behaviours/missing-behaviour.d.ts +7 -0
  30. package/lib/src/use-lunatic/commons/variables/behaviours/resizing-behaviour.d.ts +7 -0
  31. package/lib/src/use-lunatic/commons/variables/get-questionnaire-data.d.ts +4 -0
  32. package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +77 -0
  33. package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +10 -8
  34. package/lib/src/use-lunatic/reducer/reduce-handle-change.d.ts +6 -0
  35. package/lib/src/use-lunatic/reducer/reduce-on-init.d.ts +1 -12
  36. package/lib/src/use-lunatic/type-source.d.ts +7 -21
  37. package/lib/src/use-lunatic/type.d.ts +13 -11
  38. package/lib/src/use-lunatic/use-lunatic.d.ts +33 -56
  39. package/lib/src/utils/array.d.ts +6 -1
  40. package/lib/src/utils/env.d.ts +1 -0
  41. package/lib/src/utils/number.d.ts +4 -0
  42. package/lib/src/utils/variables.d.ts +5 -0
  43. package/lib/src/utils/vtl.d.ts +14 -0
  44. package/lib/use-lunatic/actions.js +3 -3
  45. package/lib/use-lunatic/commons/compile-controls.js +3 -5
  46. package/lib/use-lunatic/commons/component.js +22 -0
  47. package/lib/use-lunatic/commons/execute-condition-filter.js +1 -9
  48. package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +2 -3
  49. package/lib/use-lunatic/commons/fill-components/fill-component-value.js +21 -7
  50. package/lib/use-lunatic/commons/fill-components/fill-components.js +5 -3
  51. package/lib/use-lunatic/commons/{execute-expression/get-safety-expression.js → fill-components/fill-iterations.js} +30 -20
  52. package/lib/use-lunatic/commons/fill-components/fill-missing-response.js +6 -13
  53. package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +58 -5
  54. package/lib/use-lunatic/commons/get-compatible-vtl-expression.js +1 -0
  55. package/lib/use-lunatic/commons/index.js +0 -21
  56. package/lib/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +39 -0
  57. package/lib/use-lunatic/commons/variables/behaviours/missing-behaviour.js +47 -0
  58. package/lib/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +78 -0
  59. package/lib/use-lunatic/{reducer/reduce-handle-change/reduce-variables-array.js → commons/variables/get-questionnaire-data.js} +53 -32
  60. package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +330 -0
  61. package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +216 -0
  62. package/lib/use-lunatic/initial-state.js +5 -2
  63. package/lib/use-lunatic/reducer/overview/overview-on-change.js +1 -1
  64. package/lib/use-lunatic/reducer/{reduce-handle-change/reduce-variables-simple.js → reduce-handle-change.js} +15 -14
  65. package/lib/use-lunatic/reducer/reduce-on-init.js +89 -181
  66. package/lib/use-lunatic/reducer/reducer.js +2 -2
  67. package/lib/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.js +2 -4
  68. package/lib/use-lunatic/use-lunatic.js +18 -14
  69. package/lib/use-lunatic/use-lunatic.test.js +131 -2
  70. package/lib/utils/array.js +57 -6
  71. package/lib/utils/array.spec.js +30 -0
  72. package/lib/utils/env.js +10 -0
  73. package/lib/utils/get-component-value.js +3 -9
  74. package/lib/utils/number.js +13 -1
  75. package/lib/utils/variables.js +37 -0
  76. package/lib/utils/vtl.js +100 -0
  77. package/package.json +1 -1
  78. package/lib/components/loop/utils/get-initial-nb-rows.js +0 -17
  79. package/lib/components/pairwise-links/index.js +0 -13
  80. package/lib/components/pairwise-links/orchestrator.js +0 -71
  81. package/lib/components/pairwise-links/row.js +0 -74
  82. package/lib/components/table/cell.js +0 -89
  83. package/lib/components/table/index.js +0 -13
  84. package/lib/components/table/row.js +0 -40
  85. package/lib/components/table/table-orchestrator.js +0 -35
  86. package/lib/src/components/loop/utils/get-initial-nb-rows.d.ts +0 -4
  87. package/lib/src/components/pairwise-links/index.d.ts +0 -1
  88. package/lib/src/components/pairwise-links/orchestrator.d.ts +0 -6
  89. package/lib/src/components/pairwise-links/row.d.ts +0 -7
  90. package/lib/src/components/table/cell.d.ts +0 -19
  91. package/lib/src/components/table/index.d.ts +0 -1
  92. package/lib/src/components/table/row.d.ts +0 -18
  93. package/lib/src/components/table/table-orchestrator.d.ts +0 -4
  94. package/lib/src/use-lunatic/commons/calculated-variables.d.ts +0 -8
  95. package/lib/src/use-lunatic/commons/execute-expression/create-execute-expression.d.ts +0 -9
  96. package/lib/src/use-lunatic/commons/execute-expression/create-memoizer.d.ts +0 -8
  97. package/lib/src/use-lunatic/commons/execute-expression/create-refresh-calculated.d.ts +0 -24
  98. package/lib/src/use-lunatic/commons/execute-expression/execute-expression.d.ts +0 -11
  99. package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.d.ts +0 -7
  100. package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.spec.d.ts +0 -1
  101. package/lib/src/use-lunatic/commons/execute-expression/get-safety-expression.d.ts +0 -6
  102. package/lib/src/use-lunatic/commons/execute-expression/index.d.ts +0 -1
  103. package/lib/src/use-lunatic/commons/get-component-value/get-component-value.d.ts +0 -6
  104. package/lib/src/use-lunatic/commons/get-component-value/index.d.ts +0 -1
  105. package/lib/src/use-lunatic/commons/get-data.d.ts +0 -26
  106. package/lib/src/use-lunatic/reducer/reduce-handle-change/index.d.ts +0 -1
  107. package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.d.ts +0 -7
  108. package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.d.ts +0 -1
  109. package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.d.ts +0 -4
  110. package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.d.ts +0 -15
  111. package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-missing.d.ts +0 -7
  112. package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-resizing.d.ts +0 -4
  113. package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.d.ts +0 -14
  114. package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.d.ts +0 -9
  115. package/lib/src/use-lunatic/reducer/reduce-on-init.spec.d.ts +0 -1
  116. package/lib/src/utils/vtl/dataset-builder.d.ts +0 -5
  117. package/lib/src/utils/vtl/index.d.ts +0 -1
  118. package/lib/use-lunatic/commons/calculated-variables.js +0 -104
  119. package/lib/use-lunatic/commons/execute-expression/create-execute-expression.js +0 -233
  120. package/lib/use-lunatic/commons/execute-expression/create-execute-expression.spec.js +0 -155
  121. package/lib/use-lunatic/commons/execute-expression/create-memoizer.js +0 -63
  122. package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.js +0 -149
  123. package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.spec.js +0 -130
  124. package/lib/use-lunatic/commons/execute-expression/execute-expression.js +0 -90
  125. package/lib/use-lunatic/commons/execute-expression/execute-expression.spec.js +0 -38
  126. package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.js +0 -40
  127. package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.spec.js +0 -31
  128. package/lib/use-lunatic/commons/execute-expression/index.js +0 -13
  129. package/lib/use-lunatic/commons/get-component-value/get-component-value.js +0 -174
  130. package/lib/use-lunatic/commons/get-component-value/index.js +0 -13
  131. package/lib/use-lunatic/commons/get-data.js +0 -80
  132. package/lib/use-lunatic/reducer/reduce-handle-change/__mocks__/source-cleaning-loop.json +0 -792
  133. package/lib/use-lunatic/reducer/reduce-handle-change/index.js +0 -13
  134. package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.js +0 -72
  135. package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.js +0 -46
  136. package/lib/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.js +0 -115
  137. package/lib/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.js +0 -89
  138. package/lib/use-lunatic/reducer/reduce-handle-change/reduce-missing.js +0 -88
  139. package/lib/use-lunatic/reducer/reduce-handle-change/reduce-resizing.js +0 -110
  140. package/lib/use-lunatic/reducer/reduce-on-init.spec.js +0 -17
  141. package/lib/utils/vtl/dataset-builder.js +0 -27
  142. package/lib/utils/vtl/index.js +0 -13
  143. /package/lib/src/use-lunatic/commons/{execute-expression/create-refresh-calculated.spec.d.ts → variables/lunatic-variables-store.spec.d.ts} +0 -0
  144. /package/lib/src/{use-lunatic/commons/execute-expression/execute-expression.spec.d.ts → utils/array.spec.d.ts} +0 -0
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _lunaticVariablesStore = require("./lunatic-variables-store");
5
+ var _resizingBehaviour = require("./behaviours/resizing-behaviour");
6
+ var _cleaningBehaviour = require("./behaviours/cleaning-behaviour");
7
+ var _missingBehaviour = require("./behaviours/missing-behaviour");
8
+ (0, _vitest.describe)('lunatic-variables-store', function () {
9
+ var variables;
10
+ (0, _vitest.beforeEach)(function () {
11
+ variables = new _lunaticVariablesStore.LunaticVariablesStore();
12
+ });
13
+ (0, _vitest.it)('should record basic variables', function () {
14
+ variables.set('FIRSTNAME', 'John');
15
+ (0, _vitest.expect)(variables.get('FIRSTNAME')).toEqual('John');
16
+ });
17
+ (0, _vitest.it)('should run simple types', function () {
18
+ (0, _vitest.expect)(variables.run('"Hello world"')).toEqual('Hello world');
19
+ (0, _vitest.expect)(variables.run('true')).toEqual(true);
20
+ (0, _vitest.expect)(variables.run('2')).toEqual(2);
21
+ });
22
+ (0, _vitest.it)('should handle calculated', function () {
23
+ variables.set('FIRSTNAME', 'John');
24
+ variables.set('LASTNAME', 'Doe');
25
+ variables.setCalculated('FULLNAME', 'FIRSTNAME || " " || LASTNAME', {
26
+ dependencies: ['FIRSTNAME', 'LASTNAME']
27
+ });
28
+ (0, _vitest.expect)(variables.get('FULLNAME')).toEqual('John Doe');
29
+ (0, _vitest.expect)(variables.interpretCount).toBe(1);
30
+ // The result should be cached
31
+ (0, _vitest.expect)(variables.get('FULLNAME')).toEqual('John Doe');
32
+ (0, _vitest.expect)(variables.interpretCount).toBe(1);
33
+ // But refreshed if a variable was updated
34
+ variables.set('FIRSTNAME', 'Jane');
35
+ (0, _vitest.expect)(variables.get('FULLNAME')).toEqual('Jane Doe');
36
+ (0, _vitest.expect)(variables.interpretCount).toBe(2);
37
+ });
38
+ (0, _vitest.it)('should handle deep calculation', function () {
39
+ variables.set('FIRSTNAME', 'John');
40
+ variables.set('LASTNAME', 'Doe');
41
+ variables.set('AGE', '18');
42
+ variables.setCalculated('FULLNAME', 'FIRSTNAME || " " || LASTNAME', {
43
+ dependencies: ['FIRSTNAME', 'LASTNAME']
44
+ });
45
+ variables.setCalculated('LABEL', 'FULLNAME || " is " || AGE', {
46
+ dependencies: ['FULLNAME', 'AGE']
47
+ });
48
+ (0, _vitest.expect)(variables.get('LABEL')).toEqual('John Doe is 18');
49
+ (0, _vitest.expect)(variables.interpretCount).toBe(2);
50
+ variables.set('AGE', '20');
51
+ (0, _vitest.expect)(variables.get('LABEL')).toEqual('John Doe is 20');
52
+ (0, _vitest.expect)(variables.interpretCount).toBe(3);
53
+ variables.set('FIRSTNAME', 'Jane');
54
+ (0, _vitest.expect)(variables.get('LABEL')).toEqual('Jane Doe is 20');
55
+ (0, _vitest.expect)(variables.interpretCount).toBe(5);
56
+ variables.get('LABEL');
57
+ (0, _vitest.expect)(variables.interpretCount).toBe(5);
58
+ });
59
+ (0, _vitest.it)('should handle dependencies resolution', function () {
60
+ variables.set('FIRSTNAME', 'John');
61
+ variables.set('LASTNAME', 'Doe');
62
+ variables.setCalculated('FULLNAME', 'FIRSTNAME || " " || LASTNAME');
63
+ (0, _vitest.expect)(variables.get('FULLNAME')).toEqual('John Doe');
64
+ variables.set('FIRSTNAME', 'Jane');
65
+ (0, _vitest.expect)(variables.get('FULLNAME')).toEqual('Jane Doe');
66
+ });
67
+ (0, _vitest.it)('should run expression on the fly', function () {
68
+ variables.set('FIRSTNAME', 'John');
69
+ variables.set('LASTNAME', 'Doe');
70
+ (0, _vitest.expect)(variables.run('FIRSTNAME || " " || LASTNAME')).toEqual('John Doe');
71
+ (0, _vitest.expect)(variables.run('FIRSTNAME || " " || LASTNAME')).toEqual('John Doe');
72
+ (0, _vitest.expect)(variables.interpretCount).toBe(1);
73
+ variables.set('FIRSTNAME', 'Jane');
74
+ (0, _vitest.expect)(variables.run('FIRSTNAME || " " || LASTNAME')).toEqual('Jane Doe');
75
+ });
76
+ (0, _vitest.describe)('with iteration', function () {
77
+ (0, _vitest.it)('should handle arrays', function () {
78
+ variables.set('FIRSTNAME', ['John', 'Jane']);
79
+ (0, _vitest.expect)(variables.get('FIRSTNAME')).toEqual(['John', 'Jane']);
80
+ (0, _vitest.expect)(variables.get('FIRSTNAME', [0])).toEqual('John');
81
+ (0, _vitest.expect)(variables.get('FIRSTNAME', [1])).toEqual('Jane');
82
+ });
83
+ (0, _vitest.it)('should handle setting at a specific index', function () {
84
+ variables.set('FIRSTNAME', ['John', 'Jane']);
85
+ variables.set('LASTNAME', null);
86
+ variables.set('FIRSTNAME', 'Marc', {
87
+ iteration: [1]
88
+ });
89
+ (0, _vitest.expect)(variables.get('FIRSTNAME')).toEqual(['John', 'Marc']);
90
+ variables.set('LASTNAME', 'Doe', {
91
+ iteration: [1]
92
+ });
93
+ (0, _vitest.expect)(variables.get('LASTNAME')).toEqual([null, 'Doe']);
94
+ });
95
+ (0, _vitest.it)('should ignore non array values', function () {
96
+ variables.set('FIRSTNAME', 'John');
97
+ (0, _vitest.expect)(variables.get('FIRSTNAME', [0])).toEqual('John');
98
+ });
99
+ (0, _vitest.it)('should handle iteration in calculation', function () {
100
+ variables.set('FIRSTNAME', ['John', 'Jane']);
101
+ variables.set('LASTNAME', ['Doe', 'Dae']);
102
+ variables.setCalculated('FULLNAME', 'FIRSTNAME || " " || LASTNAME', {
103
+ dependencies: ['FIRSTNAME', 'LASTNAME']
104
+ });
105
+ (0, _vitest.expect)(variables.get('FULLNAME', [0])).toEqual('John Doe');
106
+ (0, _vitest.expect)(variables.get('FULLNAME', [1])).toEqual('Jane Dae');
107
+ (0, _vitest.expect)(variables.interpretCount).toBe(2);
108
+ (0, _vitest.expect)(variables.get('FULLNAME', [0])).toEqual('John Doe');
109
+ (0, _vitest.expect)(variables.get('FULLNAME', [1])).toEqual('Jane Dae');
110
+ (0, _vitest.expect)(variables.interpretCount).toBe(2);
111
+ (0, _vitest.expect)(variables.get('FULLNAME', [0])).toEqual('John Doe');
112
+ variables.set('FIRSTNAME', ['John', 'Marc']);
113
+ (0, _vitest.expect)(variables.get('FULLNAME', [0])).toEqual('John Doe');
114
+ (0, _vitest.expect)(variables.get('FULLNAME', [1])).toEqual('Marc Dae');
115
+ // Only the second iteration should be calculated
116
+ (0, _vitest.expect)(variables.interpretCount).toBe(3);
117
+ });
118
+ (0, _vitest.it)('should handle aggregation expression', function () {
119
+ variables.set('FIRSTNAME', ['John', 'Jane']);
120
+ (0, _vitest.expect)(variables.run('count(FIRSTNAME)')).toEqual(2);
121
+ variables.set('FIRSTNAME', ['John', 'Jane', 'Marc']);
122
+ (0, _vitest.expect)(variables.run('count(FIRSTNAME)')).toEqual(3);
123
+ });
124
+ (0, _vitest.it)('should handle non array values', function () {
125
+ variables.set('FIRSTNAME', ['John', 'Jane']);
126
+ variables.set('LASTNAME', 'Doe');
127
+ (0, _vitest.expect)(variables.run('FIRSTNAME || " " || LASTNAME', {
128
+ iteration: [0]
129
+ })).toEqual('John Doe');
130
+ (0, _vitest.expect)(variables.run('FIRSTNAME || " " || LASTNAME', {
131
+ iteration: [1]
132
+ })).toEqual('Jane Doe');
133
+ });
134
+ });
135
+ (0, _vitest.describe)('resizing', function () {
136
+ (0, _vitest.it)('should resize variables', function () {
137
+ variables.set('PRENOM', ['John', 'Jane']);
138
+ variables.set('NOM', ['Doe']);
139
+ (0, _resizingBehaviour.resizingBehaviour)(variables, {
140
+ PRENOM: {
141
+ size: 'count(PRENOM)',
142
+ variables: ['NOM']
143
+ }
144
+ });
145
+ variables.set('PRENOM', ['John', 'Jane', 'Marc']);
146
+ (0, _vitest.expect)(variables.get('PRENOM').length).toEqual(3);
147
+ (0, _vitest.expect)(variables.get('NOM').length).toEqual(3);
148
+ });
149
+ });
150
+ (0, _vitest.describe)('cleaning', function () {
151
+ (0, _vitest.it)('should clean variables', function () {
152
+ variables.set('PRENOM', 'John');
153
+ variables.set('NOM', 'Doe');
154
+ variables.set('READY', true);
155
+ (0, _cleaningBehaviour.cleaningBehaviour)(variables, {
156
+ READY: {
157
+ PRENOM: 'READY'
158
+ }
159
+ });
160
+ (0, _vitest.expect)(variables.get('PRENOM')).toEqual('John');
161
+ variables.set('READY', false);
162
+ (0, _vitest.expect)(variables.get('PRENOM')).toEqual(null);
163
+ });
164
+ (0, _vitest.it)('should clean variables with initial values', function () {
165
+ variables.set('PRENOM', 'John');
166
+ variables.set('READY', true);
167
+ (0, _cleaningBehaviour.cleaningBehaviour)(variables, {
168
+ READY: {
169
+ PRENOM: 'READY'
170
+ }
171
+ }, {
172
+ PRENOM: 'Jane'
173
+ });
174
+ variables.set('READY', false);
175
+ (0, _vitest.expect)(variables.get('PRENOM')).toEqual('Jane');
176
+ });
177
+ (0, _vitest.it)('should clean variables at a specific iteration', function () {
178
+ variables.set('PRENOM', ['John', 'Jane', 'Marc']);
179
+ variables.set('READY', [true, true, true]);
180
+ (0, _cleaningBehaviour.cleaningBehaviour)(variables, {
181
+ READY: {
182
+ PRENOM: 'READY'
183
+ }
184
+ });
185
+ variables.set('READY', false, {
186
+ iteration: [1]
187
+ });
188
+ (0, _vitest.expect)(variables.get('PRENOM')).toEqual(['John', null, 'Marc']);
189
+ });
190
+ });
191
+ (0, _vitest.describe)('missing', function () {
192
+ (0, _vitest.beforeEach)(function () {
193
+ (0, _missingBehaviour.missingBehaviour)(variables, {
194
+ PRENOM: ['PRENOM_MISSING'],
195
+ PRENOM_MISSING: ['PRENOM']
196
+ });
197
+ });
198
+ (0, _vitest.it)('should handle missing', function () {
199
+ variables.set('PRENOM', 'John');
200
+ (0, _vitest.expect)(variables.get('PRENOM')).toEqual('John');
201
+ (0, _vitest.expect)(variables.get('PRENOM_MISSING')).toEqual(null);
202
+ variables.set('PRENOM_MISSING', 'DK');
203
+ (0, _vitest.expect)(variables.get('PRENOM')).toEqual(null);
204
+ (0, _vitest.expect)(variables.get('PRENOM_MISSING')).toEqual('DK');
205
+ });
206
+ (0, _vitest.it)('should handle missing for iteration', function () {
207
+ variables.set('PRENOM', ['John', 'Jane', 'Marc']);
208
+ (0, _vitest.expect)(variables.get('PRENOM_MISSING')).toEqual(null);
209
+ variables.set('PRENOM_MISSING', 'DK', {
210
+ iteration: [1]
211
+ });
212
+ (0, _vitest.expect)(variables.get('PRENOM')).toEqual(['John', null, 'Marc']);
213
+ (0, _vitest.expect)(variables.get('PRENOM_MISSING', [1])).toEqual('DK');
214
+ });
215
+ });
216
+ });
@@ -6,9 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports["default"] = void 0;
7
7
  var _constants = require("../utils/constants");
8
8
  var _useSuggesters = require("./use-suggesters");
9
+ var _lunaticVariablesStore = require("./commons/variables/lunatic-variables-store");
10
+ var _env = require("../utils/env");
9
11
  var INITIAL_STATE = {
10
- variables: {},
11
- // map des variables du questionnaires
12
+ updatedAt: 0,
13
+ // There is a bug with this constructor in vitest
14
+ variables: (0, _env.isTestEnv)() ? null : new _lunaticVariablesStore.LunaticVariablesStore(),
12
15
  pages: {},
13
16
  isInLoop: false,
14
17
  isFirstPage: false,
@@ -37,7 +37,7 @@ var overviewOnChange = function overviewOnChange(state) {
37
37
  return _objectSpread(_objectSpread({}, overviewEntry), {}, {
38
38
  reached: isPageReached(overviewEntry.page, lastReachedPage !== null && lastReachedPage !== void 0 ? lastReachedPage : '1'),
39
39
  visible: (_executeExpression = executeExpression(overviewEntry.conditionFilter, {
40
- bindingDependencies: (_overviewEntry$condit = overviewEntry.conditionFilter) === null || _overviewEntry$condit === void 0 ? void 0 : _overviewEntry$condit.bindingDependencies
40
+ deps: (_overviewEntry$condit = overviewEntry.conditionFilter) === null || _overviewEntry$condit === void 0 ? void 0 : _overviewEntry$condit.bindingDependencies
41
41
  })) !== null && _executeExpression !== void 0 ? _executeExpression : false,
42
42
  evaluatedLabel: executeExpression(overviewEntry.label)
43
43
  });
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = void 0;
6
+ exports.reduceHandleChange = reduceHandleChange;
7
+ var _number = require("../../utils/number");
7
8
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
8
9
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
10
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -11,18 +12,18 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
11
12
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
13
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
14
  /**
14
- * Add the value for the variable in the corresponding variable object
15
+ * Update collected variables
15
16
  */
16
- function reduceVariablesSimple(variables, _ref) {
17
- var name = _ref.name,
18
- value = _ref.value;
19
- if (name in variables) {
20
- var variable = variables[name];
21
- return _objectSpread(_objectSpread({}, variables), {}, _defineProperty({}, name, _objectSpread(_objectSpread({}, variable), {}, {
22
- value: value
23
- })));
17
+ function reduceHandleChange(state, action) {
18
+ var iteration = action.payload.iteration;
19
+ // Resolve iteration from pager for loops
20
+ if (!iteration && (0, _number.isNumber)(state.pager.iteration)) {
21
+ iteration = [state.pager.iteration];
24
22
  }
25
- return variables;
26
- }
27
- var _default = reduceVariablesSimple;
28
- exports["default"] = _default;
23
+ state.updateBindings(action.payload.name, action.payload.value, {
24
+ iteration: iteration
25
+ });
26
+ return _objectSpread(_objectSpread({}, state), {}, {
27
+ updatedAt: Date.now()
28
+ });
29
+ }
@@ -8,139 +8,24 @@ var _commons = require("../commons");
8
8
  var _compose = _interopRequireDefault(require("../commons/compose"));
9
9
  var _pageTag = require("../commons/page-tag");
10
10
  var _overviewOnInit = require("./overview/overview-on-init");
11
+ var _lunaticVariablesStore = require("../commons/variables/lunatic-variables-store");
12
+ var _constants = require("../../utils/constants");
13
+ var _mdLabel = _interopRequireDefault(require("../../components/commons/components/md-label"));
14
+ var _vtl = require("../../utils/vtl");
15
+ var _number = require("../../utils/number");
16
+ var _jsxRuntime = require("react/jsx-runtime");
11
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
18
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
13
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
16
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
18
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
20
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
21
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
22
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
23
19
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
24
20
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
21
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
22
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
27
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
28
- /**
29
- * Extract value from colllected data
30
- */
31
- function getInitalValueFromCollected(variable, data) {
32
- var name = variable.name;
33
- var fromData;
34
- if (data && name in data) {
35
- var _data$name = data[name],
36
- COLLECTED = _data$name.COLLECTED,
37
- FORCED = _data$name.FORCED;
38
- fromData = COLLECTED !== null && COLLECTED !== void 0 ? COLLECTED : FORCED;
39
- }
40
- if ('values' in variable && variable.values) {
41
- var _ref, _fromData;
42
- var _variable$values = variable.values,
43
- _COLLECTED = _variable$values.COLLECTED,
44
- _FORCED = _variable$values.FORCED;
45
- return (_ref = (_fromData = fromData) !== null && _fromData !== void 0 ? _fromData : _FORCED) !== null && _ref !== void 0 ? _ref : _COLLECTED;
46
- }
47
- return undefined;
48
- }
49
-
50
- /**
51
- * Extract value from an external data
52
- */
53
- function getInitialValueFromExternal(variable) {
54
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
55
- var name = variable.name;
56
- return data === null || data === void 0 ? void 0 : data[name];
57
- }
58
-
59
- /**
60
- * Extract value from data for the variable
61
- */
62
- function getInitialValue(variable) {
63
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
64
- var COLLECTED = data.COLLECTED,
65
- EXTERNAL = data.EXTERNAL,
66
- CALCULATED = data.CALCULATED;
67
- switch (variable.variableType) {
68
- case 'COLLECTED':
69
- return getInitalValueFromCollected(variable, COLLECTED);
70
- case 'EXTERNAL':
71
- return getInitialValueFromExternal(variable, EXTERNAL);
72
- case 'CALCULATED':
73
- return getInitialValueFromExternal(variable, CALCULATED);
74
- default:
75
- return null;
76
- }
77
- }
78
- function appendToArrayMap(map, key, entry) {
79
- if (key in map) {
80
- return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, [].concat(_toConsumableArray(map[key]), [entry])));
81
- }
82
- return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, [entry]));
83
- }
84
- function appendToObjectMap(map, variable, value) {
85
- var key = variable.name;
86
- var object = {
87
- variable: variable,
88
- value: value,
89
- type: variable.variableType
90
- };
91
- if (key in map) {
92
- return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, _objectSpread(_objectSpread({}, map[key]), object)));
93
- }
94
- return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, object));
95
- }
96
-
97
- /**
98
- * Creates the variables object to set in the state
99
- */
100
- function createVariables(source, data) {
101
- var _source$variables = source.variables,
102
- variables = _source$variables === void 0 ? [] : _source$variables;
103
- var _variables$reduce = variables.reduce(function (_ref2, variable) {
104
- var _ref3 = _slicedToArray(_ref2, 2),
105
- mapType = _ref3[0],
106
- mapVar = _ref3[1];
107
- var type = variable.variableType;
108
- return [appendToArrayMap(mapType, type, variable), appendToObjectMap(mapVar, variable, getInitialValue(variable, data))];
109
- }, [{
110
- EXTERNAL: [],
111
- COLLECTED: [],
112
- CALCULATED: []
113
- }, {}]),
114
- _variables$reduce2 = _slicedToArray(_variables$reduce, 2),
115
- mapVariablesTypes = _variables$reduce2[0],
116
- mapVariables = _variables$reduce2[1];
117
- var _mapVariablesTypes$CA = mapVariablesTypes.CALCULATED,
118
- CALCULATED = _mapVariablesTypes$CA === void 0 ? [] : _mapVariablesTypes$CA;
119
- CALCULATED.forEach(function (calculated) {
120
- var _calculated$bindingDe = calculated.bindingDependencies,
121
- bindingDependencies = _calculated$bindingDe === void 0 ? [] : _calculated$bindingDe;
122
- bindingDependencies.forEach(function (name) {
123
- if (name in mapVariables) {
124
- var variable = mapVariables[name];
125
- var CalculatedLinked = variable.CalculatedLinked;
126
- if (CalculatedLinked) {
127
- CalculatedLinked.push(calculated);
128
- } else {
129
- variable.CalculatedLinked = [calculated];
130
- }
131
- }
132
- });
133
- });
134
- return mapVariables;
135
- }
136
-
137
- /**
138
- * Check if there is a loop and populate the pager accordingly
139
- */
140
- function checkInLoop(state, initialPager) {
23
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
24
+ * Check if there is a loop and populate the pager accordingly
25
+ */
26
+ function fillLoopState(state, initialPager) {
141
27
  var pager = state.pager,
142
- pages = state.pages,
143
- executeExpression = state.executeExpression;
28
+ pages = state.pages;
144
29
  var page = pager.page;
145
30
  if (page in pages) {
146
31
  var _pages$page = pages[page],
@@ -156,10 +41,9 @@ function checkInLoop(state, initialPager) {
156
41
  subPage: (_initialPager$subPage = initialPager === null || initialPager === void 0 ? void 0 : initialPager.subPage) !== null && _initialPager$subPage !== void 0 ? _initialPager$subPage : 0,
157
42
  nbSubPages: (subPages !== null && subPages !== void 0 ? subPages : []).length,
158
43
  iteration: (_initialPager$iterati = initialPager === null || initialPager === void 0 ? void 0 : initialPager.iteration) !== null && _initialPager$iterati !== void 0 ? _initialPager$iterati : 0,
159
- nbIterations: executeExpression(iterations, {
160
- iteration: undefined,
161
- bindingDependencies: loopDependencies
162
- })
44
+ nbIterations: (0, _number.forceInt)(state.executeExpression(iterations, {
45
+ deps: loopDependencies
46
+ }))
163
47
  })
164
48
  });
165
49
  }
@@ -167,12 +51,12 @@ function checkInLoop(state, initialPager) {
167
51
  return state;
168
52
  }
169
53
  function reduceOnInit(state, action) {
54
+ var _initialPager$page;
170
55
  var payload = action.payload;
171
56
  var source = payload.source,
172
57
  data = payload.data,
173
58
  initialPage = payload.initialPage,
174
59
  lastReachedPage = payload.lastReachedPage,
175
- features = payload.features,
176
60
  handleChange = payload.handleChange,
177
61
  preferences = payload.preferences,
178
62
  savingType = payload.savingType,
@@ -182,57 +66,81 @@ function reduceOnInit(state, action) {
182
66
  goToPage = payload.goToPage,
183
67
  goNextPage = payload.goNextPage,
184
68
  goPreviousPage = payload.goPreviousPage;
185
- if (source && data) {
186
- var _initialPager$page;
187
- var variables = createVariables(source, data); // map des variables
188
- var _createExecuteExpress = (0, _commons.createExecuteExpression)(variables, features),
189
- _createExecuteExpress2 = _slicedToArray(_createExecuteExpress, 2),
190
- executeExpression = _createExecuteExpress2[0],
191
- updateBindings = _createExecuteExpress2[1];
192
- var pages = (0, _commons.checkLoops)((0, _commons.createMapPages)(source));
193
- var maxPage = source.maxPage,
194
- _source$cleaning = source.cleaning,
195
- cleaning = _source$cleaning === void 0 ? {} : _source$cleaning,
196
- _source$missingBlock = source.missingBlock,
197
- missingBlock = _source$missingBlock === void 0 ? {} : _source$missingBlock,
198
- _source$resizing = source.resizing,
199
- resizing = _source$resizing === void 0 ? {} : _source$resizing;
200
- var initialPager = (0, _pageTag.getPagerFromPageTag)(initialPage);
201
- var pager = {
202
- page: (_initialPager$page = initialPager === null || initialPager === void 0 ? void 0 : initialPager.page) !== null && _initialPager$page !== void 0 ? _initialPager$page : '1',
203
- maxPage: maxPage,
204
- subPage: undefined,
205
- nbSubPages: undefined,
206
- iteration: undefined,
207
- nbIterations: undefined,
208
- lastReachedPage: lastReachedPage !== null && lastReachedPage !== void 0 ? lastReachedPage : initialPage
209
- };
210
- var _isFirstLastPage = (0, _commons.isFirstLastPage)(pager),
211
- isFirstPage = _isFirstLastPage.isFirstPage,
212
- isLastPage = _isFirstLastPage.isLastPage;
213
- return checkInLoop(_objectSpread(_objectSpread({}, state), {}, {
214
- cleaning: cleaning,
215
- missingBlock: missingBlock,
216
- resizing: resizing,
217
- variables: variables,
218
- pages: pages,
219
- isFirstPage: isFirstPage,
220
- isLastPage: isLastPage,
221
- pager: pager,
222
- executeExpression: executeExpression,
223
- updateBindings: updateBindings,
224
- handleChange: handleChange,
225
- preferences: preferences,
226
- management: management,
227
- savingType: savingType,
228
- activeControls: activeControls,
229
- goToPage: goToPage,
230
- goNextPage: goNextPage,
231
- goPreviousPage: goPreviousPage,
232
- shortcut: shortcut
233
- }), initialPager);
69
+ if (!source || !data) {
70
+ return state;
234
71
  }
235
- return state;
72
+ var variables = _lunaticVariablesStore.LunaticVariablesStore.makeFromSource(source, data);
73
+ var pages = (0, _commons.checkLoops)((0, _commons.createMapPages)(source));
74
+ var maxPage = source.maxPage,
75
+ _source$cleaning = source.cleaning,
76
+ cleaning = _source$cleaning === void 0 ? {} : _source$cleaning,
77
+ _source$missingBlock = source.missingBlock,
78
+ missingBlock = _source$missingBlock === void 0 ? {} : _source$missingBlock;
79
+ var initialPager = (0, _pageTag.getPagerFromPageTag)(initialPage);
80
+ var pager = {
81
+ page: (_initialPager$page = initialPager === null || initialPager === void 0 ? void 0 : initialPager.page) !== null && _initialPager$page !== void 0 ? _initialPager$page : '1',
82
+ maxPage: maxPage,
83
+ subPage: undefined,
84
+ nbSubPages: undefined,
85
+ iteration: undefined,
86
+ nbIterations: undefined,
87
+ lastReachedPage: lastReachedPage !== null && lastReachedPage !== void 0 ? lastReachedPage : initialPage
88
+ };
89
+ var executeExpression = function executeExpression(expression) {
90
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
91
+ // This is kept to ensure backward compatibility
92
+ if (args !== null && args !== void 0 && args.bindingDependencies) {
93
+ args.deps = args.bindingDependencies;
94
+ }
95
+ // Remove above code on next update
96
+ var expressionType = (0, _vtl.getExpressionType)(expression);
97
+ var features = action.payload.features;
98
+ if (!features.includes(_constants.VTL) || !expressionType.includes(_constants.VTL)) {
99
+ return expression;
100
+ }
101
+ var expressionString = (0, _vtl.getExpressionAsString)(expression);
102
+ try {
103
+ var result = variables.run(expressionString, _objectSpread(_objectSpread({}, args), {}, {
104
+ iteration: typeof args.iteration === 'number' ? [args.iteration] : args.iteration
105
+ }));
106
+ if (features.includes(_constants.MD) && expressionType.includes(_constants.MD) && typeof result === 'string') {
107
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_mdLabel["default"], {
108
+ expression: result
109
+ });
110
+ }
111
+ return result;
112
+ } catch (e) {
113
+ // If there is an error interpreting a variable, return the raw expression
114
+ console.error("Cannot interpret expression : ".concat(expressionString));
115
+ return expressionString;
116
+ }
117
+ };
118
+ var updateBindings = function updateBindings(variableName, value, options) {
119
+ variables.set(variableName, value, options);
120
+ };
121
+ var _isFirstLastPage = (0, _commons.isFirstLastPage)(pager),
122
+ isFirstPage = _isFirstLastPage.isFirstPage,
123
+ isLastPage = _isFirstLastPage.isLastPage;
124
+ return fillLoopState(_objectSpread(_objectSpread({}, state), {}, {
125
+ cleaning: cleaning,
126
+ missingBlock: missingBlock,
127
+ variables: variables,
128
+ pages: pages,
129
+ isFirstPage: isFirstPage,
130
+ isLastPage: isLastPage,
131
+ pager: pager,
132
+ executeExpression: executeExpression,
133
+ updateBindings: updateBindings,
134
+ handleChange: handleChange,
135
+ preferences: preferences,
136
+ management: management,
137
+ savingType: savingType,
138
+ activeControls: activeControls,
139
+ goToPage: goToPage,
140
+ goNextPage: goNextPage,
141
+ goPreviousPage: goPreviousPage,
142
+ shortcut: shortcut
143
+ }), initialPager);
236
144
  }
237
145
  var reducers = (0, _compose["default"])(reduceOnInit, _overviewOnInit.reduceOverviewOnInit);
238
146
  var _default = reducers;
@@ -8,7 +8,7 @@ var _actions = require("../actions");
8
8
  var _reduceGoNextPage = require("./reduce-go-next-page");
9
9
  var _reduceGoPreviousPage = _interopRequireDefault(require("./reduce-go-previous-page"));
10
10
  var _reduceGoToPage = _interopRequireDefault(require("./reduce-go-to-page"));
11
- var _reduceHandleChange = _interopRequireDefault(require("./reduce-handle-change"));
11
+ var _reduceHandleChange = require("./reduce-handle-change");
12
12
  var _reduceOnInit = _interopRequireDefault(require("./reduce-on-init"));
13
13
  var _reduceOnSetWaiting = _interopRequireDefault(require("./reduce-on-set-waiting"));
14
14
  var _reduceUpdateState = require("./reduce-update-state");
@@ -24,7 +24,7 @@ function reducer(state, action) {
24
24
  case _actions.ActionKind.GO_TO_PAGE:
25
25
  return (0, _reduceGoToPage["default"])(state, action);
26
26
  case _actions.ActionKind.HANDLE_CHANGE:
27
- return (0, _reduceHandleChange["default"])(state, action);
27
+ return (0, _reduceHandleChange.reduceHandleChange)(state, action);
28
28
  case _actions.ActionKind.ON_SET_WAITING:
29
29
  return (0, _reduceOnSetWaiting["default"])(state, action);
30
30
  case _actions.ActionKind.UPDATE_STATE:
@@ -16,8 +16,7 @@ function resolveSimpleControl(state, control) {
16
16
  typeOfControl = control.typeOfControl;
17
17
  var value = (_control$control$valu = control === null || control === void 0 || (_control$control = control.control) === null || _control$control === void 0 ? void 0 : _control$control.value) !== null && _control$control$valu !== void 0 ? _control$control$valu : 'true';
18
18
  var result = executeExpression(value, {
19
- iteration: iteration,
20
- linksIterations: linksIterations
19
+ iteration: linksIterations !== null && linksIterations !== void 0 ? linksIterations : iteration
21
20
  });
22
21
  try {
23
22
  /**
@@ -28,8 +27,7 @@ function resolveSimpleControl(state, control) {
28
27
  */
29
28
  if (result) return undefined;
30
29
  var label = executeExpression(errorMessage, {
31
- iteration: iteration,
32
- linksIterations: linksIterations
30
+ iteration: iteration
33
31
  });
34
32
  return {
35
33
  criticality: criticality,