@beinformed/ui 1.56.0 → 1.57.0-contextpath.0

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 (218) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/esm/constants/Settings.js +4 -1
  3. package/esm/constants/Settings.js.map +1 -1
  4. package/esm/hooks/useForm.js +3 -1
  5. package/esm/hooks/useForm.js.map +1 -1
  6. package/esm/hooks/useModularUIBasic.js +11 -1
  7. package/esm/hooks/useModularUIBasic.js.map +1 -1
  8. package/esm/hooks/useModularUIModel.js +36 -25
  9. package/esm/hooks/useModularUIModel.js.map +1 -1
  10. package/esm/models/actions/ActionCollection.js +2 -2
  11. package/esm/models/actions/ActionCollection.js.map +1 -1
  12. package/esm/models/actions/ActionModel.js +27 -8
  13. package/esm/models/actions/ActionModel.js.map +1 -1
  14. package/esm/models/application/ApplicationModel.js +1 -1
  15. package/esm/models/application/ApplicationModel.js.map +1 -1
  16. package/esm/models/base/ResourceModel.js +25 -3
  17. package/esm/models/base/ResourceModel.js.map +1 -1
  18. package/esm/models/caseview/CaseViewModel.js +2 -2
  19. package/esm/models/caseview/CaseViewModel.js.map +1 -1
  20. package/esm/models/concepts/ConceptLinkModel.js +1 -0
  21. package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
  22. package/esm/models/concepts/SourceReferenceModel.js +2 -1
  23. package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
  24. package/esm/models/content/ContentIndexModel.js +2 -2
  25. package/esm/models/content/ContentIndexModel.js.map +1 -1
  26. package/esm/models/content/ContentLinkModel.js +2 -0
  27. package/esm/models/content/ContentLinkModel.js.map +1 -1
  28. package/esm/models/content/SectionModel.js +1 -0
  29. package/esm/models/content/SectionModel.js.map +1 -1
  30. package/esm/models/detail/DetailModel.js +1 -1
  31. package/esm/models/detail/DetailModel.js.map +1 -1
  32. package/esm/models/error/ErrorResponse.js +2 -0
  33. package/esm/models/error/ErrorResponse.js.map +1 -1
  34. package/esm/models/form/FormModel.js +1 -1
  35. package/esm/models/form/FormModel.js.map +1 -1
  36. package/esm/models/href/Href.js +50 -3
  37. package/esm/models/href/Href.js.map +1 -1
  38. package/esm/models/href/ListHref.js +1 -1
  39. package/esm/models/href/ListHref.js.map +1 -1
  40. package/esm/models/links/LinkCollection.js +3 -1
  41. package/esm/models/links/LinkCollection.js.map +1 -1
  42. package/esm/models/links/LinkModel.js +10 -9
  43. package/esm/models/links/LinkModel.js.map +1 -1
  44. package/esm/models/list/ListItemModel.js +3 -1
  45. package/esm/models/list/ListItemModel.js.map +1 -1
  46. package/esm/models/list/ListModel.js +1 -1
  47. package/esm/models/list/ListModel.js.map +1 -1
  48. package/esm/models/panels/GroupingPanelModel.js +1 -1
  49. package/esm/models/panels/GroupingPanelModel.js.map +1 -1
  50. package/esm/models/tab/TabModel.js +2 -2
  51. package/esm/models/tab/TabModel.js.map +1 -1
  52. package/esm/models/taskgroup/TaskGroupModel.js +4 -2
  53. package/esm/models/taskgroup/TaskGroupModel.js.map +1 -1
  54. package/esm/modularui/Authenticate.js +2 -1
  55. package/esm/modularui/Authenticate.js.map +1 -1
  56. package/esm/modularui/ModularUIRequest.js +43 -7
  57. package/esm/modularui/ModularUIRequest.js.map +1 -1
  58. package/esm/modularui/ModularUIResponse.js +31 -0
  59. package/esm/modularui/ModularUIResponse.js.map +1 -1
  60. package/esm/redux/_modularui/ModularUIActions.js +3 -1
  61. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  62. package/esm/redux/_modularui/ModularUIMiddleware.js +6 -0
  63. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  64. package/esm/redux/_modularui/types.js.map +1 -1
  65. package/esm/redux/actions/Application.js +2 -0
  66. package/esm/redux/actions/Application.js.map +1 -1
  67. package/esm/redux/connectors/PanelRenderer.js +2 -0
  68. package/esm/redux/connectors/PanelRenderer.js.map +1 -1
  69. package/esm/utils/fetch/types.js.map +1 -1
  70. package/esm/utils/helpers/checkResource.js +2 -0
  71. package/esm/utils/helpers/checkResource.js.map +1 -1
  72. package/lib/constants/Settings.js +4 -1
  73. package/lib/constants/Settings.js.flow +2 -2
  74. package/lib/constants/Settings.js.map +1 -1
  75. package/lib/hooks/useForm.js +3 -1
  76. package/lib/hooks/useForm.js.flow +2 -0
  77. package/lib/hooks/useForm.js.map +1 -1
  78. package/lib/hooks/useModularUIBasic.js +11 -1
  79. package/lib/hooks/useModularUIBasic.js.flow +14 -0
  80. package/lib/hooks/useModularUIBasic.js.map +1 -1
  81. package/lib/hooks/useModularUIModel.js +36 -24
  82. package/lib/hooks/useModularUIModel.js.flow +58 -11
  83. package/lib/hooks/useModularUIModel.js.map +1 -1
  84. package/lib/models/actions/ActionCollection.js +2 -2
  85. package/lib/models/actions/ActionCollection.js.flow +14 -2
  86. package/lib/models/actions/ActionCollection.js.map +1 -1
  87. package/lib/models/actions/ActionModel.js +31 -12
  88. package/lib/models/actions/ActionModel.js.flow +38 -16
  89. package/lib/models/actions/ActionModel.js.map +1 -1
  90. package/lib/models/application/ApplicationModel.js +1 -1
  91. package/lib/models/application/ApplicationModel.js.flow +7 -1
  92. package/lib/models/application/ApplicationModel.js.map +1 -1
  93. package/lib/models/base/ResourceModel.js +24 -3
  94. package/lib/models/base/ResourceModel.js.flow +35 -10
  95. package/lib/models/base/ResourceModel.js.map +1 -1
  96. package/lib/models/caseview/CaseViewModel.js +2 -2
  97. package/lib/models/caseview/CaseViewModel.js.flow +3 -1
  98. package/lib/models/caseview/CaseViewModel.js.map +1 -1
  99. package/lib/models/concepts/ConceptLinkModel.js +1 -0
  100. package/lib/models/concepts/ConceptLinkModel.js.flow +1 -0
  101. package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
  102. package/lib/models/concepts/SourceReferenceModel.js +2 -1
  103. package/lib/models/concepts/SourceReferenceModel.js.flow +2 -1
  104. package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
  105. package/lib/models/content/ContentIndexModel.js +2 -2
  106. package/lib/models/content/ContentIndexModel.js.flow +2 -2
  107. package/lib/models/content/ContentIndexModel.js.map +1 -1
  108. package/lib/models/content/ContentLinkModel.js +2 -0
  109. package/lib/models/content/ContentLinkModel.js.flow +2 -0
  110. package/lib/models/content/ContentLinkModel.js.map +1 -1
  111. package/lib/models/content/SectionModel.js +1 -0
  112. package/lib/models/content/SectionModel.js.flow +1 -0
  113. package/lib/models/content/SectionModel.js.map +1 -1
  114. package/lib/models/detail/DetailModel.js +1 -1
  115. package/lib/models/detail/DetailModel.js.flow +2 -0
  116. package/lib/models/detail/DetailModel.js.map +1 -1
  117. package/lib/models/error/ErrorResponse.js +2 -0
  118. package/lib/models/error/ErrorResponse.js.flow +2 -0
  119. package/lib/models/error/ErrorResponse.js.map +1 -1
  120. package/lib/models/form/FormModel.js +1 -1
  121. package/lib/models/form/FormModel.js.flow +1 -1
  122. package/lib/models/form/FormModel.js.map +1 -1
  123. package/lib/models/href/Href.js +50 -3
  124. package/lib/models/href/Href.js.flow +58 -3
  125. package/lib/models/href/Href.js.map +1 -1
  126. package/lib/models/href/ListHref.js +1 -1
  127. package/lib/models/href/ListHref.js.flow +1 -1
  128. package/lib/models/href/ListHref.js.map +1 -1
  129. package/lib/models/links/LinkCollection.js +3 -1
  130. package/lib/models/links/LinkCollection.js.flow +8 -2
  131. package/lib/models/links/LinkCollection.js.map +1 -1
  132. package/lib/models/links/LinkModel.js +10 -9
  133. package/lib/models/links/LinkModel.js.flow +24 -16
  134. package/lib/models/links/LinkModel.js.map +1 -1
  135. package/lib/models/list/ListItemModel.js +3 -1
  136. package/lib/models/list/ListItemModel.js.flow +4 -0
  137. package/lib/models/list/ListItemModel.js.map +1 -1
  138. package/lib/models/list/ListModel.js +1 -1
  139. package/lib/models/list/ListModel.js.flow +6 -1
  140. package/lib/models/list/ListModel.js.map +1 -1
  141. package/lib/models/panels/GroupingPanelModel.js +1 -1
  142. package/lib/models/panels/GroupingPanelModel.js.flow +2 -0
  143. package/lib/models/panels/GroupingPanelModel.js.map +1 -1
  144. package/lib/models/tab/TabModel.js +2 -2
  145. package/lib/models/tab/TabModel.js.flow +4 -0
  146. package/lib/models/tab/TabModel.js.map +1 -1
  147. package/lib/models/taskgroup/TaskGroupModel.js +4 -2
  148. package/lib/models/taskgroup/TaskGroupModel.js.flow +6 -0
  149. package/lib/models/taskgroup/TaskGroupModel.js.map +1 -1
  150. package/lib/modularui/Authenticate.js +2 -1
  151. package/lib/modularui/Authenticate.js.flow +2 -1
  152. package/lib/modularui/Authenticate.js.map +1 -1
  153. package/lib/modularui/ModularUIRequest.js +43 -7
  154. package/lib/modularui/ModularUIRequest.js.flow +49 -8
  155. package/lib/modularui/ModularUIRequest.js.map +1 -1
  156. package/lib/modularui/ModularUIResponse.js +31 -0
  157. package/lib/modularui/ModularUIResponse.js.flow +35 -0
  158. package/lib/modularui/ModularUIResponse.js.map +1 -1
  159. package/lib/modularui/__tests__/CustomContextPath.spec.js.flow +61 -0
  160. package/lib/redux/_modularui/ModularUIActions.js +3 -1
  161. package/lib/redux/_modularui/ModularUIActions.js.flow +6 -1
  162. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  163. package/lib/redux/_modularui/ModularUIMiddleware.js +6 -0
  164. package/lib/redux/_modularui/ModularUIMiddleware.js.flow +10 -0
  165. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  166. package/lib/redux/_modularui/types.js.flow +2 -0
  167. package/lib/redux/_modularui/types.js.map +1 -1
  168. package/lib/redux/actions/Application.js +2 -0
  169. package/lib/redux/actions/Application.js.flow +1 -0
  170. package/lib/redux/actions/Application.js.map +1 -1
  171. package/lib/redux/connectors/PanelRenderer.js +2 -0
  172. package/lib/redux/connectors/PanelRenderer.js.flow +1 -0
  173. package/lib/redux/connectors/PanelRenderer.js.map +1 -1
  174. package/lib/utils/fetch/types.js.flow +2 -0
  175. package/lib/utils/fetch/types.js.map +1 -1
  176. package/lib/utils/helpers/checkResource.js +2 -0
  177. package/lib/utils/helpers/checkResource.js.flow +2 -0
  178. package/lib/utils/helpers/checkResource.js.map +1 -1
  179. package/package.json +1 -1
  180. package/src/constants/Settings.js +2 -2
  181. package/src/hooks/useForm.js +2 -0
  182. package/src/hooks/useModularUIBasic.js +14 -0
  183. package/src/hooks/useModularUIModel.js +58 -11
  184. package/src/models/actions/ActionCollection.js +14 -2
  185. package/src/models/actions/ActionModel.js +38 -16
  186. package/src/models/application/ApplicationModel.js +7 -1
  187. package/src/models/base/ResourceModel.js +35 -10
  188. package/src/models/caseview/CaseViewModel.js +3 -1
  189. package/src/models/concepts/ConceptLinkModel.js +1 -0
  190. package/src/models/concepts/SourceReferenceModel.js +2 -1
  191. package/src/models/content/ContentIndexModel.js +2 -2
  192. package/src/models/content/ContentLinkModel.js +2 -0
  193. package/src/models/content/SectionModel.js +1 -0
  194. package/src/models/detail/DetailModel.js +2 -0
  195. package/src/models/error/ErrorResponse.js +2 -0
  196. package/src/models/form/FormModel.js +1 -1
  197. package/src/models/href/Href.js +58 -3
  198. package/src/models/href/ListHref.js +1 -1
  199. package/src/models/links/LinkCollection.js +8 -2
  200. package/src/models/links/LinkModel.js +24 -16
  201. package/src/models/list/ListItemModel.js +4 -0
  202. package/src/models/list/ListModel.js +6 -1
  203. package/src/models/panels/GroupingPanelModel.js +2 -0
  204. package/src/models/tab/TabModel.js +4 -0
  205. package/src/models/taskgroup/TaskGroupModel.js +6 -0
  206. package/src/modularui/Authenticate.js +2 -1
  207. package/src/modularui/ModularUIRequest.js +49 -8
  208. package/src/modularui/ModularUIResponse.js +35 -0
  209. package/src/modularui/__tests__/CustomContextPath.spec.js +61 -0
  210. package/src/modularui/__tests__/contributions.json +312 -0
  211. package/src/modularui/__tests__/data.json +263 -0
  212. package/src/redux/_modularui/ModularUIActions.js +6 -1
  213. package/src/redux/_modularui/ModularUIMiddleware.js +10 -0
  214. package/src/redux/_modularui/types.js +2 -0
  215. package/src/redux/actions/Application.js +1 -0
  216. package/src/redux/connectors/PanelRenderer.js +1 -0
  217. package/src/utils/fetch/types.js +2 -0
  218. package/src/utils/helpers/checkResource.js +2 -0
@@ -6,7 +6,12 @@ import ActionModel from "./ActionModel";
6
6
  * Collection of actions
7
7
  */
8
8
  export default class ActionCollection extends BaseCollection<ActionModel> {
9
- constructor(actions?: Object, actionsContributions?: Object) {
9
+ constructor(
10
+ actions?: Object,
11
+ actionsContributions?: Object,
12
+ origin?: string,
13
+ contextPath?: string,
14
+ ) {
10
15
  super();
11
16
 
12
17
  // no actions gives an empty collection
@@ -22,7 +27,14 @@ export default class ActionCollection extends BaseCollection<ActionModel> {
22
27
  );
23
28
 
24
29
  if (actionContribution) {
25
- actionModels.push(new ActionModel(actionData, actionContribution));
30
+ actionModels.push(
31
+ new ActionModel(
32
+ actionData,
33
+ actionContribution,
34
+ origin,
35
+ contextPath,
36
+ ),
37
+ );
26
38
  }
27
39
  }
28
40
 
@@ -6,12 +6,13 @@ import AttributeCollection from "../attributes/AttributeCollection";
6
6
  import BaseModel from "../base/BaseModel";
7
7
  import Href from "../href/Href";
8
8
 
9
- import { HTTP_METHODS } from "../../constants/Constants";
10
9
  import {
10
+ getBasePath,
11
+ HTTP_METHODS,
11
12
  CREATE_ACTION,
12
13
  UPDATE_ACTION,
13
14
  DELETE_ACTION,
14
- } from "../../constants/LayoutHints";
15
+ } from "../../constants";
15
16
 
16
17
  import type { AttributeType } from "../types";
17
18
 
@@ -22,14 +23,23 @@ export default class ActionModel extends BaseModel {
22
23
  _fieldCollection: AttributeCollection;
23
24
  _href: Href;
24
25
  _icon: string;
25
-
26
- constructor(data: Object, contributions: Object) {
26
+ _origin: ?string;
27
+ _contextPath: ?string;
28
+
29
+ constructor(
30
+ data: Object,
31
+ contributions: Object,
32
+ origin?: string,
33
+ contextPath?: string,
34
+ ) {
27
35
  super(data, contributions);
28
36
 
29
37
  this._fieldCollection = new AttributeCollection(
30
38
  this.data.fields,
31
39
  this.contributions.fields,
32
40
  );
41
+ this._origin = origin;
42
+ this._contextPath = contextPath;
33
43
  }
34
44
 
35
45
  /**
@@ -39,18 +49,12 @@ export default class ActionModel extends BaseModel {
39
49
  href: string,
40
50
  label: string,
41
51
  type: string = "form",
52
+ origin?: string,
53
+ contextPath?: string,
42
54
  ): ActionModel {
43
- return new ActionModel(
44
- {
45
- name,
46
- href,
47
- },
48
- {
49
- name,
50
- label: label || name,
51
- type,
52
- },
53
- );
55
+ const data = { name, href };
56
+ const contributions = { name, label: label ?? name, type };
57
+ return new ActionModel(data, contributions, origin, contextPath);
54
58
  }
55
59
 
56
60
  /**
@@ -59,12 +63,30 @@ export default class ActionModel extends BaseModel {
59
63
  return this.data.href == null;
60
64
  }
61
65
 
66
+ /**
67
+ */
68
+ get origin(): string {
69
+ return this._origin ?? "";
70
+ }
71
+
72
+ /**
73
+ */
74
+ get contextPath(): string {
75
+ return this._contextPath ?? getBasePath();
76
+ }
77
+
62
78
  /**
63
79
  * retrieve href of action
64
80
  */
65
81
  get selfhref(): Href {
66
82
  return (
67
- this._href || new Href(`${this.data.href}?${this.querystring}`, "Form")
83
+ this._href ??
84
+ new Href(
85
+ `${this.data.href}?${this.querystring}`,
86
+ "Form",
87
+ this.origin,
88
+ this.contextPath,
89
+ )
68
90
  );
69
91
  }
70
92
 
@@ -102,7 +102,13 @@ export default class ApplicationModel extends ResourceModel {
102
102
  * Get modelcatalog link
103
103
  */
104
104
  get modelcatalog(): LinkModel {
105
- return LinkModel.create("modelcatalog", "/modelcatalog", "Model catalog");
105
+ return LinkModel.create(
106
+ "modelcatalog",
107
+ "/modelcatalog",
108
+ "Model catalog",
109
+ this.origin,
110
+ this.contextPath,
111
+ );
106
112
  }
107
113
 
108
114
  /**
@@ -13,6 +13,7 @@ import type LinkModel from "../links/LinkModel";
13
13
  import type Href from "../href/Href";
14
14
  import type { ModularUIModel, IModelWithChildModels } from "../types";
15
15
  import type ErrorResponse from "../error/ErrorResponse";
16
+ import { getBasePath } from "../../constants";
16
17
 
17
18
  /**
18
19
  * Base model, this the foundation for models that represent modular ui services, e.g. application, tab, caseview, etc
@@ -23,6 +24,8 @@ class ResourceModel extends BaseModel implements IModelWithChildModels {
23
24
  _childModels: Array<ModularUIModel>;
24
25
  _links: LinkCollection;
25
26
  _lastServerUpdate: number;
27
+ _origin: string = "";
28
+ _contextPath: string = getBasePath();
26
29
 
27
30
  /**
28
31
  * constructor
@@ -32,10 +35,12 @@ class ResourceModel extends BaseModel implements IModelWithChildModels {
32
35
 
33
36
  this._key = modularuiResponse.key;
34
37
  this._locale = modularuiResponse.locale;
35
-
36
38
  this._childModels = [];
37
39
 
38
40
  this._lastServerUpdate = Date.now();
41
+
42
+ this._origin = modularuiResponse.origin;
43
+ this._contextPath = modularuiResponse.contextPath;
39
44
  }
40
45
 
41
46
  /**
@@ -109,21 +114,39 @@ class ResourceModel extends BaseModel implements IModelWithChildModels {
109
114
  return this.getContribution("label", "");
110
115
  }
111
116
 
117
+ /**
118
+ */
119
+ get origin(): string {
120
+ return this._origin;
121
+ }
122
+
123
+ /**
124
+ */
125
+ get contextPath(): string {
126
+ return this._contextPath;
127
+ }
128
+
112
129
  /**
113
130
  * Getting the links of the resource
114
131
  */
115
132
  get links(): LinkCollection {
116
133
  if (!this._links) {
117
- this._links = new LinkCollection(
118
- Array.isArray(this.data._links)
119
- ? this.data._links[0]
120
- : this.data._links,
121
- {
122
- self: {
123
- resourcetype: this.resourcetype,
124
- },
125
- ...this.contributions._links,
134
+ const linksData = Array.isArray(this.data._links)
135
+ ? this.data._links[0]
136
+ : this.data._links;
137
+
138
+ const linksContrubtions = {
139
+ self: {
140
+ resourcetype: this.resourcetype,
126
141
  },
142
+ ...this.contributions._links,
143
+ };
144
+
145
+ this._links = new LinkCollection(
146
+ linksData,
147
+ linksContrubtions,
148
+ this.origin,
149
+ this.contextPath,
127
150
  );
128
151
  }
129
152
  return this._links;
@@ -231,6 +254,8 @@ class ResourceModel extends BaseModel implements IModelWithChildModels {
231
254
  childModels: this._childModels.map<ModularUIModel>(
232
255
  (childModel: ModularUIModel) => childModel.dehydrate(),
233
256
  ),
257
+ origin: this._origin,
258
+ contextPath: this._contextPath,
234
259
  };
235
260
  }
236
261
  }
@@ -134,7 +134,7 @@ export default class CaseViewModel extends DetailModel {
134
134
  throw new IllegalStateException("No self href available");
135
135
  }
136
136
 
137
- return new Href(selfLink.href);
137
+ return selfLink.href;
138
138
  }
139
139
 
140
140
  /**
@@ -160,6 +160,8 @@ export default class CaseViewModel extends DetailModel {
160
160
  taskgroup.name,
161
161
  taskgroup,
162
162
  taskgroupContributions,
163
+ this.origin,
164
+ this.contextPath,
163
165
  );
164
166
  });
165
167
  }
@@ -156,6 +156,7 @@ export default class ConceptLinkModel
156
156
  /**
157
157
  */
158
158
  asLinkModel(): LinkModel {
159
+ // TODO SBO: origin and contextpath
159
160
  const link = LinkModel.create(this.key, this.selfhref.href, this.label);
160
161
  link.href = this.selfhref;
161
162
 
@@ -37,7 +37,8 @@ class SourceReferenceModel {
37
37
  /**
38
38
  */
39
39
  get selfhref(): Href {
40
- return new Href(this._sourceReference._links.self.href);
40
+ // TODO SBO: origin and context
41
+ return new Href(this._sourceReference._links.self.href, "SourceReference");
41
42
  }
42
43
 
43
44
  /**
@@ -73,7 +73,7 @@ export default class ContentIndexModel extends ResourceModel {
73
73
  * Getting the self link of this list
74
74
  */
75
75
  get selfhref(): Href {
76
- const href = new Href(this.selflink.href);
76
+ const href = this.selflink.href;
77
77
 
78
78
  this.filterCollection.forEach((filter) => {
79
79
  filter.params.forEach((param) => {
@@ -150,6 +150,6 @@ export default class ContentIndexModel extends ResourceModel {
150
150
  )[0].code;
151
151
  }
152
152
 
153
- return new Href(this.selfhref.path).addParameter("index", firstChar);
153
+ return new Href(this.selfhref).addParameter("index", firstChar);
154
154
  }
155
155
  }
@@ -102,6 +102,7 @@ export default class ContentLinkModel
102
102
  /**
103
103
  */
104
104
  createEncodedHref(): Href {
105
+ // TODO SBO: origin and context
105
106
  const startURI = "/content/";
106
107
  const selfHref = new Href(this.data._links.self.href);
107
108
  const href = selfHref.path;
@@ -139,6 +140,7 @@ export default class ContentLinkModel
139
140
  */
140
141
  get links(): LinkCollection {
141
142
  if (!this._links) {
143
+ // TODO SBO: origin and context
142
144
  this._links = new LinkCollection(
143
145
  Array.isArray(this.data._links)
144
146
  ? this.data._links[0]
@@ -32,6 +32,7 @@ class SectionModel extends BaseModel {
32
32
  */
33
33
  get selflink(): LinkModel {
34
34
  if (!this._selflink) {
35
+ // TODO SBO: origin and context
35
36
  this._selflink = new LinkModel(this.data._links?.self);
36
37
  }
37
38
  return this._selflink;
@@ -171,6 +171,8 @@ export default class DetailModel extends ResourceModel {
171
171
  this._actionCollection = new ActionCollection(
172
172
  this.data.actions,
173
173
  this.contributions.actions,
174
+ this.origin,
175
+ this.contextPath,
174
176
  );
175
177
  }
176
178
 
@@ -161,6 +161,7 @@ export default class ErrorResponse {
161
161
  * Return response error redirect href
162
162
  */
163
163
  get redirectHref(): Href {
164
+ // TODO SBO: origin and context
164
165
  if (this.response.redirect?.href) {
165
166
  return new Href(this.response.redirect?.href);
166
167
  }
@@ -290,6 +291,7 @@ export default class ErrorResponse {
290
291
  * Get response url
291
292
  */
292
293
  get changePasswordHref(): ?Href {
294
+ // TODO SBO: origin and context
293
295
  return this.properties.redirect ? new Href(this.properties.redirect) : null;
294
296
  }
295
297
 
@@ -605,7 +605,7 @@ class FormModel extends ResourceModel {
605
605
  */
606
606
  get successRedirect(): Href | null {
607
607
  return this.isFinished && this.success
608
- ? new Href(this.success.redirect)
608
+ ? new Href(this.success.redirect, "", this.origin, this.contextPath)
609
609
  : null;
610
610
  }
611
611
 
@@ -29,11 +29,18 @@ class Href {
29
29
  _method: $Keys<typeof HTTP_METHODS> = HTTP_METHODS.GET;
30
30
  _state: any = null;
31
31
  _referenceHash: ?number;
32
+ _origin: string = "";
33
+ _contextPath: string = getBasePath();
32
34
 
33
35
  /**
34
36
  * Create a Href
35
37
  */
36
- constructor(href?: HrefInput, resourcetype?: string) {
38
+ constructor(
39
+ href?: HrefInput,
40
+ resourcetype?: string,
41
+ origin?: string,
42
+ contextPath?: string,
43
+ ) {
37
44
  this.resourcetype = resourcetype ?? "";
38
45
 
39
46
  if (href instanceof Href) {
@@ -43,12 +50,22 @@ class Href {
43
50
  } else if (typeof href === "object") {
44
51
  this.setFromLocationOrObject(href);
45
52
  }
53
+
54
+ if (typeof origin === "string") {
55
+ this.origin = origin;
56
+ }
57
+
58
+ if (typeof contextPath === "string") {
59
+ this.contextPath = contextPath;
60
+ }
46
61
  }
47
62
 
48
63
  /**
49
64
  * Set parameters from Href model input
50
65
  */
51
66
  setFromHref(href: Href) {
67
+ this.origin = href.origin;
68
+ this.contextPath = href.contextPath;
52
69
  this.path = href.path;
53
70
  this.parameters = href.parameters;
54
71
  this.hash = href.hash;
@@ -58,6 +75,15 @@ class Href {
58
75
  /**
59
76
  */
60
77
  setFromLocationOrObject(href: LocationShape | HrefObject) {
78
+ // $FlowFixMe
79
+ if (typeof href._origin === "string") {
80
+ this.origin = href._origin;
81
+ }
82
+ // $FlowFixMe
83
+ if (typeof href._contextPath === "string") {
84
+ this.contextPath = href._contextPath;
85
+ }
86
+
61
87
  if (typeof href["pathname"] === "string") {
62
88
  this.path = href.pathname;
63
89
  } else if (typeof href._path === "string") {
@@ -303,7 +329,36 @@ class Href {
303
329
  * Retrieve the path
304
330
  */
305
331
  get path(): string {
306
- return this._path || "";
332
+ return this._path ?? "";
333
+ }
334
+
335
+ /**
336
+ * Retrieve the origin (e.g. http://example.com:18080)<br>
337
+ * Empty when the default must be used
338
+ */
339
+ get origin(): string {
340
+ return this._origin ?? "";
341
+ }
342
+
343
+ /**
344
+ * Set the origin (e.g. http://example.com:18080)
345
+ */
346
+ set origin(origin: string) {
347
+ this._origin = origin;
348
+ }
349
+
350
+ /**
351
+ * Get the context path
352
+ */
353
+ get contextPath(): string {
354
+ return this._contextPath;
355
+ }
356
+
357
+ /**
358
+ * Set the context path if different from default
359
+ */
360
+ set contextPath(contextPath: string) {
361
+ this._contextPath = contextPath;
307
362
  }
308
363
 
309
364
  /**
@@ -362,7 +417,7 @@ class Href {
362
417
  return this.path;
363
418
  }
364
419
 
365
- return getBasePath() + this.path;
420
+ return this.origin + this.contextPath + this.path;
366
421
  }
367
422
 
368
423
  /**
@@ -22,7 +22,7 @@ export default class ListHref extends Href {
22
22
  * Create a ListHref
23
23
  */
24
24
  constructor(href?: HrefInput, list?: ListModel, isPrefixed: boolean = true) {
25
- super(href);
25
+ super(href, undefined);
26
26
 
27
27
  this._isPrefixed = isPrefixed;
28
28
 
@@ -14,12 +14,18 @@ export default class LinkCollection extends BaseCollection<LinkModel> {
14
14
  /**
15
15
  * Constructs the link collection
16
16
  */
17
- constructor(linkData: Object = {}, linkContributions: Object = {}) {
17
+ constructor(
18
+ linkData: Object = {},
19
+ linkContributions: Object = {},
20
+ origin?: string,
21
+ contextPath?: string,
22
+ ) {
18
23
  super();
19
24
 
20
25
  // There can be links in data and/or contributions (e.g. concept link is available through contributions)
21
26
  this.collection = normalizeLinkJSON(linkData, linkContributions).map(
22
- ({ data, contributions }) => new LinkModel(data, contributions),
27
+ ({ data, contributions }) =>
28
+ new LinkModel(data, contributions, origin, contextPath),
23
29
  );
24
30
  }
25
31
 
@@ -27,10 +27,15 @@ class LinkModel extends BaseModel {
27
27
  /**
28
28
  * Create a Link
29
29
  */
30
- constructor(data: Object, contributions: Object) {
30
+ constructor(
31
+ data: Object,
32
+ contributions: Object,
33
+ origin?: string,
34
+ contextPath?: string,
35
+ ) {
31
36
  super(data, contributions);
32
37
 
33
- this.createHref();
38
+ this.createHref(origin, contextPath);
34
39
 
35
40
  this._isCacheable = false;
36
41
  }
@@ -38,24 +43,27 @@ class LinkModel extends BaseModel {
38
43
  /**
39
44
  * Create a simple Link Model
40
45
  */
41
- static create(name: string, href: string | Href, label: string): LinkModel {
42
- return new LinkModel(
43
- {
44
- name,
45
- href,
46
- },
47
- {
48
- label,
49
- },
50
- );
46
+ static create(
47
+ name: string,
48
+ href: string | Href,
49
+ label: string,
50
+ origin?: string,
51
+ contextPath?: string,
52
+ ): LinkModel {
53
+ const data = { name, href };
54
+ const contributions = { label };
55
+ return new LinkModel(data, contributions, origin, contextPath);
51
56
  }
52
57
 
53
58
  /**
54
59
  */
55
- createHref() {
56
- const href = new Href(this.data.href);
57
- href.resourcetype = this.resourcetype;
58
-
60
+ createHref(origin?: string, contextPath?: string) {
61
+ const href = new Href(
62
+ this.data.href,
63
+ this.resourcetype,
64
+ origin,
65
+ contextPath,
66
+ );
59
67
  this.handleInitialFilters(href);
60
68
 
61
69
  this.href = href;
@@ -20,11 +20,15 @@ export default class ListItemModel extends DetailModel {
20
20
  key: string,
21
21
  data: Object,
22
22
  contributions: Object,
23
+ origin?: string,
24
+ contextPath?: string,
23
25
  ): ListItemModel {
24
26
  const listitemInput = new ModularUIResponse();
25
27
  listitemInput.key = key;
26
28
  listitemInput.data = data;
27
29
  listitemInput.contributions = contributions;
30
+ listitemInput.origin = origin;
31
+ listitemInput.contextPath = contextPath;
28
32
 
29
33
  return new ListItemModel(listitemInput);
30
34
  }
@@ -313,7 +313,12 @@ export default class ListModel extends ResourceModel {
313
313
  /**
314
314
  */
315
315
  setActionCollection(): ActionCollection {
316
- return new ActionCollection(this.data.actions, this.contributions.actions);
316
+ return new ActionCollection(
317
+ this.data.actions,
318
+ this.contributions.actions,
319
+ this.origin,
320
+ this.contextPath,
321
+ );
317
322
  }
318
323
 
319
324
  /**
@@ -129,6 +129,8 @@ export default class GroupingPanelModel extends ResourceModel {
129
129
  taskgroup.name,
130
130
  taskgroup,
131
131
  taskgroupContributions,
132
+ this.origin,
133
+ this.contextPath,
132
134
  );
133
135
  });
134
136
  }
@@ -26,6 +26,8 @@ export default class TabModel extends ResourceModel {
26
26
  this._actionCollection = new ActionCollection(
27
27
  this.data.actions,
28
28
  this.contributions.actions,
29
+ this.origin,
30
+ this.contextPath,
29
31
  );
30
32
  }
31
33
 
@@ -93,6 +95,8 @@ export default class TabModel extends ResourceModel {
93
95
  taskgroup.name,
94
96
  taskgroup,
95
97
  taskgroupContributions,
98
+ this.origin,
99
+ this.contextPath,
96
100
  );
97
101
  }
98
102
 
@@ -19,6 +19,8 @@ export default class TaskGroupModel extends ResourceModel {
19
19
  this._actionCollection = new ActionCollection(
20
20
  this.data.actions,
21
21
  this.contributions.actions,
22
+ this.origin,
23
+ this.contextPath,
22
24
  );
23
25
 
24
26
  const selfHref = this.links.getLinkByKey("self")
@@ -36,11 +38,15 @@ export default class TaskGroupModel extends ResourceModel {
36
38
  key: string,
37
39
  data: Object,
38
40
  contributions: Object,
41
+ origin?: string,
42
+ contextPath?: string,
39
43
  ): TaskGroupModel {
40
44
  const taskgroup = new ModularUIResponse();
41
45
  taskgroup.key = key;
42
46
  taskgroup.data = data;
43
47
  taskgroup.contributions = contributions;
48
+ taskgroup.origin = origin;
49
+ taskgroup.contextPath = contextPath;
44
50
 
45
51
  return new TaskGroupModel(taskgroup);
46
52
  }
@@ -109,8 +109,9 @@ class Authenticate {
109
109
  getFormLoginUrl(): string {
110
110
  switch (this.authenticationType) {
111
111
  case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
112
+ return `${getBasePath()}${loginPath("DirectBasicAuthClient")}`;
112
113
  case INTERNAL_LOGIN_TYPE.PAC4J_FORM:
113
- return `${getBasePath()}${loginPath()}`;
114
+ return `${getBasePath()}${loginPath("FormClient")}`;
114
115
  default:
115
116
  return `${getBasePath()}/j_security_check`;
116
117
  }