@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.
- package/CHANGELOG.md +26 -0
- package/esm/constants/Settings.js +4 -1
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js +3 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +11 -1
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/hooks/useModularUIModel.js +36 -25
- package/esm/hooks/useModularUIModel.js.map +1 -1
- package/esm/models/actions/ActionCollection.js +2 -2
- package/esm/models/actions/ActionCollection.js.map +1 -1
- package/esm/models/actions/ActionModel.js +27 -8
- package/esm/models/actions/ActionModel.js.map +1 -1
- package/esm/models/application/ApplicationModel.js +1 -1
- package/esm/models/application/ApplicationModel.js.map +1 -1
- package/esm/models/base/ResourceModel.js +25 -3
- package/esm/models/base/ResourceModel.js.map +1 -1
- package/esm/models/caseview/CaseViewModel.js +2 -2
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.js +1 -0
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.js +2 -1
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/content/ContentIndexModel.js +2 -2
- package/esm/models/content/ContentIndexModel.js.map +1 -1
- package/esm/models/content/ContentLinkModel.js +2 -0
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/SectionModel.js +1 -0
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/detail/DetailModel.js +1 -1
- package/esm/models/detail/DetailModel.js.map +1 -1
- package/esm/models/error/ErrorResponse.js +2 -0
- package/esm/models/error/ErrorResponse.js.map +1 -1
- package/esm/models/form/FormModel.js +1 -1
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/href/Href.js +50 -3
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/href/ListHref.js +1 -1
- package/esm/models/href/ListHref.js.map +1 -1
- package/esm/models/links/LinkCollection.js +3 -1
- package/esm/models/links/LinkCollection.js.map +1 -1
- package/esm/models/links/LinkModel.js +10 -9
- package/esm/models/links/LinkModel.js.map +1 -1
- package/esm/models/list/ListItemModel.js +3 -1
- package/esm/models/list/ListItemModel.js.map +1 -1
- package/esm/models/list/ListModel.js +1 -1
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/panels/GroupingPanelModel.js +1 -1
- package/esm/models/panels/GroupingPanelModel.js.map +1 -1
- package/esm/models/tab/TabModel.js +2 -2
- package/esm/models/tab/TabModel.js.map +1 -1
- package/esm/models/taskgroup/TaskGroupModel.js +4 -2
- package/esm/models/taskgroup/TaskGroupModel.js.map +1 -1
- package/esm/modularui/Authenticate.js +2 -1
- package/esm/modularui/Authenticate.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +43 -7
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/modularui/ModularUIResponse.js +31 -0
- package/esm/modularui/ModularUIResponse.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +3 -1
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js +6 -0
- package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/esm/redux/_modularui/ModularUISelectors.js +11 -0
- package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/actions/Application.js +2 -0
- package/esm/redux/actions/Application.js.map +1 -1
- package/esm/redux/connectors/PanelRenderer.js +2 -0
- package/esm/redux/connectors/PanelRenderer.js.map +1 -1
- package/esm/utils/fetch/types.js.map +1 -1
- package/esm/utils/helpers/checkResource.js +2 -0
- package/esm/utils/helpers/checkResource.js.map +1 -1
- package/lib/constants/Settings.js +4 -1
- package/lib/constants/Settings.js.flow +2 -2
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/useForm.js +3 -1
- package/lib/hooks/useForm.js.flow +2 -0
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +11 -1
- package/lib/hooks/useModularUIBasic.js.flow +14 -0
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/hooks/useModularUIModel.js +36 -24
- package/lib/hooks/useModularUIModel.js.flow +58 -11
- package/lib/hooks/useModularUIModel.js.map +1 -1
- package/lib/models/actions/ActionCollection.js +2 -2
- package/lib/models/actions/ActionCollection.js.flow +14 -2
- package/lib/models/actions/ActionCollection.js.map +1 -1
- package/lib/models/actions/ActionModel.js +31 -12
- package/lib/models/actions/ActionModel.js.flow +38 -16
- package/lib/models/actions/ActionModel.js.map +1 -1
- package/lib/models/application/ApplicationModel.js +1 -1
- package/lib/models/application/ApplicationModel.js.flow +7 -1
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/models/base/ResourceModel.js +24 -3
- package/lib/models/base/ResourceModel.js.flow +35 -10
- package/lib/models/base/ResourceModel.js.map +1 -1
- package/lib/models/caseview/CaseViewModel.js +2 -2
- package/lib/models/caseview/CaseViewModel.js.flow +3 -1
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js +1 -0
- package/lib/models/concepts/ConceptLinkModel.js.flow +1 -0
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js +2 -1
- package/lib/models/concepts/SourceReferenceModel.js.flow +2 -1
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentIndexModel.js +2 -2
- package/lib/models/content/ContentIndexModel.js.flow +2 -2
- package/lib/models/content/ContentIndexModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.js +2 -0
- package/lib/models/content/ContentLinkModel.js.flow +2 -0
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/SectionModel.js +1 -0
- package/lib/models/content/SectionModel.js.flow +1 -0
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/detail/DetailModel.js +1 -1
- package/lib/models/detail/DetailModel.js.flow +2 -0
- package/lib/models/detail/DetailModel.js.map +1 -1
- package/lib/models/error/ErrorResponse.js +2 -0
- package/lib/models/error/ErrorResponse.js.flow +2 -0
- package/lib/models/error/ErrorResponse.js.map +1 -1
- package/lib/models/form/FormModel.js +1 -1
- package/lib/models/form/FormModel.js.flow +1 -1
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/href/Href.js +50 -3
- package/lib/models/href/Href.js.flow +58 -3
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/href/ListHref.js +1 -1
- package/lib/models/href/ListHref.js.flow +1 -1
- package/lib/models/href/ListHref.js.map +1 -1
- package/lib/models/links/LinkCollection.js +3 -1
- package/lib/models/links/LinkCollection.js.flow +8 -2
- package/lib/models/links/LinkCollection.js.map +1 -1
- package/lib/models/links/LinkModel.js +10 -9
- package/lib/models/links/LinkModel.js.flow +24 -16
- package/lib/models/links/LinkModel.js.map +1 -1
- package/lib/models/list/ListItemModel.js +3 -1
- package/lib/models/list/ListItemModel.js.flow +4 -0
- package/lib/models/list/ListItemModel.js.map +1 -1
- package/lib/models/list/ListModel.js +1 -1
- package/lib/models/list/ListModel.js.flow +6 -1
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/panels/GroupingPanelModel.js +1 -1
- package/lib/models/panels/GroupingPanelModel.js.flow +2 -0
- package/lib/models/panels/GroupingPanelModel.js.map +1 -1
- package/lib/models/tab/TabModel.js +2 -2
- package/lib/models/tab/TabModel.js.flow +4 -0
- package/lib/models/tab/TabModel.js.map +1 -1
- package/lib/models/taskgroup/TaskGroupModel.js +4 -2
- package/lib/models/taskgroup/TaskGroupModel.js.flow +6 -0
- package/lib/models/taskgroup/TaskGroupModel.js.map +1 -1
- package/lib/modularui/Authenticate.js +2 -1
- package/lib/modularui/Authenticate.js.flow +2 -1
- package/lib/modularui/Authenticate.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +43 -7
- package/lib/modularui/ModularUIRequest.js.flow +49 -8
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/modularui/ModularUIResponse.js +31 -0
- package/lib/modularui/ModularUIResponse.js.flow +35 -0
- package/lib/modularui/ModularUIResponse.js.map +1 -1
- package/lib/modularui/__tests__/CustomContextPath.spec.js.flow +61 -0
- package/lib/redux/_modularui/ModularUIActions.js +3 -1
- package/lib/redux/_modularui/ModularUIActions.js.flow +6 -1
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js +6 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.flow +10 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/lib/redux/_modularui/ModularUISelectors.js +13 -1
- package/lib/redux/_modularui/ModularUISelectors.js.flow +13 -0
- package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/lib/redux/_modularui/types.js.flow +2 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/actions/Application.js +2 -0
- package/lib/redux/actions/Application.js.flow +1 -0
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/connectors/PanelRenderer.js +2 -0
- package/lib/redux/connectors/PanelRenderer.js.flow +1 -0
- package/lib/redux/connectors/PanelRenderer.js.map +1 -1
- package/lib/utils/fetch/types.js.flow +2 -0
- package/lib/utils/fetch/types.js.map +1 -1
- package/lib/utils/helpers/checkResource.js +2 -0
- package/lib/utils/helpers/checkResource.js.flow +2 -0
- package/lib/utils/helpers/checkResource.js.map +1 -1
- package/package.json +1 -1
- package/src/constants/Settings.js +2 -2
- package/src/hooks/useForm.js +2 -0
- package/src/hooks/useModularUIBasic.js +14 -0
- package/src/hooks/useModularUIModel.js +58 -11
- package/src/models/actions/ActionCollection.js +14 -2
- package/src/models/actions/ActionModel.js +38 -16
- package/src/models/application/ApplicationModel.js +7 -1
- package/src/models/base/ResourceModel.js +35 -10
- package/src/models/caseview/CaseViewModel.js +3 -1
- package/src/models/concepts/ConceptLinkModel.js +1 -0
- package/src/models/concepts/SourceReferenceModel.js +2 -1
- package/src/models/content/ContentIndexModel.js +2 -2
- package/src/models/content/ContentLinkModel.js +2 -0
- package/src/models/content/SectionModel.js +1 -0
- package/src/models/detail/DetailModel.js +2 -0
- package/src/models/error/ErrorResponse.js +2 -0
- package/src/models/form/FormModel.js +1 -1
- package/src/models/href/Href.js +58 -3
- package/src/models/href/ListHref.js +1 -1
- package/src/models/links/LinkCollection.js +8 -2
- package/src/models/links/LinkModel.js +24 -16
- package/src/models/list/ListItemModel.js +4 -0
- package/src/models/list/ListModel.js +6 -1
- package/src/models/panels/GroupingPanelModel.js +2 -0
- package/src/models/tab/TabModel.js +4 -0
- package/src/models/taskgroup/TaskGroupModel.js +6 -0
- package/src/modularui/Authenticate.js +2 -1
- package/src/modularui/ModularUIRequest.js +49 -8
- package/src/modularui/ModularUIResponse.js +35 -0
- package/src/modularui/__tests__/CustomContextPath.spec.js +61 -0
- package/src/modularui/__tests__/contributions.json +312 -0
- package/src/modularui/__tests__/data.json +263 -0
- package/src/redux/_modularui/ModularUIActions.js +6 -1
- package/src/redux/_modularui/ModularUIMiddleware.js +10 -0
- package/src/redux/_modularui/ModularUISelectors.js +13 -0
- package/src/redux/_modularui/types.js +2 -0
- package/src/redux/actions/Application.js +1 -0
- package/src/redux/connectors/PanelRenderer.js +1 -0
- package/src/utils/fetch/types.js +2 -0
- package/src/utils/helpers/checkResource.js +2 -0
|
@@ -27,10 +27,15 @@ class LinkModel extends BaseModel {
|
|
|
27
27
|
/**
|
|
28
28
|
* Create a Link
|
|
29
29
|
*/
|
|
30
|
-
constructor(
|
|
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(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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(
|
|
57
|
-
|
|
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(
|
|
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
|
/**
|
|
@@ -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
|
}
|
|
@@ -46,7 +46,8 @@ class ModularUIRequest {
|
|
|
46
46
|
|
|
47
47
|
_progressEvent: ProgressEventHandler;
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
_origin: string = "";
|
|
50
|
+
_contextPath: string = getBasePath();
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
*/
|
|
@@ -60,8 +61,6 @@ class ModularUIRequest {
|
|
|
60
61
|
);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
this._basePath = getBasePath();
|
|
64
|
-
|
|
65
64
|
this.options = options;
|
|
66
65
|
|
|
67
66
|
this._response = new ModularUIResponse();
|
|
@@ -73,6 +72,18 @@ class ModularUIRequest {
|
|
|
73
72
|
// self links are missing the request parameters
|
|
74
73
|
this._response.parameters = this.href.parameters;
|
|
75
74
|
|
|
75
|
+
if (options.contextPath) {
|
|
76
|
+
this.contextPath = options.contextPath;
|
|
77
|
+
} else if (this.href.contextPath) {
|
|
78
|
+
this.contextPath = this.href.contextPath;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (options.origin) {
|
|
82
|
+
this.origin = options.origin;
|
|
83
|
+
} else if (this.href.origin) {
|
|
84
|
+
this.origin = this.href.origin;
|
|
85
|
+
}
|
|
86
|
+
|
|
76
87
|
if (options.targetModel) {
|
|
77
88
|
this.targetModel = options.targetModel;
|
|
78
89
|
}
|
|
@@ -84,6 +95,32 @@ class ModularUIRequest {
|
|
|
84
95
|
}
|
|
85
96
|
}
|
|
86
97
|
|
|
98
|
+
/**
|
|
99
|
+
*/
|
|
100
|
+
get origin(): string {
|
|
101
|
+
return this._origin;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
*/
|
|
106
|
+
set origin(origin: ?string) {
|
|
107
|
+
this._origin = origin ?? "";
|
|
108
|
+
this._response.origin = origin ?? "";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
*/
|
|
113
|
+
get contextPath(): string {
|
|
114
|
+
return this._contextPath;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
*/
|
|
119
|
+
set contextPath(contextPath: ?string) {
|
|
120
|
+
this._contextPath = contextPath ?? getBasePath();
|
|
121
|
+
this._response.contextPath = contextPath ?? getBasePath();
|
|
122
|
+
}
|
|
123
|
+
|
|
87
124
|
/**
|
|
88
125
|
*/
|
|
89
126
|
get contributionsHref(): string {
|
|
@@ -284,7 +321,11 @@ class ModularUIRequest {
|
|
|
284
321
|
handleDataError(error: Object): void {
|
|
285
322
|
if (error.properties) {
|
|
286
323
|
const errorMessage = error.properties?.message ?? "Error in data";
|
|
287
|
-
throw new ModularUIError(
|
|
324
|
+
throw new ModularUIError(
|
|
325
|
+
errorMessage,
|
|
326
|
+
error,
|
|
327
|
+
this.href.absolutepath.toString(),
|
|
328
|
+
);
|
|
288
329
|
}
|
|
289
330
|
|
|
290
331
|
throw new IllegalArgumentException(error);
|
|
@@ -332,7 +373,7 @@ class ModularUIRequest {
|
|
|
332
373
|
}
|
|
333
374
|
|
|
334
375
|
return universalFetch({
|
|
335
|
-
url: `${this.
|
|
376
|
+
url: `${this.origin}${this.contextPath}${this.contributionsHref}`,
|
|
336
377
|
cache: true,
|
|
337
378
|
locale: this.options.locale,
|
|
338
379
|
});
|
|
@@ -343,7 +384,7 @@ class ModularUIRequest {
|
|
|
343
384
|
fetchDataService(): Promise<any> {
|
|
344
385
|
return universalFetch({
|
|
345
386
|
...this.requestOptions,
|
|
346
|
-
url: `${this.
|
|
387
|
+
url: `${this.origin}${this.contextPath}${this.href.path}`,
|
|
347
388
|
params: this.href.getQuerystringForModularUI(),
|
|
348
389
|
locale: this.options.locale,
|
|
349
390
|
onProgress: this.onProgress,
|
|
@@ -520,7 +561,7 @@ class ModularUIRequest {
|
|
|
520
561
|
|
|
521
562
|
return universalFetch({
|
|
522
563
|
...this.requestOptions,
|
|
523
|
-
url: `${this.
|
|
564
|
+
url: `${this.origin}${this.contextPath}${href}`,
|
|
524
565
|
})
|
|
525
566
|
.then((response: Object) => {
|
|
526
567
|
if (isPlainObject(response)) {
|
|
@@ -588,7 +629,7 @@ class ModularUIRequest {
|
|
|
588
629
|
const validationHref = this.href.setParameter("commit", "false");
|
|
589
630
|
return universalFetch({
|
|
590
631
|
...this.requestOptions,
|
|
591
|
-
url: `${this.
|
|
632
|
+
url: `${this.origin}${this.contextPath}${this.href.path}`,
|
|
592
633
|
params: validationHref.getQuerystringForModularUI(),
|
|
593
634
|
data: this.getDynamicValidationData(model),
|
|
594
635
|
}).then((data) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { has } from "../utils/helpers/objects";
|
|
3
|
+
import { getBasePath } from "../constants";
|
|
3
4
|
|
|
4
5
|
import type Parameter from "../models/parameter/Parameter";
|
|
5
6
|
|
|
@@ -11,6 +12,8 @@ class ModularUIResponse {
|
|
|
11
12
|
_contributions: Object;
|
|
12
13
|
_locale: string = "en";
|
|
13
14
|
_parameters: Array<Parameter> = [];
|
|
15
|
+
_contextPath: string = getBasePath();
|
|
16
|
+
_origin: string = "";
|
|
14
17
|
|
|
15
18
|
/**
|
|
16
19
|
*/
|
|
@@ -18,6 +21,8 @@ class ModularUIResponse {
|
|
|
18
21
|
key: string,
|
|
19
22
|
data: Object,
|
|
20
23
|
contributions: Object,
|
|
24
|
+
origin?: string,
|
|
25
|
+
contextPath?: string,
|
|
21
26
|
}): ModularUIResponse {
|
|
22
27
|
const response = new ModularUIResponse();
|
|
23
28
|
|
|
@@ -28,11 +33,37 @@ class ModularUIResponse {
|
|
|
28
33
|
response.key = input.key ?? contributionsKey;
|
|
29
34
|
response.data = input.data?.[dataKey];
|
|
30
35
|
response.contributions = input.contributions?.[contributionsKey];
|
|
36
|
+
response.origin = input.origin;
|
|
37
|
+
response.contextPath = input.contextPath;
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
return response;
|
|
34
41
|
}
|
|
35
42
|
|
|
43
|
+
/**
|
|
44
|
+
*/
|
|
45
|
+
set origin(origin: ?string) {
|
|
46
|
+
this._origin = origin ?? "";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*/
|
|
51
|
+
get origin(): string {
|
|
52
|
+
return this._origin;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*/
|
|
57
|
+
set contextPath(contextPath: ?string) {
|
|
58
|
+
this._contextPath = contextPath ?? getBasePath();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
*/
|
|
63
|
+
get contextPath(): string {
|
|
64
|
+
return this._contextPath;
|
|
65
|
+
}
|
|
66
|
+
|
|
36
67
|
/**
|
|
37
68
|
*/
|
|
38
69
|
set locale(locale: string) {
|
|
@@ -100,9 +131,13 @@ class ModularUIResponse {
|
|
|
100
131
|
locale: string,
|
|
101
132
|
data: Object,
|
|
102
133
|
contributions: Object,
|
|
134
|
+
origin?: string,
|
|
135
|
+
contextPath?: string,
|
|
103
136
|
}): ModularUIResponse {
|
|
104
137
|
const modelData = new ModularUIResponse();
|
|
105
138
|
|
|
139
|
+
modelData.origin = data.origin;
|
|
140
|
+
modelData.contextPath = data.contextPath;
|
|
106
141
|
modelData.locale = data.locale;
|
|
107
142
|
modelData.key = data.key;
|
|
108
143
|
modelData.data = data.data;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import xhrMock from "xhr-mock";
|
|
2
|
+
|
|
3
|
+
import ModularUIRequest from "../ModularUIRequest";
|
|
4
|
+
|
|
5
|
+
import dataJSON from "./data.json";
|
|
6
|
+
import contributionsJSON from "./contributions.json";
|
|
7
|
+
|
|
8
|
+
import ApplicationModel from "../../models/application/ApplicationModel";
|
|
9
|
+
|
|
10
|
+
const JSON_TYPE = "application/json";
|
|
11
|
+
|
|
12
|
+
describe("modularUIRequest", () => {
|
|
13
|
+
// replace the real XHR object with the mock XHR object before each test
|
|
14
|
+
// eslint-disable-next-line jest/no-hooks
|
|
15
|
+
beforeEach(() => xhrMock.setup());
|
|
16
|
+
|
|
17
|
+
// put the real XHR object back and clear the mocks after each test
|
|
18
|
+
// eslint-disable-next-line jest/no-hooks
|
|
19
|
+
afterEach(() => xhrMock.teardown());
|
|
20
|
+
|
|
21
|
+
it("creates a model from a response with custom origin and contextPath", async () => {
|
|
22
|
+
expect.assertions(12);
|
|
23
|
+
xhrMock.get("http://www.example.com/custom-path/", (req, res) => {
|
|
24
|
+
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
25
|
+
expect(req.header("Content-Type")).toBe(JSON_TYPE);
|
|
26
|
+
expect(req.header("accept-language")).toBe("en");
|
|
27
|
+
|
|
28
|
+
return res.status(200).body(dataJSON);
|
|
29
|
+
});
|
|
30
|
+
xhrMock.get(
|
|
31
|
+
"http://www.example.com/custom-path/contributions/",
|
|
32
|
+
(req, res) => {
|
|
33
|
+
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
34
|
+
expect(req.header("Content-Type")).toBe(JSON_TYPE);
|
|
35
|
+
expect(req.header("accept-language")).toBe("en");
|
|
36
|
+
|
|
37
|
+
return res.status(200).body(contributionsJSON);
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const request = new ModularUIRequest("/", {
|
|
42
|
+
origin: "http://www.example.com",
|
|
43
|
+
contextPath: "/custom-path",
|
|
44
|
+
childmodels: false,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const model = await request.fetch();
|
|
48
|
+
expect(model).toBeInstanceOf(ApplicationModel);
|
|
49
|
+
expect(model.origin).toBe("http://www.example.com");
|
|
50
|
+
expect(model.contextPath).toBe("/custom-path");
|
|
51
|
+
expect(model.selfhref.absolutehref).toBe(
|
|
52
|
+
"http://www.example.com/custom-path/",
|
|
53
|
+
);
|
|
54
|
+
expect(model.modelcatalog.href.absolutehref).toBe(
|
|
55
|
+
"http://www.example.com/custom-path/modelcatalog",
|
|
56
|
+
);
|
|
57
|
+
expect(model.tabs.first.href.absolutehref).toBe(
|
|
58
|
+
"http://www.example.com/custom-path/books",
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
});
|