@beinformed/ui 1.57.0-contextpath.0 → 1.57.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 +63 -0
- package/esm/constants/Settings.js +10 -2
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useModularUI.js +24 -18
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +52 -41
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +1 -8
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/ConceptIndexModel.js +1 -1
- package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.js +8 -9
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/ConceptTypeDetailModel.js +3 -20
- package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceCollection.js +3 -1
- package/esm/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.js +9 -3
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/content/ContentLinkModel.js +10 -4
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/SectionModel.js +10 -6
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/error/ErrorResponse.js +20 -5
- package/esm/models/error/ErrorResponse.js.map +1 -1
- package/esm/models/href/Href.js +21 -4
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/list/ListItemCollection.js +1 -1
- package/esm/models/list/ListItemCollection.js.map +1 -1
- package/esm/modularui/CaptchaRequest.js +12 -3
- package/esm/modularui/CaptchaRequest.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +1 -1
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/modularui/UploadRequest.js +7 -3
- package/esm/modularui/UploadRequest.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +11 -9
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js +4 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +2 -1
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/esm/redux/_modularui/ModularUISelectors.js +7 -6
- package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/actions/Application.js +11 -6
- package/esm/redux/actions/Application.js.map +1 -1
- package/esm/redux/connectors/PanelRenderer.js +0 -2
- package/esm/redux/connectors/PanelRenderer.js.map +1 -1
- package/esm/utils/helpers/checkResource.js +0 -2
- package/esm/utils/helpers/checkResource.js.map +1 -1
- package/esm/utils/helpers/repositoryResource.js +6 -5
- package/esm/utils/helpers/repositoryResource.js.map +1 -1
- package/lib/constants/Settings.js +10 -2
- package/lib/constants/Settings.js.flow +8 -2
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +11 -4
- package/lib/hooks/__tests__/useAuthentication.spec.js.flow +2 -8
- package/lib/hooks/__tests__/useForm.spec.js.flow +14 -12
- package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +10 -4
- package/lib/hooks/__tests__/useModels.spec.js.flow +3 -12
- package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +9 -8
- package/lib/hooks/useModularUI.js +23 -17
- package/lib/hooks/useModularUI.js.flow +31 -16
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +52 -41
- package/lib/hooks/useModularUIBasic.js.flow +66 -50
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +1 -8
- package/lib/models/concepts/ConceptDetailModel.js.flow +2 -7
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptIndexModel.js +1 -1
- package/lib/models/concepts/ConceptIndexModel.js.flow +7 -1
- package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js +8 -9
- package/lib/models/concepts/ConceptLinkModel.js.flow +14 -9
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/ConceptTypeDetailModel.js +3 -20
- package/lib/models/concepts/ConceptTypeDetailModel.js.flow +3 -25
- package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceCollection.js +3 -1
- package/lib/models/concepts/SourceReferenceCollection.js.flow +8 -1
- package/lib/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js +9 -3
- package/lib/models/concepts/SourceReferenceModel.js.flow +19 -3
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/concepts/__mock__/conceptindex.js.flow +15 -0
- package/lib/models/concepts/__tests__/ConceptIndexModel.spec.js.flow +30 -2
- package/lib/models/concepts/__tests__/ConceptTypeDetailModel.spec.js.flow +1 -18
- package/lib/models/content/ContentLinkModel.js +9 -4
- package/lib/models/content/ContentLinkModel.js.flow +19 -4
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/SectionModel.js +10 -6
- package/lib/models/content/SectionModel.js.flow +31 -5
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/error/ErrorResponse.js +20 -5
- package/lib/models/error/ErrorResponse.js.flow +34 -5
- package/lib/models/error/ErrorResponse.js.map +1 -1
- package/lib/models/href/Href.js +21 -4
- package/lib/models/href/Href.js.flow +21 -4
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/href/__tests__/Href.spec.js.flow +9 -3
- package/lib/models/list/ListItemCollection.js +1 -1
- package/lib/models/list/ListItemCollection.js.flow +2 -0
- package/lib/models/list/ListItemCollection.js.map +1 -1
- package/lib/modularui/CaptchaRequest.js +11 -2
- package/lib/modularui/CaptchaRequest.js.flow +17 -3
- package/lib/modularui/CaptchaRequest.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +1 -1
- package/lib/modularui/ModularUIRequest.js.flow +3 -1
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/modularui/UploadRequest.js +6 -2
- package/lib/modularui/UploadRequest.js.flow +12 -2
- package/lib/modularui/UploadRequest.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +11 -9
- package/lib/redux/_modularui/ModularUIActions.js.flow +20 -10
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js +3 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.flow +6 -3
- package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +2 -1
- package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/ModularUISelectors.js +5 -6
- package/lib/redux/_modularui/ModularUISelectors.js.flow +22 -10
- package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/lib/redux/_modularui/__tests__/actions.spec.js.flow +1 -4
- package/lib/redux/_modularui/types.js.flow +1 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/actions/Application.js +10 -5
- package/lib/redux/actions/Application.js.flow +16 -5
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -8
- package/lib/redux/actions/__tests__/Authorization.spec.js.flow +0 -4
- package/lib/redux/connectors/PanelRenderer.js +0 -2
- package/lib/redux/connectors/PanelRenderer.js.flow +0 -1
- package/lib/redux/connectors/PanelRenderer.js.map +1 -1
- package/lib/utils/helpers/checkResource.js +0 -2
- package/lib/utils/helpers/checkResource.js.flow +0 -2
- package/lib/utils/helpers/checkResource.js.map +1 -1
- package/lib/utils/helpers/repositoryResource.js +6 -5
- package/lib/utils/helpers/repositoryResource.js.flow +8 -6
- package/lib/utils/helpers/repositoryResource.js.map +1 -1
- package/package.json +18 -18
- package/src/constants/Settings.js +8 -2
- package/src/hooks/__tests__/UseModularUIModel.spec.js +11 -4
- package/src/hooks/__tests__/useAuthentication.spec.js +2 -8
- package/src/hooks/__tests__/useForm.spec.js +14 -12
- package/src/hooks/__tests__/useModelCatalog.spec.js +10 -4
- package/src/hooks/__tests__/useModels.spec.js +3 -12
- package/src/hooks/__tests__/useModularUIBasic.spec.js +9 -8
- package/src/hooks/useModularUI.js +31 -16
- package/src/hooks/useModularUIBasic.js +66 -50
- package/src/models/concepts/ConceptDetailModel.js +2 -7
- package/src/models/concepts/ConceptIndexModel.js +7 -1
- package/src/models/concepts/ConceptLinkModel.js +14 -9
- package/src/models/concepts/ConceptTypeDetailModel.js +3 -25
- package/src/models/concepts/SourceReferenceCollection.js +8 -1
- package/src/models/concepts/SourceReferenceModel.js +19 -3
- package/src/models/concepts/__mock__/conceptindex.js +15 -0
- package/src/models/concepts/__mock__/conceptindex_contributions.json +86 -0
- package/src/models/concepts/__mock__/conceptindex_data.json +323 -0
- package/src/models/concepts/__mock__/concepttype_hierarchy.json +1 -11
- package/src/models/concepts/__tests__/ConceptIndexModel.spec.js +30 -2
- package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +1 -18
- package/src/models/content/ContentLinkModel.js +19 -4
- package/src/models/content/SectionModel.js +31 -5
- package/src/models/error/ErrorResponse.js +34 -5
- package/src/models/href/Href.js +21 -4
- package/src/models/href/__tests__/Href.spec.js +9 -3
- package/src/models/list/ListItemCollection.js +2 -0
- package/src/modularui/CaptchaRequest.js +17 -3
- package/src/modularui/ModularUIRequest.js +3 -1
- package/src/modularui/UploadRequest.js +12 -2
- package/src/redux/_modularui/ModularUIActions.js +20 -10
- package/src/redux/_modularui/ModularUIMiddleware.js +6 -3
- package/src/redux/_modularui/ModularUIReducer.js +1 -0
- package/src/redux/_modularui/ModularUISelectors.js +22 -10
- package/src/redux/_modularui/__tests__/actions.spec.js +1 -4
- package/src/redux/_modularui/types.js +1 -0
- package/src/redux/actions/Application.js +16 -5
- package/src/redux/actions/__tests__/Application.spec.js +1 -8
- package/src/redux/actions/__tests__/Authorization.spec.js +0 -4
- package/src/redux/connectors/PanelRenderer.js +0 -1
- package/src/utils/helpers/checkResource.js +0 -2
- package/src/utils/helpers/repositoryResource.js +8 -6
|
@@ -6,22 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.useModularUIBasic = void 0;
|
|
8
8
|
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
|
|
9
|
+
var _react = require("react");
|
|
9
10
|
var _useModularUI = require("./useModularUI");
|
|
10
11
|
var _useRouter = require("./useRouter");
|
|
11
12
|
var _exceptions = require("../exceptions");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const useModularUIBasic = function (key, href) {
|
|
13
|
+
// Helper to create useModularUI options
|
|
14
|
+
const createUseModularUIOptions = (options, href, location) => {
|
|
15
15
|
var _context;
|
|
16
|
-
|
|
17
|
-
expectedModels: [],
|
|
18
|
-
targetModel: undefined,
|
|
19
|
-
forceTargetModel: false,
|
|
20
|
-
origin: undefined,
|
|
21
|
-
contextPath: undefined
|
|
22
|
-
};
|
|
23
|
-
const location = (0, _useRouter.useLocation)();
|
|
24
|
-
const useModularUIOptions = {
|
|
16
|
+
const baseOptions = {
|
|
25
17
|
targetModel: undefined,
|
|
26
18
|
forceTargetModel: undefined,
|
|
27
19
|
isReload: false,
|
|
@@ -29,44 +21,63 @@ const useModularUIBasic = function (key, href) {
|
|
|
29
21
|
contextPath: undefined,
|
|
30
22
|
cache: false
|
|
31
23
|
};
|
|
24
|
+
|
|
25
|
+
// Handle targetModel and forceTargetModel
|
|
32
26
|
if (options.targetModel) {
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
baseOptions.targetModel = options.targetModel;
|
|
28
|
+
baseOptions.forceTargetModel = options.forceTargetModel;
|
|
35
29
|
}
|
|
30
|
+
|
|
31
|
+
// Handle cache option
|
|
36
32
|
if (options.cache) {
|
|
37
|
-
|
|
33
|
+
baseOptions.cache = options.cache;
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
//
|
|
41
|
-
if (location.state?.reload && (0, _startsWith.default)(_context = location.pathname).call(_context, href
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
if (options.origin) {
|
|
45
|
-
useModularUIOptions.origin = options.origin;
|
|
46
|
-
}
|
|
47
|
-
if (options.contextPath) {
|
|
48
|
-
useModularUIOptions.contextPath = options.contextPath;
|
|
36
|
+
// Check for reload if location matches href
|
|
37
|
+
if (location.state?.reload && (0, _startsWith.default)(_context = location.pathname).call(_context, href)) {
|
|
38
|
+
baseOptions.isReload = true;
|
|
49
39
|
}
|
|
50
40
|
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
throw new _exceptions.IllegalStateException("Resolved model has incorrect type");
|
|
65
|
-
}
|
|
41
|
+
// Handle origin and contextPath options
|
|
42
|
+
baseOptions.origin = options.origin ?? baseOptions.origin;
|
|
43
|
+
baseOptions.contextPath = options.contextPath ?? baseOptions.contextPath;
|
|
44
|
+
return baseOptions;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// Helper to validate the model against expectedModels
|
|
48
|
+
const validateModel = (model, expectedModels) => {
|
|
49
|
+
if (expectedModels.length > 0) {
|
|
50
|
+
const isCorrectModel = expectedModels.some(expectedModel => model.type === expectedModel);
|
|
51
|
+
if (!isCorrectModel) {
|
|
52
|
+
console.error(model, "is not of instance", expectedModels);
|
|
53
|
+
throw new _exceptions.IllegalStateException("Resolved model has incorrect type");
|
|
66
54
|
}
|
|
67
|
-
return model;
|
|
68
55
|
}
|
|
69
|
-
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* useModularUIBasic Hook
|
|
60
|
+
*/
|
|
61
|
+
const useModularUIBasic = function (key, href) {
|
|
62
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
63
|
+
expectedModels: [],
|
|
64
|
+
targetModel: undefined,
|
|
65
|
+
forceTargetModel: false,
|
|
66
|
+
origin: undefined,
|
|
67
|
+
contextPath: undefined
|
|
68
|
+
};
|
|
69
|
+
const location = (0, _useRouter.useLocation)();
|
|
70
|
+
const memoizedHref = (0, _react.useMemo)(() => href.toString(), [href]);
|
|
71
|
+
const useModularUIOptions = (0, _react.useMemo)(() => createUseModularUIOptions(options, memoizedHref, location), [options, memoizedHref, location]);
|
|
72
|
+
const modularUI = (0, _useModularUI.useModularUI)(key, memoizedHref, useModularUIOptions);
|
|
73
|
+
const expectedModels = (0, _react.useMemo)(() => options.expectedModels ?? [], [options.expectedModels]);
|
|
74
|
+
return (0, _react.useMemo)(() => {
|
|
75
|
+
if (modularUI?.model) {
|
|
76
|
+
validateModel(modularUI.model, expectedModels);
|
|
77
|
+
return modularUI.model;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}, [expectedModels, modularUI]);
|
|
70
81
|
};
|
|
71
82
|
exports.useModularUIBasic = useModularUIBasic;
|
|
72
83
|
//# sourceMappingURL=useModularUIBasic.js.map
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// @flow
|
|
2
|
+
import { useMemo } from "react";
|
|
2
3
|
import { useModularUI } from "./useModularUI";
|
|
3
|
-
|
|
4
4
|
import { useLocation } from "./useRouter";
|
|
5
|
-
|
|
6
5
|
import { IllegalStateException } from "../exceptions";
|
|
7
|
-
|
|
8
6
|
import type { ModularUIModel, Href } from "../models";
|
|
9
7
|
|
|
10
8
|
export type UseModularUIBasicOptions<T: ModularUIModel> = {
|
|
@@ -16,22 +14,13 @@ export type UseModularUIBasicOptions<T: ModularUIModel> = {
|
|
|
16
14
|
cache?: boolean,
|
|
17
15
|
};
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
targetModel: undefined,
|
|
27
|
-
forceTargetModel: false,
|
|
28
|
-
origin: undefined,
|
|
29
|
-
contextPath: undefined,
|
|
30
|
-
},
|
|
31
|
-
): T | null => {
|
|
32
|
-
const location = useLocation();
|
|
33
|
-
|
|
34
|
-
const useModularUIOptions = {
|
|
17
|
+
// Helper to create useModularUI options
|
|
18
|
+
const createUseModularUIOptions = <T: ModularUIModel>(
|
|
19
|
+
options: UseModularUIBasicOptions<T>,
|
|
20
|
+
href: string,
|
|
21
|
+
location: any,
|
|
22
|
+
): Object => {
|
|
23
|
+
const baseOptions = {
|
|
35
24
|
targetModel: undefined,
|
|
36
25
|
forceTargetModel: undefined,
|
|
37
26
|
isReload: false,
|
|
@@ -39,48 +28,75 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
39
28
|
contextPath: undefined,
|
|
40
29
|
cache: false,
|
|
41
30
|
};
|
|
31
|
+
|
|
32
|
+
// Handle targetModel and forceTargetModel
|
|
42
33
|
if (options.targetModel) {
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
baseOptions.targetModel = options.targetModel;
|
|
35
|
+
baseOptions.forceTargetModel = options.forceTargetModel;
|
|
45
36
|
}
|
|
46
37
|
|
|
38
|
+
// Handle cache option
|
|
47
39
|
if (options.cache) {
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// reload when the modular service starts with the current location
|
|
52
|
-
if (location.state?.reload && location.pathname.startsWith(href.toString())) {
|
|
53
|
-
useModularUIOptions.isReload = true;
|
|
40
|
+
baseOptions.cache = options.cache;
|
|
54
41
|
}
|
|
55
42
|
|
|
56
|
-
if
|
|
57
|
-
|
|
43
|
+
// Check for reload if location matches href
|
|
44
|
+
if (location.state?.reload && location.pathname.startsWith(href)) {
|
|
45
|
+
baseOptions.isReload = true;
|
|
58
46
|
}
|
|
59
47
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// $FlowFixMe[incompatible-call]
|
|
65
|
-
const modularUI = useModularUI(key, href, useModularUIOptions);
|
|
66
|
-
|
|
67
|
-
if (modularUI?.model) {
|
|
68
|
-
const { model } = modularUI;
|
|
48
|
+
// Handle origin and contextPath options
|
|
49
|
+
baseOptions.origin = options.origin ?? baseOptions.origin;
|
|
50
|
+
baseOptions.contextPath = options.contextPath ?? baseOptions.contextPath;
|
|
69
51
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const isCorrectModel = expectedModels.some((expectedModel) => {
|
|
73
|
-
return model.type === expectedModel;
|
|
74
|
-
});
|
|
52
|
+
return baseOptions;
|
|
53
|
+
};
|
|
75
54
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
55
|
+
// Helper to validate the model against expectedModels
|
|
56
|
+
const validateModel = (model: any, expectedModels: Array<string>) => {
|
|
57
|
+
if (expectedModels.length > 0) {
|
|
58
|
+
const isCorrectModel = expectedModels.some(
|
|
59
|
+
(expectedModel) => model.type === expectedModel,
|
|
60
|
+
);
|
|
61
|
+
if (!isCorrectModel) {
|
|
62
|
+
console.error(model, "is not of instance", expectedModels);
|
|
63
|
+
throw new IllegalStateException("Resolved model has incorrect type");
|
|
80
64
|
}
|
|
81
|
-
|
|
82
|
-
return model;
|
|
83
65
|
}
|
|
66
|
+
};
|
|
84
67
|
|
|
85
|
-
|
|
68
|
+
/**
|
|
69
|
+
* useModularUIBasic Hook
|
|
70
|
+
*/
|
|
71
|
+
export const useModularUIBasic = <T: ModularUIModel>(
|
|
72
|
+
key: string,
|
|
73
|
+
href: string | Href,
|
|
74
|
+
options: UseModularUIBasicOptions<T> = {
|
|
75
|
+
expectedModels: [],
|
|
76
|
+
targetModel: undefined,
|
|
77
|
+
forceTargetModel: false,
|
|
78
|
+
origin: undefined,
|
|
79
|
+
contextPath: undefined,
|
|
80
|
+
},
|
|
81
|
+
): T | null => {
|
|
82
|
+
const location = useLocation();
|
|
83
|
+
const memoizedHref = useMemo(() => href.toString(), [href]);
|
|
84
|
+
const useModularUIOptions = useMemo(
|
|
85
|
+
() => createUseModularUIOptions(options, memoizedHref, location),
|
|
86
|
+
[options, memoizedHref, location],
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const modularUI = useModularUI(key, memoizedHref, useModularUIOptions);
|
|
90
|
+
const expectedModels = useMemo(
|
|
91
|
+
() => options.expectedModels ?? [],
|
|
92
|
+
[options.expectedModels],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
return useMemo((): T | null => {
|
|
96
|
+
if (modularUI?.model) {
|
|
97
|
+
validateModel(modularUI.model, expectedModels);
|
|
98
|
+
return modularUI.model;
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}, [expectedModels, modularUI]);
|
|
86
102
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIBasic.js","names":["
|
|
1
|
+
{"version":3,"file":"useModularUIBasic.js","names":["_react","require","_useModularUI","_useRouter","_exceptions","createUseModularUIOptions","options","href","location","_context","baseOptions","targetModel","undefined","forceTargetModel","isReload","origin","contextPath","cache","state","reload","_startsWith","default","pathname","call","validateModel","model","expectedModels","length","isCorrectModel","some","expectedModel","type","console","error","IllegalStateException","useModularUIBasic","key","arguments","useLocation","memoizedHref","useMemo","toString","useModularUIOptions","modularUI","useModularUI","exports"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useMemo } from \"react\";\nimport { useModularUI } from \"./useModularUI\";\nimport { useLocation } from \"./useRouter\";\nimport { IllegalStateException } from \"../exceptions\";\nimport type { ModularUIModel, Href } from \"../models\";\n\nexport type UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels?: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n origin?: string,\n contextPath?: string,\n cache?: boolean,\n};\n\n// Helper to create useModularUI options\nconst createUseModularUIOptions = <T: ModularUIModel>(\n options: UseModularUIBasicOptions<T>,\n href: string,\n location: any,\n): Object => {\n const baseOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n origin: undefined,\n contextPath: undefined,\n cache: false,\n };\n\n // Handle targetModel and forceTargetModel\n if (options.targetModel) {\n baseOptions.targetModel = options.targetModel;\n baseOptions.forceTargetModel = options.forceTargetModel;\n }\n\n // Handle cache option\n if (options.cache) {\n baseOptions.cache = options.cache;\n }\n\n // Check for reload if location matches href\n if (location.state?.reload && location.pathname.startsWith(href)) {\n baseOptions.isReload = true;\n }\n\n // Handle origin and contextPath options\n baseOptions.origin = options.origin ?? baseOptions.origin;\n baseOptions.contextPath = options.contextPath ?? baseOptions.contextPath;\n\n return baseOptions;\n};\n\n// Helper to validate the model against expectedModels\nconst validateModel = (model: any, expectedModels: Array<string>) => {\n if (expectedModels.length > 0) {\n const isCorrectModel = expectedModels.some(\n (expectedModel) => model.type === expectedModel,\n );\n if (!isCorrectModel) {\n console.error(model, \"is not of instance\", expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n};\n\n/**\n * useModularUIBasic Hook\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n origin: undefined,\n contextPath: undefined,\n },\n): T | null => {\n const location = useLocation();\n const memoizedHref = useMemo(() => href.toString(), [href]);\n const useModularUIOptions = useMemo(\n () => createUseModularUIOptions(options, memoizedHref, location),\n [options, memoizedHref, location],\n );\n\n const modularUI = useModularUI(key, memoizedHref, useModularUIOptions);\n const expectedModels = useMemo(\n () => options.expectedModels ?? [],\n [options.expectedModels],\n );\n\n return useMemo((): T | null => {\n if (modularUI?.model) {\n validateModel(modularUI.model, expectedModels);\n return modularUI.model;\n }\n return null;\n }, [expectedModels, modularUI]);\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAYA;AACA,MAAMI,yBAAyB,GAAGA,CAChCC,OAAoC,EACpCC,IAAY,EACZC,QAAa,KACF;EAAA,IAAAC,QAAA;EACX,MAAMC,WAAW,GAAG;IAClBC,WAAW,EAAEC,SAAS;IACtBC,gBAAgB,EAAED,SAAS;IAC3BE,QAAQ,EAAE,KAAK;IACfC,MAAM,EAAEH,SAAS;IACjBI,WAAW,EAAEJ,SAAS;IACtBK,KAAK,EAAE;EACT,CAAC;;EAED;EACA,IAAIX,OAAO,CAACK,WAAW,EAAE;IACvBD,WAAW,CAACC,WAAW,GAAGL,OAAO,CAACK,WAAW;IAC7CD,WAAW,CAACG,gBAAgB,GAAGP,OAAO,CAACO,gBAAgB;EACzD;;EAEA;EACA,IAAIP,OAAO,CAACW,KAAK,EAAE;IACjBP,WAAW,CAACO,KAAK,GAAGX,OAAO,CAACW,KAAK;EACnC;;EAEA;EACA,IAAIT,QAAQ,CAACU,KAAK,EAAEC,MAAM,IAAI,IAAAC,WAAA,CAAAC,OAAA,EAAAZ,QAAA,GAAAD,QAAQ,CAACc,QAAQ,EAAAC,IAAA,CAAAd,QAAA,EAAYF,IAAI,CAAC,EAAE;IAChEG,WAAW,CAACI,QAAQ,GAAG,IAAI;EAC7B;;EAEA;EACAJ,WAAW,CAACK,MAAM,GAAGT,OAAO,CAACS,MAAM,IAAIL,WAAW,CAACK,MAAM;EACzDL,WAAW,CAACM,WAAW,GAAGV,OAAO,CAACU,WAAW,IAAIN,WAAW,CAACM,WAAW;EAExE,OAAON,WAAW;AACpB,CAAC;;AAED;AACA,MAAMc,aAAa,GAAGA,CAACC,KAAU,EAAEC,cAA6B,KAAK;EACnE,IAAIA,cAAc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B,IAAIG,SAAS,EAAElB,KAAK,EAAE;MACpBD,aAAa,CAACmB,SAAS,CAAClB,KAAK,EAAEC,cAAc,CAAC;MAC9C,OAAOiB,SAAS,CAAClB,KAAK;IACxB;IACA,OAAO,IAAI;EACb,CAAC,EAAE,CAACC,cAAc,EAAEiB,SAAS,CAAC,CAAC;AACjC,CAAC;AAACE,OAAA,CAAAV,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -230,7 +230,7 @@ class ConceptDetailModel extends _ResourceModel.default {
|
|
|
230
230
|
getSourceReferenceCollection() {
|
|
231
231
|
let availableLocales = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
232
232
|
if (!this._sourceReferences) {
|
|
233
|
-
this._sourceReferences = new _SourceReferenceCollection.default(this.getSourceReferencesForCurrentLanguage(availableLocales), this.entryDate);
|
|
233
|
+
this._sourceReferences = new _SourceReferenceCollection.default(this.getSourceReferencesForCurrentLanguage(availableLocales), this.entryDate, this.origin, this.contextPath);
|
|
234
234
|
}
|
|
235
235
|
return this._sourceReferences;
|
|
236
236
|
}
|
|
@@ -276,13 +276,6 @@ class ConceptDetailModel extends _ResourceModel.default {
|
|
|
276
276
|
isOfConceptType(conceptTypeId) {
|
|
277
277
|
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
278
278
|
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
282
|
-
*/
|
|
283
|
-
hasMetamodelIdInConceptTypeHierarchy(metamodelId) {
|
|
284
|
-
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
285
|
-
}
|
|
286
279
|
}
|
|
287
280
|
exports.default = ConceptDetailModel;
|
|
288
281
|
//# sourceMappingURL=ConceptDetailModel.js.map
|
|
@@ -273,6 +273,8 @@ export default class ConceptDetailModel extends ResourceModel {
|
|
|
273
273
|
this._sourceReferences = new SourceReferenceCollection(
|
|
274
274
|
this.getSourceReferencesForCurrentLanguage(availableLocales),
|
|
275
275
|
this.entryDate,
|
|
276
|
+
this.origin,
|
|
277
|
+
this.contextPath,
|
|
276
278
|
);
|
|
277
279
|
}
|
|
278
280
|
|
|
@@ -338,11 +340,4 @@ export default class ConceptDetailModel extends ResourceModel {
|
|
|
338
340
|
isOfConceptType(conceptTypeId: string): boolean {
|
|
339
341
|
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
340
342
|
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
344
|
-
*/
|
|
345
|
-
hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean {
|
|
346
|
-
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
347
|
-
}
|
|
348
343
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptDetailModel.js","names":["_ResourceModel","_interopRequireDefault","require","_ConceptRelationCollection","_SourceReferenceCollection","_ConceptTypeDetailModel","_Constants","ConceptDetailModel","ResourceModel","constructor","modularuiResponse","_defineProperty2","default","_relations","ConceptRelationCollection","data","relations","entryDate","type","modelName","isApplicableModel","contributions","resourcetype","getInitialChildModelLinks","conceptTypeLink","links","getLinkByKey","relationsCollectionLinks","relationsCollection","isCacheable","setChildModels","models","errors","conceptTypeModel","_find","call","model","ConceptTypeDetailModel","conceptType","key","getData","selfhref","href","selflink","setParameter","TIMEVERSION_FILTER_NAME","removeParameter","diagramLinks","getLinksByGroup","_conceptType","label","conceptLabel","modelCategory","taxonomyType","formula","labels","_context","labelTypes","_map","labelType","_context2","setting","_id","getLabelElementByIds","ids","_context3","_filter","_includes","conceptProperties","_context4","propertyTypes","propertyType","_context5","properties","property","getConceptPropertiesByIds","_context6","textfragments","_context7","_context9","textFragments","textFragment","_context8","textFragmentConfig","textFragmentTypes","textFragmentType","notConfiguredTextFragments","some","textfragment","getTextFragmentByKeys","keys","_context10","getSourceReferenceCollection","availableLocales","arguments","length","undefined","_sourceReferences","SourceReferenceCollection","getSourceReferencesForCurrentLanguage","LANGUAGE_POSTFIX_LENGTH","sourceReferences","_context11","_context14","availableLanguagesInSourceReferences","sourceReference","substring","currentLanguagePostfix","locale","_context12","_context13","_endsWith","availableLanguages","split","value","isOfConceptType","conceptTypeId","hasMetamodelIdInConceptTypeHierarchy","metamodelId","hasMetamodelIdInHierarchy","exports"],"sources":["../../../src/models/concepts/ConceptDetailModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport ConceptRelationCollection from \"./ConceptRelationCollection\";\nimport SourceReferenceCollection from \"./SourceReferenceCollection\";\nimport ConceptTypeDetailModel from \"./ConceptTypeDetailModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type {\n ModularUIModel,\n labelsJSON,\n textfragmentJSON,\n propertyJSON,\n} from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type Href from \"../href/Href\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Model for concept details, available through modelcatalog\n */\nexport default class ConceptDetailModel extends ResourceModel {\n _relations: ConceptRelationCollection;\n _conceptType: ?ConceptTypeDetailModel;\n _sourceReferences: SourceReferenceCollection;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this._relations = new ConceptRelationCollection(\n this.data.relations,\n this.entryDate,\n );\n }\n\n /**\n */\n get type(): string {\n return \"ConceptDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ConceptDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"ConceptDetail\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const conceptTypeLink = this.links.getLinkByKey(\"concepttype\");\n const relationsCollectionLinks =\n this.relationsCollection.getInitialChildModelLinks();\n\n if (conceptTypeLink) {\n conceptTypeLink.isCacheable = true;\n return [conceptTypeLink, ...relationsCollectionLinks];\n }\n\n return relationsCollectionLinks;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n // $FlowExpectedError[incompatible-type]\n const conceptTypeModel: ?ConceptTypeDetailModel = models.find(\n (model) => model instanceof ConceptTypeDetailModel,\n );\n\n if (conceptTypeModel) {\n this.conceptType = conceptTypeModel;\n }\n\n this.relationsCollection.setChildModels(models, errors);\n }\n\n /**\n * Retrieve concept detail identifier as key for this model\n */\n get key(): string {\n return this.getData(\"_id\", \"concept\");\n }\n\n /**\n * Getting the self link of this Concept\n */\n get selfhref(): Href {\n const { href } = this.selflink;\n\n if (this.entryDate) {\n href.setParameter(TIMEVERSION_FILTER_NAME, this.entryDate);\n } else {\n href.removeParameter(TIMEVERSION_FILTER_NAME);\n }\n\n return href;\n }\n\n /**\n * Available diagrams for the concept, most of the time just one\n */\n get diagramLinks(): LinkCollection {\n return this.links.getLinksByGroup(\"diagram\");\n }\n\n /**\n * Get conceptType of concept\n */\n get conceptType(): ?ConceptTypeDetailModel {\n return this._conceptType;\n }\n\n /**\n */\n set conceptType(conceptType: ?ConceptTypeDetailModel) {\n this._conceptType = conceptType;\n }\n\n /**\n * Get concept label\n */\n get label(): string {\n return this.data.conceptLabel;\n }\n\n /**\n * Get model category of the concept\n */\n get modelCategory(): string {\n return this.getData(\"modelCategory\", \"\");\n }\n\n /**\n * Get taxonomy type\n */\n get taxonomyType(): string {\n return this.getData(\"taxonomyType\", \"default\");\n }\n\n /**\n * Get concept relations collection\n */\n get relationsCollection(): ConceptRelationCollection {\n return this._relations;\n }\n\n /**\n * Get concept formula\n */\n get formula(): string {\n return this.data.formula;\n }\n\n /**\n * Get additional labels of concept\n */\n get labels(): Array<labelsJSON> {\n return this.conceptType && this.conceptType.labelTypes\n ? this.conceptType.labelTypes.map((labelType) => {\n const setting = this.data.labels\n ? this.data.labels.find((label) => label.type === labelType._id)\n : {};\n\n return {\n ...labelType,\n ...setting,\n };\n })\n : [];\n }\n\n /**\n * Get label elements by id\n */\n getLabelElementByIds(ids: Array<string>): Array<labelsJSON> {\n return this.labels.filter((label: labelsJSON) => ids.includes(label._id));\n }\n\n /**\n * Get concept properties\n */\n get conceptProperties(): Array<propertyJSON> {\n return this.conceptType && this.conceptType.propertyTypes\n ? this.conceptType.propertyTypes.map((propertyType) => {\n const setting = this.data.properties\n ? this.data.properties.find(\n (property) => property.type === propertyType._id,\n )\n : {};\n\n return {\n ...propertyType,\n ...setting,\n };\n })\n : [];\n }\n\n /**\n * Get concept properties by id\n */\n getConceptPropertiesByIds(ids: Array<string>): Array<propertyJSON> {\n return this.conceptProperties.filter((property) =>\n ids.includes(property._id),\n );\n }\n\n /**\n * Get Text fragments\n */\n get textfragments(): Array<textfragmentJSON> {\n const textFragments = this.data.textFragments\n ? this.data.textFragments.map((textFragment) => {\n const textFragmentConfig =\n this.conceptType &&\n this.conceptType.textFragmentTypes.find(\n (textFragmentType) => textFragment.type === textFragmentType._id,\n );\n\n return {\n ...textFragmentConfig,\n ...textFragment,\n };\n })\n : [];\n\n const notConfiguredTextFragments =\n this.conceptType && this.conceptType.textFragmentTypes\n ? this.conceptType.textFragmentTypes.filter((textFragmentType) => {\n if (!this.data.textFragments) {\n return true;\n }\n\n return !this.data.textFragments.some(\n (textfragment) => textfragment.type === textFragmentType._id,\n );\n })\n : [];\n\n return [...textFragments, ...notConfiguredTextFragments];\n }\n\n /**\n * Get text fragments by id\n */\n getTextFragmentByKeys(keys: Array<string>): Array<textfragmentJSON> {\n return this.textfragments.filter((textfragment) =>\n keys.includes(textfragment.type),\n );\n }\n\n /**\n * Get source reference collection\n */\n getSourceReferenceCollection(\n availableLocales: Array<string> = [],\n ): SourceReferenceCollection {\n if (!this._sourceReferences) {\n this._sourceReferences = new SourceReferenceCollection(\n this.getSourceReferencesForCurrentLanguage(availableLocales),\n this.entryDate,\n );\n }\n\n return this._sourceReferences;\n }\n\n /*\n * Retrieve all sourceReferenceTypes that are valid for the current language\n * Used by sourceRef collection\n */\n /**\n */\n getSourceReferencesForCurrentLanguage(\n availableLocales: Array<string>,\n ): Array<Object> {\n const LANGUAGE_POSTFIX_LENGTH = 3;\n if (this.data.sourceReferences) {\n const availableLanguagesInSourceReferences =\n this.data.sourceReferences.map((sourceReference) =>\n sourceReference.type.substring(\n sourceReference.type.length - LANGUAGE_POSTFIX_LENGTH,\n ),\n );\n\n const currentLanguagePostfix = `_${this.locale}`;\n\n if (\n availableLanguagesInSourceReferences.includes(currentLanguagePostfix)\n ) {\n // return all sourceReferences that end with language that is selected\n return this.data.sourceReferences.filter((sourceReference) =>\n sourceReference.type.endsWith(currentLanguagePostfix),\n );\n }\n\n const availableLanguages = availableLocales.map(\n (locale) => `_${locale.split(\"-\")[0]}`,\n );\n\n // return all sourceReferences that do not end with language postfix\n return this.data.sourceReferences.filter(\n (sourceReference) =>\n !availableLanguages.includes(\n sourceReference.type.substring(\n sourceReference.type.length - LANGUAGE_POSTFIX_LENGTH,\n ),\n ),\n );\n }\n return [];\n }\n\n /**\n * Retrieve entrydate\n */\n get entryDate(): string | null {\n return this.data.filter?.[TIMEVERSION_FILTER_NAME]?.value ?? null;\n }\n\n /**\n * Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept\n */\n isOfConceptType(conceptTypeId: string): boolean {\n return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;\n }\n\n /**\n * Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept\n */\n hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean {\n return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE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H;MAEA,MAAMK,kBAAkB,GAAG,IAAAtD,IAAA,CAAA9C,OAAA,EAAAiF,gBAAgB,EAAA1D,IAAA,CAAhB0D,gBAAgB,EACxCe,MAAM,IAAK,IAAIA,MAAM,CAACK,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EACtC,CAAC;;MAED;MACA,OAAO,IAAA/C,OAAA,CAAAtD,OAAA,EAAA2F,UAAA,OAAI,CAACxF,IAAI,CAACsF,gBAAgB,EAAAlE,IAAA,CAAAoE,UAAA,EAC9BE,eAAe,IACd,CAAC,IAAAtC,SAAA,CAAAvD,OAAA,EAAAoG,kBAAkB,EAAA7E,IAAA,CAAlB6E,kBAAkB,EACjBP,eAAe,CAACvF,IAAI,CAACwF,SAAS,CAC5BD,eAAe,CAACvF,IAAI,CAAC6E,MAAM,GAAGK,uBAChC,CACF,CACJ,CAAC;IACH;IACA,OAAO,EAAE;EACX;;EAEA;AACF;AACA;EACE,IAAInF,SAASA,CAAA,EAAkB;IAC7B,OAAO,IAAAiD,OAAA,CAAAtD,OAAA,MAAI,CAACG,IAAI,IAAU8B,kCAAuB,CAAC,EAAEqE,KAAK,IAAI,IAAI;EACnE;;EAEA;AACF;AACA;EACEC,eAAeA,CAACC,aAAqB,EAAW;IAC9C,OAAO,IAAI,CAAC9E,WAAW,EAAE6E,eAAe,CAACC,aAAa,CAAC,IAAI,KAAK;EAClE;;EAEA;AACF;AACA;EACEC,oCAAoCA,CAACC,WAAmB,EAAW;IACjE,OAAO,IAAI,CAAChF,WAAW,EAAEiF,yBAAyB,CAACD,WAAW,CAAC,IAAI,KAAK;EAC1E;AACF;AAACE,OAAA,CAAA5G,OAAA,GAAAL,kBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ConceptDetailModel.js","names":["_ResourceModel","_interopRequireDefault","require","_ConceptRelationCollection","_SourceReferenceCollection","_ConceptTypeDetailModel","_Constants","ConceptDetailModel","ResourceModel","constructor","modularuiResponse","_defineProperty2","default","_relations","ConceptRelationCollection","data","relations","entryDate","type","modelName","isApplicableModel","contributions","resourcetype","getInitialChildModelLinks","conceptTypeLink","links","getLinkByKey","relationsCollectionLinks","relationsCollection","isCacheable","setChildModels","models","errors","conceptTypeModel","_find","call","model","ConceptTypeDetailModel","conceptType","key","getData","selfhref","href","selflink","setParameter","TIMEVERSION_FILTER_NAME","removeParameter","diagramLinks","getLinksByGroup","_conceptType","label","conceptLabel","modelCategory","taxonomyType","formula","labels","_context","labelTypes","_map","labelType","_context2","setting","_id","getLabelElementByIds","ids","_context3","_filter","_includes","conceptProperties","_context4","propertyTypes","propertyType","_context5","properties","property","getConceptPropertiesByIds","_context6","textfragments","_context7","_context9","textFragments","textFragment","_context8","textFragmentConfig","textFragmentTypes","textFragmentType","notConfiguredTextFragments","some","textfragment","getTextFragmentByKeys","keys","_context10","getSourceReferenceCollection","availableLocales","arguments","length","undefined","_sourceReferences","SourceReferenceCollection","getSourceReferencesForCurrentLanguage","origin","contextPath","LANGUAGE_POSTFIX_LENGTH","sourceReferences","_context11","_context14","availableLanguagesInSourceReferences","sourceReference","substring","currentLanguagePostfix","locale","_context12","_context13","_endsWith","availableLanguages","split","value","isOfConceptType","conceptTypeId","exports"],"sources":["../../../src/models/concepts/ConceptDetailModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport ConceptRelationCollection from \"./ConceptRelationCollection\";\nimport SourceReferenceCollection from \"./SourceReferenceCollection\";\nimport ConceptTypeDetailModel from \"./ConceptTypeDetailModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type {\n ModularUIModel,\n labelsJSON,\n textfragmentJSON,\n propertyJSON,\n} from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type Href from \"../href/Href\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Model for concept details, available through modelcatalog\n */\nexport default class ConceptDetailModel extends ResourceModel {\n _relations: ConceptRelationCollection;\n _conceptType: ?ConceptTypeDetailModel;\n _sourceReferences: SourceReferenceCollection;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this._relations = new ConceptRelationCollection(\n this.data.relations,\n this.entryDate,\n );\n }\n\n /**\n */\n get type(): string {\n return \"ConceptDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ConceptDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"ConceptDetail\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const conceptTypeLink = this.links.getLinkByKey(\"concepttype\");\n const relationsCollectionLinks =\n this.relationsCollection.getInitialChildModelLinks();\n\n if (conceptTypeLink) {\n conceptTypeLink.isCacheable = true;\n return [conceptTypeLink, ...relationsCollectionLinks];\n }\n\n return relationsCollectionLinks;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n // $FlowExpectedError[incompatible-type]\n const conceptTypeModel: ?ConceptTypeDetailModel = models.find(\n (model) => model instanceof ConceptTypeDetailModel,\n );\n\n if (conceptTypeModel) {\n this.conceptType = conceptTypeModel;\n }\n\n this.relationsCollection.setChildModels(models, errors);\n }\n\n /**\n * Retrieve concept detail identifier as key for this model\n */\n get key(): string {\n return this.getData(\"_id\", \"concept\");\n }\n\n /**\n * Getting the self link of this Concept\n */\n get selfhref(): Href {\n const { href } = this.selflink;\n\n if (this.entryDate) {\n href.setParameter(TIMEVERSION_FILTER_NAME, this.entryDate);\n } else {\n href.removeParameter(TIMEVERSION_FILTER_NAME);\n }\n\n return href;\n }\n\n /**\n * Available diagrams for the concept, most of the time just one\n */\n get diagramLinks(): LinkCollection {\n return this.links.getLinksByGroup(\"diagram\");\n }\n\n /**\n * Get conceptType of concept\n */\n get conceptType(): ?ConceptTypeDetailModel {\n return this._conceptType;\n }\n\n /**\n */\n set conceptType(conceptType: ?ConceptTypeDetailModel) {\n this._conceptType = conceptType;\n }\n\n /**\n * Get concept label\n */\n get label(): string {\n return this.data.conceptLabel;\n }\n\n /**\n * Get model category of the concept\n */\n get modelCategory(): string {\n return this.getData(\"modelCategory\", \"\");\n }\n\n /**\n * Get taxonomy type\n */\n get taxonomyType(): string {\n return this.getData(\"taxonomyType\", \"default\");\n }\n\n /**\n * Get concept relations collection\n */\n get relationsCollection(): ConceptRelationCollection {\n return this._relations;\n }\n\n /**\n * Get concept formula\n */\n get formula(): string {\n return this.data.formula;\n }\n\n /**\n * Get additional labels of concept\n */\n get labels(): Array<labelsJSON> {\n return this.conceptType && this.conceptType.labelTypes\n ? this.conceptType.labelTypes.map((labelType) => {\n const setting = this.data.labels\n ? this.data.labels.find((label) => label.type === labelType._id)\n : {};\n\n return {\n ...labelType,\n ...setting,\n };\n })\n : [];\n }\n\n /**\n * Get label elements by id\n */\n getLabelElementByIds(ids: Array<string>): Array<labelsJSON> {\n return this.labels.filter((label: labelsJSON) => ids.includes(label._id));\n }\n\n /**\n * Get concept properties\n */\n get conceptProperties(): Array<propertyJSON> {\n return this.conceptType && this.conceptType.propertyTypes\n ? this.conceptType.propertyTypes.map((propertyType) => {\n const setting = this.data.properties\n ? this.data.properties.find(\n (property) => property.type === propertyType._id,\n )\n : {};\n\n return {\n ...propertyType,\n ...setting,\n };\n })\n : [];\n }\n\n /**\n * Get concept properties by id\n */\n getConceptPropertiesByIds(ids: Array<string>): Array<propertyJSON> {\n return this.conceptProperties.filter((property) =>\n ids.includes(property._id),\n );\n }\n\n /**\n * Get Text fragments\n */\n get textfragments(): Array<textfragmentJSON> {\n const textFragments = this.data.textFragments\n ? this.data.textFragments.map((textFragment) => {\n const textFragmentConfig =\n this.conceptType &&\n this.conceptType.textFragmentTypes.find(\n (textFragmentType) => textFragment.type === textFragmentType._id,\n );\n\n return {\n ...textFragmentConfig,\n ...textFragment,\n };\n })\n : [];\n\n const notConfiguredTextFragments =\n this.conceptType && this.conceptType.textFragmentTypes\n ? this.conceptType.textFragmentTypes.filter((textFragmentType) => {\n if (!this.data.textFragments) {\n return true;\n }\n\n return !this.data.textFragments.some(\n (textfragment) => textfragment.type === textFragmentType._id,\n );\n })\n : [];\n\n return [...textFragments, ...notConfiguredTextFragments];\n }\n\n /**\n * Get text fragments by id\n */\n getTextFragmentByKeys(keys: Array<string>): Array<textfragmentJSON> {\n return this.textfragments.filter((textfragment) =>\n keys.includes(textfragment.type),\n );\n }\n\n /**\n * Get source reference collection\n */\n getSourceReferenceCollection(\n availableLocales: Array<string> = [],\n ): SourceReferenceCollection {\n if (!this._sourceReferences) {\n this._sourceReferences = new SourceReferenceCollection(\n this.getSourceReferencesForCurrentLanguage(availableLocales),\n this.entryDate,\n this.origin,\n this.contextPath,\n );\n }\n\n return this._sourceReferences;\n }\n\n /*\n * Retrieve all sourceReferenceTypes that are valid for the current language\n * Used by sourceRef collection\n */\n /**\n */\n getSourceReferencesForCurrentLanguage(\n availableLocales: Array<string>,\n ): Array<Object> {\n const LANGUAGE_POSTFIX_LENGTH = 3;\n if (this.data.sourceReferences) {\n const availableLanguagesInSourceReferences =\n this.data.sourceReferences.map((sourceReference) =>\n sourceReference.type.substring(\n sourceReference.type.length - LANGUAGE_POSTFIX_LENGTH,\n ),\n );\n\n const currentLanguagePostfix = `_${this.locale}`;\n\n if (\n availableLanguagesInSourceReferences.includes(currentLanguagePostfix)\n ) {\n // return all sourceReferences that end with language that is selected\n return this.data.sourceReferences.filter((sourceReference) =>\n sourceReference.type.endsWith(currentLanguagePostfix),\n );\n }\n\n const availableLanguages = availableLocales.map(\n (locale) => `_${locale.split(\"-\")[0]}`,\n );\n\n // return all sourceReferences that do not end with language postfix\n return this.data.sourceReferences.filter(\n (sourceReference) =>\n !availableLanguages.includes(\n sourceReference.type.substring(\n sourceReference.type.length - LANGUAGE_POSTFIX_LENGTH,\n ),\n ),\n );\n }\n return [];\n }\n\n /**\n * Retrieve entrydate\n */\n get entryDate(): string | null {\n return this.data.filter?.[TIMEVERSION_FILTER_NAME]?.value ?? null;\n }\n\n /**\n * Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept\n */\n isOfConceptType(conceptTypeId: string): boolean {\n return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,0BAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,uBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AAcA;AACA;AACA;AACe,MAAMK,kBAAkB,SAASC,sBAAa,CAAC;EAK5D;AACF;EACEC,WAAWA,CAACC,iBAAoC,EAAE;IAChD,KAAK,CAACA,iBAAiB,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEzB,IAAI,CAACC,UAAU,GAAG,IAAIC,kCAAyB,CAC7C,IAAI,CAACC,IAAI,CAACC,SAAS,EACnB,IAAI,CAACC,SACP,CAAC;EACH;;EAEA;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,eAAe;EACxB;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,oBAAoB;EAC7B;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACL,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACM,aAAa,CAACC,YAAY,IAC/BP,IAAI,CAACM,aAAa,CAACC,YAAY,KAAK,eAAe;EAEvD;;EAEA;AACF;EACEC,yBAAyBA,CAAA,EAAqB;IAC5C,MAAMC,eAAe,GAAG,IAAI,CAACC,KAAK,CAACC,YAAY,CAAC,aAAa,CAAC;IAC9D,MAAMC,wBAAw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I,KAAK;EAClE;AACF;AAACC,OAAA,CAAA3G,OAAA,GAAAL,kBAAA","ignoreList":[]}
|
|
@@ -29,7 +29,7 @@ class ConceptIndexModel extends _ResourceModel.default {
|
|
|
29
29
|
dynamicschema: this.data.dynamicschema
|
|
30
30
|
});
|
|
31
31
|
this._concepts = new _ResourceCollection.default();
|
|
32
|
-
this._concepts.collection = this.data._embedded ? (0, _map.default)(_context = this.data._embedded.results).call(_context, concept => new _ConceptLinkModel.default(concept.concept, this.entryDate)) : [];
|
|
32
|
+
this._concepts.collection = this.data._embedded ? (0, _map.default)(_context = this.data._embedded.results).call(_context, concept => new _ConceptLinkModel.default(concept.concept, this.entryDate, this.origin, this.contextPath)) : [];
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -32,7 +32,13 @@ export default class ConceptIndexModel extends ResourceModel {
|
|
|
32
32
|
this._concepts = new ResourceCollection();
|
|
33
33
|
this._concepts.collection = this.data._embedded
|
|
34
34
|
? this.data._embedded.results.map(
|
|
35
|
-
(concept) =>
|
|
35
|
+
(concept) =>
|
|
36
|
+
new ConceptLinkModel(
|
|
37
|
+
concept.concept,
|
|
38
|
+
this.entryDate,
|
|
39
|
+
this.origin,
|
|
40
|
+
this.contextPath,
|
|
41
|
+
),
|
|
36
42
|
)
|
|
37
43
|
: [];
|
|
38
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptIndexModel.js","names":["_ResourceModel","_interopRequireDefault","require","_ResourceCollection","_FilterCollection","_ConceptLinkModel","_Constants","ConceptIndexModel","ResourceModel","constructor","modularuiResponse","_context","_defineProperty2","default","_filterCollection","FilterCollection","_filter","data","filter","contributions","dynamicschema","_concepts","ResourceCollection","collection","_embedded","_map","results","call","concept","ConceptLinkModel","entryDate","type","resourcetype","modelName","isApplicableModel","resourceType","getInitialChildModelLinks","items","setChildModels","models","errors","selfhref","href","selflink","filterCollection","hasItems","forEach","params","param","value","setParameter","name","removeParameter","label","getContribution","indexfilter","getFilterByAttributeKey","timeversionFilter","TIMEVERSION_FILTER_NAME","attribute","searchtermfilter","modelCategoryFilter","itemCollection","exports"],"sources":["../../../src/models/concepts/ConceptIndexModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ConceptLinkModel from \"./ConceptLinkModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type { FilterType, ModularUIModel } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type Href from \"../href/Href\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Get Index of concepts, to filter model catalog\n */\nexport default class ConceptIndexModel extends ResourceModel {\n _filterCollection: FilterCollection;\n _concepts: ResourceCollection<ConceptLinkModel>;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this._filterCollection = new FilterCollection(this.data.filter, {\n filter: this.contributions.filter,\n dynamicschema: this.data.dynamicschema,\n });\n\n this._concepts = new ResourceCollection();\n this._concepts.collection = this.data._embedded\n ? this.data._embedded.results.map(\n (concept)
|
|
1
|
+
{"version":3,"file":"ConceptIndexModel.js","names":["_ResourceModel","_interopRequireDefault","require","_ResourceCollection","_FilterCollection","_ConceptLinkModel","_Constants","ConceptIndexModel","ResourceModel","constructor","modularuiResponse","_context","_defineProperty2","default","_filterCollection","FilterCollection","_filter","data","filter","contributions","dynamicschema","_concepts","ResourceCollection","collection","_embedded","_map","results","call","concept","ConceptLinkModel","entryDate","origin","contextPath","type","resourcetype","modelName","isApplicableModel","resourceType","getInitialChildModelLinks","items","setChildModels","models","errors","selfhref","href","selflink","filterCollection","hasItems","forEach","params","param","value","setParameter","name","removeParameter","label","getContribution","indexfilter","getFilterByAttributeKey","timeversionFilter","TIMEVERSION_FILTER_NAME","attribute","searchtermfilter","modelCategoryFilter","itemCollection","exports"],"sources":["../../../src/models/concepts/ConceptIndexModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ConceptLinkModel from \"./ConceptLinkModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type { FilterType, ModularUIModel } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type Href from \"../href/Href\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Get Index of concepts, to filter model catalog\n */\nexport default class ConceptIndexModel extends ResourceModel {\n _filterCollection: FilterCollection;\n _concepts: ResourceCollection<ConceptLinkModel>;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this._filterCollection = new FilterCollection(this.data.filter, {\n filter: this.contributions.filter,\n dynamicschema: this.data.dynamicschema,\n });\n\n this._concepts = new ResourceCollection();\n this._concepts.collection = this.data._embedded\n ? this.data._embedded.results.map(\n (concept) =>\n new ConceptLinkModel(\n concept.concept,\n this.entryDate,\n this.origin,\n this.contextPath,\n ),\n )\n : [];\n }\n\n /**\n */\n get type(): string {\n if (this.resourcetype === \"RelatedConcepts\") {\n return \"RelatedConcepts\";\n }\n\n return \"ConceptIndex\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ConceptIndexModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourceType = data.contributions?.resourcetype;\n return (\n resourceType === \"ConceptSearch\" || resourceType === \"relatedConcepts\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this.items.getInitialChildModelLinks();\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this.items.setChildModels(models, errors);\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const { href } = this.selflink;\n\n if (this.filterCollection.hasItems) {\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n }\n\n return href;\n }\n\n /**\n */\n get label(): string {\n return this.getContribution(\"label\");\n }\n\n /**\n * Retrieve filters of conceptindex model\n */\n get filterCollection(): FilterCollection {\n return this._filterCollection;\n }\n\n /**\n * Get index filter\n */\n get indexfilter(): FilterType | null {\n return this.filterCollection.getFilterByAttributeKey(\"index\");\n }\n\n /**\n * Retrieve entrydate of content toc\n */\n get entryDate(): string | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n if (timeversionFilter && timeversionFilter.attribute) {\n return timeversionFilter.attribute.value;\n }\n\n return null;\n }\n\n /**\n * get searchterm filter\n */\n get searchtermfilter(): FilterType | null {\n return this.filterCollection.getFilterByAttributeKey(\"label\");\n }\n\n /**\n * Get model category filter\n */\n get modelCategoryFilter(): FilterType | null {\n return this.filterCollection.getFilterByAttributeKey(\"modelCategory\");\n }\n\n /**\n * Get concept links found by index filter\n */\n get items(): ResourceCollection<ConceptLinkModel> {\n return this._concepts;\n }\n\n /**\n * Replace the items collection\n */\n set items(itemCollection: ResourceCollection<ConceptLinkModel>) {\n this._concepts = itemCollection;\n }\n}\n"],"mappings":";;;;;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,iBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,iBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AAQA;AACA;AACA;AACe,MAAMK,iBAAiB,SAASC,sBAAa,CAAC;EAI3D;AACF;EACEC,WAAWA,CAACC,iBAAoC,EAAE;IAAA,IAAAC,QAAA;IAChD,KAAK,CAAC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AAO,IAAI;EACb;;EAEA;AACF;AACA;EACE,IAAIW,gBAAgBA,CAAA,EAAsB;IACxC,OAAO,IAAI,CAAChB,gBAAgB,CAACY,uBAAuB,CAAC,OAAO,CAAC;EAC/D;;EAEA;AACF;AACA;EACE,IAAIK,mBAAmBA,CAAA,EAAsB;IAC3C,OAAO,IAAI,CAACjB,gBAAgB,CAACY,uBAAuB,CAAC,eAAe,CAAC;EACvE;;EAEA;AACF;AACA;EACE,IAAInB,KAAKA,CAAA,EAAyC;IAChD,OAAO,IAAI,CAAClB,SAAS;EACvB;;EAEA;AACF;AACA;EACE,IAAIkB,KAAKA,CAACyB,cAAoD,EAAE;IAC9D,IAAI,CAAC3C,SAAS,GAAG2C,cAAc;EACjC;AACF;AAACC,OAAA,CAAApD,OAAA,GAAAN,iBAAA","ignoreList":[]}
|
|
@@ -12,6 +12,7 @@ var _LinkModel = _interopRequireDefault(require("../links/LinkModel"));
|
|
|
12
12
|
var _LinkCollection = _interopRequireDefault(require("../links/LinkCollection"));
|
|
13
13
|
var _ConceptTypeDetailModel = _interopRequireDefault(require("./ConceptTypeDetailModel"));
|
|
14
14
|
var _Constants = require("../../constants/Constants");
|
|
15
|
+
var _constants = require("../../constants");
|
|
15
16
|
/**
|
|
16
17
|
* Link to a concept
|
|
17
18
|
*/
|
|
@@ -21,11 +22,17 @@ class ConceptLinkModel extends _BaseModel.default {
|
|
|
21
22
|
*/
|
|
22
23
|
constructor(data) {
|
|
23
24
|
let entryDate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
25
|
+
let origin = arguments.length > 2 ? arguments[2] : undefined;
|
|
26
|
+
let contextPath = arguments.length > 3 ? arguments[3] : undefined;
|
|
24
27
|
super(data, {});
|
|
25
28
|
(0, _defineProperty2.default)(this, "_links", void 0);
|
|
26
29
|
(0, _defineProperty2.default)(this, "_entryDate", void 0);
|
|
27
30
|
(0, _defineProperty2.default)(this, "_conceptType", void 0);
|
|
31
|
+
(0, _defineProperty2.default)(this, "_origin", "");
|
|
32
|
+
(0, _defineProperty2.default)(this, "_contextPath", (0, _constants.getBasePath)());
|
|
28
33
|
this._entryDate = entryDate;
|
|
34
|
+
this._origin = origin || "";
|
|
35
|
+
this._contextPath = contextPath || (0, _constants.getBasePath)();
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
/**
|
|
@@ -87,7 +94,7 @@ class ConceptLinkModel extends _BaseModel.default {
|
|
|
87
94
|
*/
|
|
88
95
|
get links() {
|
|
89
96
|
if (!this._links) {
|
|
90
|
-
this._links = new _LinkCollection.default(Array.isArray(this.data._links) ? this.data._links[0] : this.data._links);
|
|
97
|
+
this._links = new _LinkCollection.default(Array.isArray(this.data._links) ? this.data._links[0] : this.data._links, null, this._contextPath, this._origin);
|
|
91
98
|
}
|
|
92
99
|
return this._links;
|
|
93
100
|
}
|
|
@@ -135,7 +142,6 @@ class ConceptLinkModel extends _BaseModel.default {
|
|
|
135
142
|
/**
|
|
136
143
|
*/
|
|
137
144
|
asLinkModel() {
|
|
138
|
-
// TODO SBO: origin and contextpath
|
|
139
145
|
const link = _LinkModel.default.create(this.key, this.selfhref.href, this.label);
|
|
140
146
|
link.href = this.selfhref;
|
|
141
147
|
return link;
|
|
@@ -147,13 +153,6 @@ class ConceptLinkModel extends _BaseModel.default {
|
|
|
147
153
|
isOfConceptType(conceptTypeId) {
|
|
148
154
|
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
149
155
|
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
153
|
-
*/
|
|
154
|
-
hasMetamodelIdInConceptTypeHierarchy(metamodelId) {
|
|
155
|
-
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
156
|
-
}
|
|
157
156
|
}
|
|
158
157
|
exports.default = ConceptLinkModel;
|
|
159
158
|
//# sourceMappingURL=ConceptLinkModel.js.map
|
|
@@ -7,6 +7,7 @@ import { TIMEVERSION_FILTER_NAME } from "../../constants/Constants";
|
|
|
7
7
|
|
|
8
8
|
import type { IModelWithChildModels, ModularUIModel } from "../types";
|
|
9
9
|
import type Href from "../href/Href";
|
|
10
|
+
import { getBasePath } from "../../constants";
|
|
10
11
|
/**
|
|
11
12
|
* Link to a concept
|
|
12
13
|
*/
|
|
@@ -17,14 +18,23 @@ export default class ConceptLinkModel
|
|
|
17
18
|
_links: ?LinkCollection;
|
|
18
19
|
_entryDate: ?ISO_DATE;
|
|
19
20
|
_conceptType: ?ConceptTypeDetailModel;
|
|
21
|
+
_origin: string = "";
|
|
22
|
+
_contextPath: string = getBasePath();
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* Construct ConceptLinkModel
|
|
23
26
|
*/
|
|
24
|
-
constructor(
|
|
27
|
+
constructor(
|
|
28
|
+
data: Object,
|
|
29
|
+
entryDate: ?ISO_DATE = null,
|
|
30
|
+
origin?: string,
|
|
31
|
+
contextPath?: string,
|
|
32
|
+
) {
|
|
25
33
|
super(data, {});
|
|
26
34
|
|
|
27
35
|
this._entryDate = entryDate;
|
|
36
|
+
this._origin = origin || "";
|
|
37
|
+
this._contextPath = contextPath || getBasePath();
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
/**
|
|
@@ -97,6 +107,9 @@ export default class ConceptLinkModel
|
|
|
97
107
|
Array.isArray(this.data._links)
|
|
98
108
|
? this.data._links[0]
|
|
99
109
|
: this.data._links,
|
|
110
|
+
null,
|
|
111
|
+
this._contextPath,
|
|
112
|
+
this._origin,
|
|
100
113
|
);
|
|
101
114
|
}
|
|
102
115
|
|
|
@@ -156,7 +169,6 @@ export default class ConceptLinkModel
|
|
|
156
169
|
/**
|
|
157
170
|
*/
|
|
158
171
|
asLinkModel(): LinkModel {
|
|
159
|
-
// TODO SBO: origin and contextpath
|
|
160
172
|
const link = LinkModel.create(this.key, this.selfhref.href, this.label);
|
|
161
173
|
link.href = this.selfhref;
|
|
162
174
|
|
|
@@ -169,11 +181,4 @@ export default class ConceptLinkModel
|
|
|
169
181
|
isOfConceptType(conceptTypeId: string): boolean {
|
|
170
182
|
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
171
183
|
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
175
|
-
*/
|
|
176
|
-
hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean {
|
|
177
|
-
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
178
|
-
}
|
|
179
184
|
}
|