@beinformed/ui 1.9.0-beta.8 → 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.
- package/CHANGELOG.md +6 -0
- package/esm/constants/Settings.js +10 -8
- package/esm/constants/Settings.js.map +1 -1
- package/esm/models/attributes/AttributeContent.js +92 -68
- package/esm/models/attributes/AttributeContent.js.map +1 -1
- package/esm/models/attributes/AttributeModel.js +3 -3
- package/esm/models/attributes/AttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionModel.js +4 -4
- package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/esm/models/attributes/HelptextAttributeModel.js +15 -1
- package/esm/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/lib/constants/Settings.js +12 -1
- package/lib/constants/Settings.js.flow +9 -5
- package/lib/constants/Settings.js.map +1 -1
- package/lib/models/attributes/AttributeContent.js +93 -69
- package/lib/models/attributes/AttributeContent.js.flow +66 -43
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/attributes/AttributeModel.js +1 -1
- package/lib/models/attributes/AttributeModel.js.flow +2 -3
- package/lib/models/attributes/AttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js +3 -3
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +4 -7
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/HelptextAttributeModel.js +15 -1
- package/lib/models/attributes/HelptextAttributeModel.js.flow +11 -1
- package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +9 -3
- package/lib/models/attributes/__tests__/HelptextAttributeModel.spec.js.flow +39 -1
- package/lib/models/types.js.flow +9 -4
- package/package.json +1 -1
- package/src/constants/Settings.js +9 -5
- package/src/models/attributes/AttributeContent.js +66 -43
- package/src/models/attributes/AttributeModel.js +2 -3
- package/src/models/attributes/ChoiceAttributeOptionModel.js +4 -7
- package/src/models/attributes/HelptextAttributeModel.js +11 -1
- package/src/models/attributes/__tests__/AttributeContent.spec.js +9 -3
- package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +39 -1
- package/src/models/form/__tests__/FormWithContentData.json +1 -1
- package/src/models/types.js +9 -4
|
@@ -26,6 +26,16 @@ export default class HelptextAttributeModel extends LabelAttributeModel {
|
|
|
26
26
|
* Get helptext text
|
|
27
27
|
*/
|
|
28
28
|
get text(): string | null {
|
|
29
|
-
|
|
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,7 +2,12 @@ import AttributeContent from "../AttributeContent";
|
|
|
2
2
|
import SectionModel from "../../content/SectionModel";
|
|
3
3
|
|
|
4
4
|
const json = {
|
|
5
|
-
|
|
5
|
+
header: {
|
|
6
|
+
label: "Blaastest geslaagd",
|
|
7
|
+
description: {
|
|
8
|
+
message: "Dit is de beschrijving",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
6
11
|
elements: [
|
|
7
12
|
{
|
|
8
13
|
propertyElement: {
|
|
@@ -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.
|
|
227
|
+
expect(content.elements).toHaveLength(4);
|
|
222
228
|
});
|
|
223
229
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import HelptextAttributeModel from "../HelptextAttributeModel";
|
|
2
2
|
|
|
3
3
|
describe("helptextAttributeModel", () => {
|
|
4
|
-
it("should be able to create
|
|
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
|
});
|
package/src/models/types.js
CHANGED
|
@@ -212,10 +212,6 @@ export type ContentElement = {
|
|
|
212
212
|
sections: Array<SectionData>,
|
|
213
213
|
},
|
|
214
214
|
};
|
|
215
|
-
export type ContentData = {
|
|
216
|
-
label: string | null,
|
|
217
|
-
elements: Array<PropertiesElement | TextFragmentElement | ContentElement>,
|
|
218
|
-
};
|
|
219
215
|
|
|
220
216
|
type ContentElementMapped = {
|
|
221
217
|
contentElement: {
|
|
@@ -223,6 +219,15 @@ type ContentElementMapped = {
|
|
|
223
219
|
sections: Array<SectionModel>,
|
|
224
220
|
},
|
|
225
221
|
};
|
|
222
|
+
|
|
226
223
|
export type ContentAll = Array<
|
|
227
224
|
PropertiesElement | TextFragmentElement | ContentElementMapped
|
|
228
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
|
+
};
|