@beinformed/ui 1.56.1 → 1.56.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/esm/hooks/useModularUI.js +20 -18
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +18 -16
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +0 -7
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.js +0 -7
- 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/redux/_modularui/ModularUISelectors.js +3 -2
- package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +10 -0
- package/lib/hooks/__tests__/useForm.spec.js.flow +12 -1
- package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +9 -0
- package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +9 -0
- package/lib/hooks/useModularUI.js +19 -17
- package/lib/hooks/useModularUI.js.flow +26 -16
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +18 -16
- package/lib/hooks/useModularUIBasic.js.flow +23 -16
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +0 -7
- package/lib/models/concepts/ConceptDetailModel.js.flow +0 -7
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js +0 -7
- package/lib/models/concepts/ConceptLinkModel.js.flow +0 -7
- 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/__tests__/ConceptTypeDetailModel.spec.js.flow +1 -18
- package/lib/redux/_modularui/ModularUISelectors.js +2 -2
- package/lib/redux/_modularui/ModularUISelectors.js.flow +8 -3
- package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/__tests__/UseModularUIModel.spec.js +10 -0
- package/src/hooks/__tests__/useForm.spec.js +12 -1
- package/src/hooks/__tests__/useModelCatalog.spec.js +9 -0
- package/src/hooks/__tests__/useModularUIBasic.spec.js +9 -0
- package/src/hooks/useModularUI.js +26 -16
- package/src/hooks/useModularUIBasic.js +23 -16
- package/src/models/concepts/ConceptDetailModel.js +0 -7
- package/src/models/concepts/ConceptLinkModel.js +0 -7
- package/src/models/concepts/ConceptTypeDetailModel.js +3 -25
- package/src/models/concepts/__mock__/concepttype_hierarchy.json +1 -11
- package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +1 -18
- package/src/redux/_modularui/ModularUISelectors.js +8 -3
|
@@ -3,6 +3,7 @@ import thunk from "redux-thunk";
|
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
4
|
import { renderHook } from "@testing-library/react";
|
|
5
5
|
import xhrMock from "xhr-mock";
|
|
6
|
+
import { useLocation } from "react-router";
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
useAttributeSet,
|
|
@@ -19,12 +20,22 @@ import { IllegalArgumentException } from "../../exceptions";
|
|
|
19
20
|
const middlewares = [thunk];
|
|
20
21
|
const mockStore = configureMockStore(middlewares);
|
|
21
22
|
|
|
23
|
+
jest.mock("react-router", () => ({
|
|
24
|
+
...jest.requireActual("react-router"), // Keep other methods from react-router as is
|
|
25
|
+
useLocation: jest.fn(), // Mock useLocation
|
|
26
|
+
}));
|
|
27
|
+
|
|
22
28
|
const JSON_TYPE = "application/json";
|
|
23
29
|
|
|
24
30
|
describe("form hooks", () => {
|
|
25
31
|
// replace the real XHR object with the mock XHR object before each test
|
|
26
32
|
// eslint-disable-next-line jest/no-hooks
|
|
27
|
-
beforeEach(() =>
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
useLocation.mockReturnValue({
|
|
35
|
+
state: null,
|
|
36
|
+
});
|
|
37
|
+
xhrMock.setup();
|
|
38
|
+
});
|
|
28
39
|
|
|
29
40
|
// put the real XHR object back and clear the mocks after each test
|
|
30
41
|
// eslint-disable-next-line jest/no-hooks
|
|
@@ -3,6 +3,7 @@ import thunk from "redux-thunk";
|
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
4
|
import { renderHook } from "@testing-library/react";
|
|
5
5
|
import xhrMock from "xhr-mock";
|
|
6
|
+
import { useLocation } from "react-router";
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
ConceptIndexModel,
|
|
@@ -26,6 +27,11 @@ import {
|
|
|
26
27
|
const middlewares = [thunk];
|
|
27
28
|
const mockStore = configureMockStore(middlewares);
|
|
28
29
|
|
|
30
|
+
jest.mock("react-router", () => ({
|
|
31
|
+
...jest.requireActual("react-router"), // Keep other methods from react-router as is
|
|
32
|
+
useLocation: jest.fn(), // Mock useLocation
|
|
33
|
+
}));
|
|
34
|
+
|
|
29
35
|
const JSON_TYPE = "application/json";
|
|
30
36
|
|
|
31
37
|
describe("modelcatalog hooks", () => {
|
|
@@ -77,6 +83,9 @@ describe("modelcatalog hooks", () => {
|
|
|
77
83
|
// replace the real XHR object with the mock XHR object before each test
|
|
78
84
|
// eslint-disable-next-line jest/no-hooks
|
|
79
85
|
beforeEach(() => {
|
|
86
|
+
useLocation.mockReturnValue({
|
|
87
|
+
state: null,
|
|
88
|
+
});
|
|
80
89
|
xhrMock.setup();
|
|
81
90
|
});
|
|
82
91
|
|
|
@@ -6,16 +6,25 @@ import xhrMock from "xhr-mock";
|
|
|
6
6
|
|
|
7
7
|
import { useModularUIBasic } from "../useModularUIBasic";
|
|
8
8
|
import { ApplicationModel, Href } from "../../models";
|
|
9
|
+
import { useLocation } from "react-router";
|
|
9
10
|
|
|
10
11
|
const middlewares = [thunk];
|
|
11
12
|
const mockStore = configureMockStore(middlewares);
|
|
12
13
|
|
|
14
|
+
jest.mock("react-router", () => ({
|
|
15
|
+
...jest.requireActual("react-router"), // Keep other methods from react-router as is
|
|
16
|
+
useLocation: jest.fn(), // Mock useLocation
|
|
17
|
+
}));
|
|
18
|
+
|
|
13
19
|
const JSON_TYPE = "application/json";
|
|
14
20
|
|
|
15
21
|
describe("modularui hooks", () => {
|
|
16
22
|
// replace the real XHR object with the mock XHR object before each test
|
|
17
23
|
// eslint-disable-next-line jest/no-hooks
|
|
18
24
|
beforeEach(() => {
|
|
25
|
+
useLocation.mockReturnValue({
|
|
26
|
+
state: null,
|
|
27
|
+
});
|
|
19
28
|
xhrMock.setup();
|
|
20
29
|
});
|
|
21
30
|
|
|
@@ -7,15 +7,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.useModularUI = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _reactRedux = require("react-redux");
|
|
10
|
+
var _reactRouter = require("react-router");
|
|
10
11
|
var _constants = require("../constants");
|
|
11
12
|
var _ModularUIActions = require("../redux/_modularui/ModularUIActions");
|
|
12
13
|
var _useDeepCompareEffect = _interopRequireDefault(require("./useDeepCompareEffect"));
|
|
13
14
|
var _useI18n = require("./useI18n");
|
|
15
|
+
var _Href = _interopRequireDefault(require("../models/href/Href"));
|
|
14
16
|
/**
|
|
15
17
|
*/
|
|
16
18
|
const useKeyForHook = (modelKey, url) => {
|
|
17
19
|
const locale = (0, _useI18n.useLocale)();
|
|
18
|
-
return `${modelKey}(${url.split("?")[0]})(${locale})
|
|
20
|
+
return (0, _react.useMemo)(() => `${modelKey}(${url.split("?")[0]})(${locale})`, [modelKey, url, locale]);
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -27,36 +29,36 @@ const useModularUI = function (modelKey, url) {
|
|
|
27
29
|
removeOnUnmount: false
|
|
28
30
|
};
|
|
29
31
|
const dispatch = (0, _reactRedux.useDispatch)();
|
|
30
|
-
const href = url?.toString() || "";
|
|
32
|
+
const href = (0, _react.useMemo)(() => url?.toString() || "", [url]);
|
|
31
33
|
const key = useKeyForHook(modelKey, href);
|
|
34
|
+
const location = (0, _reactRouter.useLocation)();
|
|
35
|
+
const redirectLocation = location.state?.redirectLocation;
|
|
36
|
+
const forceReload = redirectLocation instanceof _Href.default ? redirectLocation?.equals(href) : false;
|
|
32
37
|
const prevOptions = (0, _react.useRef)(options);
|
|
33
38
|
const prevHref = (0, _react.useRef)(href);
|
|
39
|
+
const prevForceReload = (0, _react.useRef)(forceReload);
|
|
34
40
|
|
|
35
41
|
// dispatch loadModularUI
|
|
36
42
|
(0, _useDeepCompareEffect.default)(() => {
|
|
37
43
|
// prevent reloads when previous option had the isReload, but the new options not
|
|
38
44
|
const isOldReload = prevHref.current === href && prevOptions.current.isReload && !options.isReload;
|
|
39
|
-
|
|
45
|
+
const doForceReload = forceReload && !prevForceReload.current;
|
|
46
|
+
if (href !== "" && (doForceReload || !isOldReload)) {
|
|
40
47
|
dispatch((0, _ModularUIActions.loadModularUI)(key, href, options));
|
|
41
48
|
}
|
|
42
49
|
prevOptions.current = options;
|
|
43
50
|
prevHref.current = href;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
removeOnUnmount = false
|
|
47
|
-
} = options;
|
|
51
|
+
prevForceReload.current = forceReload;
|
|
52
|
+
}, [key, href, options, forceReload]);
|
|
48
53
|
(0, _react.useEffect)(() => {
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
if (options.removeOnUnmount) {
|
|
55
|
+
return () => {
|
|
51
56
|
dispatch((0, _ModularUIActions.removeModelByKey)(key));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}, [dispatch, key, removeOnUnmount]);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return (0, _reactRedux.useSelector)(state => {
|
|
58
|
-
return state.modularui[key];
|
|
59
|
-
});
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}, [dispatch, key, options.removeOnUnmount]);
|
|
60
|
+
const selector = (0, _react.useMemo)(() => state => state.modularui[key], [key]);
|
|
61
|
+
return (0, _reactRedux.useSelector)(selector);
|
|
60
62
|
};
|
|
61
63
|
exports.useModularUI = useModularUI;
|
|
62
64
|
//# sourceMappingURL=useModularUI.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
2
|
+
import { useEffect, useRef, useMemo } from "react";
|
|
3
3
|
import { useDispatch, useSelector } from "react-redux";
|
|
4
|
+
import { useLocation } from "react-router";
|
|
4
5
|
|
|
5
6
|
import { HTTP_METHODS } from "../constants";
|
|
6
7
|
import {
|
|
@@ -12,14 +13,17 @@ import useDeepCompareEffect from "./useDeepCompareEffect";
|
|
|
12
13
|
|
|
13
14
|
import { useLocale } from "./useI18n";
|
|
14
15
|
|
|
15
|
-
import
|
|
16
|
+
import Href from "../models/href/Href";
|
|
16
17
|
import type { RequestModularUIOptions } from "../utils";
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
*/
|
|
20
21
|
const useKeyForHook = (modelKey: string, url: string) => {
|
|
21
22
|
const locale = useLocale();
|
|
22
|
-
return
|
|
23
|
+
return useMemo(
|
|
24
|
+
() => `${modelKey}(${url.split("?")[0]})(${locale})`,
|
|
25
|
+
[modelKey, url, locale],
|
|
26
|
+
);
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
/**
|
|
@@ -34,11 +38,17 @@ export const useModularUI = (
|
|
|
34
38
|
},
|
|
35
39
|
): any => {
|
|
36
40
|
const dispatch = useDispatch();
|
|
37
|
-
const href = url?.toString() || "";
|
|
41
|
+
const href = useMemo(() => url?.toString() || "", [url]);
|
|
38
42
|
const key = useKeyForHook(modelKey, href);
|
|
39
43
|
|
|
44
|
+
const location = useLocation();
|
|
45
|
+
const redirectLocation = location.state?.redirectLocation;
|
|
46
|
+
const forceReload =
|
|
47
|
+
redirectLocation instanceof Href ? redirectLocation?.equals(href) : false;
|
|
48
|
+
|
|
40
49
|
const prevOptions = useRef(options);
|
|
41
50
|
const prevHref = useRef(href);
|
|
51
|
+
const prevForceReload = useRef(forceReload);
|
|
42
52
|
|
|
43
53
|
// dispatch loadModularUI
|
|
44
54
|
useDeepCompareEffect(() => {
|
|
@@ -48,25 +58,25 @@ export const useModularUI = (
|
|
|
48
58
|
prevOptions.current.isReload &&
|
|
49
59
|
!options.isReload;
|
|
50
60
|
|
|
51
|
-
|
|
61
|
+
const doForceReload = forceReload && !prevForceReload.current;
|
|
62
|
+
|
|
63
|
+
if (href !== "" && (doForceReload || !isOldReload)) {
|
|
52
64
|
dispatch(loadModularUI(key, href, options));
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
prevOptions.current = options;
|
|
56
68
|
prevHref.current = href;
|
|
57
|
-
|
|
69
|
+
prevForceReload.current = forceReload;
|
|
70
|
+
}, [key, href, options, forceReload]);
|
|
58
71
|
|
|
59
|
-
const { removeOnUnmount = false } = options;
|
|
60
72
|
useEffect(() => {
|
|
61
|
-
|
|
62
|
-
|
|
73
|
+
if (options.removeOnUnmount) {
|
|
74
|
+
return () => {
|
|
63
75
|
dispatch(removeModelByKey(key));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}, [dispatch, key, removeOnUnmount]);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}, [dispatch, key, options.removeOnUnmount]);
|
|
67
79
|
|
|
68
|
-
|
|
69
|
-
return useSelector(
|
|
70
|
-
return state.modularui[key];
|
|
71
|
-
});
|
|
80
|
+
const selector = useMemo(() => (state) => state.modularui[key], [key]);
|
|
81
|
+
return useSelector(selector);
|
|
72
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUI.js","names":["_react","require","_reactRedux","_constants","_ModularUIActions","_useDeepCompareEffect","_interopRequireDefault","_useI18n","useKeyForHook","modelKey","url","locale","useLocale","split","useModularUI","options","arguments","length","undefined","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","prevOptions","useRef","prevHref","useDeepCompareEffect","isOldReload","current","isReload","loadModularUI","useEffect","removeModelByKey","
|
|
1
|
+
{"version":3,"file":"useModularUI.js","names":["_react","require","_reactRedux","_reactRouter","_constants","_ModularUIActions","_useDeepCompareEffect","_interopRequireDefault","_useI18n","_Href","useKeyForHook","modelKey","url","locale","useLocale","useMemo","split","useModularUI","options","arguments","length","undefined","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","location","useLocation","redirectLocation","state","forceReload","Href","equals","prevOptions","useRef","prevHref","prevForceReload","useDeepCompareEffect","isOldReload","current","isReload","doForceReload","loadModularUI","useEffect","removeModelByKey","selector","modularui","useSelector","exports"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef, useMemo } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\n\nimport Href from \"../models/href/Href\";\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return useMemo(\n () => `${modelKey}(${url.split(\"?\")[0]})(${locale})`,\n [modelKey, url, locale],\n );\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n },\n): any => {\n const dispatch = useDispatch();\n const href = useMemo(() => url?.toString() || \"\", [url]);\n const key = useKeyForHook(modelKey, href);\n\n const location = useLocation();\n const redirectLocation = location.state?.redirectLocation;\n const forceReload =\n redirectLocation instanceof Href ? redirectLocation?.equals(href) : false;\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n const prevForceReload = useRef(forceReload);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n const doForceReload = forceReload && !prevForceReload.current;\n\n if (href !== \"\" && (doForceReload || !isOldReload)) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n prevForceReload.current = forceReload;\n }, [key, href, options, forceReload]);\n\n useEffect(() => {\n if (options.removeOnUnmount) {\n return () => {\n dispatch(removeModelByKey(key));\n };\n }\n }, [dispatch, key, options.removeOnUnmount]);\n\n const selector = useMemo(() => (state) => state.modularui[key], [key]);\n return useSelector(selector);\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAKA,IAAAK,qBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAEA,IAAAO,QAAA,GAAAP,OAAA;AAEA,IAAAQ,KAAA,GAAAF,sBAAA,CAAAN,OAAA;AAGA;AACA;AACA,MAAMS,aAAa,GAAGA,CAACC,QAAgB,EAAEC,GAAW,KAAK;EACvD,MAAMC,MAAM,GAAG,IAAAC,kBAAS,EAAC,CAAC;EAC1B,OAAO,IAAAC,cAAO,EACZ,MAAM,GAAGJ,QAAQ,IAAIC,GAAG,CAACI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAKH,MAAM,GAAG,EACpD,CAACF,QAAQ,EAAEC,GAAG,EAAEC,MAAM,CACxB,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACO,MAAMI,YAAY,GAAG,SAAAA,CAC1BN,QAAgB,EA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AAC,CAAC;IAC7C;IAEAoB,WAAW,CAACM,OAAO,GAAG1B,OAAO;IAC7BsB,QAAQ,CAACI,OAAO,GAAGhB,IAAI;IACvBa,eAAe,CAACG,OAAO,GAAGT,WAAW;EACvC,CAAC,EAAE,CAACL,GAAG,EAAEF,IAAI,EAAEV,OAAO,EAAEiB,WAAW,CAAC,CAAC;EAErC,IAAAa,gBAAS,EAAC,MAAM;IACd,IAAI9B,OAAO,CAACO,eAAe,EAAE;MAC3B,OAAO,MAAM;QACXC,QAAQ,CAAC,IAAAuB,kCAAgB,EAACnB,GAAG,CAAC,CAAC;MACjC,CAAC;IACH;EACF,CAAC,EAAE,CAACJ,QAAQ,EAAEI,GAAG,EAAEZ,OAAO,CAACO,eAAe,CAAC,CAAC;EAE5C,MAAMyB,QAAQ,GAAG,IAAAnC,cAAO,EAAC,MAAOmB,KAAK,IAAKA,KAAK,CAACiB,SAAS,CAACrB,GAAG,CAAC,EAAE,CAACA,GAAG,CAAC,CAAC;EACtE,OAAO,IAAAsB,uBAAW,EAACF,QAAQ,CAAC;AAC9B,CAAC;AAACG,OAAA,CAAApC,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ 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");
|
|
@@ -19,6 +20,7 @@ const useModularUIBasic = function (key, href) {
|
|
|
19
20
|
forceTargetModel: false
|
|
20
21
|
};
|
|
21
22
|
const location = (0, _useRouter.useLocation)();
|
|
23
|
+
const memoizedHref = (0, _react.useMemo)(() => href.toString(), [href]);
|
|
22
24
|
const useModularUIOptions = {
|
|
23
25
|
targetModel: undefined,
|
|
24
26
|
forceTargetModel: undefined,
|
|
@@ -39,24 +41,24 @@ const useModularUIBasic = function (key, href) {
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
// $FlowFixMe[incompatible-call]
|
|
42
|
-
const modularUI = (0, _useModularUI.useModularUI)(key,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
const modularUI = (0, _useModularUI.useModularUI)(key, memoizedHref, useModularUIOptions);
|
|
45
|
+
const expectedModels = (0, _react.useMemo)(() => options.expectedModels ?? [], [options.expectedModels]);
|
|
46
|
+
return (0, _react.useMemo)(() => {
|
|
47
|
+
if (modularUI?.model) {
|
|
48
|
+
const {
|
|
49
|
+
model
|
|
50
|
+
} = modularUI;
|
|
51
|
+
if (expectedModels.length > 0) {
|
|
52
|
+
const isCorrectModel = expectedModels.some(expectedModel => model.type === expectedModel);
|
|
53
|
+
if (!isCorrectModel) {
|
|
54
|
+
console.error(modularUI, "is not of instance", expectedModels);
|
|
55
|
+
throw new _exceptions.IllegalStateException("Resolved model has incorrect type");
|
|
56
|
+
}
|
|
55
57
|
}
|
|
58
|
+
return model;
|
|
56
59
|
}
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
+
return null;
|
|
61
|
+
}, [expectedModels, modularUI]);
|
|
60
62
|
};
|
|
61
63
|
exports.useModularUIBasic = useModularUIBasic;
|
|
62
64
|
//# sourceMappingURL=useModularUIBasic.js.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
|
|
2
4
|
import { useModularUI } from "./useModularUI";
|
|
3
5
|
|
|
4
6
|
import { useLocation } from "./useRouter";
|
|
@@ -26,6 +28,7 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
26
28
|
},
|
|
27
29
|
): T | null => {
|
|
28
30
|
const location = useLocation();
|
|
31
|
+
const memoizedHref = useMemo(() => href.toString(), [href]);
|
|
29
32
|
|
|
30
33
|
const useModularUIOptions = {
|
|
31
34
|
targetModel: undefined,
|
|
@@ -48,25 +51,29 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
// $FlowFixMe[incompatible-call]
|
|
51
|
-
const modularUI = useModularUI(key,
|
|
54
|
+
const modularUI = useModularUI(key, memoizedHref, useModularUIOptions);
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
const expectedModels = useMemo(
|
|
57
|
+
() => options.expectedModels ?? [],
|
|
58
|
+
[options.expectedModels],
|
|
59
|
+
);
|
|
55
60
|
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
return model.type === expectedModel;
|
|
60
|
-
});
|
|
61
|
+
return useMemo((): T | null => {
|
|
62
|
+
if (modularUI?.model) {
|
|
63
|
+
const { model } = modularUI;
|
|
61
64
|
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
if (expectedModels.length > 0) {
|
|
66
|
+
const isCorrectModel = expectedModels.some(
|
|
67
|
+
(expectedModel) => model.type === expectedModel,
|
|
68
|
+
);
|
|
69
|
+
if (!isCorrectModel) {
|
|
70
|
+
console.error(modularUI, "is not of instance", expectedModels);
|
|
71
|
+
throw new IllegalStateException("Resolved model has incorrect type");
|
|
72
|
+
}
|
|
65
73
|
}
|
|
66
|
-
}
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
return model;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}, [expectedModels, modularUI]);
|
|
72
79
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIBasic.js","names":["
|
|
1
|
+
{"version":3,"file":"useModularUIBasic.js","names":["_react","require","_useModularUI","_useRouter","_exceptions","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useLocation","memoizedHref","useMemo","toString","useModularUIOptions","isReload","cache","state","reload","_startsWith","default","pathname","call","modularUI","useModularUI","model","isCorrectModel","some","expectedModel","type","console","error","IllegalStateException","exports"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useMemo } from \"react\";\n\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\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 cache?: boolean,\n};\n\n/**\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 },\n): T | null => {\n const location = useLocation();\n const memoizedHref = useMemo(() => href.toString(), [href]);\n\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n cache: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\n }\n\n if (options.cache) {\n useModularUIOptions.cache = options.cache;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n // $FlowFixMe[incompatible-call]\n const modularUI = useModularUI(key, memoizedHref, useModularUIOptions);\n\n const expectedModels = useMemo(\n () => options.expectedModels ?? [],\n [options.expectedModels],\n );\n\n return useMemo((): T | null => {\n if (modularUI?.model) {\n const { model } = modularUI;\n\n if (expectedModels.length > 0) {\n const isCorrectModel = expectedModels.some(\n (expectedModel) => model.type === expectedModel,\n );\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n return null;\n }, [expectedModels, modularUI]);\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AAWA;AACA;AACO,MAAMI,iBAAiB,GAAG,SAAAA,CAC/BC,GAAW,EACXC,IAAmB,EAMN;EAAA,IAAAC,QAAA;EAAA,IALbC,OAAoC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IACrCG,cAAc,EAAE,EAAE;IAClBC,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAE;EACpB,CAAC;EAED,MAAMC,QAAQ,GAAG,IAAAC,sBAAW,EAAC,CAAC;EAC9B,MAAMC,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAMZ,IAAI,CAACa,QAAQ,CAAC,CAAC,EAAE,CAACb,IAAI,CAAC,CAAC;EAE3D,MAAMc,mBAAmB,GAAG;IAC1BP,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAEH,SAAS;IAC3BU,QAAQ,EAAE,KAAK;IACfC,KAAK,EAAE;EACT,CAAC;EACD,IAAId,OAAO,CAACK,WAAW,EAAE;IACvBO,mBAAmB,CAACP,WAAW,GAAGL,OAAO,CAACK,WAAW;IACrDO,mBAAmB,CAACN,gBAAgB,GAAGN,OAAO,CAACM,gBAAgB;EACjE;EAEA,IAAIN,OAAO,CAACc,KAAK,EAAE;IACjBF,mBAAmB,CAACE,KAAK,GAAGd,OAAO,CAACc,KAAK;EAC3C;;EAEA;EACA,IAAIP,QAAQ,CAACQ,KAAK,EAAEC,MAAM,IAAI,IAAAC,WAAA,CAAAC,OAAA,EAAAnB,QAAA,GAAAQ,QAAQ,CAACY,QAAQ,EAAAC,IAAA,CAAArB,QAAA,EAAYD,IAAI,CAACa,QAAQ,CAAC,CAAC,CAAC,EAAE;IAC3EC,mBAAmB,CAACC,QAAQ,GAAG,IAAI;EACrC;;EAEA;EACA,MAAMQ,SAAS,GAAG,IAAAC,0BAAY,EAACzB,GAAG,EAAEY,YAAY,EAAEG,mBAAmB,CAAC;EAEtE,MAAMR,cAAc,GAAG,IAAAM,cAAO,EAC5B,MAAMV,OAAO,CAACI,cAAc,IAAI,EAAE,EAClC,CAACJ,OAAO,CAACI,cAAc,CACzB,CAAC;EAED,OAAO,IAAAM,cAAO,EAAC,MAAgB;IAC7B,IAAIW,SAAS,EAAEE,KAAK,EAAE;MACpB,MAAM;QAAEA;MAAM,CAAC,GAAGF,SAAS;MAE3B,IAAIjB,cAAc,CAACF,MAAM,GAAG,CAAC,EAAE;QAC7B,MAAMsB,cAAc,GAAGpB,cAAc,CAACqB,IAAI,CACvCC,aAAa,IAAKH,KAAK,CAACI,IAAI,KAAKD,aACpC,CAAC;QACD,IAAI,CAACF,cAAc,EAAE;UACnBI,OAAO,CAACC,KAAK,CAACR,SAAS,EAAE,oBAAoB,EAAEjB,cAAc,CAAC;UAC9D,MAAM,IAAI0B,iCAAqB,CAAC,mCAAmC,CAAC;QACtE;MACF;MAEA,OAAOP,KAAK;IACd;IACA,OAAO,IAAI;EACb,CAAC,EAAE,CAACnB,cAAc,EAAEiB,SAAS,CAAC,CAAC;AACjC,CAAC;AAACU,OAAA,CAAAnC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -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
|
|
@@ -338,11 +338,4 @@ export default class ConceptDetailModel extends ResourceModel {
|
|
|
338
338
|
isOfConceptType(conceptTypeId: string): boolean {
|
|
339
339
|
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
340
340
|
}
|
|
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
341
|
}
|
|
@@ -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,sBA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,CAAC;QAAA,CACvD,CAAC;MACH;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","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 );\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,wBAAwB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AAL,kBAAA","ignoreList":[]}
|
|
@@ -146,13 +146,6 @@ class ConceptLinkModel extends _BaseModel.default {
|
|
|
146
146
|
isOfConceptType(conceptTypeId) {
|
|
147
147
|
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
152
|
-
*/
|
|
153
|
-
hasMetamodelIdInConceptTypeHierarchy(metamodelId) {
|
|
154
|
-
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
155
|
-
}
|
|
156
149
|
}
|
|
157
150
|
exports.default = ConceptLinkModel;
|
|
158
151
|
//# sourceMappingURL=ConceptLinkModel.js.map
|
|
@@ -168,11 +168,4 @@ export default class ConceptLinkModel
|
|
|
168
168
|
isOfConceptType(conceptTypeId: string): boolean {
|
|
169
169
|
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
170
170
|
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
174
|
-
*/
|
|
175
|
-
hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean {
|
|
176
|
-
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
177
|
-
}
|
|
178
171
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptLinkModel.js","names":["_BaseModel","_interopRequireDefault","require","_LinkModel","_LinkCollection","_ConceptTypeDetailModel","_Constants","ConceptLinkModel","BaseModel","constructor","data","entryDate","arguments","length","undefined","_defineProperty2","default","_entryDate","getInitialChildModelLinks","conceptTypeLink","isCacheable","setChildModels","models","href","conceptTypeModel","_find","call","model","selfhref","equalsWithParameters","type","conceptType","_conceptType","ConceptTypeDetailModel","key","_id","label","getData","links","_links","LinkCollection","Array","isArray","selflink","getLinkByKey","Error","addParameter","TIMEVERSION_FILTER_NAME","concepttypeHref","taxonomyType","asLinkModel","link","LinkModel","create","isOfConceptType","conceptTypeId","
|
|
1
|
+
{"version":3,"file":"ConceptLinkModel.js","names":["_BaseModel","_interopRequireDefault","require","_LinkModel","_LinkCollection","_ConceptTypeDetailModel","_Constants","ConceptLinkModel","BaseModel","constructor","data","entryDate","arguments","length","undefined","_defineProperty2","default","_entryDate","getInitialChildModelLinks","conceptTypeLink","isCacheable","setChildModels","models","href","conceptTypeModel","_find","call","model","selfhref","equalsWithParameters","type","conceptType","_conceptType","ConceptTypeDetailModel","key","_id","label","getData","links","_links","LinkCollection","Array","isArray","selflink","getLinkByKey","Error","addParameter","TIMEVERSION_FILTER_NAME","concepttypeHref","taxonomyType","asLinkModel","link","LinkModel","create","isOfConceptType","conceptTypeId","exports"],"sources":["../../../src/models/concepts/ConceptLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport ConceptTypeDetailModel from \"./ConceptTypeDetailModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type { IModelWithChildModels, ModularUIModel } from \"../types\";\nimport type Href from \"../href/Href\";\n/**\n * Link to a concept\n */\nexport default class ConceptLinkModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _links: ?LinkCollection;\n _entryDate: ?ISO_DATE;\n _conceptType: ?ConceptTypeDetailModel;\n\n /**\n * Construct ConceptLinkModel\n */\n constructor(data: Object, entryDate: ?ISO_DATE = null) {\n super(data, {});\n\n this._entryDate = entryDate;\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n if (this.conceptTypeLink) {\n this.conceptTypeLink.isCacheable = true;\n return [this.conceptTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n if (this.conceptTypeLink) {\n const href = this.conceptTypeLink.href;\n const conceptTypeModel = models.find((model) =>\n model.selfhref.equalsWithParameters(href),\n );\n\n if (conceptTypeModel?.type === \"ConceptTypeDetail\") {\n this.conceptType = conceptTypeModel;\n }\n }\n }\n\n /**\n * Retrieve concept type\n */\n get conceptType(): ?ConceptTypeDetailModel {\n return this._conceptType;\n }\n\n /**\n * Set concept type\n */\n set conceptType(conceptType: ?ModularUIModel) {\n this._conceptType =\n conceptType instanceof ConceptTypeDetailModel ? conceptType : null;\n }\n\n /**\n * Retrieve key\n */\n get key(): string {\n return this.data._id;\n }\n\n /**\n * Retrieve label\n */\n get label(): string {\n const label = this.getData(\"label\");\n\n if (label) {\n return label;\n }\n\n return this.getData(\"conceptLabel\", \"\");\n }\n\n /**\n * Getting the links of the resource\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n Array.isArray(this.data._links)\n ? this.data._links[0]\n : this.data._links,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel {\n const selflink = this.links.getLinkByKey(\"self\");\n\n if (selflink === null) {\n throw new Error(\n `Could not find self link for ${\n this.key === null ? \"unknown\" : this.key\n }`,\n );\n }\n\n return selflink;\n }\n\n /**\n * Self href of concept\n */\n get selfhref(): Href {\n if (this._entryDate !== null) {\n return this.selflink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this._entryDate,\n );\n }\n\n return this.selflink.href;\n }\n\n /**\n */\n get conceptTypeLink(): LinkModel | null {\n return this.links.getLinkByKey(\"concepttype\");\n }\n\n /**\n * Concept type href of concept\n */\n get concepttypeHref(): Href | null {\n return this.conceptTypeLink?.href ?? null;\n }\n\n /**\n */\n get taxonomyType(): string {\n return \"default\";\n }\n\n /**\n */\n asLinkModel(): LinkModel {\n const link = LinkModel.create(this.key, this.selfhref.href, this.label);\n link.href = this.selfhref;\n\n return link;\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;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