@beinformed/ui 1.9.0-beta.4 → 1.9.0-beta.9

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 (77) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/esm/constants/Settings.js +10 -8
  3. package/esm/constants/Settings.js.map +1 -1
  4. package/esm/models/attributes/AttributeContent.js +99 -60
  5. package/esm/models/attributes/AttributeContent.js.map +1 -1
  6. package/esm/models/attributes/AttributeDataHelper.js +41 -14
  7. package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
  8. package/esm/models/attributes/AttributeModel.js +3 -3
  9. package/esm/models/attributes/AttributeModel.js.map +1 -1
  10. package/esm/models/attributes/ChoiceAttributeOptionModel.js +4 -4
  11. package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  12. package/esm/models/attributes/HelptextAttributeModel.js +15 -1
  13. package/esm/models/attributes/HelptextAttributeModel.js.map +1 -1
  14. package/esm/models/content/SectionModel.js +2 -1
  15. package/esm/models/content/SectionModel.js.map +1 -1
  16. package/esm/models/content/SubSectionModel.js +3 -1
  17. package/esm/models/content/SubSectionModel.js.map +1 -1
  18. package/esm/models/list/ListDetailModel.js +7 -3
  19. package/esm/models/list/ListDetailModel.js.map +1 -1
  20. package/esm/utils/helpers/text.js +19 -0
  21. package/esm/utils/helpers/text.js.map +1 -0
  22. package/esm/utils/index.js +2 -1
  23. package/esm/utils/index.js.map +1 -1
  24. package/lib/constants/Settings.js +12 -1
  25. package/lib/constants/Settings.js.flow +9 -5
  26. package/lib/constants/Settings.js.map +1 -1
  27. package/lib/models/attributes/AttributeContent.js +107 -61
  28. package/lib/models/attributes/AttributeContent.js.flow +67 -42
  29. package/lib/models/attributes/AttributeContent.js.map +1 -1
  30. package/lib/models/attributes/AttributeDataHelper.js +43 -13
  31. package/lib/models/attributes/AttributeDataHelper.js.flow +30 -5
  32. package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
  33. package/lib/models/attributes/AttributeModel.js +1 -1
  34. package/lib/models/attributes/AttributeModel.js.flow +2 -3
  35. package/lib/models/attributes/AttributeModel.js.map +1 -1
  36. package/lib/models/attributes/ChoiceAttributeOptionModel.js +3 -3
  37. package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +4 -7
  38. package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  39. package/lib/models/attributes/HelptextAttributeModel.js +15 -1
  40. package/lib/models/attributes/HelptextAttributeModel.js.flow +11 -1
  41. package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
  42. package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +11 -5
  43. package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +156 -0
  44. package/lib/models/attributes/__tests__/HelptextAttributeModel.spec.js.flow +39 -1
  45. package/lib/models/content/SectionModel.js +3 -1
  46. package/lib/models/content/SectionModel.js.flow +2 -1
  47. package/lib/models/content/SectionModel.js.map +1 -1
  48. package/lib/models/content/SubSectionModel.js +4 -1
  49. package/lib/models/content/SubSectionModel.js.flow +3 -1
  50. package/lib/models/content/SubSectionModel.js.map +1 -1
  51. package/lib/models/list/ListDetailModel.js +7 -3
  52. package/lib/models/list/ListDetailModel.js.flow +2 -0
  53. package/lib/models/list/ListDetailModel.js.map +1 -1
  54. package/lib/models/types.js.flow +15 -6
  55. package/lib/utils/helpers/text.js +28 -0
  56. package/lib/utils/helpers/text.js.flow +23 -0
  57. package/lib/utils/helpers/text.js.map +1 -0
  58. package/lib/utils/index.js +14 -0
  59. package/lib/utils/index.js.flow +1 -0
  60. package/lib/utils/index.js.map +1 -1
  61. package/package.json +11 -11
  62. package/src/constants/Settings.js +9 -5
  63. package/src/models/attributes/AttributeContent.js +67 -42
  64. package/src/models/attributes/AttributeDataHelper.js +30 -5
  65. package/src/models/attributes/AttributeModel.js +2 -3
  66. package/src/models/attributes/ChoiceAttributeOptionModel.js +4 -7
  67. package/src/models/attributes/HelptextAttributeModel.js +11 -1
  68. package/src/models/attributes/__tests__/AttributeContent.spec.js +11 -5
  69. package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +156 -0
  70. package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +39 -1
  71. package/src/models/content/SectionModel.js +2 -1
  72. package/src/models/content/SubSectionModel.js +3 -1
  73. package/src/models/form/__tests__/FormWithContentData.json +6 -6
  74. package/src/models/list/ListDetailModel.js +2 -0
  75. package/src/models/types.js +15 -6
  76. package/src/utils/helpers/text.js +23 -0
  77. package/src/utils/index.js +1 -0
@@ -14,12 +14,11 @@ import ConceptDetailModel from "../concepts/ConceptDetailModel";
14
14
 
15
15
  import { MANDATORY, DISABLED } from "../../constants/LayoutHints";
16
16
  import {
17
- ALL_CONTENT_IN_DATA_SETTING,
18
17
  ATTRIBUTE_WIDTH,
19
18
  TIMEVERSION_FILTER_NAME,
20
19
  } from "../../constants/Constants";
21
20
 
22
- import { getSetting } from "../../constants/Settings";
21
+ import { getSetting, hasAllContentInData } from "../../constants/Settings";
23
22
 
24
23
  import {
25
24
  IllegalArgumentException,
@@ -952,7 +951,7 @@ export default class AttributeModel extends BaseModel {
952
951
  * Indicates if content comes from the data service
953
952
  */
954
953
  get hasContentFromData(): boolean {
955
- return getSetting(ALL_CONTENT_IN_DATA_SETTING, true);
954
+ return hasAllContentInData();
956
955
  }
957
956
 
958
957
  /**
@@ -4,21 +4,18 @@ import ChoiceAttributeOptionCollection from "./ChoiceAttributeOptionCollection";
4
4
 
5
5
  import { DateUtil } from "../../utils/datetime/DateTimeUtil";
6
6
  import { has } from "../../utils/helpers/objects";
7
- import {
8
- ALL_CONTENT_IN_DATA_SETTING,
9
- TIMEVERSION_FILTER_NAME,
10
- } from "../../constants/Constants";
7
+ import { TIMEVERSION_FILTER_NAME } from "../../constants/Constants";
11
8
  import { TITLE } from "../../constants/LayoutHints";
9
+ import { hasAllContentInData } from "../../constants/Settings";
12
10
 
13
11
  import LinkCollection from "../links/LinkCollection";
14
12
  import AttributeCollection from "./AttributeCollection";
15
13
  import ConceptDetailModel from "../concepts/ConceptDetailModel";
14
+ import AttributeContent from "./AttributeContent";
16
15
 
17
16
  import type { ModularUIModel } from "../types";
18
17
  import type ListItemModel from "../list/ListItemModel";
19
18
  import type LinkModel from "../links/LinkModel";
20
- import { getSetting } from "../../constants";
21
- import AttributeContent from "./AttributeContent";
22
19
 
23
20
  /**
24
21
  */
@@ -358,7 +355,7 @@ class ChoiceAttributeOptionModel extends BaseModel {
358
355
  * Indicates if content comes from the data service
359
356
  */
360
357
  get hasContentFromData(): boolean {
361
- return getSetting(ALL_CONTENT_IN_DATA_SETTING, true);
358
+ return hasAllContentInData();
362
359
  }
363
360
 
364
361
  /**
@@ -26,6 +26,16 @@ export default class HelptextAttributeModel extends LabelAttributeModel {
26
26
  * Get helptext text
27
27
  */
28
28
  get text(): string | null {
29
- return this.getContribution("text");
29
+ const dataText = this.getData("value");
30
+ if (dataText) {
31
+ return dataText.message;
32
+ }
33
+
34
+ const contributionText = this.getContribution("text");
35
+ if (contributionText) {
36
+ return contributionText.message ?? contributionText;
37
+ }
38
+
39
+ return null;
30
40
  }
31
41
  }
@@ -2,10 +2,15 @@ import AttributeContent from "../AttributeContent";
2
2
  import SectionModel from "../../content/SectionModel";
3
3
 
4
4
  const json = {
5
- label: "Blaastest geslaagd",
5
+ header: {
6
+ label: "Blaastest geslaagd",
7
+ description: {
8
+ message: "Dit is de beschrijving",
9
+ },
10
+ },
6
11
  elements: [
7
12
  {
8
- propertiesElement: {
13
+ propertyElement: {
9
14
  label: "Properties",
10
15
  id: "properties",
11
16
  properties: [
@@ -18,7 +23,7 @@ const json = {
18
23
  },
19
24
  },
20
25
  {
21
- propertiesElement: {
26
+ propertyElement: {
22
27
  label: "Second Properties",
23
28
  id: "secondProperties",
24
29
  properties: [
@@ -38,7 +43,7 @@ const json = {
38
43
  {
39
44
  type: "Description",
40
45
  label: "Description",
41
- text: "Dit is een text fragment",
46
+ text: { message: "Dit is een text fragment" },
42
47
  },
43
48
  ],
44
49
  },
@@ -147,6 +152,7 @@ describe("AttributeContent", () => {
147
152
  it("Handles basic content elements", () => {
148
153
  const content = new AttributeContent(json);
149
154
  expect(content.label).toBe("Blaastest geslaagd");
155
+ expect(content.description).toBe("Dit is de beschrijving");
150
156
  expect(content.properties).toHaveLength(2);
151
157
  expect(content.textfragments).toHaveLength(1);
152
158
  expect(content.sections).toHaveLength(1);
@@ -218,6 +224,6 @@ describe("AttributeContent", () => {
218
224
  it("can retrieve all content", () => {
219
225
  const content = new AttributeContent(json);
220
226
 
221
- expect(content.all).toHaveLength(4);
227
+ expect(content.elements).toHaveLength(4);
222
228
  });
223
229
  });
@@ -384,4 +384,160 @@ describe("attributeDataHelper", () => {
384
384
  content: null,
385
385
  });
386
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",
500
+ content: {
501
+ InvestigationNecessary: {
502
+ elements: [
503
+ {
504
+ textFragmentElement: {
505
+ label: "Text fragment: Description",
506
+ textfragments: [
507
+ {
508
+ type: "Description",
509
+ label: "Description",
510
+ text: "Text fragment for investigation necessary",
511
+ },
512
+ ],
513
+ "layout-hint": ["full"],
514
+ },
515
+ },
516
+ ],
517
+ },
518
+ },
519
+ results: { InvestigationNecessary: true },
520
+ };
521
+ const key = "results";
522
+ const childrenKeys = [{ key: "InvestigationNecessary", children: [] }];
523
+
524
+ const dataHelper = new AttributeDataHelper(data, key, childrenKeys);
525
+ const dataHelperData = dataHelper.getData();
526
+
527
+ expect(dataHelperData.content).toBeNull();
528
+ expect(dataHelperData.dynamicschemaId).toBe("results");
529
+ expect(dataHelperData.key).toBe("results");
530
+ expect(dataHelperData.value).toStrictEqual({
531
+ InvestigationNecessary: true,
532
+ });
533
+ expect(dataHelperData.children).toHaveLength(1);
534
+
535
+ const firstChild = dataHelperData.children[0];
536
+ expect(firstChild.dynamicschemaId).toBe("results.InvestigationNecessary");
537
+ expect(firstChild.key).toBe("InvestigationNecessary");
538
+ expect(firstChild.value).toBe(true);
539
+ expect(firstChild.content.elements).toHaveLength(1);
540
+
541
+ expect(firstChild.dynamicschema).toBeUndefined();
542
+ });
387
543
  });
@@ -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
  });
@@ -7,6 +7,7 @@ import { createHashFromHref } from "../../utils/helpers/createHash";
7
7
  import LinkModel from "../links/LinkModel";
8
8
 
9
9
  import type Href from "../href/Href";
10
+ import { retrieveText } from "../../utils";
10
11
 
11
12
  class SectionModel extends BaseModel {
12
13
  _entryDate: ISO_DATE | null;
@@ -88,7 +89,7 @@ class SectionModel extends BaseModel {
88
89
  * Get content body
89
90
  */
90
91
  get body(): ?string {
91
- return this.data.body;
92
+ return retrieveText(this.data.body);
92
93
  }
93
94
 
94
95
  /**
@@ -5,6 +5,7 @@ import BaseModel from "../base/BaseModel";
5
5
  import LinkCollection from "../links/LinkCollection";
6
6
  import Href from "../href/Href";
7
7
  import LinkModel from "../links/LinkModel";
8
+ import { retrieveText } from "../../utils";
8
9
 
9
10
  /**
10
11
  * Link to a concept
@@ -41,7 +42,8 @@ export default class SubSectionModel extends BaseModel {
41
42
  * Retrieve html body
42
43
  */
43
44
  get body(): string {
44
- return this.getData("body", "");
45
+ const body = this.getData("body", "");
46
+ return retrieveText(body);
45
47
  }
46
48
 
47
49
  /**
@@ -19,7 +19,7 @@
19
19
  {
20
20
  "elementid": "UitslagBlaastestType",
21
21
  "content": {
22
- "label": "Uitslag blaastest label",
22
+ "header": { "label": "Uitslag blaastest label" },
23
23
  "elements": [
24
24
  {
25
25
  "contentElement": {
@@ -56,7 +56,7 @@
56
56
  }
57
57
  },
58
58
  {
59
- "propertiesElement": {
59
+ "propertyElement": {
60
60
  "label": "Properties",
61
61
  "id": "properties",
62
62
  "properties": [
@@ -93,7 +93,7 @@
93
93
  }
94
94
  },
95
95
  {
96
- "propertiesElement": {
96
+ "propertyElement": {
97
97
  "label": "Properties",
98
98
  "id": "properties",
99
99
  "properties": [
@@ -143,7 +143,7 @@
143
143
  }
144
144
  },
145
145
  {
146
- "propertiesElement": {
146
+ "propertyElement": {
147
147
  "label": "Properties",
148
148
  "id": "properties",
149
149
  "properties": [
@@ -180,7 +180,7 @@
180
180
  }
181
181
  },
182
182
  {
183
- "propertiesElement": {
183
+ "propertyElement": {
184
184
  "label": "Properties",
185
185
  "id": "properties",
186
186
  "properties": [
@@ -217,7 +217,7 @@
217
217
  }
218
218
  },
219
219
  {
220
- "propertiesElement": {
220
+ "propertyElement": {
221
221
  "label": "Properties",
222
222
  "id": "properties",
223
223
  "properties": [
@@ -157,6 +157,7 @@ export default class ListDetailModel extends DetailModel {
157
157
  {
158
158
  key: "results",
159
159
  dynamicschema: this.data.dynamicschema,
160
+ content: this.data.content?.results,
160
161
  ...this.data.resultSection,
161
162
  },
162
163
  this.contributions.resultSection.results
@@ -194,6 +195,7 @@ export default class ListDetailModel extends DetailModel {
194
195
  {
195
196
  key: "givenAnswers",
196
197
  dynamicschema: this.data.dynamicschema,
198
+ content: this.data.content?.givenAnswers,
197
199
  ...this.data.resultSection,
198
200
  },
199
201
  filteredContributions
@@ -176,13 +176,17 @@ export type FilesizeConstraintsType = {
176
176
  };
177
177
 
178
178
  export type PropertyData = { type: string, label: string, value: string };
179
- export type TextFragmentData = { type: string, label: string, text: string };
179
+ export type TextFragmentData = {
180
+ type: string,
181
+ label: string,
182
+ text: string | { id?: string, message: string, properties?: Object },
183
+ };
180
184
  export type SectionData = {
181
185
  id: string,
182
186
  type: string,
183
187
  label?: string,
184
188
  number?: string,
185
- body: string,
189
+ body: string | { id?: string, message: string, properties?: Object },
186
190
  _links: { self: { href: string } },
187
191
  childSections: Array<SectionData>,
188
192
  subSections: Array<SectionData>,
@@ -208,10 +212,6 @@ export type ContentElement = {
208
212
  sections: Array<SectionData>,
209
213
  },
210
214
  };
211
- export type ContentData = {
212
- label: string | null,
213
- elements: Array<PropertiesElement | TextFragmentElement | ContentElement>,
214
- };
215
215
 
216
216
  type ContentElementMapped = {
217
217
  contentElement: {
@@ -219,6 +219,15 @@ type ContentElementMapped = {
219
219
  sections: Array<SectionModel>,
220
220
  },
221
221
  };
222
+
222
223
  export type ContentAll = Array<
223
224
  PropertiesElement | TextFragmentElement | ContentElementMapped
224
225
  >;
226
+
227
+ export type ContentData = {
228
+ header: {
229
+ label?: string,
230
+ description?: { id?: string, message: string, properties?: Object },
231
+ },
232
+ elements: Array<PropertiesElement | TextFragmentElement | ContentElement>,
233
+ };