@beinformed/ui 1.9.0-beta.1 → 1.9.0-beta.13

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 (143) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/esm/constants/Settings.js +10 -8
  3. package/esm/constants/Settings.js.map +1 -1
  4. package/esm/hooks/useForm.js.map +1 -1
  5. package/esm/hooks/useModelCatalog.js +12 -5
  6. package/esm/hooks/useModelCatalog.js.map +1 -1
  7. package/esm/hooks/useNotification.js.map +1 -1
  8. package/esm/hooks/useRouter.js.map +1 -1
  9. package/esm/models/attributes/AttributeContent.js +132 -30
  10. package/esm/models/attributes/AttributeContent.js.map +1 -1
  11. package/esm/models/attributes/AttributeDataHelper.js +43 -53
  12. package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
  13. package/esm/models/attributes/AttributeModel.js +6 -4
  14. package/esm/models/attributes/AttributeModel.js.map +1 -1
  15. package/esm/models/attributes/ChoiceAttributeOptionModel.js +5 -5
  16. package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  17. package/esm/models/attributes/HelptextAttributeModel.js +17 -1
  18. package/esm/models/attributes/HelptextAttributeModel.js.map +1 -1
  19. package/esm/models/caseview/CaseViewModel.js +16 -12
  20. package/esm/models/caseview/CaseViewModel.js.map +1 -1
  21. package/esm/models/content/SectionModel.js +2 -1
  22. package/esm/models/content/SectionModel.js.map +1 -1
  23. package/esm/models/content/SubSectionModel.js +3 -1
  24. package/esm/models/content/SubSectionModel.js.map +1 -1
  25. package/esm/models/form/FormObjectModel.js +7 -1
  26. package/esm/models/form/FormObjectModel.js.map +1 -1
  27. package/esm/models/list/ListDetailModel.js +32 -3
  28. package/esm/models/list/ListDetailModel.js.map +1 -1
  29. package/esm/models/list/ListModel.js +22 -16
  30. package/esm/models/list/ListModel.js.map +1 -1
  31. package/esm/models/panels/GroupingPanelModel.js +19 -17
  32. package/esm/models/panels/GroupingPanelModel.js.map +1 -1
  33. package/esm/modularui/ModularUIRequest.js +2 -1
  34. package/esm/modularui/ModularUIRequest.js.map +1 -1
  35. package/esm/utils/helpers/text.js +19 -0
  36. package/esm/utils/helpers/text.js.map +1 -0
  37. package/esm/utils/index.js +2 -1
  38. package/esm/utils/index.js.map +1 -1
  39. package/lib/constants/Settings.js +12 -1
  40. package/lib/constants/Settings.js.flow +9 -5
  41. package/lib/constants/Settings.js.map +1 -1
  42. package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +3 -3
  43. package/lib/hooks/useForm.js.flow +10 -5
  44. package/lib/hooks/useForm.js.map +1 -1
  45. package/lib/hooks/useModelCatalog.js +13 -5
  46. package/lib/hooks/useModelCatalog.js.flow +12 -4
  47. package/lib/hooks/useModelCatalog.js.map +1 -1
  48. package/lib/hooks/useNotification.js.flow +5 -2
  49. package/lib/hooks/useNotification.js.map +1 -1
  50. package/lib/hooks/useRouter.js.flow +12 -5
  51. package/lib/hooks/useRouter.js.map +1 -1
  52. package/lib/models/attributes/AttributeContent.js +142 -31
  53. package/lib/models/attributes/AttributeContent.js.flow +104 -21
  54. package/lib/models/attributes/AttributeContent.js.map +1 -1
  55. package/lib/models/attributes/AttributeDataHelper.js +45 -52
  56. package/lib/models/attributes/AttributeDataHelper.js.flow +31 -32
  57. package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
  58. package/lib/models/attributes/AttributeModel.js +4 -2
  59. package/lib/models/attributes/AttributeModel.js.flow +3 -4
  60. package/lib/models/attributes/AttributeModel.js.map +1 -1
  61. package/lib/models/attributes/ChoiceAttributeOptionModel.js +4 -4
  62. package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +5 -8
  63. package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  64. package/lib/models/attributes/HelptextAttributeModel.js +17 -1
  65. package/lib/models/attributes/HelptextAttributeModel.js.flow +11 -1
  66. package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
  67. package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +137 -93
  68. package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +177 -88
  69. package/lib/models/attributes/__tests__/HelptextAttributeModel.spec.js.flow +39 -1
  70. package/lib/models/caseview/CaseViewModel.js +17 -13
  71. package/lib/models/caseview/CaseViewModel.js.flow +9 -7
  72. package/lib/models/caseview/CaseViewModel.js.map +1 -1
  73. package/lib/models/caseview/__tests__/CaseViewModel.spec.js.flow +68 -184
  74. package/lib/models/content/SectionModel.js +3 -1
  75. package/lib/models/content/SectionModel.js.flow +2 -1
  76. package/lib/models/content/SectionModel.js.map +1 -1
  77. package/lib/models/content/SubSectionModel.js +4 -1
  78. package/lib/models/content/SubSectionModel.js.flow +3 -1
  79. package/lib/models/content/SubSectionModel.js.map +1 -1
  80. package/lib/models/form/FormObjectModel.js +7 -1
  81. package/lib/models/form/FormObjectModel.js.flow +4 -0
  82. package/lib/models/form/FormObjectModel.js.map +1 -1
  83. package/lib/models/form/__tests__/FormWithContent.spec.js.flow +10 -2
  84. package/lib/models/list/ListDetailModel.js +32 -3
  85. package/lib/models/list/ListDetailModel.js.flow +21 -0
  86. package/lib/models/list/ListDetailModel.js.map +1 -1
  87. package/lib/models/list/ListModel.js +23 -16
  88. package/lib/models/list/ListModel.js.flow +9 -5
  89. package/lib/models/list/ListModel.js.map +1 -1
  90. package/lib/models/list/__tests__/ListDetailModel.spec.js.flow +64 -0
  91. package/lib/models/list/__tests__/ListModel.spec.js.flow +64 -2
  92. package/lib/models/panels/GroupingPanelModel.js +21 -18
  93. package/lib/models/panels/GroupingPanelModel.js.flow +10 -9
  94. package/lib/models/panels/GroupingPanelModel.js.map +1 -1
  95. package/lib/models/panels/__tests__/GroupingPanelModel.spec.js.flow +90 -0
  96. package/lib/models/types.js.flow +75 -0
  97. package/lib/modularui/ModularUIRequest.js +2 -1
  98. package/lib/modularui/ModularUIRequest.js.flow +1 -0
  99. package/lib/modularui/ModularUIRequest.js.map +1 -1
  100. package/lib/utils/helpers/text.js +28 -0
  101. package/lib/utils/helpers/text.js.flow +23 -0
  102. package/lib/utils/helpers/text.js.map +1 -0
  103. package/lib/utils/index.js +14 -0
  104. package/lib/utils/index.js.flow +1 -0
  105. package/lib/utils/index.js.map +1 -1
  106. package/package.json +19 -18
  107. package/src/constants/Settings.js +9 -5
  108. package/src/hooks/__tests__/useModelCatalog.spec.js +3 -3
  109. package/src/hooks/useForm.js +10 -5
  110. package/src/hooks/useModelCatalog.js +12 -4
  111. package/src/hooks/useNotification.js +5 -2
  112. package/src/hooks/useRouter.js +12 -5
  113. package/src/models/attributes/AttributeContent.js +104 -21
  114. package/src/models/attributes/AttributeDataHelper.js +31 -32
  115. package/src/models/attributes/AttributeModel.js +3 -4
  116. package/src/models/attributes/ChoiceAttributeOptionModel.js +5 -8
  117. package/src/models/attributes/HelptextAttributeModel.js +11 -1
  118. package/src/models/attributes/__tests__/AttributeContent.spec.js +137 -93
  119. package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +177 -88
  120. package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +39 -1
  121. package/src/models/caseview/CaseViewModel.js +9 -7
  122. package/src/models/caseview/__tests__/CaseViewModel.spec.js +68 -184
  123. package/src/models/caseview/__tests__/caseview.json +38 -0
  124. package/src/models/caseview/__tests__/caseviewContributions.json +147 -0
  125. package/src/models/content/SectionModel.js +2 -1
  126. package/src/models/content/SubSectionModel.js +3 -1
  127. package/src/models/form/FormObjectModel.js +4 -0
  128. package/src/models/form/__tests__/FormWithContent.spec.js +10 -2
  129. package/src/models/form/__tests__/FormWithContentData.json +177 -80
  130. package/src/models/list/ListDetailModel.js +21 -0
  131. package/src/models/list/ListModel.js +9 -5
  132. package/src/models/list/__tests__/ListDetailModel.spec.js +64 -0
  133. package/src/models/list/__tests__/ListModel.spec.js +64 -2
  134. package/src/models/list/__tests__/caselist-34.contributions.json +1 -1
  135. package/src/models/list/__tests__/listContributions.json +1 -1
  136. package/src/models/panels/GroupingPanelModel.js +10 -9
  137. package/src/models/panels/__tests__/GroupingPanelModel.spec.js +90 -0
  138. package/src/models/panels/__tests__/groupingPanel.json +30 -0
  139. package/src/models/panels/__tests__/groupingPanelContributions.json +46 -0
  140. package/src/models/types.js +75 -0
  141. package/src/modularui/ModularUIRequest.js +1 -0
  142. package/src/utils/helpers/text.js +23 -0
  143. package/src/utils/index.js +1 -0
@@ -2,111 +2,148 @@ import AttributeContent from "../AttributeContent";
2
2
  import SectionModel from "../../content/SectionModel";
3
3
 
4
4
  const json = {
5
- label: "Blaastest geslaagd",
6
- properties: [
7
- {
8
- key: "Gemiddelde",
9
- label: "Gemiddelde",
10
- value: "80%",
5
+ header: {
6
+ label: "Blaastest geslaagd",
7
+ description: {
8
+ message: "Dit is de beschrijving",
11
9
  },
12
- ],
13
- textfragments: [
10
+ },
11
+ elements: [
14
12
  {
15
- type: "Description",
16
- label: "Description",
17
- text: "Dit is een text fragment",
13
+ propertyElement: {
14
+ label: "Properties",
15
+ id: "properties",
16
+ properties: [
17
+ {
18
+ type: "Gemiddelde",
19
+ label: "Gemiddelde",
20
+ value: "80%",
21
+ },
22
+ ],
23
+ },
18
24
  },
19
- ],
20
- sections: [
21
25
  {
22
- id: "Alert",
23
- type: "Reference",
24
- label: "Alert",
25
- number: "1",
26
- body: "<p>The limit of 0.5 per mille has been exceeded.</p>",
27
- _links: {
28
- self: {
29
- href: "/content/_Context/Police incident decisions/Content/Breath analysis/Breathalyzer test.formalsource/Alert",
30
- },
31
- },
32
- childSections: [
33
- {
34
- id: "pass",
35
- label: "Pass",
36
- body: "<p>Nog een sectie voor optie Pass.</p>",
37
- _links: {
38
- self: {
39
- href: "/content/Incident/Business design/Content/Blaastest.textilesource/pass",
40
- },
26
+ propertyElement: {
27
+ label: "Second Properties",
28
+ id: "secondProperties",
29
+ properties: [
30
+ {
31
+ type: "SecondGemiddelde",
32
+ label: "Second Gemiddelde",
33
+ value: "20%",
41
34
  },
42
- },
43
- {
44
- id: "pass_alert",
45
- label: "Pass / Alert",
46
- body: "<p>Nog een sectie voor optie Pass / Alert.</p>",
47
- _links: {
48
- self: {
49
- href: "/content/Incident/Business design/Content/Blaastest.textilesource/pass_alert",
50
- },
35
+ ],
36
+ },
37
+ },
38
+ {
39
+ textFragmentElement: {
40
+ label: "Description",
41
+ id: "Description",
42
+ textfragments: [
43
+ {
44
+ type: "Description",
45
+ label: "Description",
46
+ text: { message: "Dit is een text fragment" },
51
47
  },
52
- },
53
- ],
54
- subSections: [
55
- {
56
- id: "Pass",
57
- body: "<p>De blaastest heeft geen alcohol constateerd (versie 2017)</p>",
58
- _links: {
59
- self: {
60
- href: "/content/Incident/Business design/Content/Blaastest subsections.formalsource/BlaastestOpties#Pass",
48
+ ],
49
+ },
50
+ },
51
+ {
52
+ contentElement: {
53
+ label: "Description",
54
+ sections: [
55
+ {
56
+ id: "Alert",
57
+ type: "Reference",
58
+ label: "Alert",
59
+ number: "1",
60
+ body: "<p>The limit of 0.5 per mille has been exceeded.</p>",
61
+ _links: {
62
+ self: {
63
+ href: "/content/_Context/Police incident decisions/Content/Breath analysis/Breathalyzer test.formalsource/Alert",
64
+ },
61
65
  },
62
- },
63
- subSections: [
64
- {
65
- id: "PassSubSection",
66
- referred: true,
67
- body: "<p>Sub sub section</p>",
68
- _links: {
69
- self: {
70
- href: "/content/Incident/Business design/Content/Blaastest subsections.formalsource/BlaastestOpties#PassSubSection",
66
+ childSections: [
67
+ {
68
+ id: "pass",
69
+ label: "Pass",
70
+ body: "<p>Nog een sectie voor optie Pass.</p>",
71
+ _links: {
72
+ self: {
73
+ href: "/content/Incident/Business design/Content/Blaastest.textilesource/pass",
74
+ },
71
75
  },
72
76
  },
73
- subSections: [
74
- {
75
- id: "PassSubSubSection",
76
- body: "<p>Sub sub sub section</p>",
77
- _links: {
78
- self: {
79
- href: "/content/Incident/Business design/Content/Blaastest subsections.formalsource/BlaastestOpties#PassSubSubSection",
80
- },
77
+ {
78
+ id: "pass_alert",
79
+ label: "Pass / Alert",
80
+ body: "<p>Nog een sectie voor optie Pass / Alert.</p>",
81
+ _links: {
82
+ self: {
83
+ href: "/content/Incident/Business design/Content/Blaastest.textilesource/pass_alert",
81
84
  },
82
- subSections: [
83
- {
84
- id: "PassSubSubSubSection",
85
- referred: true,
86
- body: "<p>Sub sub sub sub section</p>",
87
- _links: {
88
- self: {
89
- href: "/content/Incident/Business design/Content/Blaastest subsections.formalsource/BlaastestOpties#PassSubSubSubSection",
90
- },
85
+ },
86
+ },
87
+ ],
88
+ subSections: [
89
+ {
90
+ id: "Pass",
91
+ body: "<p>De blaastest heeft geen alcohol constateerd (versie 2017)</p>",
92
+ _links: {
93
+ self: {
94
+ href: "/content/Incident/Business design/Content/Blaastest subsections.formalsource/BlaastestOpties#Pass",
95
+ },
96
+ },
97
+ subSections: [
98
+ {
99
+ id: "PassSubSection",
100
+ referred: true,
101
+ body: "<p>Sub sub section</p>",
102
+ _links: {
103
+ self: {
104
+ href: "/content/Incident/Business design/Content/Blaastest subsections.formalsource/BlaastestOpties#PassSubSection",
91
105
  },
92
106
  },
93
- ],
107
+ subSections: [
108
+ {
109
+ id: "PassSubSubSection",
110
+ body: "<p>Sub sub sub section</p>",
111
+ _links: {
112
+ self: {
113
+ href: "/content/Incident/Business design/Content/Blaastest subsections.formalsource/BlaastestOpties#PassSubSubSection",
114
+ },
115
+ },
116
+ subSections: [
117
+ {
118
+ id: "PassSubSubSubSection",
119
+ referred: true,
120
+ body: "<p>Sub sub sub sub section</p>",
121
+ _links: {
122
+ self: {
123
+ href: "/content/Incident/Business design/Content/Blaastest subsections.formalsource/BlaastestOpties#PassSubSubSubSection",
124
+ },
125
+ },
126
+ },
127
+ ],
128
+ },
129
+ ],
130
+ },
131
+ ],
132
+ },
133
+ {
134
+ id: "PassAlert",
135
+ referred: true,
136
+ body: "<p>De limiet voor beginnende bestuurders is overschreden (0,2 promille). (versie 2017)</p>",
137
+ _links: {
138
+ self: {
139
+ href: "/content/Incident/Business design/Content/Blaastest subsections.formalsource/BlaastestOpties#PassAlert",
140
+ },
94
141
  },
95
- ],
96
- },
97
- ],
98
- },
99
- {
100
- id: "PassAlert",
101
- referred: true,
102
- body: "<p>De limiet voor beginnende bestuurders is overschreden (0,2 promille). (versie 2017)</p>",
103
- _links: {
104
- self: {
105
- href: "/content/Incident/Business design/Content/Blaastest subsections.formalsource/BlaastestOpties#PassAlert",
106
- },
142
+ },
143
+ ],
107
144
  },
108
- },
109
- ],
145
+ ],
146
+ },
110
147
  },
111
148
  ],
112
149
  };
@@ -115,12 +152,13 @@ describe("AttributeContent", () => {
115
152
  it("Handles basic content elements", () => {
116
153
  const content = new AttributeContent(json);
117
154
  expect(content.label).toBe("Blaastest geslaagd");
118
- expect(content.properties).toHaveLength(1);
155
+ expect(content.description).toBe("Dit is de beschrijving");
156
+ expect(content.properties).toHaveLength(2);
119
157
  expect(content.textfragments).toHaveLength(1);
120
158
  expect(content.sections).toHaveLength(1);
121
159
 
122
160
  const firstProperty = content.properties[0];
123
- expect(firstProperty.key).toBe("Gemiddelde");
161
+ expect(firstProperty.type).toBe("Gemiddelde");
124
162
  expect(firstProperty.label).toBe("Gemiddelde");
125
163
  expect(firstProperty.value).toBe("80%");
126
164
 
@@ -182,4 +220,10 @@ describe("AttributeContent", () => {
182
220
  expect(referredSections[1].id).toBe("PassSubSubSubSection");
183
221
  expect(referredSections[2].id).toBe("PassAlert");
184
222
  });
223
+
224
+ it("can retrieve all content", () => {
225
+ const content = new AttributeContent(json);
226
+
227
+ expect(content.elements).toHaveLength(4);
228
+ });
185
229
  });
@@ -28,12 +28,7 @@ describe("attributeDataHelper", () => {
28
28
  referenceDate: undefined,
29
29
  static: false,
30
30
  value: null,
31
- content: {
32
- label: null,
33
- properties: null,
34
- sections: null,
35
- textfragments: null,
36
- },
31
+ content: null,
37
32
  });
38
33
  });
39
34
 
@@ -116,12 +111,7 @@ describe("attributeDataHelper", () => {
116
111
  referenceDate: undefined,
117
112
  static: false,
118
113
  value: "Matilda",
119
- content: {
120
- label: null,
121
- properties: null,
122
- sections: null,
123
- textfragments: null,
124
- },
114
+ content: null,
125
115
  },
126
116
  {
127
117
  _links: {},
@@ -135,12 +125,7 @@ describe("attributeDataHelper", () => {
135
125
  referenceDate: undefined,
136
126
  static: false,
137
127
  value: "Printers united",
138
- content: {
139
- label: null,
140
- properties: null,
141
- sections: null,
142
- textfragments: null,
143
- },
128
+ content: null,
144
129
  },
145
130
  {
146
131
  _links: {},
@@ -154,12 +139,7 @@ describe("attributeDataHelper", () => {
154
139
  referenceDate: undefined,
155
140
  static: false,
156
141
  value: 5000,
157
- content: {
158
- label: null,
159
- properties: null,
160
- sections: null,
161
- textfragments: null,
162
- },
142
+ content: null,
163
143
  },
164
144
  {
165
145
  _links: {},
@@ -173,12 +153,7 @@ describe("attributeDataHelper", () => {
173
153
  referenceDate: undefined,
174
154
  static: false,
175
155
  value: "2013-01-01",
176
- content: {
177
- label: null,
178
- properties: null,
179
- sections: null,
180
- textfragments: null,
181
- },
156
+ content: null,
182
157
  },
183
158
  ],
184
159
  dynamicschema: undefined,
@@ -196,12 +171,7 @@ describe("attributeDataHelper", () => {
196
171
  Title: "Matilda",
197
172
  _id: "62",
198
173
  },
199
- content: {
200
- label: null,
201
- properties: null,
202
- sections: null,
203
- textfragments: null,
204
- },
174
+ content: null,
205
175
  });
206
176
  });
207
177
 
@@ -285,12 +255,7 @@ describe("attributeDataHelper", () => {
285
255
  referenceDate: undefined,
286
256
  static: false,
287
257
  value: "Matilda",
288
- content: {
289
- label: null,
290
- properties: null,
291
- sections: null,
292
- textfragments: null,
293
- },
258
+ content: null,
294
259
  },
295
260
  {
296
261
  _links: {},
@@ -304,12 +269,7 @@ describe("attributeDataHelper", () => {
304
269
  referenceDate: undefined,
305
270
  static: false,
306
271
  value: "Printers united",
307
- content: {
308
- label: null,
309
- properties: null,
310
- sections: null,
311
- textfragments: null,
312
- },
272
+ content: null,
313
273
  },
314
274
  {
315
275
  _links: {},
@@ -323,12 +283,7 @@ describe("attributeDataHelper", () => {
323
283
  referenceDate: undefined,
324
284
  static: false,
325
285
  value: null,
326
- content: {
327
- label: null,
328
- properties: null,
329
- sections: null,
330
- textfragments: null,
331
- },
286
+ content: null,
332
287
  },
333
288
  {
334
289
  _links: {},
@@ -342,12 +297,7 @@ describe("attributeDataHelper", () => {
342
297
  referenceDate: undefined,
343
298
  static: false,
344
299
  value: "2013-01-01",
345
- content: {
346
- label: null,
347
- properties: null,
348
- sections: null,
349
- textfragments: null,
350
- },
300
+ content: null,
351
301
  },
352
302
  ],
353
303
  [
@@ -363,12 +313,7 @@ describe("attributeDataHelper", () => {
363
313
  referenceDate: undefined,
364
314
  static: false,
365
315
  value: "The safety of objects",
366
- content: {
367
- label: null,
368
- properties: null,
369
- sections: null,
370
- textfragments: null,
371
- },
316
+ content: null,
372
317
  },
373
318
  {
374
319
  _links: {},
@@ -382,12 +327,7 @@ describe("attributeDataHelper", () => {
382
327
  referenceDate: undefined,
383
328
  static: false,
384
329
  value: "Printers united",
385
- content: {
386
- label: null,
387
- properties: null,
388
- sections: null,
389
- textfragments: null,
390
- },
330
+ content: null,
391
331
  },
392
332
  {
393
333
  _links: {},
@@ -401,12 +341,7 @@ describe("attributeDataHelper", () => {
401
341
  referenceDate: undefined,
402
342
  static: false,
403
343
  value: null,
404
- content: {
405
- label: null,
406
- properties: null,
407
- sections: null,
408
- textfragments: null,
409
- },
344
+ content: null,
410
345
  },
411
346
  {
412
347
  _links: {},
@@ -420,12 +355,7 @@ describe("attributeDataHelper", () => {
420
355
  referenceDate: undefined,
421
356
  static: false,
422
357
  value: "2014-01-01",
423
- content: {
424
- label: null,
425
- properties: null,
426
- sections: null,
427
- textfragments: null,
428
- },
358
+ content: null,
429
359
  },
430
360
  ],
431
361
  ],
@@ -451,12 +381,171 @@ describe("attributeDataHelper", () => {
451
381
  _id: "44",
452
382
  },
453
383
  ],
384
+ content: null,
385
+ });
386
+ });
387
+
388
+ it("can handle classification result list detail", () => {
389
+ const data = {
390
+ key: "results",
391
+ dynamicschema: {
392
+ "results.Sanctions": [
393
+ {
394
+ code: "DrivingBan",
395
+ label: "Driving ban",
396
+ _links: {
397
+ concept: {
398
+ href: "/concepts/_Context/Police incident decisions/Models/Sanctions/Sanctions.bixml/DrivingBan",
399
+ },
400
+ },
401
+ content: {
402
+ elements: [
403
+ {
404
+ propertyElement: {
405
+ id: "3d38501d",
406
+ label: "Property: Abbreviation",
407
+ properties: {
408
+ type: "Abbreviation",
409
+ label: "Abbreviation",
410
+ value: "DB",
411
+ },
412
+ },
413
+ },
414
+ ],
415
+ },
416
+ },
417
+ {
418
+ code: "PoliceReport",
419
+ label: "Police report",
420
+ _links: {
421
+ concept: {
422
+ href: "/concepts/_Context/Police incident decisions/Models/Sanctions/Sanctions.bixml/PoliceReport",
423
+ },
424
+ },
425
+ content: {
426
+ elements: [
427
+ {
428
+ propertyElement: {
429
+ id: "3d38501d",
430
+ label: "Property: Abbreviation",
431
+ properties: {
432
+ type: "Abbreviation",
433
+ label: "Abbreviation",
434
+ value: "PR",
435
+ },
436
+ },
437
+ },
438
+ ],
439
+ },
440
+ },
441
+ {
442
+ code: "RevocateLicense",
443
+ label: "Revocate license",
444
+ _links: {
445
+ concept: {
446
+ href: "/concepts/_Context/Police incident decisions/Models/Sanctions/Sanctions.bixml/RevocateLicense",
447
+ },
448
+ },
449
+ content: {
450
+ elements: [
451
+ {
452
+ propertyElement: {
453
+ id: "6c4e8b69",
454
+ label: "Property: Abbreviation",
455
+ properties: {
456
+ type: "Abbreviation",
457
+ label: "Abbreviation",
458
+ value: "RL",
459
+ },
460
+ },
461
+ },
462
+ ],
463
+ },
464
+ },
465
+ ],
466
+ },
467
+ results: { Sanctions: ["DrivingBan", "PoliceReport"] },
468
+ };
469
+ const key = "results";
470
+ const childrenKeys = [{ key: "Sanctions", children: [] }];
471
+
472
+ const dataHelper = new AttributeDataHelper(data, key, childrenKeys);
473
+ const dataHelperData = dataHelper.getData();
474
+
475
+ expect(dataHelperData.content).toBeNull();
476
+ expect(dataHelperData.dynamicschemaId).toBe("results");
477
+ expect(dataHelperData.key).toBe("results");
478
+ expect(dataHelperData.value).toStrictEqual({
479
+ Sanctions: ["DrivingBan", "PoliceReport"],
480
+ });
481
+ expect(dataHelperData.children).toHaveLength(1);
482
+
483
+ const firstChild = dataHelperData.children[0];
484
+ expect(firstChild.dynamicschemaId).toBe("results.Sanctions");
485
+ expect(firstChild.key).toBe("Sanctions");
486
+ expect(firstChild.value).toStrictEqual(["DrivingBan", "PoliceReport"]);
487
+ expect(firstChild.content).toBeNull();
488
+
489
+ expect(firstChild.dynamicschema).toHaveLength(3);
490
+ const firstDynamicSchema = firstChild.dynamicschema[0];
491
+
492
+ expect(firstDynamicSchema.code).toBe("DrivingBan");
493
+ expect(firstDynamicSchema.label).toBe("Driving ban");
494
+ expect(firstDynamicSchema.content.elements).toHaveLength(1);
495
+ });
496
+
497
+ it("can handle decision result list detail", () => {
498
+ const data = {
499
+ key: "results",
454
500
  content: {
455
- label: null,
456
- properties: null,
457
- sections: null,
458
- textfragments: null,
501
+ InvestigationNecessary: {
502
+ content: {
503
+ header: {
504
+ label: "label",
505
+ description: "description",
506
+ },
507
+ elements: [
508
+ {
509
+ textFragmentElement: {
510
+ label: "Text fragment: Description",
511
+ textfragments: [
512
+ {
513
+ text: "Text fragment for investigation necessary",
514
+ },
515
+ ],
516
+ layouthint: ["full"],
517
+ },
518
+ },
519
+ ],
520
+ },
521
+ },
459
522
  },
523
+ results: { InvestigationNecessary: true },
524
+ };
525
+ const key = "results";
526
+ const childrenKeys = [{ key: "InvestigationNecessary", children: [] }];
527
+
528
+ const dataHelper = new AttributeDataHelper(data, key, childrenKeys);
529
+ const dataHelperData = dataHelper.getData();
530
+
531
+ expect(dataHelperData.content).toBeNull();
532
+ expect(dataHelperData.dynamicschemaId).toBe("results");
533
+ expect(dataHelperData.key).toBe("results");
534
+ expect(dataHelperData.value).toStrictEqual({
535
+ InvestigationNecessary: true,
536
+ });
537
+ expect(dataHelperData.children).toHaveLength(1);
538
+
539
+ const firstChild = dataHelperData.children[0];
540
+ expect(firstChild.dynamicschemaId).toBe("results.InvestigationNecessary");
541
+ expect(firstChild.key).toBe("InvestigationNecessary");
542
+ expect(firstChild.value).toBe(true);
543
+ expect(firstChild.content.header).toStrictEqual({
544
+ label: "label",
545
+ description: "description",
460
546
  });
547
+ expect(firstChild.content.elements).toHaveLength(1);
548
+
549
+ expect(firstChild.dynamicschema).toBeUndefined();
461
550
  });
462
551
  });
@@ -1,7 +1,7 @@
1
1
  import HelptextAttributeModel from "../HelptextAttributeModel";
2
2
 
3
3
  describe("helptextAttributeModel", () => {
4
- it("should be able to create an empty HelptextAttribute object", () => {
4
+ it("should be able to create a HelptextAttribute object", () => {
5
5
  const attribute = new HelptextAttributeModel();
6
6
 
7
7
  expect(attribute).toBeInstanceOf(HelptextAttributeModel);
@@ -15,4 +15,42 @@ describe("helptextAttributeModel", () => {
15
15
 
16
16
  expect(attributeWithText.text).toBe("Example helptext text");
17
17
  });
18
+
19
+ it("should be able to handle content in data", () => {
20
+ const attributeWithText = new HelptextAttributeModel(
21
+ {
22
+ key: "CarDetails",
23
+ value: {
24
+ id: "CarDetails.text",
25
+ properties: {
26
+ PersonPrivateCar: "Ferrari GTO",
27
+ PersonLessFavoriteCars: "Mercedes",
28
+ PersonFavoriteCars: "BMW 5 Series, Fiat Panda",
29
+ },
30
+ message:
31
+ "<p>Currently the person drives in a Ferrari GTO, although his favorite cars are BMW 5 Series, Fiat Panda. Less favorite cars of the person are Mercedes.</p>",
32
+ },
33
+ static: true,
34
+ dynamicschemaId: "CarDetails",
35
+ isResult: false,
36
+ children: [],
37
+ content: null,
38
+ },
39
+ {
40
+ type: "string",
41
+ label: "Car details",
42
+ mandatory: false,
43
+ readonly: true,
44
+ text: {
45
+ id: "CarDetails.text",
46
+ rawText:
47
+ "<p>Currently the person drives in a ${PersonPrivateCar}, although his favorite cars are ${PersonFavoriteCars}. Less favorite cars of the person are ${PersonLessFavoriteCars}.</p>",
48
+ },
49
+ }
50
+ );
51
+
52
+ expect(attributeWithText.text).toBe(
53
+ "<p>Currently the person drives in a Ferrari GTO, although his favorite cars are BMW 5 Series, Fiat Panda. Less favorite cars of the person are Mercedes.</p>"
54
+ );
55
+ });
18
56
  });