@beinformed/ui 1.9.0-beta.10 → 1.9.0-beta.14
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 +24 -0
- 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 +49 -20
- 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/caseview/CaseViewModel.js +16 -12
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/form/FormObjectModel.js +7 -1
- 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/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 +51 -20
- package/lib/models/attributes/AttributeContent.js.flow +38 -13
- 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/__tests__/AttributeContent.spec.js.flow +4 -2
- package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +9 -3
- package/lib/models/caseview/CaseViewModel.js +17 -13
- package/lib/models/caseview/CaseViewModel.js.flow +9 -7
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/caseview/__tests__/CaseViewModel.spec.js.flow +68 -184
- package/lib/models/form/FormObjectModel.js +7 -1
- package/lib/models/form/FormObjectModel.js.flow +4 -0
- package/lib/models/form/FormObjectModel.js.map +1 -1
- 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 +24 -6
- package/lib/modularui/ModularUIRequest.js +2 -1
- package/lib/modularui/ModularUIRequest.js.flow +1 -0
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/package.json +11 -11
- 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 +38 -13
- package/src/models/attributes/AttributeDataHelper.js +2 -1
- package/src/models/attributes/__tests__/AttributeContent.spec.js +4 -2
- package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +9 -3
- package/src/models/caseview/CaseViewModel.js +9 -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/form/FormObjectModel.js +4 -0
- package/src/models/form/__tests__/FormWithContentData.json +2 -1
- 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 +24 -6
- package/src/modularui/ModularUIRequest.js +1 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
{
|
|
2
|
+
"label": "Book",
|
|
3
|
+
"resourcetype": "CaseView",
|
|
4
|
+
"texts": [
|
|
5
|
+
{
|
|
6
|
+
"type": "master",
|
|
7
|
+
"text": "<p>This is introtext</p>"
|
|
8
|
+
}
|
|
9
|
+
],
|
|
10
|
+
"_links": {
|
|
11
|
+
"panel": [
|
|
12
|
+
{
|
|
13
|
+
"name": "Creator",
|
|
14
|
+
"label": "Creator",
|
|
15
|
+
"resourcetype": "CaseRelationListPanel"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "Editions",
|
|
19
|
+
"label": "Editions",
|
|
20
|
+
"resourcetype": "RecordListPanel"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "Activities",
|
|
24
|
+
"label": "Activities",
|
|
25
|
+
"resourcetype": "GroupingPanel"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"taskgroup": [
|
|
29
|
+
{
|
|
30
|
+
"name": "Tasks",
|
|
31
|
+
"label": "Tasks",
|
|
32
|
+
"resourcetype": "TaskGroup"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"metadata": {
|
|
37
|
+
"_id": {
|
|
38
|
+
"label": "Id",
|
|
39
|
+
"type": "integer"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"attributes": [
|
|
43
|
+
{
|
|
44
|
+
"CaseName": {
|
|
45
|
+
"label": "Case name",
|
|
46
|
+
"type": "string",
|
|
47
|
+
"layouthint": ["title"]
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"CaseType": {
|
|
52
|
+
"label": "Case type",
|
|
53
|
+
"type": "string",
|
|
54
|
+
"layouthint": ["type"]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"Owner": {
|
|
59
|
+
"label": "Case owner",
|
|
60
|
+
"type": "string",
|
|
61
|
+
"layouthint": ["owner"]
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"State": {
|
|
66
|
+
"label": "State",
|
|
67
|
+
"type": "string",
|
|
68
|
+
"layouthint": ["state"],
|
|
69
|
+
"options": [
|
|
70
|
+
{
|
|
71
|
+
"code": "Registered",
|
|
72
|
+
"label": "Registered"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"Format": {
|
|
79
|
+
"label": "Format",
|
|
80
|
+
"type": "string",
|
|
81
|
+
"multiplechoice": false,
|
|
82
|
+
"layouthint": ["combobox"],
|
|
83
|
+
"options": [
|
|
84
|
+
{
|
|
85
|
+
"code": "Hardcover",
|
|
86
|
+
"label": "Hardcover"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"code": "Paperback",
|
|
90
|
+
"label": "Paperback"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"code": "Ebook",
|
|
94
|
+
"label": "Ebook"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"code": "Audio",
|
|
98
|
+
"label": "Audio book"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"ISBN10": {
|
|
105
|
+
"label": "ISBN10",
|
|
106
|
+
"type": "string",
|
|
107
|
+
"displaysize": 50
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"ISBN13": {
|
|
112
|
+
"label": "ISBN13",
|
|
113
|
+
"type": "string",
|
|
114
|
+
"displaysize": 50
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"Language": {
|
|
119
|
+
"label": "Language",
|
|
120
|
+
"type": "string",
|
|
121
|
+
"multiplechoice": false,
|
|
122
|
+
"layouthint": ["radiobutton"],
|
|
123
|
+
"options": [
|
|
124
|
+
{
|
|
125
|
+
"code": "EN",
|
|
126
|
+
"label": "English"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"code": "DU",
|
|
130
|
+
"label": "Dutch"
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"NumberOfPages": {
|
|
137
|
+
"label": "Number of pages",
|
|
138
|
+
"type": "number",
|
|
139
|
+
"format": "0",
|
|
140
|
+
"groupingSeparator": ".",
|
|
141
|
+
"decimalSeparator": ",",
|
|
142
|
+
"minimum": 1,
|
|
143
|
+
"maximum": 1000
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
@@ -295,6 +295,10 @@ export default class FormObjectModel extends BaseModel {
|
|
|
295
295
|
* Get introText of form object
|
|
296
296
|
*/
|
|
297
297
|
get introText(): string {
|
|
298
|
+
if (this.data.content?.text) {
|
|
299
|
+
return this.data.content.text.message ?? this.data.content.text;
|
|
300
|
+
}
|
|
301
|
+
|
|
298
302
|
return (
|
|
299
303
|
this.contributions.introText?.rawText ?? this.contributions.introText
|
|
300
304
|
);
|
|
@@ -35,11 +35,13 @@ export default class LayoutHintCollection extends BaseCollection<string> {
|
|
|
35
35
|
has(...hints: Array<string>): boolean {
|
|
36
36
|
const hintArray = hints.length > 0 ? [...hints] : [];
|
|
37
37
|
|
|
38
|
-
return hintArray
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
return hintArray
|
|
39
|
+
.flat()
|
|
40
|
+
.some(
|
|
41
|
+
(hint) =>
|
|
42
|
+
this.layouthint.includes(hint) ||
|
|
43
|
+
this.layouthint.some((hint2) => hint2.startsWith(hint))
|
|
44
|
+
);
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
/**
|
|
@@ -51,8 +53,7 @@ export default class LayoutHintCollection extends BaseCollection<string> {
|
|
|
51
53
|
*/
|
|
52
54
|
hasExact(...hints: Array<string>): boolean {
|
|
53
55
|
const hintArray = hints.length > 0 ? [...hints] : [];
|
|
54
|
-
|
|
55
|
-
return hintArray.some((hint) => this.layouthint.includes(hint));
|
|
56
|
+
return hintArray.flat().some((hint) => this.layouthint.includes(hint));
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
/**
|
|
@@ -133,6 +133,25 @@ export default class ListDetailModel extends DetailModel {
|
|
|
133
133
|
this._contentConfiguration = configuration;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Getting the introduction text configured on the case view
|
|
138
|
+
*/
|
|
139
|
+
get introtext(): string {
|
|
140
|
+
if (this.data._text) {
|
|
141
|
+
return this.data._text.message ?? this.data._text;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (this.contributions.text) {
|
|
145
|
+
return this.contributions.text.rawText ?? this.contributions.text;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
149
|
+
return this.contributions.texts[0].text;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return "";
|
|
153
|
+
}
|
|
154
|
+
|
|
136
155
|
/**
|
|
137
156
|
*/
|
|
138
157
|
setResultSection() {
|
|
@@ -98,12 +98,16 @@ export default class ListModel extends ResourceModel {
|
|
|
98
98
|
* Getting the introduction text
|
|
99
99
|
*/
|
|
100
100
|
get introtext(): string {
|
|
101
|
-
if (this.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
if (this.data.text) {
|
|
102
|
+
return this.data.text.message ?? this.data.text;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (this.contributions.text) {
|
|
106
|
+
return this.contributions.text.rawText ?? this.contributions.text;
|
|
107
|
+
}
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
110
|
+
return this.contributions.texts[0].text;
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
return "";
|
|
@@ -27,4 +27,68 @@ describe("listDetailModel", () => {
|
|
|
27
27
|
"Highly Inappropriate Tales for Young People"
|
|
28
28
|
);
|
|
29
29
|
});
|
|
30
|
+
|
|
31
|
+
it("should be able to handle different kind of introtext", () => {
|
|
32
|
+
const listdetailOldStructure = new ListDetailModel({
|
|
33
|
+
key: "Book",
|
|
34
|
+
data: data.Book,
|
|
35
|
+
contributions: contributions.Book,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
expect(listdetailOldStructure.introtext).toBe("<p>This is introtext</p>");
|
|
39
|
+
|
|
40
|
+
const listdetailFromDataPlain = new ListDetailModel({
|
|
41
|
+
key: "Book",
|
|
42
|
+
data: {
|
|
43
|
+
_text: "<p>This is introtext</p>",
|
|
44
|
+
...data.Book,
|
|
45
|
+
},
|
|
46
|
+
contributions: contributions.Book,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
expect(listdetailFromDataPlain.introtext).toBe("<p>This is introtext</p>");
|
|
50
|
+
|
|
51
|
+
const listdetailFromDataApplicationMessage = new ListDetailModel({
|
|
52
|
+
key: "Book",
|
|
53
|
+
data: {
|
|
54
|
+
...data.Book,
|
|
55
|
+
_text: {
|
|
56
|
+
message: "<p>This is introtext</p>",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
contributions: contributions.Book,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect(listdetailFromDataApplicationMessage.introtext).toBe(
|
|
63
|
+
"<p>This is introtext</p>"
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const listdetailFromNewContributionsRawTextMessage = new ListDetailModel({
|
|
67
|
+
key: "Book",
|
|
68
|
+
data: data.Book,
|
|
69
|
+
contributions: {
|
|
70
|
+
...contributions.Book,
|
|
71
|
+
text: {
|
|
72
|
+
rawText: "<p>This is introtext</p>",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
expect(listdetailFromNewContributionsRawTextMessage.introtext).toBe(
|
|
78
|
+
"<p>This is introtext</p>"
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const listdetailFromNewContributionsSimpleMessage = new ListDetailModel({
|
|
82
|
+
key: "Book",
|
|
83
|
+
data: data.Book,
|
|
84
|
+
contributions: {
|
|
85
|
+
...contributions.Book,
|
|
86
|
+
text: "<p>This is introtext</p>",
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
expect(listdetailFromNewContributionsSimpleMessage.introtext).toBe(
|
|
91
|
+
"<p>This is introtext</p>"
|
|
92
|
+
);
|
|
93
|
+
});
|
|
30
94
|
});
|
|
@@ -54,8 +54,70 @@ describe("listModel spec", () => {
|
|
|
54
54
|
|
|
55
55
|
expect(list.headers).toHaveLength(6);
|
|
56
56
|
|
|
57
|
-
expect(list.introtext).toStrictEqual(
|
|
58
|
-
|
|
57
|
+
expect(list.introtext).toStrictEqual("<p>This is introtext</p>");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("should be able to handle different kind of introtext", () => {
|
|
61
|
+
const listOldStructure = new ListModel({
|
|
62
|
+
key: "Books",
|
|
63
|
+
data: mockList.Books,
|
|
64
|
+
contributions: mockListContributions.Books,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(listOldStructure.introtext).toBe("<p>This is introtext</p>");
|
|
68
|
+
|
|
69
|
+
const listFromDataPlain = new ListModel({
|
|
70
|
+
key: "Books",
|
|
71
|
+
data: {
|
|
72
|
+
text: "<p>This is introtext</p>",
|
|
73
|
+
...mockList.Books,
|
|
74
|
+
},
|
|
75
|
+
contributions: mockListContributions.Books,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(listFromDataPlain.introtext).toBe("<p>This is introtext</p>");
|
|
79
|
+
|
|
80
|
+
const listFromDataApplicationMessage = new ListModel({
|
|
81
|
+
key: "Books",
|
|
82
|
+
data: {
|
|
83
|
+
...mockList.Books,
|
|
84
|
+
text: {
|
|
85
|
+
message: "<p>This is introtext</p>",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
contributions: mockListContributions.Books,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(listFromDataApplicationMessage.introtext).toBe(
|
|
92
|
+
"<p>This is introtext</p>"
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const listFromNewContributionsRawTextMessage = new ListModel({
|
|
96
|
+
key: "Books",
|
|
97
|
+
data: mockList.Books,
|
|
98
|
+
contributions: {
|
|
99
|
+
...mockListContributions.Books,
|
|
100
|
+
text: {
|
|
101
|
+
rawText: "<p>This is introtext</p>",
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
expect(listFromNewContributionsRawTextMessage.introtext).toBe(
|
|
107
|
+
"<p>This is introtext</p>"
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const listFromNewContributionsSimpleMessage = new ListModel({
|
|
111
|
+
key: "Books",
|
|
112
|
+
data: mockList.Books,
|
|
113
|
+
contributions: {
|
|
114
|
+
...mockListContributions.Books,
|
|
115
|
+
text: "<p>This is introtext</p>",
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(listFromNewContributionsSimpleMessage.introtext).toBe(
|
|
120
|
+
"<p>This is introtext</p>"
|
|
59
121
|
);
|
|
60
122
|
});
|
|
61
123
|
});
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"texts": [
|
|
6
6
|
{
|
|
7
7
|
"type": "master",
|
|
8
|
-
"text": "<p>This
|
|
8
|
+
"text": "<p>This is introtext</p>"
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"_links": {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"texts": [
|
|
7
7
|
{
|
|
8
8
|
"type": "master",
|
|
9
|
-
"text": "<p>This is
|
|
9
|
+
"text": "<p>This is introtext</p>"
|
|
10
10
|
}
|
|
11
11
|
],
|
|
12
12
|
"actions": [
|
|
@@ -78,22 +78,23 @@ export default class GroupingPanelModel extends ResourceModel {
|
|
|
78
78
|
* Check if an introtext exists for this caseview
|
|
79
79
|
*/
|
|
80
80
|
hasIntroText(): boolean {
|
|
81
|
-
return
|
|
82
|
-
this.contributions.texts &&
|
|
83
|
-
this.contributions.texts.find((item) => item.type === "master")
|
|
84
|
-
);
|
|
81
|
+
return this.introtext !== "";
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
/**
|
|
88
85
|
* Getting the introduction text configured on the grouping panel
|
|
89
86
|
*/
|
|
90
87
|
get introtext(): string {
|
|
91
|
-
if (this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
if (this.data._text) {
|
|
89
|
+
return this.data._text.message ?? this.data._text;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (this.contributions.text) {
|
|
93
|
+
return this.contributions.text.rawText ?? this.contributions.text;
|
|
94
|
+
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
97
|
+
return this.contributions.texts[0].text;
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
return "";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import GroupingPanelModel from "../GroupingPanelModel";
|
|
2
2
|
|
|
3
|
+
import panelJson from "./groupingPanel.json";
|
|
4
|
+
import panelContributionsJson from "./groupingPanelContributions.json";
|
|
5
|
+
import CaseViewModel from "../../caseview/CaseViewModel";
|
|
6
|
+
|
|
3
7
|
describe("groupingPanelModel", () => {
|
|
4
8
|
it("should be able to create an empty GroupingPanelModel object", () => {
|
|
5
9
|
const groupingPanel = new GroupingPanelModel();
|
|
@@ -30,4 +34,90 @@ describe("groupingPanelModel", () => {
|
|
|
30
34
|
})
|
|
31
35
|
).toBe(true);
|
|
32
36
|
});
|
|
37
|
+
|
|
38
|
+
it("should be able to create a grouping panel from a typical modular UI json structure", () => {
|
|
39
|
+
const groupingPanel = new GroupingPanelModel({
|
|
40
|
+
key: "AskingQuestions",
|
|
41
|
+
data: panelJson,
|
|
42
|
+
contributions: panelContributionsJson,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(groupingPanel).toBeInstanceOf(GroupingPanelModel);
|
|
46
|
+
|
|
47
|
+
expect(groupingPanel.key).toBe("AskingQuestions");
|
|
48
|
+
expect(groupingPanel.label).toBe("Asking questions");
|
|
49
|
+
|
|
50
|
+
expect(groupingPanel.links).toHaveLength(8);
|
|
51
|
+
expect(groupingPanel.panelLinks).toHaveLength(1);
|
|
52
|
+
|
|
53
|
+
expect(groupingPanel.hasIntroText()).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should be able to handle different kind of introtext", () => {
|
|
57
|
+
const groupingPanelOldStructure = new CaseViewModel({
|
|
58
|
+
key: "Book",
|
|
59
|
+
data: panelJson,
|
|
60
|
+
contributions: panelContributionsJson,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
expect(groupingPanelOldStructure.introtext).toBe(
|
|
64
|
+
"<p>This is introtext</p>"
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const groupingPanelFromDataPlain = new CaseViewModel({
|
|
68
|
+
key: "Book",
|
|
69
|
+
data: {
|
|
70
|
+
_text: "<p>This is introtext</p>",
|
|
71
|
+
...panelJson,
|
|
72
|
+
},
|
|
73
|
+
contributions: panelContributionsJson,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
expect(groupingPanelFromDataPlain.introtext).toBe(
|
|
77
|
+
"<p>This is introtext</p>"
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const groupingPanelFromDataApplicationMessage = new CaseViewModel({
|
|
81
|
+
key: "Book",
|
|
82
|
+
data: {
|
|
83
|
+
...panelJson,
|
|
84
|
+
_text: {
|
|
85
|
+
message: "<p>This is introtext</p>",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
contributions: panelContributionsJson,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(groupingPanelFromDataApplicationMessage.introtext).toBe(
|
|
92
|
+
"<p>This is introtext</p>"
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const groupingPanelFromNewContributionsRawTextMessage = new CaseViewModel({
|
|
96
|
+
key: "Book",
|
|
97
|
+
data: panelJson,
|
|
98
|
+
contributions: {
|
|
99
|
+
...panelContributionsJson,
|
|
100
|
+
text: {
|
|
101
|
+
rawText: "<p>This is introtext</p>",
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
expect(groupingPanelFromNewContributionsRawTextMessage.introtext).toBe(
|
|
107
|
+
"<p>This is introtext</p>"
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
const groupingPanelFromNewContributionsSimpleMessage = new CaseViewModel({
|
|
111
|
+
key: "Book",
|
|
112
|
+
data: panelJson,
|
|
113
|
+
contributions: {
|
|
114
|
+
...panelContributionsJson,
|
|
115
|
+
text: "<p>This is introtext</p>",
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
expect(groupingPanelFromNewContributionsSimpleMessage.introtext).toBe(
|
|
120
|
+
"<p>This is introtext</p>"
|
|
121
|
+
);
|
|
122
|
+
});
|
|
33
123
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_links": {
|
|
3
|
+
"self": { "href": "/iq-content/case/1/asking-questions" },
|
|
4
|
+
"api_doc": {
|
|
5
|
+
"href": "/api-docs/v3/iq-content/case/(case-id)/asking-questions"
|
|
6
|
+
},
|
|
7
|
+
"contributions": {
|
|
8
|
+
"href": "/contributions/iq-content/case/(case-id)/asking-questions"
|
|
9
|
+
},
|
|
10
|
+
"Decisions": { "href": "/iq-content/case/1/asking-questions/decisions" },
|
|
11
|
+
"taskgroup": [
|
|
12
|
+
{
|
|
13
|
+
"href": "/iq-content/case/1/asking-questions/labels",
|
|
14
|
+
"name": "Labels"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"href": "/iq-content/case/1/asking-questions/properties",
|
|
18
|
+
"name": "Properties"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"href": "/iq-content/case/1/asking-questions/sources",
|
|
22
|
+
"name": "Sources"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"href": "/iq-content/case/1/asking-questions/text-fragments",
|
|
26
|
+
"name": "TextFragments"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"label": "Asking questions",
|
|
3
|
+
"resourcetype": "GroupingPanel",
|
|
4
|
+
"layouthint": ["hint"],
|
|
5
|
+
"texts": [
|
|
6
|
+
{
|
|
7
|
+
"type": "master",
|
|
8
|
+
"text": "<p>This is introtext</p>"
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"_links": {
|
|
12
|
+
"panel": [
|
|
13
|
+
{
|
|
14
|
+
"name": "Decisions",
|
|
15
|
+
"label": "Decisions",
|
|
16
|
+
"resourcetype": "InstrumentResultListPanel"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"taskgroup": [
|
|
20
|
+
{
|
|
21
|
+
"name": "Labels",
|
|
22
|
+
"label": "Labels",
|
|
23
|
+
"layouthint": ["not-in-dropdown"],
|
|
24
|
+
"resourcetype": "TaskGroup"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Properties",
|
|
28
|
+
"label": "Properties",
|
|
29
|
+
"layouthint": ["not-in-dropdown"],
|
|
30
|
+
"resourcetype": "TaskGroup"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Sources",
|
|
34
|
+
"label": "Sources",
|
|
35
|
+
"layouthint": ["not-in-dropdown"],
|
|
36
|
+
"resourcetype": "TaskGroup"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "TextFragments",
|
|
40
|
+
"label": "Text fragments",
|
|
41
|
+
"layouthint": ["not-in-dropdown"],
|
|
42
|
+
"resourcetype": "TaskGroup"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
}
|