@beinformed/ui 1.55.2 → 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 (224) hide show
  1. package/CHANGELOG.md +26 -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/ModularUISelectors.js +11 -0
  65. package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
  66. package/esm/redux/_modularui/types.js.map +1 -1
  67. package/esm/redux/actions/Application.js +2 -0
  68. package/esm/redux/actions/Application.js.map +1 -1
  69. package/esm/redux/connectors/PanelRenderer.js +2 -0
  70. package/esm/redux/connectors/PanelRenderer.js.map +1 -1
  71. package/esm/utils/fetch/types.js.map +1 -1
  72. package/esm/utils/helpers/checkResource.js +2 -0
  73. package/esm/utils/helpers/checkResource.js.map +1 -1
  74. package/lib/constants/Settings.js +4 -1
  75. package/lib/constants/Settings.js.flow +2 -2
  76. package/lib/constants/Settings.js.map +1 -1
  77. package/lib/hooks/useForm.js +3 -1
  78. package/lib/hooks/useForm.js.flow +2 -0
  79. package/lib/hooks/useForm.js.map +1 -1
  80. package/lib/hooks/useModularUIBasic.js +11 -1
  81. package/lib/hooks/useModularUIBasic.js.flow +14 -0
  82. package/lib/hooks/useModularUIBasic.js.map +1 -1
  83. package/lib/hooks/useModularUIModel.js +36 -24
  84. package/lib/hooks/useModularUIModel.js.flow +58 -11
  85. package/lib/hooks/useModularUIModel.js.map +1 -1
  86. package/lib/models/actions/ActionCollection.js +2 -2
  87. package/lib/models/actions/ActionCollection.js.flow +14 -2
  88. package/lib/models/actions/ActionCollection.js.map +1 -1
  89. package/lib/models/actions/ActionModel.js +31 -12
  90. package/lib/models/actions/ActionModel.js.flow +38 -16
  91. package/lib/models/actions/ActionModel.js.map +1 -1
  92. package/lib/models/application/ApplicationModel.js +1 -1
  93. package/lib/models/application/ApplicationModel.js.flow +7 -1
  94. package/lib/models/application/ApplicationModel.js.map +1 -1
  95. package/lib/models/base/ResourceModel.js +24 -3
  96. package/lib/models/base/ResourceModel.js.flow +35 -10
  97. package/lib/models/base/ResourceModel.js.map +1 -1
  98. package/lib/models/caseview/CaseViewModel.js +2 -2
  99. package/lib/models/caseview/CaseViewModel.js.flow +3 -1
  100. package/lib/models/caseview/CaseViewModel.js.map +1 -1
  101. package/lib/models/concepts/ConceptLinkModel.js +1 -0
  102. package/lib/models/concepts/ConceptLinkModel.js.flow +1 -0
  103. package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
  104. package/lib/models/concepts/SourceReferenceModel.js +2 -1
  105. package/lib/models/concepts/SourceReferenceModel.js.flow +2 -1
  106. package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
  107. package/lib/models/content/ContentIndexModel.js +2 -2
  108. package/lib/models/content/ContentIndexModel.js.flow +2 -2
  109. package/lib/models/content/ContentIndexModel.js.map +1 -1
  110. package/lib/models/content/ContentLinkModel.js +2 -0
  111. package/lib/models/content/ContentLinkModel.js.flow +2 -0
  112. package/lib/models/content/ContentLinkModel.js.map +1 -1
  113. package/lib/models/content/SectionModel.js +1 -0
  114. package/lib/models/content/SectionModel.js.flow +1 -0
  115. package/lib/models/content/SectionModel.js.map +1 -1
  116. package/lib/models/detail/DetailModel.js +1 -1
  117. package/lib/models/detail/DetailModel.js.flow +2 -0
  118. package/lib/models/detail/DetailModel.js.map +1 -1
  119. package/lib/models/error/ErrorResponse.js +2 -0
  120. package/lib/models/error/ErrorResponse.js.flow +2 -0
  121. package/lib/models/error/ErrorResponse.js.map +1 -1
  122. package/lib/models/form/FormModel.js +1 -1
  123. package/lib/models/form/FormModel.js.flow +1 -1
  124. package/lib/models/form/FormModel.js.map +1 -1
  125. package/lib/models/href/Href.js +50 -3
  126. package/lib/models/href/Href.js.flow +58 -3
  127. package/lib/models/href/Href.js.map +1 -1
  128. package/lib/models/href/ListHref.js +1 -1
  129. package/lib/models/href/ListHref.js.flow +1 -1
  130. package/lib/models/href/ListHref.js.map +1 -1
  131. package/lib/models/links/LinkCollection.js +3 -1
  132. package/lib/models/links/LinkCollection.js.flow +8 -2
  133. package/lib/models/links/LinkCollection.js.map +1 -1
  134. package/lib/models/links/LinkModel.js +10 -9
  135. package/lib/models/links/LinkModel.js.flow +24 -16
  136. package/lib/models/links/LinkModel.js.map +1 -1
  137. package/lib/models/list/ListItemModel.js +3 -1
  138. package/lib/models/list/ListItemModel.js.flow +4 -0
  139. package/lib/models/list/ListItemModel.js.map +1 -1
  140. package/lib/models/list/ListModel.js +1 -1
  141. package/lib/models/list/ListModel.js.flow +6 -1
  142. package/lib/models/list/ListModel.js.map +1 -1
  143. package/lib/models/panels/GroupingPanelModel.js +1 -1
  144. package/lib/models/panels/GroupingPanelModel.js.flow +2 -0
  145. package/lib/models/panels/GroupingPanelModel.js.map +1 -1
  146. package/lib/models/tab/TabModel.js +2 -2
  147. package/lib/models/tab/TabModel.js.flow +4 -0
  148. package/lib/models/tab/TabModel.js.map +1 -1
  149. package/lib/models/taskgroup/TaskGroupModel.js +4 -2
  150. package/lib/models/taskgroup/TaskGroupModel.js.flow +6 -0
  151. package/lib/models/taskgroup/TaskGroupModel.js.map +1 -1
  152. package/lib/modularui/Authenticate.js +2 -1
  153. package/lib/modularui/Authenticate.js.flow +2 -1
  154. package/lib/modularui/Authenticate.js.map +1 -1
  155. package/lib/modularui/ModularUIRequest.js +43 -7
  156. package/lib/modularui/ModularUIRequest.js.flow +49 -8
  157. package/lib/modularui/ModularUIRequest.js.map +1 -1
  158. package/lib/modularui/ModularUIResponse.js +31 -0
  159. package/lib/modularui/ModularUIResponse.js.flow +35 -0
  160. package/lib/modularui/ModularUIResponse.js.map +1 -1
  161. package/lib/modularui/__tests__/CustomContextPath.spec.js.flow +61 -0
  162. package/lib/redux/_modularui/ModularUIActions.js +3 -1
  163. package/lib/redux/_modularui/ModularUIActions.js.flow +6 -1
  164. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  165. package/lib/redux/_modularui/ModularUIMiddleware.js +6 -0
  166. package/lib/redux/_modularui/ModularUIMiddleware.js.flow +10 -0
  167. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  168. package/lib/redux/_modularui/ModularUISelectors.js +13 -1
  169. package/lib/redux/_modularui/ModularUISelectors.js.flow +13 -0
  170. package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
  171. package/lib/redux/_modularui/types.js.flow +2 -0
  172. package/lib/redux/_modularui/types.js.map +1 -1
  173. package/lib/redux/actions/Application.js +2 -0
  174. package/lib/redux/actions/Application.js.flow +1 -0
  175. package/lib/redux/actions/Application.js.map +1 -1
  176. package/lib/redux/connectors/PanelRenderer.js +2 -0
  177. package/lib/redux/connectors/PanelRenderer.js.flow +1 -0
  178. package/lib/redux/connectors/PanelRenderer.js.map +1 -1
  179. package/lib/utils/fetch/types.js.flow +2 -0
  180. package/lib/utils/fetch/types.js.map +1 -1
  181. package/lib/utils/helpers/checkResource.js +2 -0
  182. package/lib/utils/helpers/checkResource.js.flow +2 -0
  183. package/lib/utils/helpers/checkResource.js.map +1 -1
  184. package/package.json +1 -1
  185. package/src/constants/Settings.js +2 -2
  186. package/src/hooks/useForm.js +2 -0
  187. package/src/hooks/useModularUIBasic.js +14 -0
  188. package/src/hooks/useModularUIModel.js +58 -11
  189. package/src/models/actions/ActionCollection.js +14 -2
  190. package/src/models/actions/ActionModel.js +38 -16
  191. package/src/models/application/ApplicationModel.js +7 -1
  192. package/src/models/base/ResourceModel.js +35 -10
  193. package/src/models/caseview/CaseViewModel.js +3 -1
  194. package/src/models/concepts/ConceptLinkModel.js +1 -0
  195. package/src/models/concepts/SourceReferenceModel.js +2 -1
  196. package/src/models/content/ContentIndexModel.js +2 -2
  197. package/src/models/content/ContentLinkModel.js +2 -0
  198. package/src/models/content/SectionModel.js +1 -0
  199. package/src/models/detail/DetailModel.js +2 -0
  200. package/src/models/error/ErrorResponse.js +2 -0
  201. package/src/models/form/FormModel.js +1 -1
  202. package/src/models/href/Href.js +58 -3
  203. package/src/models/href/ListHref.js +1 -1
  204. package/src/models/links/LinkCollection.js +8 -2
  205. package/src/models/links/LinkModel.js +24 -16
  206. package/src/models/list/ListItemModel.js +4 -0
  207. package/src/models/list/ListModel.js +6 -1
  208. package/src/models/panels/GroupingPanelModel.js +2 -0
  209. package/src/models/tab/TabModel.js +4 -0
  210. package/src/models/taskgroup/TaskGroupModel.js +6 -0
  211. package/src/modularui/Authenticate.js +2 -1
  212. package/src/modularui/ModularUIRequest.js +49 -8
  213. package/src/modularui/ModularUIResponse.js +35 -0
  214. package/src/modularui/__tests__/CustomContextPath.spec.js +61 -0
  215. package/src/modularui/__tests__/contributions.json +312 -0
  216. package/src/modularui/__tests__/data.json +263 -0
  217. package/src/redux/_modularui/ModularUIActions.js +6 -1
  218. package/src/redux/_modularui/ModularUIMiddleware.js +10 -0
  219. package/src/redux/_modularui/ModularUISelectors.js +13 -0
  220. package/src/redux/_modularui/types.js +2 -0
  221. package/src/redux/actions/Application.js +1 -0
  222. package/src/redux/connectors/PanelRenderer.js +1 -0
  223. package/src/utils/fetch/types.js +2 -0
  224. package/src/utils/helpers/checkResource.js +2 -0
@@ -11,103 +11,150 @@ import UserProfileModel from "../models/user/UserProfileModel";
11
11
 
12
12
  import { useModularUIBasic } from "./useModularUIBasic";
13
13
 
14
+ type HookOptions = {
15
+ origin?: string,
16
+ contextPath?: string,
17
+ };
18
+
14
19
  /**
15
20
  * Load application
16
21
  */
17
- export const useApplication = (): ApplicationModel | null =>
22
+ export const useApplication = (
23
+ options?: HookOptions,
24
+ ): ApplicationModel | null =>
18
25
  useModularUIBasic("application", "/", {
19
26
  expectedModels: ["Application"],
20
27
  targetModel: ApplicationModel,
28
+ ...options,
21
29
  });
22
30
 
23
31
  /**
24
32
  * Load a tab by href
25
33
  */
26
- export const useTab = (href: string): TabModel | null =>
34
+ export const useTab = (href: string, options?: HookOptions): TabModel | null =>
27
35
  useModularUIBasic("tab", href, {
28
36
  expectedModels: ["Tab"],
29
37
  targetModel: TabModel,
38
+ ...options,
30
39
  });
31
40
 
32
41
  /**
33
42
  * Load caseview by href
34
43
  */
35
- export const useCaseView = (href: string): CaseViewModel | null =>
44
+ export const useCaseView = (
45
+ href: string,
46
+ options?: HookOptions,
47
+ ): CaseViewModel | null =>
36
48
  useModularUIBasic("caseview", href, {
37
49
  expectedModels: ["CaseView"],
38
50
  targetModel: CaseViewModel,
51
+ ...options,
39
52
  });
40
53
 
41
54
  /**
42
55
  */
43
56
  export const usePanel = (
44
57
  href: string,
58
+ options?: HookOptions,
45
59
  ): ListModel | GroupingPanelModel | DetailModel | null =>
46
60
  useModularUIBasic("panel", href, {
47
61
  expectedModels: ["List", "GroupingPanel", "Detail"],
62
+ ...options,
48
63
  });
49
64
 
50
65
  /**
51
66
  */
52
- export const useList = (href: string): ListModel | null =>
67
+ export const useList = (
68
+ href: string,
69
+ options?: HookOptions,
70
+ ): ListModel | null =>
53
71
  useModularUIBasic("list", href, {
54
72
  expectedModels: ["List"],
55
73
  targetModel: ListModel,
74
+ ...options,
56
75
  });
57
76
 
58
77
  /**
59
78
  */
60
- export const useListOrDetail = (href: string): ListModel | DetailModel | null =>
79
+ export const useListOrDetail = (
80
+ href: string,
81
+ options?: HookOptions,
82
+ ): ListModel | DetailModel | null =>
61
83
  useModularUIBasic("list", href, {
62
84
  expectedModels: ["List", "Detail"],
63
85
  targetModel: [ListModel, DetailModel],
86
+ ...options,
64
87
  });
65
88
 
66
89
  /**
67
90
  */
68
- export const useListDetail = (href: string): ListDetailModel | null =>
91
+ export const useListDetail = (
92
+ href: string,
93
+ options?: HookOptions,
94
+ ): ListDetailModel | null =>
69
95
  useModularUIBasic("listdetail", href, {
70
96
  expectedModels: ["ListDetail"],
71
97
  targetModel: ListDetailModel,
72
98
  forceTargetModel: true,
99
+ ...options,
73
100
  });
74
101
 
75
102
  /**
76
103
  */
77
- export const useGroupingPanel = (href: string): GroupingPanelModel | null =>
104
+ export const useGroupingPanel = (
105
+ href: string,
106
+ options?: HookOptions,
107
+ ): GroupingPanelModel | null =>
78
108
  useModularUIBasic("groupingpanel", href, {
79
109
  expectedModels: ["GroupingPanel"],
80
110
  targetModel: GroupingPanelModel,
111
+ ...options,
81
112
  });
82
113
 
83
114
  /**
84
115
  */
85
- export const useDetailPanel = (href: string): DetailModel | null =>
116
+ export const useDetailPanel = (
117
+ href: string,
118
+ options?: HookOptions,
119
+ ): DetailModel | null =>
86
120
  useModularUIBasic("detailpanel", href, {
87
121
  expectedModels: ["Detail"],
88
122
  targetModel: DetailModel,
123
+ ...options,
89
124
  });
90
125
 
91
126
  /**
92
127
  */
93
- export const useQuicksearch = (href: string): CaseSearchModel | null =>
128
+ export const useQuicksearch = (
129
+ href: string,
130
+ options?: HookOptions,
131
+ ): CaseSearchModel | null =>
94
132
  useModularUIBasic("quicksearch", href, {
95
133
  expectedModels: ["CaseSearch"],
96
134
  targetModel: CaseSearchModel,
135
+ ...options,
97
136
  });
98
137
 
99
138
  /**
100
139
  */
101
- export const useSearch = (href: string): CaseSearchModel | null =>
140
+ export const useSearch = (
141
+ href: string,
142
+ options?: HookOptions,
143
+ ): CaseSearchModel | null =>
102
144
  useModularUIBasic("search", href, {
103
145
  expectedModels: ["CaseSearch"],
104
146
  targetModel: CaseSearchModel,
147
+ ...options,
105
148
  });
106
149
 
107
150
  /**
108
151
  */
109
- export const useUserProfile = (href: string): UserProfileModel | null =>
152
+ export const useUserProfile = (
153
+ href: string,
154
+ options?: HookOptions,
155
+ ): UserProfileModel | null =>
110
156
  useModularUIBasic("userprofile", href, {
111
157
  expectedModels: ["UserProfile"],
112
158
  targetModel: UserProfileModel,
159
+ ...options,
113
160
  });
@@ -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