@beinformed/ui 1.9.0-beta.9 → 1.9.3
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 +48 -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/attributes/HelptextAttributeModel.js +3 -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/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/redux/actions/FormAutosave.js +2 -1
- package/esm/redux/actions/FormAutosave.js.map +1 -1
- package/esm/redux/actions/FormValidations.js +2 -1
- package/esm/redux/actions/FormValidations.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/HelptextAttributeModel.js +3 -1
- package/lib/models/attributes/HelptextAttributeModel.js.flow +1 -1
- package/lib/models/attributes/HelptextAttributeModel.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/attributes/__tests__/HelptextAttributeModel.spec.js.flow +1 -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/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 +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/lib/redux/actions/FormAutosave.js +2 -1
- package/lib/redux/actions/FormAutosave.js.flow +1 -0
- package/lib/redux/actions/FormAutosave.js.map +1 -1
- package/lib/redux/actions/FormValidations.js +2 -1
- package/lib/redux/actions/FormValidations.js.flow +1 -0
- package/lib/redux/actions/FormValidations.js.map +1 -1
- package/package.json +15 -15
- 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/HelptextAttributeModel.js +1 -1
- package/src/models/attributes/__tests__/AttributeContent.spec.js +4 -2
- package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +9 -3
- package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +1 -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/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 +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
- package/src/redux/actions/FormAutosave.js +1 -0
- package/src/redux/actions/FormValidations.js +1 -0
|
@@ -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
|
+
message: "<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
|
+
message: "<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
|
});
|
|
@@ -9,12 +9,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.default = void 0;
|
|
11
11
|
|
|
12
|
-
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
13
|
-
|
|
14
12
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
15
13
|
|
|
16
14
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
|
17
15
|
|
|
16
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
17
|
+
|
|
18
18
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
19
19
|
|
|
20
20
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
@@ -123,11 +123,7 @@ var GroupingPanelModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
123
123
|
}, {
|
|
124
124
|
key: "hasIntroText",
|
|
125
125
|
value: function hasIntroText() {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return this.contributions.texts && (0, _find.default)(_context = this.contributions.texts).call(_context, function (item) {
|
|
129
|
-
return item.type === "master";
|
|
130
|
-
});
|
|
126
|
+
return this.introtext !== "";
|
|
131
127
|
}
|
|
132
128
|
/**
|
|
133
129
|
* Getting the introduction text configured on the grouping panel
|
|
@@ -136,13 +132,20 @@ var GroupingPanelModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
136
132
|
}, {
|
|
137
133
|
key: "introtext",
|
|
138
134
|
get: function get() {
|
|
139
|
-
if (this.
|
|
140
|
-
var
|
|
135
|
+
if (this.data._text) {
|
|
136
|
+
var _this$data$_text$mess;
|
|
141
137
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
return (_this$data$_text$mess = this.data._text.message) !== null && _this$data$_text$mess !== void 0 ? _this$data$_text$mess : this.data._text;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (this.contributions.text) {
|
|
142
|
+
var _this$contributions$t;
|
|
143
|
+
|
|
144
|
+
return (_this$contributions$t = this.contributions.text.message) !== null && _this$contributions$t !== void 0 ? _this$contributions$t : this.contributions.text;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
148
|
+
return this.contributions.texts[0].text;
|
|
146
149
|
}
|
|
147
150
|
|
|
148
151
|
return "";
|
|
@@ -153,15 +156,15 @@ var GroupingPanelModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
153
156
|
}, {
|
|
154
157
|
key: "createTaskGroupCollection",
|
|
155
158
|
value: function createTaskGroupCollection() {
|
|
156
|
-
var
|
|
159
|
+
var _context;
|
|
157
160
|
|
|
158
161
|
var allTaskgroupsData = this.getData("taskgroups", []);
|
|
159
162
|
var allTaskgroupsContributions = this.getContribution("taskgroups", []);
|
|
160
|
-
this.taskGroupCollection = (0, _map.default)(
|
|
163
|
+
this.taskGroupCollection = (0, _map.default)(_context = (0, _filter.default)(allTaskgroupsData).call(allTaskgroupsData, function (taskgroup) {
|
|
161
164
|
return allTaskgroupsContributions.some(function (taskgroupContribution) {
|
|
162
165
|
return taskgroupContribution.name === taskgroup.name;
|
|
163
166
|
});
|
|
164
|
-
})).call(
|
|
167
|
+
})).call(_context, function (taskgroup) {
|
|
165
168
|
var taskgroupContributions = (0, _find.default)(allTaskgroupsContributions).call(allTaskgroupsContributions, function (taskgroupContribution) {
|
|
166
169
|
return taskgroupContribution.name === taskgroup.name;
|
|
167
170
|
});
|
|
@@ -205,9 +208,9 @@ var GroupingPanelModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
205
208
|
}], [{
|
|
206
209
|
key: "isApplicableModel",
|
|
207
210
|
value: function isApplicableModel(data) {
|
|
208
|
-
var
|
|
211
|
+
var _context2;
|
|
209
212
|
|
|
210
|
-
return data.contributions.resourcetype && (0, _includes.default)(
|
|
213
|
+
return data.contributions.resourcetype && (0, _includes.default)(_context2 = ["GroupingPanel", "CaseTabGroupingPanel", "TabGroupingPanel"]).call(_context2, data.contributions.resourcetype);
|
|
211
214
|
}
|
|
212
215
|
}]);
|
|
213
216
|
return GroupingPanelModel;
|
|
@@ -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.message ?? 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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/panels/GroupingPanelModel.js"],"names":["GroupingPanelModel","modularuiResponse","createTaskGroupCollection","contributions","label","links","getLinksByGroup","all","models","taskGroups","i","length","TaskGroupModel","push","taskGroupCollection","add","
|
|
1
|
+
{"version":3,"sources":["../../../src/models/panels/GroupingPanelModel.js"],"names":["GroupingPanelModel","modularuiResponse","createTaskGroupCollection","contributions","label","links","getLinksByGroup","all","models","taskGroups","i","length","TaskGroupModel","push","taskGroupCollection","add","introtext","data","_text","message","text","Array","isArray","texts","allTaskgroupsData","getData","allTaskgroupsContributions","getContribution","taskgroup","some","taskgroupContribution","name","taskgroupContributions","create","_taskGroupCollection","taskgroups","TaskGroupCollection","hasItems","hasTasks","resourcetype","ResourceModel"],"mappings":"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","sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport TaskGroupCollection from \"../taskgroup/TaskGroupCollection\";\n\nimport TaskGroupModel from \"../taskgroup/TaskGroupModel\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type { ModularUIModel } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type LinkCollection from \"../links/LinkCollection\";\n\n/**\n * Panel that groups other panels\n */\nexport default class GroupingPanelModel extends ResourceModel {\n _taskGroupCollection: TaskGroupCollection;\n\n /**\n * Constructs GroupingPanel\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this.createTaskGroupCollection();\n }\n\n /**\n */\n get type(): string {\n return \"GroupingPanel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n [\"GroupingPanel\", \"CaseTabGroupingPanel\", \"TabGroupingPanel\"].includes(\n data.contributions.resourcetype\n )\n );\n }\n\n /**\n * Getting the label of the panel\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this.links.getLinksByGroup(\"taskgroup\").all;\n }\n\n /**\n */\n get panelLinks(): LinkCollection {\n return this.links.getLinksByGroup(\"panel\");\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const taskGroups = [];\n\n for (let i = 0; i < models.length; i++) {\n if (models[i] instanceof TaskGroupModel) {\n taskGroups.push(models[i]);\n }\n }\n\n this.taskGroupCollection.add(taskGroups);\n }\n\n /**\n * Check if an introtext exists for this caseview\n */\n hasIntroText(): boolean {\n return this.introtext !== \"\";\n }\n\n /**\n * Getting the introduction text configured on the grouping panel\n */\n get introtext(): string {\n if (this.data._text) {\n return this.data._text.message ?? this.data._text;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n */\n createTaskGroupCollection() {\n const allTaskgroupsData = this.getData(\"taskgroups\", []);\n const allTaskgroupsContributions = this.getContribution(\"taskgroups\", []);\n\n this.taskGroupCollection = allTaskgroupsData\n .filter((taskgroup) =>\n allTaskgroupsContributions.some(\n (taskgroupContribution) =>\n taskgroupContribution.name === taskgroup.name\n )\n )\n .map((taskgroup) => {\n const taskgroupContributions = allTaskgroupsContributions.find(\n (taskgroupContribution) =>\n taskgroupContribution.name === taskgroup.name\n );\n\n return TaskGroupModel.create(\n taskgroup.name,\n taskgroup,\n taskgroupContributions\n );\n });\n }\n\n /**\n * Setting the taskgroup panel collection\n */\n set taskGroupCollection(taskgroups: Array<TaskGroupModel>) {\n this._taskGroupCollection = new TaskGroupCollection(taskgroups);\n }\n\n /**\n * Getting the taskgrouppanels on the tab\n */\n get taskGroupCollection(): TaskGroupCollection {\n return this._taskGroupCollection;\n }\n\n /**\n * Has taskgroups\n */\n hasTaskGroups(): boolean {\n return this.taskGroupCollection && this.taskGroupCollection.hasItems;\n }\n\n /**\n * Has tasks\n */\n hasTasks(): boolean {\n return this.taskGroupCollection.hasTasks();\n }\n}\n"],"file":"GroupingPanelModel.js"}
|
|
@@ -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
|
+
message: "<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
|
});
|
package/lib/models/types.js.flow
CHANGED
|
@@ -44,6 +44,7 @@ import type LookupOptionsModel from "./lookup/LookupOptionsModel";
|
|
|
44
44
|
import type BaseFilterModel from "./filters/BaseFilterModel";
|
|
45
45
|
import type AttributeCollection from "./attributes/AttributeCollection";
|
|
46
46
|
import type AttributeModel from "./attributes/AttributeModel";
|
|
47
|
+
import type LayoutHintCollection from "./layouthint/LayoutHintCollection";
|
|
47
48
|
|
|
48
49
|
export type ModularUIModel =
|
|
49
50
|
| ApplicationModel
|
|
@@ -192,36 +193,52 @@ export type SectionData = {
|
|
|
192
193
|
subSections: Array<SectionData>,
|
|
193
194
|
};
|
|
194
195
|
|
|
195
|
-
export type
|
|
196
|
-
|
|
196
|
+
export type PropertyElement = {
|
|
197
|
+
propertyElement: {
|
|
197
198
|
label: string,
|
|
198
|
-
|
|
199
|
+
layouthint: Array<string>,
|
|
199
200
|
properties: Array<PropertyData>,
|
|
200
201
|
},
|
|
201
202
|
};
|
|
202
203
|
export type TextFragmentElement = {
|
|
203
204
|
textFragmentElement: {
|
|
204
205
|
label: string,
|
|
205
|
-
|
|
206
|
+
layouthint: Array<string>,
|
|
206
207
|
textfragments: Array<TextFragmentData>,
|
|
207
208
|
},
|
|
208
209
|
};
|
|
209
210
|
export type ContentElement = {
|
|
210
211
|
contentElement: {
|
|
211
212
|
label: string,
|
|
213
|
+
layouthint: Array<string>,
|
|
212
214
|
sections: Array<SectionData>,
|
|
213
215
|
},
|
|
214
216
|
};
|
|
215
217
|
|
|
218
|
+
type PropertyElementMapped = {
|
|
219
|
+
propertyElement: {
|
|
220
|
+
label: string,
|
|
221
|
+
layouthint: LayoutHintCollection,
|
|
222
|
+
properties: Array<PropertyData>,
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
type TextFragmentElementMapped = {
|
|
226
|
+
textFragmentElement: {
|
|
227
|
+
label: string,
|
|
228
|
+
layouthint: LayoutHintCollection,
|
|
229
|
+
textfragments: Array<TextFragmentData>,
|
|
230
|
+
},
|
|
231
|
+
};
|
|
216
232
|
type ContentElementMapped = {
|
|
217
233
|
contentElement: {
|
|
218
234
|
label: string,
|
|
235
|
+
layouthint: LayoutHintCollection,
|
|
219
236
|
sections: Array<SectionModel>,
|
|
220
237
|
},
|
|
221
238
|
};
|
|
222
239
|
|
|
223
240
|
export type ContentAll = Array<
|
|
224
|
-
|
|
241
|
+
PropertyElementMapped | TextFragmentElementMapped | ContentElementMapped
|
|
225
242
|
>;
|
|
226
243
|
|
|
227
244
|
export type ContentData = {
|
|
@@ -229,5 +246,6 @@ export type ContentData = {
|
|
|
229
246
|
label?: string,
|
|
230
247
|
description?: { id?: string, message: string, properties?: Object },
|
|
231
248
|
},
|
|
232
|
-
|
|
249
|
+
label?: string,
|
|
250
|
+
elements: Array<PropertyElement | TextFragmentElement | ContentElement>,
|
|
233
251
|
};
|
|
@@ -659,7 +659,8 @@ var ModularUIRequest = /*#__PURE__*/function () {
|
|
|
659
659
|
var prevData = typeof this.options.data === "string" ? JSON.parse(this.options.data) : this.options.data;
|
|
660
660
|
|
|
661
661
|
if (model instanceof _FormModel.default) {
|
|
662
|
-
var newData = JSON.parse(model.validationData);
|
|
662
|
+
var newData = JSON.parse(model.validationData); // $FlowFixMe incompatible-call
|
|
663
|
+
|
|
663
664
|
return (0, _stringify.default)((0, _deepmerge.default)(prevData || {}, newData));
|
|
664
665
|
}
|
|
665
666
|
|