@beinformed/ui 1.9.0-beta.6 → 1.9.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.
- package/CHANGELOG.md +50 -0
- package/esm/constants/Settings.js +10 -8
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useNotification.js.map +1 -1
- package/esm/hooks/useRouter.js.map +1 -1
- package/esm/models/attributes/AttributeContent.js +126 -58
- package/esm/models/attributes/AttributeContent.js.map +1 -1
- package/esm/models/attributes/AttributeDataHelper.js +1 -1
- package/esm/models/attributes/AttributeDataHelper.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 +17 -1
- package/esm/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/esm/models/caseview/CaseViewModel.js +26 -12
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/content/SectionModel.js +2 -1
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/content/SubSectionModel.js +3 -1
- package/esm/models/content/SubSectionModel.js.map +1 -1
- package/esm/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/esm/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
- package/esm/models/form/FormObjectModel.js +8 -2
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/esm/models/layouthint/LayoutHintCollection.js +3 -2
- package/esm/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/esm/models/list/ListDetailModel.js +25 -0
- package/esm/models/list/ListDetailModel.js.map +1 -1
- package/esm/models/list/ListModel.js +22 -16
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/panels/GroupingPanelModel.js +19 -17
- package/esm/models/panels/GroupingPanelModel.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +2 -1
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/utils/helpers/text.js +19 -0
- package/esm/utils/helpers/text.js.map +1 -0
- package/esm/utils/index.js +2 -1
- package/esm/utils/index.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/hooks/useForm.js.flow +10 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useNotification.js.flow +5 -2
- package/lib/hooks/useNotification.js.map +1 -1
- package/lib/hooks/useRouter.js.flow +12 -5
- package/lib/hooks/useRouter.js.map +1 -1
- package/lib/models/attributes/AttributeContent.js +136 -59
- package/lib/models/attributes/AttributeContent.js.flow +91 -39
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/attributes/AttributeDataHelper.js +1 -1
- package/lib/models/attributes/AttributeDataHelper.js.flow +2 -1
- package/lib/models/attributes/AttributeDataHelper.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 +17 -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 +10 -2
- package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +9 -3
- package/lib/models/attributes/__tests__/HelptextAttributeModel.spec.js.flow +39 -1
- package/lib/models/caseview/CaseViewModel.js +27 -13
- package/lib/models/caseview/CaseViewModel.js.flow +17 -7
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/caseview/__tests__/CaseViewModel.spec.js.flow +68 -184
- package/lib/models/concepts/__mock__/business_scenario.js.flow +14 -1
- package/lib/models/concepts/__mock__/conceptdetail.js.flow +15 -6
- package/lib/models/concepts/__tests__/BusinessScenarioModel.spec.js.flow +5 -6
- package/lib/models/concepts/__tests__/ConceptDetailModel.spec.js.flow +58 -3
- package/lib/models/content/SectionModel.js +3 -1
- package/lib/models/content/SectionModel.js.flow +2 -1
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/content/SubSectionModel.js +4 -1
- package/lib/models/content/SubSectionModel.js.flow +3 -1
- package/lib/models/content/SubSectionModel.js.map +1 -1
- package/lib/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/lib/models/contentconfiguration/ContentConfigurationResults.js.flow +2 -2
- package/lib/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
- package/lib/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js.flow +6 -6
- package/lib/models/form/FormObjectModel.js +8 -2
- package/lib/models/form/FormObjectModel.js.flow +5 -1
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/form/__tests__/FormObjectModel.spec.js.flow +2 -2
- package/lib/models/layouthint/LayoutHintCollection.js +4 -2
- package/lib/models/layouthint/LayoutHintCollection.js.flow +8 -7
- package/lib/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/lib/models/list/ListDetailModel.js +25 -0
- package/lib/models/list/ListDetailModel.js.flow +19 -0
- package/lib/models/list/ListDetailModel.js.map +1 -1
- package/lib/models/list/ListModel.js +23 -16
- package/lib/models/list/ListModel.js.flow +9 -5
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/list/__tests__/ListDetailModel.spec.js.flow +64 -0
- package/lib/models/list/__tests__/ListModel.spec.js.flow +64 -2
- package/lib/models/panels/GroupingPanelModel.js +21 -18
- package/lib/models/panels/GroupingPanelModel.js.flow +10 -9
- package/lib/models/panels/GroupingPanelModel.js.map +1 -1
- package/lib/models/panels/__tests__/GroupingPanelModel.spec.js.flow +90 -0
- package/lib/models/types.js.flow +38 -11
- package/lib/modularui/ModularUIRequest.js +2 -1
- package/lib/modularui/ModularUIRequest.js.flow +1 -0
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/utils/helpers/text.js +28 -0
- package/lib/utils/helpers/text.js.flow +23 -0
- package/lib/utils/helpers/text.js.map +1 -0
- package/lib/utils/index.js +14 -0
- package/lib/utils/index.js.flow +1 -0
- package/lib/utils/index.js.map +1 -1
- package/package.json +13 -13
- package/src/constants/Settings.js +9 -5
- package/src/hooks/useForm.js +10 -5
- package/src/hooks/useNotification.js +5 -2
- package/src/hooks/useRouter.js +12 -5
- package/src/models/attributes/AttributeContent.js +91 -39
- package/src/models/attributes/AttributeDataHelper.js +2 -1
- 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 +10 -2
- package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +9 -3
- package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +39 -1
- package/src/models/caseview/CaseViewModel.js +17 -7
- package/src/models/caseview/__tests__/CaseViewModel.spec.js +68 -184
- package/src/models/caseview/__tests__/caseview.json +38 -0
- package/src/models/caseview/__tests__/caseviewContributions.json +147 -0
- package/src/models/concepts/__mock__/business_scenario.js +14 -1
- package/src/models/concepts/__mock__/business_scenario_step.json +64 -0
- package/src/models/concepts/__mock__/conceptdetail.js +15 -6
- package/src/models/concepts/__mock__/conceptdetail_data.json +117 -17
- package/src/models/concepts/__mock__/concepttype_Calculation.json +75 -0
- package/src/models/concepts/__tests__/BusinessScenarioModel.spec.js +5 -6
- package/src/models/concepts/__tests__/ConceptDetailModel.spec.js +58 -3
- package/src/models/content/SectionModel.js +2 -1
- package/src/models/content/SubSectionModel.js +3 -1
- package/src/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/src/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js +6 -6
- package/src/models/form/FormObjectModel.js +5 -1
- package/src/models/form/__tests__/FormObjectModel.spec.js +2 -2
- package/src/models/form/__tests__/FormWithContentData.json +1 -0
- package/src/models/layouthint/LayoutHintCollection.js +8 -7
- package/src/models/list/ListDetailModel.js +19 -0
- package/src/models/list/ListModel.js +9 -5
- package/src/models/list/__tests__/ListDetailModel.spec.js +64 -0
- package/src/models/list/__tests__/ListModel.spec.js +64 -2
- package/src/models/list/__tests__/caselist-34.contributions.json +1 -1
- package/src/models/list/__tests__/listContributions.json +1 -1
- package/src/models/panels/GroupingPanelModel.js +10 -9
- package/src/models/panels/__tests__/GroupingPanelModel.spec.js +90 -0
- package/src/models/panels/__tests__/groupingPanel.json +30 -0
- package/src/models/panels/__tests__/groupingPanelContributions.json +46 -0
- package/src/models/types.js +38 -11
- package/src/modularui/ModularUIRequest.js +1 -0
- package/src/utils/helpers/text.js +23 -0
- package/src/utils/index.js +1 -0
|
@@ -267,9 +267,10 @@ class AttributeDataHelper {
|
|
|
267
267
|
const pickedContent = pick(this._attribute.content, [
|
|
268
268
|
"header",
|
|
269
269
|
"label",
|
|
270
|
-
"description",
|
|
271
270
|
"elements",
|
|
271
|
+
"layouthint",
|
|
272
272
|
]);
|
|
273
|
+
|
|
273
274
|
if (Object.keys(pickedContent).length > 0) {
|
|
274
275
|
return pickedContent;
|
|
275
276
|
}
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
29
|
+
const dataText = this.getData("value");
|
|
30
|
+
if (dataText) {
|
|
31
|
+
return dataText.message ?? dataText;
|
|
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,6 +2,12 @@ import AttributeContent from "../AttributeContent";
|
|
|
2
2
|
import SectionModel from "../../content/SectionModel";
|
|
3
3
|
|
|
4
4
|
const json = {
|
|
5
|
+
header: {
|
|
6
|
+
label: "Header label",
|
|
7
|
+
description: {
|
|
8
|
+
message: "Dit is de beschrijving",
|
|
9
|
+
},
|
|
10
|
+
},
|
|
5
11
|
label: "Blaastest geslaagd",
|
|
6
12
|
elements: [
|
|
7
13
|
{
|
|
@@ -38,7 +44,7 @@ const json = {
|
|
|
38
44
|
{
|
|
39
45
|
type: "Description",
|
|
40
46
|
label: "Description",
|
|
41
|
-
text: "Dit is een text fragment",
|
|
47
|
+
text: { message: "Dit is een text fragment" },
|
|
42
48
|
},
|
|
43
49
|
],
|
|
44
50
|
},
|
|
@@ -147,6 +153,8 @@ describe("AttributeContent", () => {
|
|
|
147
153
|
it("Handles basic content elements", () => {
|
|
148
154
|
const content = new AttributeContent(json);
|
|
149
155
|
expect(content.label).toBe("Blaastest geslaagd");
|
|
156
|
+
expect(content.header.label).toBe("Header label");
|
|
157
|
+
expect(content.header.description).toBe("Dit is de beschrijving");
|
|
150
158
|
expect(content.properties).toHaveLength(2);
|
|
151
159
|
expect(content.textfragments).toHaveLength(1);
|
|
152
160
|
expect(content.sections).toHaveLength(1);
|
|
@@ -218,6 +226,6 @@ describe("AttributeContent", () => {
|
|
|
218
226
|
it("can retrieve all content", () => {
|
|
219
227
|
const content = new AttributeContent(json);
|
|
220
228
|
|
|
221
|
-
expect(content.
|
|
229
|
+
expect(content.elements).toHaveLength(4);
|
|
222
230
|
});
|
|
223
231
|
});
|
|
@@ -499,18 +499,20 @@ describe("attributeDataHelper", () => {
|
|
|
499
499
|
key: "results",
|
|
500
500
|
content: {
|
|
501
501
|
InvestigationNecessary: {
|
|
502
|
+
header: {
|
|
503
|
+
label: "label",
|
|
504
|
+
description: "description",
|
|
505
|
+
},
|
|
502
506
|
elements: [
|
|
503
507
|
{
|
|
504
508
|
textFragmentElement: {
|
|
505
509
|
label: "Text fragment: Description",
|
|
506
510
|
textfragments: [
|
|
507
511
|
{
|
|
508
|
-
type: "Description",
|
|
509
|
-
label: "Description",
|
|
510
512
|
text: "Text fragment for investigation necessary",
|
|
511
513
|
},
|
|
512
514
|
],
|
|
513
|
-
|
|
515
|
+
layouthint: ["full"],
|
|
514
516
|
},
|
|
515
517
|
},
|
|
516
518
|
],
|
|
@@ -536,6 +538,10 @@ describe("attributeDataHelper", () => {
|
|
|
536
538
|
expect(firstChild.dynamicschemaId).toBe("results.InvestigationNecessary");
|
|
537
539
|
expect(firstChild.key).toBe("InvestigationNecessary");
|
|
538
540
|
expect(firstChild.value).toBe(true);
|
|
541
|
+
expect(firstChild.content.header).toStrictEqual({
|
|
542
|
+
label: "label",
|
|
543
|
+
description: "description",
|
|
544
|
+
});
|
|
539
545
|
expect(firstChild.content.elements).toHaveLength(1);
|
|
540
546
|
|
|
541
547
|
expect(firstChild.dynamicschema).toBeUndefined();
|
|
@@ -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
|
+
message:
|
|
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
|
});
|
|
@@ -76,11 +76,19 @@ export default class CaseViewModel extends DetailModel {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
+
* Retrieve the case label, this can be configured with a case property with the layout hint 'title'
|
|
79
80
|
*/
|
|
80
81
|
get label(): string {
|
|
81
82
|
return this.casename ? this.casename.value : "";
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Retrieve the label that was configured on the caseview
|
|
87
|
+
*/
|
|
88
|
+
get viewLabel(): string {
|
|
89
|
+
return this.getContribution("label", "");
|
|
90
|
+
}
|
|
91
|
+
|
|
84
92
|
/**
|
|
85
93
|
* Check if an introtext exists for this caseview
|
|
86
94
|
*/
|
|
@@ -92,14 +100,16 @@ export default class CaseViewModel extends DetailModel {
|
|
|
92
100
|
* Getting the introduction text configured on the case view
|
|
93
101
|
*/
|
|
94
102
|
get introtext(): string {
|
|
95
|
-
if (this.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
);
|
|
103
|
+
if (this.data._text) {
|
|
104
|
+
return this.data._text.message ?? this.data._text;
|
|
105
|
+
}
|
|
99
106
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
if (this.contributions.text) {
|
|
108
|
+
return this.contributions.text.message ?? this.contributions.text;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
112
|
+
return this.contributions.texts[0].text;
|
|
103
113
|
}
|
|
104
114
|
|
|
105
115
|
return "";
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import CaseViewModel from "../CaseViewModel";
|
|
2
2
|
import DetailModel from "../../detail/DetailModel";
|
|
3
3
|
|
|
4
|
+
import caseviewJson from "./caseview.json";
|
|
5
|
+
import caseviewContributionsJson from "./caseviewContributions.json";
|
|
6
|
+
|
|
4
7
|
describe("caseViewModel", () => {
|
|
5
8
|
it("should be able to create an empty casedetail", () => {
|
|
6
9
|
const caseview = new CaseViewModel({});
|
|
@@ -10,200 +13,81 @@ describe("caseViewModel", () => {
|
|
|
10
13
|
|
|
11
14
|
it("should be able to create a casedetail from a typical modular UI json structure", () => {
|
|
12
15
|
const caseDetail = new CaseViewModel({
|
|
16
|
+
key: "Book",
|
|
17
|
+
data: caseviewJson,
|
|
18
|
+
contributions: caseviewContributionsJson,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
expect(caseDetail).toBeInstanceOf(CaseViewModel);
|
|
22
|
+
expect(caseDetail).toBeInstanceOf(DetailModel);
|
|
23
|
+
|
|
24
|
+
expect(caseDetail.key).toBe("Book");
|
|
25
|
+
expect(caseDetail.id).toBe(24);
|
|
26
|
+
|
|
27
|
+
expect(caseDetail.casename.value).toBe("The safety of objects");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should be able to handle different kind of introtext", () => {
|
|
31
|
+
const caseviewOldStructure = new CaseViewModel({
|
|
32
|
+
key: "Book",
|
|
33
|
+
data: caseviewJson,
|
|
34
|
+
contributions: caseviewContributionsJson,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
expect(caseviewOldStructure.introtext).toBe("<p>This is introtext</p>");
|
|
38
|
+
|
|
39
|
+
const caseviewFromDataPlain = new CaseViewModel({
|
|
13
40
|
key: "Book",
|
|
14
41
|
data: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
href: "/books/book/24/editions",
|
|
30
|
-
},
|
|
31
|
-
Activities: {
|
|
32
|
-
href: "/books/book/24/activities",
|
|
33
|
-
},
|
|
34
|
-
taskgroup: [
|
|
35
|
-
{
|
|
36
|
-
href: "/books/book/24/Tasks",
|
|
37
|
-
name: "Tasks",
|
|
38
|
-
},
|
|
39
|
-
],
|
|
42
|
+
_text: "<p>This is introtext</p>",
|
|
43
|
+
...caseviewJson,
|
|
44
|
+
},
|
|
45
|
+
contributions: caseviewContributionsJson,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(caseviewFromDataPlain.introtext).toBe("<p>This is introtext</p>");
|
|
49
|
+
|
|
50
|
+
const caseviewFromDataApplicationMessage = new CaseViewModel({
|
|
51
|
+
key: "Book",
|
|
52
|
+
data: {
|
|
53
|
+
...caseviewJson,
|
|
54
|
+
_text: {
|
|
55
|
+
message: "<p>This is introtext</p>",
|
|
40
56
|
},
|
|
41
|
-
_id: 24,
|
|
42
|
-
CaseName: "The safety of objects",
|
|
43
|
-
CaseType: "Book",
|
|
44
|
-
Owner: "Arnold",
|
|
45
|
-
Format: "Paperback",
|
|
46
|
-
ISBN10: "1847087302",
|
|
47
|
-
ISBN13: "9781847087300",
|
|
48
|
-
Language: "EN",
|
|
49
|
-
NumberOfPages: 176,
|
|
50
|
-
State: "Registered",
|
|
51
57
|
},
|
|
58
|
+
contributions: caseviewContributionsJson,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(caseviewFromDataApplicationMessage.introtext).toBe(
|
|
62
|
+
"<p>This is introtext</p>"
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const caseviewFromNewContributionsRawTextMessage = new CaseViewModel({
|
|
66
|
+
key: "Book",
|
|
67
|
+
data: caseviewJson,
|
|
52
68
|
contributions: {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
type: "master",
|
|
58
|
-
text: "<p>This view contains all the data about this book. It contains a list of the creators and editions. A person can be an author(1) or an illustrator(2)<br /><br />This is a list of books that is ordered by the role (author (1), co-author, illustrator(2)) of the person that contributed to the book.<br /><br />1) An author is broadly defined as "the person who originated or gave existence to anything" and whose authorship determines responsibility for what was created. Narrowly defined, an author is the originator of any written work and can also be described as a writer.<br /><br />2) An illustrator is an artist who specializes in enhancing writing or elucidating concepts by providing a visual representation that corresponds to the content of the associated text or idea. The illustration may be intended to clarify complicated concepts or objects that are difficult to describe textually, which is the reason illustrations are often found in children's books.<br /></p>",
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
_links: {
|
|
62
|
-
panel: [
|
|
63
|
-
{
|
|
64
|
-
name: "Creator",
|
|
65
|
-
label: "Creator",
|
|
66
|
-
resourcetype: "CaseRelationListPanel",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: "Editions",
|
|
70
|
-
label: "Editions",
|
|
71
|
-
resourcetype: "RecordListPanel",
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: "Activities",
|
|
75
|
-
label: "Activities",
|
|
76
|
-
resourcetype: "GroupingPanel",
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
taskgroup: [
|
|
80
|
-
{
|
|
81
|
-
name: "Tasks",
|
|
82
|
-
label: "Tasks",
|
|
83
|
-
resourcetype: "TaskGroup",
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
},
|
|
87
|
-
metadata: {
|
|
88
|
-
_id: {
|
|
89
|
-
label: "Id",
|
|
90
|
-
type: "integer",
|
|
91
|
-
},
|
|
69
|
+
...caseviewContributionsJson,
|
|
70
|
+
text: {
|
|
71
|
+
message: "<p>This is introtext</p>",
|
|
92
72
|
},
|
|
93
|
-
attributes: [
|
|
94
|
-
{
|
|
95
|
-
CaseName: {
|
|
96
|
-
label: "Case name",
|
|
97
|
-
type: "string",
|
|
98
|
-
layouthint: ["title"],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
CaseType: {
|
|
103
|
-
label: "Case type",
|
|
104
|
-
type: "string",
|
|
105
|
-
layouthint: ["type"],
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
Owner: {
|
|
110
|
-
label: "Case owner",
|
|
111
|
-
type: "string",
|
|
112
|
-
layouthint: ["owner"],
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
State: {
|
|
117
|
-
label: "State",
|
|
118
|
-
type: "string",
|
|
119
|
-
layouthint: ["state"],
|
|
120
|
-
options: [
|
|
121
|
-
{
|
|
122
|
-
code: "Registered",
|
|
123
|
-
label: "Registered",
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
Format: {
|
|
130
|
-
label: "Format",
|
|
131
|
-
type: "string",
|
|
132
|
-
multiplechoice: false,
|
|
133
|
-
layouthint: ["combobox"],
|
|
134
|
-
options: [
|
|
135
|
-
{
|
|
136
|
-
code: "Hardcover",
|
|
137
|
-
label: "Hardcover",
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
code: "Paperback",
|
|
141
|
-
label: "Paperback",
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
code: "Ebook",
|
|
145
|
-
label: "Ebook",
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
code: "Audio",
|
|
149
|
-
label: "Audio book",
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
ISBN10: {
|
|
156
|
-
label: "ISBN10",
|
|
157
|
-
type: "string",
|
|
158
|
-
displaysize: 50,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
ISBN13: {
|
|
163
|
-
label: "ISBN13",
|
|
164
|
-
type: "string",
|
|
165
|
-
displaysize: 50,
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
Language: {
|
|
170
|
-
label: "Language",
|
|
171
|
-
type: "string",
|
|
172
|
-
multiplechoice: false,
|
|
173
|
-
layouthint: ["radiobutton"],
|
|
174
|
-
options: [
|
|
175
|
-
{
|
|
176
|
-
code: "EN",
|
|
177
|
-
label: "English",
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
code: "DU",
|
|
181
|
-
label: "Dutch",
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
NumberOfPages: {
|
|
188
|
-
label: "Number of pages",
|
|
189
|
-
type: "number",
|
|
190
|
-
format: "0",
|
|
191
|
-
groupingSeparator: ".",
|
|
192
|
-
decimalSeparator: ",",
|
|
193
|
-
minimum: 1,
|
|
194
|
-
maximum: 1000,
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
],
|
|
198
73
|
},
|
|
199
74
|
});
|
|
200
75
|
|
|
201
|
-
expect(
|
|
202
|
-
|
|
76
|
+
expect(caseviewFromNewContributionsRawTextMessage.introtext).toBe(
|
|
77
|
+
"<p>This is introtext</p>"
|
|
78
|
+
);
|
|
203
79
|
|
|
204
|
-
|
|
205
|
-
|
|
80
|
+
const caseviewFromNewContributionsSimpleMessage = new CaseViewModel({
|
|
81
|
+
key: "Book",
|
|
82
|
+
data: caseviewJson,
|
|
83
|
+
contributions: {
|
|
84
|
+
...caseviewContributionsJson,
|
|
85
|
+
text: "<p>This is introtext</p>",
|
|
86
|
+
},
|
|
87
|
+
});
|
|
206
88
|
|
|
207
|
-
expect(
|
|
89
|
+
expect(caseviewFromNewContributionsSimpleMessage.introtext).toBe(
|
|
90
|
+
"<p>This is introtext</p>"
|
|
91
|
+
);
|
|
208
92
|
});
|
|
209
93
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_links": {
|
|
3
|
+
"self": {
|
|
4
|
+
"href": "/books/book/24"
|
|
5
|
+
},
|
|
6
|
+
"api_doc": {
|
|
7
|
+
"href": "/api-docs/books/book/24"
|
|
8
|
+
},
|
|
9
|
+
"contributions": {
|
|
10
|
+
"href": "/contributions/books/book/24"
|
|
11
|
+
},
|
|
12
|
+
"Creator": {
|
|
13
|
+
"href": "/books/book/24/creator"
|
|
14
|
+
},
|
|
15
|
+
"Editions": {
|
|
16
|
+
"href": "/books/book/24/editions"
|
|
17
|
+
},
|
|
18
|
+
"Activities": {
|
|
19
|
+
"href": "/books/book/24/activities"
|
|
20
|
+
},
|
|
21
|
+
"taskgroup": [
|
|
22
|
+
{
|
|
23
|
+
"href": "/books/book/24/Tasks",
|
|
24
|
+
"name": "Tasks"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"_id": 24,
|
|
29
|
+
"CaseName": "The safety of objects",
|
|
30
|
+
"CaseType": "Book",
|
|
31
|
+
"Owner": "Arnold",
|
|
32
|
+
"Format": "Paperback",
|
|
33
|
+
"ISBN10": "1847087302",
|
|
34
|
+
"ISBN13": "9781847087300",
|
|
35
|
+
"Language": "EN",
|
|
36
|
+
"NumberOfPages": 176,
|
|
37
|
+
"State": "Registered"
|
|
38
|
+
}
|