@beinformed/ui 1.13.0 → 1.13.4

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 (123) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/esm/builder/mergeLayoutHintConfigurations.js +3 -3
  3. package/esm/builder/mergeLayoutHintConfigurations.js.map +1 -1
  4. package/esm/constants/LayoutHintConfig.js +9 -0
  5. package/esm/constants/LayoutHintConfig.js.map +1 -1
  6. package/esm/constants/LayoutHints.js +5 -0
  7. package/esm/constants/LayoutHints.js.map +1 -1
  8. package/esm/constants/Settings.js +2 -1
  9. package/esm/constants/Settings.js.map +1 -1
  10. package/esm/hooks/useContent.js +2 -2
  11. package/esm/hooks/useContent.js.map +1 -1
  12. package/esm/hooks/useDeepCompareEffect.js +2 -1
  13. package/esm/hooks/useDeepCompareEffect.js.map +1 -1
  14. package/esm/hooks/useForm.js.map +1 -1
  15. package/esm/hooks/useModal.js +2 -2
  16. package/esm/hooks/useModal.js.map +1 -1
  17. package/esm/hooks/useModularUI.js +0 -1
  18. package/esm/hooks/useModularUI.js.map +1 -1
  19. package/esm/models/attributes/DatetimeAttributeModel.js +8 -3
  20. package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
  21. package/esm/models/caseview/CaseViewModel.js +2 -1
  22. package/esm/models/caseview/CaseViewModel.js.map +1 -1
  23. package/esm/models/list/ListItemCollection.js +38 -0
  24. package/esm/models/list/ListItemCollection.js.map +1 -1
  25. package/esm/models/list/ListItemModel.js +14 -2
  26. package/esm/models/list/ListItemModel.js.map +1 -1
  27. package/esm/models/list/ListModel.js +16 -69
  28. package/esm/models/list/ListModel.js.map +1 -1
  29. package/esm/modularui/ModularUIRequest.js +69 -47
  30. package/esm/modularui/ModularUIRequest.js.map +1 -1
  31. package/esm/utils/browser/Cookies.js +18 -32
  32. package/esm/utils/browser/Cookies.js.map +1 -1
  33. package/esm/utils/fetch/xhr.js +4 -2
  34. package/esm/utils/fetch/xhr.js.map +1 -1
  35. package/lib/builder/mergeLayoutHintConfigurations.js +3 -3
  36. package/lib/builder/mergeLayoutHintConfigurations.js.flow +3 -3
  37. package/lib/builder/mergeLayoutHintConfigurations.js.map +1 -1
  38. package/lib/constants/LayoutHintConfig.js +9 -0
  39. package/lib/constants/LayoutHintConfig.js.flow +9 -0
  40. package/lib/constants/LayoutHintConfig.js.map +1 -1
  41. package/lib/constants/LayoutHints.js +8 -2
  42. package/lib/constants/LayoutHints.js.flow +4 -0
  43. package/lib/constants/LayoutHints.js.map +1 -1
  44. package/lib/constants/Settings.js +2 -1
  45. package/lib/constants/Settings.js.flow +2 -0
  46. package/lib/constants/Settings.js.map +1 -1
  47. package/lib/hooks/useContent.js +2 -2
  48. package/lib/hooks/useContent.js.flow +2 -2
  49. package/lib/hooks/useContent.js.map +1 -1
  50. package/lib/hooks/useDeepCompareEffect.js +2 -1
  51. package/lib/hooks/useDeepCompareEffect.js.flow +1 -1
  52. package/lib/hooks/useDeepCompareEffect.js.map +1 -1
  53. package/lib/hooks/useForm.js.flow +1 -2
  54. package/lib/hooks/useForm.js.map +1 -1
  55. package/lib/hooks/useModal.js +2 -2
  56. package/lib/hooks/useModal.js.flow +1 -1
  57. package/lib/hooks/useModal.js.map +1 -1
  58. package/lib/hooks/useModularUI.js +0 -1
  59. package/lib/hooks/useModularUI.js.flow +0 -2
  60. package/lib/hooks/useModularUI.js.map +1 -1
  61. package/lib/models/attributes/DatetimeAttributeModel.js +9 -3
  62. package/lib/models/attributes/DatetimeAttributeModel.js.flow +7 -4
  63. package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
  64. package/lib/models/attributes/__tests__/StringAttributeModel.spec.js.flow +1 -1
  65. package/lib/models/base/__tests__/BaseModel.spec.js.flow +5 -5
  66. package/lib/models/caseview/CaseViewModel.js +3 -1
  67. package/lib/models/caseview/CaseViewModel.js.flow +3 -1
  68. package/lib/models/caseview/CaseViewModel.js.map +1 -1
  69. package/lib/models/caseview/__tests__/CaseViewModel.spec.js.flow +38 -1
  70. package/lib/models/list/ListItemCollection.js +40 -0
  71. package/lib/models/list/ListItemCollection.js.flow +38 -1
  72. package/lib/models/list/ListItemCollection.js.map +1 -1
  73. package/lib/models/list/ListItemModel.js +14 -2
  74. package/lib/models/list/ListItemModel.js.flow +15 -0
  75. package/lib/models/list/ListItemModel.js.map +1 -1
  76. package/lib/models/list/ListModel.js +15 -70
  77. package/lib/models/list/ListModel.js.flow +1 -45
  78. package/lib/models/list/ListModel.js.map +1 -1
  79. package/lib/models/list/__tests__/ListItemCollection.spec.js.flow +22 -0
  80. package/lib/models/list/__tests__/ListModel.spec.js.flow +0 -2
  81. package/lib/models/panels/__tests__/GroupingPanelModel.spec.js.flow +38 -21
  82. package/lib/models/process/__tests__/ProcessStatusSettingsModel.spec.js.flow +11 -0
  83. package/lib/modularui/ModularUIRequest.js +67 -47
  84. package/lib/modularui/ModularUIRequest.js.flow +38 -22
  85. package/lib/modularui/ModularUIRequest.js.map +1 -1
  86. package/lib/utils/browser/Cookies.js +18 -31
  87. package/lib/utils/browser/Cookies.js.flow +22 -28
  88. package/lib/utils/browser/Cookies.js.map +1 -1
  89. package/lib/utils/browser/__tests__/Cookies.spec.js.flow +51 -0
  90. package/lib/utils/fetch/xhr.js +5 -2
  91. package/lib/utils/fetch/xhr.js.flow +6 -2
  92. package/lib/utils/fetch/xhr.js.map +1 -1
  93. package/package.json +30 -28
  94. package/src/builder/mergeLayoutHintConfigurations.js +3 -3
  95. package/src/constants/LayoutHintConfig.js +9 -0
  96. package/src/constants/LayoutHints.js +4 -0
  97. package/src/constants/Settings.js +2 -0
  98. package/src/hooks/useContent.js +2 -2
  99. package/src/hooks/useDeepCompareEffect.js +1 -1
  100. package/src/hooks/useForm.js +1 -2
  101. package/src/hooks/useModal.js +1 -1
  102. package/src/hooks/useModularUI.js +0 -2
  103. package/src/models/attributes/DatetimeAttributeModel.js +7 -4
  104. package/src/models/attributes/__tests__/StringAttributeModel.spec.js +1 -1
  105. package/src/models/base/__tests__/BaseModel.spec.js +5 -5
  106. package/src/models/caseview/CaseViewModel.js +3 -1
  107. package/src/models/caseview/__tests__/CaseViewModel.spec.js +38 -1
  108. package/src/models/caseview/__tests__/caseview.json +14 -3
  109. package/src/models/caseview/__tests__/caseviewContributions.json +48 -77
  110. package/src/models/caseview/__tests__/caseview_local_taskgroup.json +57 -0
  111. package/src/models/list/ListItemCollection.js +38 -1
  112. package/src/models/list/ListItemModel.js +15 -0
  113. package/src/models/list/ListModel.js +1 -45
  114. package/src/models/list/__tests__/ListItemCollection.spec.js +22 -0
  115. package/src/models/list/__tests__/ListModel.spec.js +0 -2
  116. package/src/models/panels/__tests__/GroupingPanelModel.spec.js +38 -21
  117. package/src/models/panels/__tests__/groupingPanel.json +20 -1
  118. package/src/models/panels/__tests__/groupingPanelContributions.json +14 -1
  119. package/src/models/process/__tests__/ProcessStatusSettingsModel.spec.js +11 -0
  120. package/src/modularui/ModularUIRequest.js +38 -22
  121. package/src/utils/browser/Cookies.js +22 -28
  122. package/src/utils/browser/__tests__/Cookies.spec.js +51 -0
  123. package/src/utils/fetch/xhr.js +6 -2
@@ -1,14 +1,17 @@
1
1
  {
2
2
  "label": "Book",
3
3
  "resourcetype": "CaseView",
4
- "texts": [
5
- {
6
- "type": "master",
7
- "text": "<p>This is introtext</p>"
8
- }
9
- ],
4
+ "text": {
5
+ "id": "Book_master",
6
+ "message": "<p>This is introtext</p>"
7
+ },
10
8
  "_links": {
11
9
  "panel": [
10
+ {
11
+ "name": "Details",
12
+ "label": "Details",
13
+ "resourcetype": "CasePropertiesPanel"
14
+ },
12
15
  {
13
16
  "name": "Creator",
14
17
  "label": "Creator",
@@ -27,12 +30,35 @@
27
30
  ],
28
31
  "taskgroup": [
29
32
  {
30
- "name": "Tasks",
31
- "label": "Tasks",
33
+ "name": "Contributors",
34
+ "label": "Contributors",
35
+ "resourcetype": "TaskGroup"
36
+ },
37
+ {
38
+ "name": "Delivery",
39
+ "label": "Delivery",
40
+ "resourcetype": "TaskGroup"
41
+ },
42
+ {
43
+ "name": "Book",
44
+ "label": "Book",
32
45
  "resourcetype": "TaskGroup"
33
46
  }
34
47
  ]
35
48
  },
49
+ "taskgroups": [
50
+ {
51
+ "name": "Book",
52
+ "label": "Book",
53
+ "actions": [
54
+ {
55
+ "name": "delete-book",
56
+ "label": "Delete book",
57
+ "type": "form"
58
+ }
59
+ ]
60
+ }
61
+ ],
36
62
  "metadata": {
37
63
  "_id": {
38
64
  "label": "Id",
@@ -42,44 +68,25 @@
42
68
  "attributes": [
43
69
  {
44
70
  "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
71
  "type": "string",
68
- "layouthint": ["state"],
69
- "options": [
70
- {
71
- "code": "Registered",
72
- "label": "Registered"
73
- }
74
- ]
72
+ "label": "Dossiernaam",
73
+ "layouthint": [
74
+ "title"
75
+ ],
76
+ "displaysize": 50,
77
+ "maxLength": 255
75
78
  }
76
79
  },
77
80
  {
78
81
  "Format": {
79
- "label": "Format",
80
82
  "type": "string",
83
+ "label": "Format",
84
+ "optionMode": "static",
81
85
  "multiplechoice": false,
82
- "layouthint": ["combobox"],
86
+ "layouthint": [
87
+ "combobox"
88
+ ],
89
+ "enumerated": true,
83
90
  "options": [
84
91
  {
85
92
  "code": "Hardcover",
@@ -102,46 +109,10 @@
102
109
  },
103
110
  {
104
111
  "ISBN10": {
105
- "label": "ISBN10",
106
- "type": "string",
107
- "displaysize": 50
108
- }
109
- },
110
- {
111
- "ISBN13": {
112
- "label": "ISBN13",
113
112
  "type": "string",
113
+ "label": "ISBN10",
114
114
  "displaysize": 50
115
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
116
  }
146
117
  ]
147
- }
118
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "_links": {
3
+ "self": {
4
+ "href": "/books/book/24"
5
+ },
6
+ "api_doc": {
7
+ "href": "/api-docs/v3/books/book/(case-id)"
8
+ },
9
+ "contributions": {
10
+ "href": "/contributions/books/book/(case-id)"
11
+ },
12
+ "Details": {
13
+ "href": "/books/book/24/details"
14
+ },
15
+ "Creator": {
16
+ "href": "/books/book/24/creator"
17
+ },
18
+ "Editions": {
19
+ "href": "/books/book/24/editions"
20
+ },
21
+ "Activities": {
22
+ "href": "/books/book/24/activities"
23
+ },
24
+ "taskgroup": [
25
+ {
26
+ "href": "/books/book/24/contributors-tasks",
27
+ "name": "Contributors"
28
+ },
29
+ {
30
+ "href": "/books/book/24/delivery-tasks",
31
+ "name": "Delivery"
32
+ }
33
+ ]
34
+ },
35
+ "taskgroups": [
36
+ {
37
+ "name": "Book",
38
+ "actions": [
39
+ {
40
+ "name": "delete-book",
41
+ "method": "POST",
42
+ "href": "/books/book/24/delete-book"
43
+ }
44
+ ]
45
+ }
46
+ ],
47
+ "_id": 24,
48
+ "CaseName": "The safety of objects",
49
+ "CaseType": "Book",
50
+ "Owner": "Arnold",
51
+ "Format": "Paperback",
52
+ "ISBN10": "1847087302",
53
+ "ISBN13": "9781847087300",
54
+ "Language": "EN",
55
+ "NumberOfPages": 176,
56
+ "State": "Registered"
57
+ }
@@ -1,13 +1,50 @@
1
1
  // @flow
2
2
  import BaseCollection from "../base/BaseCollection";
3
3
  import ActionCollection from "../actions/ActionCollection";
4
+ import ListItemModel from "../list/ListItemModel";
4
5
 
5
- import type ListItemModel from "../list/ListItemModel";
6
+ import ConfigurationException from "../../exceptions/ConfigurationException";
7
+
8
+ import type ListModel from "../list/ListModel";
6
9
 
7
10
  /**
8
11
  * Collection of list items
9
12
  */
10
13
  class ListItemCollection extends BaseCollection<ListItemModel> {
14
+ /**
15
+ * Create a list item collection from the given list
16
+ */
17
+ static createFromList(list: ListModel): ListItemCollection {
18
+ const _embedded = list.getData("_embedded");
19
+ if (_embedded != null) {
20
+ if (Array.isArray(_embedded)) {
21
+ throw new ConfigurationException(
22
+ `One record panel with multiple tables is not supported, place all types in one panel for the panel with key ${list.key}`
23
+ );
24
+ }
25
+
26
+ const dynamicschema = list.getData("dynamicschema");
27
+
28
+ const collection = _embedded.results.map((resultItem) => {
29
+ const [key] = Object.keys(resultItem);
30
+ const listitemData = resultItem[key];
31
+ listitemData.dynamicschema = dynamicschema;
32
+
33
+ const listitemContributions = list.contributions.results[key];
34
+
35
+ return ListItemModel.createFromListResult(
36
+ key,
37
+ listitemData,
38
+ listitemContributions
39
+ );
40
+ });
41
+
42
+ return new ListItemCollection(collection);
43
+ }
44
+
45
+ return new ListItemCollection();
46
+ }
47
+
11
48
  /**
12
49
  */
13
50
  get additionalDetailRoutePath(): string {
@@ -14,6 +14,21 @@ import type LinkCollection from "../links/LinkCollection";
14
14
  * List Item
15
15
  */
16
16
  export default class ListItemModel extends DetailModel {
17
+ /**
18
+ */
19
+ static createFromListResult(
20
+ key: string,
21
+ data: Object,
22
+ contributions: Object
23
+ ): ListItemModel {
24
+ const listitemInput = new ModularUIResponse();
25
+ listitemInput.key = key;
26
+ listitemInput.data = data;
27
+ listitemInput.contributions = contributions;
28
+
29
+ return new ListItemModel(listitemInput);
30
+ }
31
+
17
32
  /**
18
33
  */
19
34
  static createFromChoiceAttributeOption(
@@ -1,6 +1,4 @@
1
1
  // @flow
2
- import { ConfigurationException } from "../../exceptions";
3
-
4
2
  import ModularUIResponse from "../../modularui/ModularUIResponse";
5
3
 
6
4
  import ListItemCollection from "../list/ListItemCollection";
@@ -113,54 +111,12 @@ export default class ListModel extends ResourceModel {
113
111
  return "";
114
112
  }
115
113
 
116
- /**
117
- * Create a listitem collection from the data and contributions of a list
118
- */
119
- createListItemCollection(): ListItemCollection {
120
- const listitemCollection = new ListItemCollection();
121
-
122
- const _embedded = this.getData("_embedded");
123
- if (_embedded !== null) {
124
- if (Array.isArray(_embedded)) {
125
- throw new ConfigurationException(
126
- `One record panel with multiple tables is not supported, place all types in one panel for the panel with key ${this.key}`
127
- );
128
- }
129
-
130
- listitemCollection.collection = _embedded.results.map((result) =>
131
- this.createListItem(result)
132
- );
133
- }
134
-
135
- return listitemCollection;
136
- }
137
-
138
- /**
139
- * Create a ListItem
140
- */
141
- createListItem(resultItem: Object): ListItemModel {
142
- const [key] = Object.keys(resultItem);
143
- const listitemData = resultItem[key];
144
- const listitemContributions = this.contributions.results[key];
145
-
146
- if (this.data.dynamicschema) {
147
- listitemData.dynamicschema = this.data.dynamicschema;
148
- }
149
-
150
- const listitemModelInput = new ModularUIResponse();
151
- listitemModelInput.key = key;
152
- listitemModelInput.data = listitemData;
153
- listitemModelInput.contributions = listitemContributions;
154
-
155
- return new ListItemModel(listitemModelInput);
156
- }
157
-
158
114
  /**
159
115
  * Getting the results
160
116
  */
161
117
  get listItemCollection(): ListItemCollection {
162
118
  if (!this._listItemCollection) {
163
- this._listItemCollection = this.createListItemCollection();
119
+ this._listItemCollection = ListItemCollection.createFromList(this);
164
120
  }
165
121
 
166
122
  return this._listItemCollection;
@@ -0,0 +1,22 @@
1
+ import ListItemCollection from "../ListItemCollection";
2
+
3
+ import caselist from "../__mock__/caselist";
4
+
5
+ describe("listItemCollection spec", () => {
6
+ it("should be able to create an empty collection", () => {
7
+ const collection = new ListItemCollection();
8
+
9
+ expect(collection).toBeInstanceOf(ListItemCollection);
10
+ expect(collection.additionalDetailRoutePath).toBe("__NON_EXISTING_ROUTE__");
11
+ });
12
+
13
+ it("can create a ListItemCollection from list items", () => {
14
+ const collection = ListItemCollection.createFromList(caselist);
15
+ expect(collection).toBeInstanceOf(ListItemCollection);
16
+
17
+ expect(collection.additionalDetailRoutePath).toBe(
18
+ "(/books/books/34/contributors|/books/books/34/publishedbypublishinghouse|/books/books/35/contributors|/books/books/35/publishedbypublishinghouse|/books/books/36/contributors|/books/books/36/publishedbypublishinghouse|/books/books/37/contributors|/books/books/37/publishedbypublishinghouse|/books/books/38/contributors|/books/books/38/publishedbypublishinghouse|/books/books/39/contributors|/books/books/39/publishedbypublishinghouse|/books/books/42/contributors|/books/books/42/publishedbypublishinghouse|/books/books/45/contributors|/books/books/45/publishedbypublishinghouse|/books/books/46/contributors|/books/books/46/publishedbypublishinghouse|/books/books/47/contributors|/books/books/47/publishedbypublishinghouse)"
19
+ );
20
+ expect(collection.actionCollection).toHaveLength(42);
21
+ });
22
+ });
@@ -24,8 +24,6 @@ describe("listModel spec", () => {
24
24
  expect(list.headers).toHaveLength(0);
25
25
 
26
26
  expect(list.introtext).toBe("");
27
-
28
- expect(typeof list.createListItem).toBe("function");
29
27
  });
30
28
 
31
29
  it("should be able to create a list from a typical modular ui response", () => {
@@ -2,13 +2,14 @@ import GroupingPanelModel from "../GroupingPanelModel";
2
2
 
3
3
  import panelJson from "./groupingPanel.json";
4
4
  import panelContributionsJson from "./groupingPanelContributions.json";
5
- import CaseViewModel from "../../caseview/CaseViewModel";
6
5
 
7
6
  describe("groupingPanelModel", () => {
8
7
  it("should be able to create an empty GroupingPanelModel object", () => {
9
8
  const groupingPanel = new GroupingPanelModel();
10
9
 
11
10
  expect(groupingPanel).toBeInstanceOf(GroupingPanelModel);
11
+ expect(groupingPanel.type).toBe("GroupingPanel");
12
+ expect(groupingPanel.introtext).toBe("");
12
13
 
13
14
  expect(
14
15
  GroupingPanelModel.isApplicableModel({
@@ -51,10 +52,24 @@ describe("groupingPanelModel", () => {
51
52
  expect(groupingPanel.panelLinks).toHaveLength(1);
52
53
 
53
54
  expect(groupingPanel.hasIntroText()).toBe(true);
55
+
56
+ expect(groupingPanel.getInitialChildModelLinks()).toHaveLength(4);
57
+ });
58
+
59
+ it("can handle local taskgroups", () => {
60
+ const groupingPanel = new GroupingPanelModel({
61
+ key: "AskingQuestions",
62
+ data: panelJson,
63
+ contributions: panelContributionsJson,
64
+ });
65
+
66
+ expect(groupingPanel.hasTaskGroups()).toBe(true);
67
+ expect(groupingPanel.hasTasks()).toBe(true);
68
+ expect(groupingPanel.taskGroupCollection).toHaveLength(1);
54
69
  });
55
70
 
56
71
  it("should be able to handle different kind of introtext", () => {
57
- const groupingPanelOldStructure = new CaseViewModel({
72
+ const groupingPanelOldStructure = new GroupingPanelModel({
58
73
  key: "Book",
59
74
  data: panelJson,
60
75
  contributions: panelContributionsJson,
@@ -64,7 +79,7 @@ describe("groupingPanelModel", () => {
64
79
  "<p>This is introtext</p>"
65
80
  );
66
81
 
67
- const groupingPanelFromDataPlain = new CaseViewModel({
82
+ const groupingPanelFromDataPlain = new GroupingPanelModel({
68
83
  key: "Book",
69
84
  data: {
70
85
  _content: { text: { message: "<p>This is introtext</p>" } },
@@ -77,7 +92,7 @@ describe("groupingPanelModel", () => {
77
92
  "<p>This is introtext</p>"
78
93
  );
79
94
 
80
- const groupingPanelFromDataApplicationMessage = new CaseViewModel({
95
+ const groupingPanelFromDataApplicationMessage = new GroupingPanelModel({
81
96
  key: "Book",
82
97
  data: {
83
98
  ...panelJson,
@@ -94,29 +109,31 @@ describe("groupingPanelModel", () => {
94
109
  "<p>This is introtext</p>"
95
110
  );
96
111
 
97
- const groupingPanelFromNewContributionsRawTextMessage = new CaseViewModel({
98
- key: "Book",
99
- data: panelJson,
100
- contributions: {
101
- ...panelContributionsJson,
102
- text: {
103
- message: "<p>This is introtext</p>",
112
+ const groupingPanelFromNewContributionsRawTextMessage =
113
+ new GroupingPanelModel({
114
+ key: "Book",
115
+ data: panelJson,
116
+ contributions: {
117
+ ...panelContributionsJson,
118
+ text: {
119
+ message: "<p>This is introtext</p>",
120
+ },
104
121
  },
105
- },
106
- });
122
+ });
107
123
 
108
124
  expect(groupingPanelFromNewContributionsRawTextMessage.introtext).toBe(
109
125
  "<p>This is introtext</p>"
110
126
  );
111
127
 
112
- const groupingPanelFromNewContributionsSimpleMessage = new CaseViewModel({
113
- key: "Book",
114
- data: panelJson,
115
- contributions: {
116
- ...panelContributionsJson,
117
- text: "<p>This is introtext</p>",
118
- },
119
- });
128
+ const groupingPanelFromNewContributionsSimpleMessage =
129
+ new GroupingPanelModel({
130
+ key: "Book",
131
+ data: panelJson,
132
+ contributions: {
133
+ ...panelContributionsJson,
134
+ text: "<p>This is introtext</p>",
135
+ },
136
+ });
120
137
 
121
138
  expect(groupingPanelFromNewContributionsSimpleMessage.introtext).toBe(
122
139
  "<p>This is introtext</p>"
@@ -26,5 +26,24 @@
26
26
  "name": "TextFragments"
27
27
  }
28
28
  ]
29
- }
29
+ },
30
+ "taskgroups": [
31
+ {
32
+ "name": "taskgroup",
33
+ "actions": [
34
+ {
35
+ "name": "delivery",
36
+ "method": "POST",
37
+ "href": "/books/book/24/activities/delivery",
38
+ "fields": [
39
+ {
40
+ "name": "PrintAssignmentID",
41
+ "type": "number",
42
+ "value": null
43
+ }
44
+ ]
45
+ }
46
+ ]
47
+ }
48
+ ]
30
49
  }
@@ -42,5 +42,18 @@
42
42
  "resourcetype": "TaskGroup"
43
43
  }
44
44
  ]
45
- }
45
+ },
46
+ "taskgroups": [
47
+ {
48
+ "name": "taskgroup",
49
+ "label": "taskgroup",
50
+ "actions": [
51
+ {
52
+ "name": "delivery",
53
+ "label": "delivery",
54
+ "type": "form"
55
+ }
56
+ ]
57
+ }
58
+ ]
46
59
  }
@@ -1,4 +1,5 @@
1
1
  import ProcessStatusSettingsModel from "../ProcessStatusSettingsModel";
2
+ import { DateUtil } from "../../../utils";
2
3
 
3
4
  describe("processStatusSettingsModel", () => {
4
5
  it("should be able to create an empty ProcessStatusSettingsModel object", () => {
@@ -37,5 +38,15 @@ describe("processStatusSettingsModel", () => {
37
38
  expect(processStatus.isApplicable).toBeTruthy();
38
39
  expect(processStatus.isCompleted).toBeFalsy();
39
40
  expect(processStatus.isNeeded).toBeTruthy();
41
+
42
+ expect(processStatus.state).toBeNull();
43
+ expect(processStatus.canComplete).toBeNull();
44
+
45
+ expect(processStatus.referenceDate).toBe(DateUtil.now());
46
+
47
+ expect(processStatus.links).toHaveLength(1);
48
+ expect(processStatus.conceptLink.href.path).toBe(
49
+ "/concepts/Research grant/Business design/Constraints/Eligible for research grant.bixml/EligibleResearchGrant"
50
+ );
40
51
  });
41
52
  });
@@ -386,6 +386,20 @@ class ModularUIRequest {
386
386
  return Promise.resolve();
387
387
  }
388
388
 
389
+ /**
390
+ * Retrieve an object of key: link
391
+ */
392
+ dataLinksPerName(dataLinks: any): { [linkName: string]: any } {
393
+ if (Array.isArray(dataLinks)) {
394
+ const links = {};
395
+ for (const dataLink of dataLinks) {
396
+ links[dataLink.name] = dataLink;
397
+ }
398
+ return links;
399
+ }
400
+ return dataLinks;
401
+ }
402
+
389
403
  /**
390
404
  * Check if links are empty and hide them when hide-when-empty hint exists
391
405
  */
@@ -393,42 +407,44 @@ class ModularUIRequest {
393
407
  dataLinks: any,
394
408
  contributionLinks: any
395
409
  ): Promise<Object | Array<Object>> {
410
+ const linksPerName = this.dataLinksPerName(dataLinks);
411
+ const hideWhenEmptyLinks = contributionLinks.filter((contributionLink) =>
412
+ contributionLink.layouthint?.includes(HIDE_WHEN_EMPTY)
413
+ );
414
+
396
415
  const isHiddenListChecks = [];
397
- for (const contributionLink of contributionLinks) {
398
- if (contributionLink.layouthint?.includes(HIDE_WHEN_EMPTY)) {
399
- const dataLink = Array.isArray(dataLinks)
400
- ? dataLinks.find((link) => link.name === contributionLink.name)
401
- : dataLinks[contributionLink.name];
402
-
403
- if (dataLink?.href) {
404
- isHiddenListChecks.push(
405
- this.isHiddenList(contributionLink.name, dataLink.href)
406
- );
407
- }
416
+
417
+ for (const contributionLink of hideWhenEmptyLinks) {
418
+ const dataLink = linksPerName[contributionLink.name];
419
+ if (dataLink?.href) {
420
+ isHiddenListChecks.push(
421
+ this.isHiddenList(contributionLink.name, dataLink.href)
422
+ );
408
423
  }
409
424
  }
410
425
 
411
- return Promise.all(isHiddenListChecks).then((hiddenLinks) => {
412
- let newDataLinks;
413
- if (Array.isArray(dataLinks)) {
414
- newDataLinks = dataLinks.filter(
415
- (dataLink) => !hiddenLinks.includes(dataLink.name)
416
- );
417
- } else {
418
- newDataLinks = {};
426
+ return Promise.all(isHiddenListChecks).then(
427
+ (hiddenLinks: Array<string>) => {
428
+ if (Array.isArray(dataLinks)) {
429
+ return dataLinks.filter(
430
+ (dataLink) => !hiddenLinks.includes(dataLink.name)
431
+ );
432
+ }
433
+
434
+ const newDataLinks = {};
419
435
  for (const dataLinkKey in dataLinks) {
420
436
  if (!hiddenLinks.includes(dataLinkKey)) {
421
437
  newDataLinks[dataLinkKey] = dataLinks[dataLinkKey];
422
438
  }
423
439
  }
440
+ return newDataLinks;
424
441
  }
425
- return newDataLinks;
426
- });
442
+ );
427
443
  }
428
444
 
429
445
  /**
430
446
  */
431
- isHiddenList(name: string, href: string): Promise<?string> {
447
+ isHiddenList(name: string, href: string): Promise<string> {
432
448
  return universalFetch({
433
449
  ...this.options,
434
450
  url: `${BASE}${href}`,