@beinformed/ui 1.50.4 → 1.52.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 +15 -0
- package/esm/hooks/useModularUI.js +2 -2
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +1 -4
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +15 -1
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/ConceptTypeDetailModel.js +29 -0
- package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/esm/models/links/LinkCollection.js +14 -0
- package/esm/models/links/LinkCollection.js.map +1 -1
- package/esm/models/user/UserServicesModel.js.map +1 -1
- package/lib/hooks/useModularUI.js +2 -2
- package/lib/hooks/useModularUI.js.flow +2 -2
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +0 -3
- package/lib/hooks/useModularUIBasic.js.flow +1 -4
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +15 -1
- package/lib/models/concepts/ConceptDetailModel.js.flow +15 -1
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptTypeDetailModel.js +29 -0
- package/lib/models/concepts/ConceptTypeDetailModel.js.flow +34 -0
- package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/lib/models/concepts/__mock__/concepttype_hierarchy.js.flow +13 -0
- package/lib/models/concepts/__tests__/ConceptTypeDetailModel.spec.js.flow +40 -2
- package/lib/models/links/LinkCollection.js +14 -0
- package/lib/models/links/LinkCollection.js.flow +14 -0
- package/lib/models/links/LinkCollection.js.map +1 -1
- package/lib/models/user/UserServicesModel.js.flow +1 -1
- package/lib/models/user/UserServicesModel.js.map +1 -1
- package/package.json +19 -19
- package/src/hooks/useModularUI.js +2 -2
- package/src/hooks/useModularUIBasic.js +1 -4
- package/src/models/concepts/ConceptDetailModel.js +15 -1
- package/src/models/concepts/ConceptTypeDetailModel.js +34 -0
- package/src/models/concepts/__mock__/concepttype_hierarchy.js +13 -0
- package/src/models/concepts/__mock__/concepttype_hierarchy.json +42 -0
- package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +40 -2
- package/src/models/links/LinkCollection.js +14 -0
- package/src/models/user/UserServicesModel.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.52.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.51.0...v1.52.0) (2024-08-23)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **concept-type:** support concept type hierarchy ([e1dc633](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/e1dc63305d1c2db4596b5d62138e751bb3deffe8))
|
|
11
|
+
* **concept-type:** support concept type hierarchy ([070293c](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/070293ceb4fc54663395619680c08f8a968d5957))
|
|
12
|
+
|
|
13
|
+
## [1.51.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.50.4...v1.51.0) (2024-08-01)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **modularui:** make it possible to call useModularUI with null or empty href ([0546de5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/0546de599f10d7d5ec2cb2746083f3c644b84379))
|
|
19
|
+
|
|
5
20
|
## [1.50.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.50.3...v1.50.4) (2024-07-23)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -20,7 +20,7 @@ export const useModularUI = function (modelKey, url) {
|
|
|
20
20
|
removeOnUnmount: false
|
|
21
21
|
};
|
|
22
22
|
const dispatch = useDispatch();
|
|
23
|
-
const href = url
|
|
23
|
+
const href = url?.toString() || "";
|
|
24
24
|
const key = useKeyForHook(modelKey, href);
|
|
25
25
|
const prevOptions = useRef(options);
|
|
26
26
|
const prevHref = useRef(href);
|
|
@@ -29,7 +29,7 @@ export const useModularUI = function (modelKey, url) {
|
|
|
29
29
|
useDeepCompareEffect(() => {
|
|
30
30
|
// prevent reloads when previous option had the isReload, but the new options not
|
|
31
31
|
const isOldReload = prevHref.current === href && prevOptions.current.isReload && !options.isReload;
|
|
32
|
-
if (!isOldReload) {
|
|
32
|
+
if (href !== "" && !isOldReload) {
|
|
33
33
|
dispatch(loadModularUI(key, href, options));
|
|
34
34
|
}
|
|
35
35
|
prevOptions.current = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useDispatch","useSelector","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useLocale","useKeyForHook","modelKey","url","locale","split","useModularUI","options","arguments","length","undefined","method","GET","removeOnUnmount","dispatch","href","toString","key","prevOptions","prevHref","isOldReload","current","isReload","state","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\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 type 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 `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\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 = url
|
|
1
|
+
{"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useDispatch","useSelector","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useLocale","useKeyForHook","modelKey","url","locale","split","useModularUI","options","arguments","length","undefined","method","GET","removeOnUnmount","dispatch","href","toString","key","prevOptions","prevHref","isOldReload","current","isReload","state","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\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 type 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 `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\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 = url?.toString() || \"\";\n const key = useKeyForHook(modelKey, href);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\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 if (href !== \"\" && !isOldReload) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n }, [key, href, options]);\n\n const { removeOnUnmount = false } = options;\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(key));\n }\n };\n }, [dispatch, key, removeOnUnmount]);\n\n // retrieve current model from modularui reducer\n return useSelector((state) => {\n return state.modularui[key];\n });\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa;AAEtD,SAASC,YAAY,QAAQ,cAAc;AAC3C,SACEC,aAAa,EACbC,gBAAgB,QACX,sCAAsC;AAE7C,OAAOC,oBAAoB,MAAM,wBAAwB;AAEzD,SAASC,SAAS,QAAQ,WAAW;AAKrC;AACA;AACA,MAAMC,aAAa,GAAGA,CAACC,QAAgB,EAAEC,GAAW,KAAK;EACvD,MAAMC,MAAM,GAAGJ,SAAS,CAAC,CAAC;EAC1B,OAAO,GAAGE,QAAQ,IAAIC,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAKD,MAAM,GAAG;AACvD,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAME,YAAY,GAAG,SAAAA,CAC1BJ,QAAgB,EAChBC,GAAkB,EAKV;EAAA,IAJRI,OAAgC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IACjCG,MAAM,EAAEf,YAAY,CAACgB,GAAG;IACxBC,eAAe,EAAE;EACnB,CAAC;EAED,MAAMC,QAAQ,GAAGpB,WAAW,CAAC,CAAC;EAC9B,MAAMqB,IAAI,GAAGZ,GAAG,EAAEa,QAAQ,CAAC,CAAC,IAAI,EAAE;EAClC,MAAMC,GAAG,GAAGhB,aAAa,CAACC,QAAQ,EAAEa,IAAI,CAAC;EAEzC,MAAMG,WAAW,GAAGzB,MAAM,CAACc,OAAO,CAAC;EACnC,MAAMY,QAAQ,GAAG1B,MAAM,CAACsB,IAAI,CAAC;;EAE7B;EACAhB,oBAAoB,CAAC,MAAM;IACzB;IACA,MAAMqB,WAAW,GACfD,QAAQ,CAACE,OAAO,KAAKN,IAAI,IACzBG,WAAW,CAACG,OAAO,CAACC,QAAQ,IAC5B,CAACf,OAAO,CAACe,QAAQ;IAEnB,IAAIP,IAAI,KAAK,EAAE,IAAI,CAACK,WAAW,EAAE;MAC/BN,QAAQ,CAACjB,aAAa,CAACoB,GAAG,EAAEF,IAAI,EAAER,OAAO,CAAC,CAAC;IAC7C;IAEAW,WAAW,CAACG,OAAO,GAAGd,OAAO;IAC7BY,QAAQ,CAACE,OAAO,GAAGN,IAAI;EACzB,CAAC,EAAE,CAACE,GAAG,EAAEF,IAAI,EAAER,OAAO,CAAC,CAAC;EAExB,MAAM;IAAEM,eAAe,GAAG;EAAM,CAAC,GAAGN,OAAO;EAC3Cf,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX,IAAIqB,eAAe,EAAE;QACnBC,QAAQ,CAAChB,gBAAgB,CAACmB,GAAG,CAAC,CAAC;MACjC;IACF,CAAC;EACH,CAAC,EAAE,CAACH,QAAQ,EAAEG,GAAG,EAAEJ,eAAe,CAAC,CAAC;;EAEpC;EACA,OAAOlB,WAAW,CAAE4B,KAAK,IAAK;IAC5B,OAAOA,KAAK,CAACC,SAAS,CAACP,GAAG,CAAC;EAC7B,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
|
|
2
2
|
import { useModularUI } from "./useModularUI";
|
|
3
3
|
import { useLocation } from "./useRouter";
|
|
4
|
-
import {
|
|
4
|
+
import { IllegalStateException } from "../exceptions";
|
|
5
5
|
/**
|
|
6
6
|
*/
|
|
7
7
|
export const useModularUIBasic = function (key, href) {
|
|
@@ -12,9 +12,6 @@ export const useModularUIBasic = function (key, href) {
|
|
|
12
12
|
forceTargetModel: false
|
|
13
13
|
};
|
|
14
14
|
const location = useLocation();
|
|
15
|
-
if (!href) {
|
|
16
|
-
throw new IllegalArgumentException("Missing href");
|
|
17
|
-
}
|
|
18
15
|
const useModularUIOptions = {
|
|
19
16
|
targetModel: undefined,
|
|
20
17
|
forceTargetModel: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIBasic.js","names":["useModularUI","useLocation","
|
|
1
|
+
{"version":3,"file":"useModularUIBasic.js","names":["useModularUI","useLocation","IllegalStateException","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useModularUIOptions","isReload","state","reload","_startsWithInstanceProperty","pathname","call","toString","modularUI","model","isCorrectModel","some","expectedModel","type","console","error"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\ntype UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: 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\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\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, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n if (options.expectedModels.length > 0) {\n const isCorrectModel = options.expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", options.expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n\n return null;\n};\n"],"mappings":";AACA,SAASA,YAAY,QAAQ,gBAAgB;AAE7C,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,qBAAqB,QAAQ,eAAe;AAUrD;AACA;AACA,OAAO,MAAMC,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,GAAGb,WAAW,CAAC,CAAC;EAE9B,MAAMc,mBAAmB,GAAG;IAC1BH,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAEH,SAAS;IAC3BM,QAAQ,EAAE;EACZ,CAAC;EACD,IAAIT,OAAO,CAACK,WAAW,EAAE;IACvBG,mBAAmB,CAACH,WAAW,GAAGL,OAAO,CAACK,WAAW;IACrDG,mBAAmB,CAACF,gBAAgB,GAAGN,OAAO,CAACM,gBAAgB;EACjE;;EAEA;EACA,IAAIC,QAAQ,CAACG,KAAK,EAAEC,MAAM,IAAIC,2BAAA,CAAAb,QAAA,GAAAQ,QAAQ,CAACM,QAAQ,EAAAC,IAAA,CAAAf,QAAA,EAAYD,IAAI,CAACiB,QAAQ,CAAC,CAAC,CAAC,EAAE;IAC3EP,mBAAmB,CAACC,QAAQ,GAAG,IAAI;EACrC;;EAEA;EACA,MAAMO,SAAS,GAAGvB,YAAY,CAACI,GAAG,EAAEC,IAAI,EAAEU,mBAAmB,CAAC;EAE9D,IAAIQ,SAAS,EAAEC,KAAK,EAAE;IACpB,MAAM;MAAEA;IAAM,CAAC,GAAGD,SAAS;IAC3B,IAAIhB,OAAO,CAACI,cAAc,CAACF,MAAM,GAAG,CAAC,EAAE;MACrC,MAAMgB,cAAc,GAAGlB,OAAO,CAACI,cAAc,CAACe,IAAI,CAAEC,aAAa,IAAK;QACpE,OAAOH,KAAK,CAACI,IAAI,KAAKD,aAAa;MACrC,CAAC,CAAC;MAEF,IAAI,CAACF,cAAc,EAAE;QACnBI,OAAO,CAACC,KAAK,CAACP,SAAS,EAAE,oBAAoB,EAAEhB,OAAO,CAACI,cAAc,CAAC;QACtE,MAAM,IAAIT,qBAAqB,CAAC,mCAAmC,CAAC;MACtE;IACF;IAEA,OAAOsB,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
|
|
@@ -250,10 +250,24 @@ export default class ConceptDetailModel extends ResourceModel {
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
|
-
* Retrieve entrydate
|
|
253
|
+
* Retrieve entrydate
|
|
254
254
|
*/
|
|
255
255
|
get entryDate() {
|
|
256
256
|
return _filterInstanceProperty(this.data)?.[TIMEVERSION_FILTER_NAME]?.value ?? null;
|
|
257
257
|
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept
|
|
261
|
+
*/
|
|
262
|
+
isOfConceptType(conceptTypeId) {
|
|
263
|
+
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
268
|
+
*/
|
|
269
|
+
hasMetamodelIdInConceptTypeHierarchy(metamodelId) {
|
|
270
|
+
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
271
|
+
}
|
|
258
272
|
}
|
|
259
273
|
//# sourceMappingURL=ConceptDetailModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptDetailModel.js","names":["ResourceModel","ConceptRelationCollection","SourceReferenceCollection","ConceptTypeDetailModel","TIMEVERSION_FILTER_NAME","ConceptDetailModel","constructor","modularuiResponse","_defineProperty","_relations","data","relations","entryDate","type","modelName","isApplicableModel","contributions","resourcetype","getInitialChildModelLinks","conceptTypeLink","links","getLinkByKey","relationsCollectionLinks","relationsCollection","isCacheable","setChildModels","models","errors","conceptTypeModel","_findInstanceProperty","call","model","conceptType","key","getData","selfhref","href","selflink","setParameter","removeParameter","diagramLinks","getLinksByGroup","_conceptType","label","conceptLabel","taxonomyType","formula","labels","_context","labelTypes","_mapInstanceProperty","labelType","_context2","setting","_id","getLabelElementByIds","ids","_context3","_filterInstanceProperty","_includesInstanceProperty","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","getSourceReferencesForCurrentLanguage","LANGUAGE_POSTFIX_LENGTH","sourceReferences","_context11","_context14","availableLanguagesInSourceReferences","sourceReference","substring","currentLanguagePostfix","locale","_context12","_context13","_endsWithInstanceProperty","availableLanguages","split","value"],"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 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 of content toc\n */\n get entryDate(): string | null {\n return this.data.filter?.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ACoF,SAAS,CAC5BD,eAAe,CAACnF,IAAI,CAAC0E,MAAM,GAAGI,uBAChC,CACF,CACJ,CAAC;IACH;IACA,OAAO,EAAE;EACX;;EAEA;AACF;AACA;EACE,IAAI/E,SAASA,CAAA,EAAkB;IAC7B,OAAO8C,uBAAA,KAAI,CAAChD,IAAI,IAAUN,uBAAuB,CAAC,EAAEqG,KAAK,IAAI,IAAI;EACnE;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ConceptDetailModel.js","names":["ResourceModel","ConceptRelationCollection","SourceReferenceCollection","ConceptTypeDetailModel","TIMEVERSION_FILTER_NAME","ConceptDetailModel","constructor","modularuiResponse","_defineProperty","_relations","data","relations","entryDate","type","modelName","isApplicableModel","contributions","resourcetype","getInitialChildModelLinks","conceptTypeLink","links","getLinkByKey","relationsCollectionLinks","relationsCollection","isCacheable","setChildModels","models","errors","conceptTypeModel","_findInstanceProperty","call","model","conceptType","key","getData","selfhref","href","selflink","setParameter","removeParameter","diagramLinks","getLinksByGroup","_conceptType","label","conceptLabel","taxonomyType","formula","labels","_context","labelTypes","_mapInstanceProperty","labelType","_context2","setting","_id","getLabelElementByIds","ids","_context3","_filterInstanceProperty","_includesInstanceProperty","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","getSourceReferencesForCurrentLanguage","LANGUAGE_POSTFIX_LENGTH","sourceReferences","_context11","_context14","availableLanguagesInSourceReferences","sourceReference","substring","currentLanguagePostfix","locale","_context12","_context13","_endsWithInstanceProperty","availableLanguages","split","value","isOfConceptType","conceptTypeId","hasMetamodelIdInConceptTypeHierarchy","metamodelId","hasMetamodelIdInHierarchy"],"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 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,OAAOA,aAAa,MAAM,uBAAuB;AACjD,OAAOC,yBAAyB,MAAM,6BAA6B;AACnE,OAAOC,yBAAyB,MAAM,6BAA6B;AACnE,OAAOC,sBAAsB,MAAM,0BAA0B;AAE7D,SAASC,uBAAuB,QAAQ,2BAA2B;AAcnE;AACA;AACA;AACA,eAAe,MAAMC,kBAAkB,SAASL,aAAa,CAAC;EAK5D;AACF;EACEM,WAAWA,CAACC,iBAAoC,EAAE;IAChD,KAAK,CAACA,iBAAiB,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAEzB,IAAI,CAACC,UAAU,GAAG,IAAIR,yBAAyB,CAC7C,IAAI,CAACS,IAAI,CAACC,SAAS,EACnB,IAAI,CAACC,SACP,CAAC;EACH;;EAEA;AACF;EACE,IAAIC,IAAIA,CA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@@
|
|
|
1
|
+
import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
|
|
1
2
|
import ResourceModel from "../base/ResourceModel";
|
|
2
3
|
/**
|
|
3
4
|
* Model for concept details, available through modelcatalog
|
|
@@ -34,6 +35,12 @@ class ConceptTypeDetailModel extends ResourceModel {
|
|
|
34
35
|
return this.getData("label", "");
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
/**
|
|
39
|
+
*/
|
|
40
|
+
get isCoreTaxonomy() {
|
|
41
|
+
return this.getData("coreTaxonomy", "false") === "true";
|
|
42
|
+
}
|
|
43
|
+
|
|
37
44
|
/**
|
|
38
45
|
* Get concept type icon
|
|
39
46
|
*/
|
|
@@ -89,6 +96,28 @@ class ConceptTypeDetailModel extends ResourceModel {
|
|
|
89
96
|
get sectionReferenceTypes() {
|
|
90
97
|
return this.getData("sectionReferenceTypes", []);
|
|
91
98
|
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
*/
|
|
102
|
+
get conceptTypeHierarchy() {
|
|
103
|
+
return this.links.getLinksByGroup("conceptTypeHierarchy");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
*/
|
|
108
|
+
isOfConceptType(conceptTypeId) {
|
|
109
|
+
return this.conceptTypeHierarchy?.hasLinkByKey(conceptTypeId) || this.conceptTypeHierarchy?.hasLinkByHref(conceptTypeId) || this.selfhref.equals(conceptTypeId);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types
|
|
114
|
+
*/
|
|
115
|
+
hasMetamodelIdInHierarchy(metamodelId) {
|
|
116
|
+
return this.conceptTypeHierarchy?.all.some(link => {
|
|
117
|
+
var _context;
|
|
118
|
+
return _startsWithInstanceProperty(_context = link.key).call(_context, metamodelId + "#");
|
|
119
|
+
}) || false;
|
|
120
|
+
}
|
|
92
121
|
}
|
|
93
122
|
export default ConceptTypeDetailModel;
|
|
94
123
|
//# sourceMappingURL=ConceptTypeDetailModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptTypeDetailModel.js","names":["ResourceModel","ConceptTypeDetailModel","type","modelName","isApplicableModel","data","contributions","resourcetype","key","_id","label","getData","icon","textColor","backgroundColor","borderColor","labelTypes","propertyTypes","textFragmentTypes","sectionReferenceTypes"],"sources":["../../../src/models/concepts/ConceptTypeDetailModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport type ModularUIResponse from \"../../modularui/ModularUIResponse\";\n\n/**\n * Model for concept details, available through modelcatalog\n */\nclass ConceptTypeDetailModel extends ResourceModel {\n /**\n */\n get type(): string {\n return \"ConceptTypeDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ConceptTypeDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"ConceptTypeDetail\"\n );\n }\n\n /**\n */\n get key(): string {\n return this.data._id;\n }\n\n /**\n * Get concept type label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Get concept type icon\n */\n get icon(): string {\n return this.getData(\"icon\", \"\");\n }\n\n /**\n * Get concept type text color\n */\n get textColor(): string {\n return this.getData(\"textColor\", \"#000\");\n }\n\n /**\n * Get concept type background color\n */\n get backgroundColor(): string {\n return this.getData(\"backgroundColor\", \"#fff\");\n }\n\n /**\n * Get concept line color\n */\n get borderColor(): string {\n return this.getData(\"lineColor\", \"#000\");\n }\n\n /**\n * Get label types\n */\n get labelTypes(): ?Array<Object> {\n return this.data.labelTypes;\n }\n\n /**\n * Get propertyTypes\n */\n get propertyTypes(): Array<Object> {\n return this.getData(\"propertyTypes\", []);\n }\n\n /**\n * Get textFragmentTypes\n */\n get textFragmentTypes(): Array<Object> {\n return this.getData(\"textFragmentTypes\", []);\n }\n\n /**\n * Get sectionReferenceTypes\n */\n get sectionReferenceTypes(): Array<Object> {\n return this.getData(\"sectionReferenceTypes\", []);\n }\n}\n\nexport default ConceptTypeDetailModel;\n"],"mappings":"AACA,OAAOA,aAAa,MAAM,uBAAuB;
|
|
1
|
+
{"version":3,"file":"ConceptTypeDetailModel.js","names":["ResourceModel","ConceptTypeDetailModel","type","modelName","isApplicableModel","data","contributions","resourcetype","key","_id","label","getData","isCoreTaxonomy","icon","textColor","backgroundColor","borderColor","labelTypes","propertyTypes","textFragmentTypes","sectionReferenceTypes","conceptTypeHierarchy","links","getLinksByGroup","isOfConceptType","conceptTypeId","hasLinkByKey","hasLinkByHref","selfhref","equals","hasMetamodelIdInHierarchy","metamodelId","all","some","link","_context","_startsWithInstanceProperty","call"],"sources":["../../../src/models/concepts/ConceptTypeDetailModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport type ModularUIResponse from \"../../modularui/ModularUIResponse\";\nimport type LinkCollection from \"../links/LinkCollection\";\n\n/**\n * Model for concept details, available through modelcatalog\n */\nclass ConceptTypeDetailModel extends ResourceModel {\n /**\n */\n get type(): string {\n return \"ConceptTypeDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ConceptTypeDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"ConceptTypeDetail\"\n );\n }\n\n /**\n */\n get key(): string {\n return this.data._id;\n }\n\n /**\n * Get concept type label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n */\n get isCoreTaxonomy(): boolean {\n return this.getData(\"coreTaxonomy\", \"false\") === \"true\";\n }\n\n /**\n * Get concept type icon\n */\n get icon(): string {\n return this.getData(\"icon\", \"\");\n }\n\n /**\n * Get concept type text color\n */\n get textColor(): string {\n return this.getData(\"textColor\", \"#000\");\n }\n\n /**\n * Get concept type background color\n */\n get backgroundColor(): string {\n return this.getData(\"backgroundColor\", \"#fff\");\n }\n\n /**\n * Get concept line color\n */\n get borderColor(): string {\n return this.getData(\"lineColor\", \"#000\");\n }\n\n /**\n * Get label types\n */\n get labelTypes(): ?Array<Object> {\n return this.data.labelTypes;\n }\n\n /**\n * Get propertyTypes\n */\n get propertyTypes(): Array<Object> {\n return this.getData(\"propertyTypes\", []);\n }\n\n /**\n * Get textFragmentTypes\n */\n get textFragmentTypes(): Array<Object> {\n return this.getData(\"textFragmentTypes\", []);\n }\n\n /**\n * Get sectionReferenceTypes\n */\n get sectionReferenceTypes(): Array<Object> {\n return this.getData(\"sectionReferenceTypes\", []);\n }\n\n /**\n */\n get conceptTypeHierarchy(): LinkCollection {\n return this.links.getLinksByGroup(\"conceptTypeHierarchy\");\n }\n\n /**\n */\n isOfConceptType(conceptTypeId: string): boolean {\n return (\n this.conceptTypeHierarchy?.hasLinkByKey(conceptTypeId) ||\n this.conceptTypeHierarchy?.hasLinkByHref(conceptTypeId) ||\n this.selfhref.equals(conceptTypeId)\n );\n }\n\n /**\n * Indicates if the given metamodel functional identifier exists in the hierarchy of concept types\n */\n hasMetamodelIdInHierarchy(metamodelId: string): boolean {\n return (\n this.conceptTypeHierarchy?.all.some((link) =>\n link.key.startsWith(metamodelId + \"#\"),\n ) || false\n );\n }\n}\n\nexport default ConceptTypeDetailModel;\n"],"mappings":";AACA,OAAOA,aAAa,MAAM,uBAAuB;AAKjD;AACA;AACA;AACA,MAAMC,sBAAsB,SAASD,aAAa,CAAC;EACjD;AACF;EACE,IAAIE,IAAIA,CAAA,EAAW;IACjB,OAAO,mBAAmB;EAC5B;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,wBAAwB;EACjC;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aAAa,CAACC,YAAY,KAAK,mBAAmB;EAE3D;;EAEA;AACF;EACE,IAAIC,GAAGA,CAAA,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AAIU,oBAAoBA,CAAA,EAAmB;IACzC,OAAO,IAAI,CAACC,KAAK,CAACC,eAAe,CAAC,sBAAsB,CAAC;EAC3D;;EAEA;AACF;EACEC,eAAeA,CAACC,aAAqB,EAAW;IAC9C,OACE,IAAI,CAACJ,oBAAoB,EAAEK,YAAY,CAACD,aAAa,CAAC,IACtD,IAAI,CAACJ,oBAAoB,EAAEM,aAAa,CAACF,aAAa,CAAC,IACvD,IAAI,CAACG,QAAQ,CAACC,MAAM,CAACJ,aAAa,CAAC;EAEvC;;EAEA;AACF;AACA;EACEK,yBAAyBA,CAACC,WAAmB,EAAW;IACtD,OACE,IAAI,CAACV,oBAAoB,EAAEW,GAAG,CAACC,IAAI,CAAEC,IAAI;MAAA,IAAAC,QAAA;MAAA,OACvCC,2BAAA,CAAAD,QAAA,GAAAD,IAAI,CAAC1B,GAAG,EAAA6B,IAAA,CAAAF,QAAA,EAAYJ,WAAW,GAAG,GAAG,CAAC;IAAA,CACxC,CAAC,IAAI,KAAK;EAEd;AACF;AAEA,eAAe9B,sBAAsB","ignoreList":[]}
|
|
@@ -54,6 +54,13 @@ export default class LinkCollection extends BaseCollection {
|
|
|
54
54
|
return _findInstanceProperty(_context2 = this.links).call(_context2, link => link.key === key) || null;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Indicate if a link by key exists
|
|
59
|
+
*/
|
|
60
|
+
hasLinkByKey(key) {
|
|
61
|
+
return this.all.some(link => link.key === key);
|
|
62
|
+
}
|
|
63
|
+
|
|
57
64
|
/**
|
|
58
65
|
* Get a link by it's Href
|
|
59
66
|
*/
|
|
@@ -62,6 +69,13 @@ export default class LinkCollection extends BaseCollection {
|
|
|
62
69
|
return _findInstanceProperty(_context3 = this.links).call(_context3, link => link.href.equals(href)) || null;
|
|
63
70
|
}
|
|
64
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Indicate if a link by href exists
|
|
74
|
+
*/
|
|
75
|
+
hasLinkByHref(href) {
|
|
76
|
+
return this.all.some(link => link.href.equals(href));
|
|
77
|
+
}
|
|
78
|
+
|
|
65
79
|
/**
|
|
66
80
|
* Getting the links by group key. For instance getting all 'tab' links of the web application.
|
|
67
81
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkCollection.js","names":["BaseCollection","normalizeLinkJSON","LinkModel","LinkCollection","constructor","_context","linkData","arguments","length","undefined","linkContributions","collection","_mapInstanceProperty","call","_ref","data","contributions","links","getLinkByKey","key","_context2","_findInstanceProperty","link","getLinkByHref","href","_context3","equals","getLinksByGroup","_context4","_len","args","Array","_key","findGroups","groupLinks","_filterInstanceProperty","_includesInstanceProperty","group","linkCollection","getLinkByResourceType","resourceType","_context5","resourcetype","getLinksByLayoutHint","hint","_context6","newCollection","
|
|
1
|
+
{"version":3,"file":"LinkCollection.js","names":["BaseCollection","normalizeLinkJSON","LinkModel","LinkCollection","constructor","_context","linkData","arguments","length","undefined","linkContributions","collection","_mapInstanceProperty","call","_ref","data","contributions","links","getLinkByKey","key","_context2","_findInstanceProperty","link","hasLinkByKey","all","some","getLinkByHref","href","_context3","equals","hasLinkByHref","getLinksByGroup","_context4","_len","args","Array","_key","findGroups","groupLinks","_filterInstanceProperty","_includesInstanceProperty","group","linkCollection","getLinkByResourceType","resourceType","_context5","resourcetype","getLinksByLayoutHint","hint","_context6","newCollection","layouthint","has","hasLinksByLayoutHint","toHrefArray","_context7","hasLink","l","update","newLink","_context8","_context9","_context10","oldIndex","_findIndexInstanceProperty","_sliceInstanceProperty","routePath","_context11","path","join"],"sources":["../../../src/models/links/LinkCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport normalizeLinkJSON from \"./normalizeLinkJSON\";\nimport LinkModel from \"./LinkModel\";\n\nimport type Href from \"../href/Href\";\n\n/**\n * Collection of links\n *\n * @see {LinkModel}\n */\nexport default class LinkCollection extends BaseCollection<LinkModel> {\n /**\n * Constructs the link collection\n */\n constructor(linkData: Object = {}, linkContributions: Object = {}) {\n super();\n\n // There can be links in data and/or contributions (e.g. concept link is available through contributions)\n this.collection = normalizeLinkJSON(linkData, linkContributions).map(\n ({ data, contributions }) => new LinkModel(data, contributions),\n );\n }\n\n /**\n * Getting links\n */\n get links(): Array<LinkModel> {\n return this.collection;\n }\n\n /**\n * Set Link collection\n */\n set links(links: Array<LinkModel>) {\n this.collection = links;\n }\n\n /**\n * Get a link by it's key, handy for getting the self link\n */\n getLinkByKey(key: string): LinkModel | null {\n return this.links.find((link) => link.key === key) || null;\n }\n\n /**\n * Indicate if a link by key exists\n */\n hasLinkByKey(key: string): boolean {\n return this.all.some((link) => link.key === key);\n }\n\n /**\n * Get a link by it's Href\n */\n getLinkByHref(href: Href | string): LinkModel | null {\n return this.links.find((link) => link.href.equals(href)) || null;\n }\n\n /**\n * Indicate if a link by href exists\n */\n hasLinkByHref(href: Href | string): boolean {\n return this.all.some((link) => link.href.equals(href));\n }\n\n /**\n * Getting the links by group key. For instance getting all 'tab' links of the web application.\n */\n getLinksByGroup(...args: Array<string>): LinkCollection {\n const findGroups = args.length > 0 ? [...args] : [];\n const groupLinks = this.links.filter((link) =>\n findGroups.includes(link.group),\n );\n\n const linkCollection = new LinkCollection();\n\n linkCollection.links = groupLinks;\n\n return linkCollection;\n }\n\n /**\n * Retrieve links by resource type\n */\n getLinkByResourceType(resourceType: string): LinkCollection {\n const linkCollection = new LinkCollection();\n\n linkCollection.collection = this.links.filter(\n (link) => link.resourcetype === resourceType,\n );\n\n return linkCollection;\n }\n\n /**\n * Retrieve links including a layout hint\n */\n getLinksByLayoutHint(hint: string): LinkCollection {\n const newCollection = new LinkCollection();\n\n newCollection.collection = this.all.filter((link) =>\n link.layouthint.has(hint),\n );\n\n return newCollection;\n }\n\n /**\n * Indicates if a link with layout hint exists\n */\n hasLinksByLayoutHint(hint: string): boolean {\n return this.all.some((link) => link.layouthint.has(hint));\n }\n\n /**\n * Get all href of links in collection in an array of Href's\n */\n toHrefArray(): Array<Href> {\n return this.links.map((link) => link.href);\n }\n\n /**\n * Check if link exists in collection\n */\n hasLink(link: LinkModel): boolean {\n return this.some((l) => l.href.equals(link.href));\n }\n\n /**\n * Updates the collection with a new link, when the link to update does not exist, it is added to the collection\n */\n update(newLink: LinkModel): LinkCollection {\n const oldIndex = this.links.findIndex((link) => link.key === newLink.key);\n\n if (oldIndex === -1) {\n this.collection = [...this.collection, newLink];\n\n return this;\n }\n\n this.collection = [\n ...this.links.slice(0, oldIndex),\n newLink,\n ...this.links.slice(oldIndex + 1),\n ];\n\n return this;\n }\n\n /**\n * Use as path regex for react router routes\n */\n get routePath(): string {\n if (this.length === 0) {\n return \"__NON_EXISTING_ROUTE__\";\n }\n\n const path = this.collection.map((link) => link.href.path).join(\"|\");\n return this.length > 1 ? `(${path})` : path;\n }\n}\n"],"mappings":";;;;;;AACA,OAAOA,cAAc,MAAM,wBAAwB;AACnD,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD,OAAOC,SAAS,MAAM,aAAa;AAInC;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,cAAc,SAASH,cAAc,CAAY;EACpE;AACF;AACA;EACEI,WAAWA,CAAA,EAAwD;IAAA,IAAAC,QAAA;IAAA,IAAvDC,QAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IAAEG,iBAAyB,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAC/D,KAAK,CAAC,CAAC;;IAEP;IACA,IAAI,CAACI,UAAU,GAAGC,oBAAA,CAAAP,QAAA,GAAAJ,iBAAiB,CAACK,QAAQ,EAAEI,iBAAiB,CAAC,EAAAG,IAAA,CAAAR,QAAA,EAC9DS,IAAA;MAAA,IAAC;QAAEC,IAAI;QAAEC;MAAc,CAAC,GAAAF,IAAA;MAAA,OAAK,IAAIZ,SAAS,CAACa,IAAI,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IAAA,IAAAC,UAAA;IACtB,IAAI,IAAI,CAAC3D,MAAM,KAAK,CAAC,EAAE;MACrB,OAAO,wBAAwB;IACjC;IAEA,MAAM4D,IAAI,GAAGxD,oBAAA,CAAAuD,UAAA,OAAI,CAACxD,UAAU,EAAAE,IAAA,CAAAsD,UAAA,EAAM7C,IAAI,IAAKA,IAAI,CAACK,IAAI,CAACyC,IAAI,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;IACpE,OAAO,IAAI,CAAC7D,MAAM,GAAG,CAAC,GAAG,IAAI4D,IAAI,GAAG,GAAGA,IAAI;EAC7C;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserServicesModel.js","names":["ResourceModel","UserModel","ErrorResponse","UserServicesModel","constructor","arguments","_defineProperty","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userData","userLink","setChildModels","models","errors","mustChangePassword","Array","isArray","some","error","isChangePassword","user","_findInstanceProperty","call","model","links","getLinkByKey","_user","label","getContribution","changePassword","changePasswordLink","href","changeAvatar","changeAvatarLink","isLoggedIn","hasUser","UNSECURE_LINK_COUNT","length","_mustChangePassword"],"sources":["../../../src/models/user/UserServicesModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport UserModel from \"../user/UserModel\";\nimport ErrorResponse from \"../error/ErrorResponse\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type Href from \"../href/Href\";\n\n/**\n * UserServicesModel model\n */\nclass UserServicesModel extends ResourceModel {\n _user: ?UserModel;\n _mustChangePassword: boolean = false;\n\n /**\n */\n get type(): string {\n return \"UserServices\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"UserServicesModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"user_services\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userData = this.userLink;\n return userData ? [userData] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this.mustChangePassword = Array.isArray(errors)\n ? errors.some((error) => error.isChangePassword) ?? false\n : false;\n this.user = models.find((model) => model.type === \"User\");\n }\n\n /**\n */\n get userLink(): LinkModel | null {\n return this.links.getLinkByKey(\"Userdata\");\n }\n\n /**\n * return the user model for the current user\n */\n get user(): UserModel | null {\n return this._user || null;\n }\n\n /**\n * Set user data\n */\n set user(model: ?ModularUIModel) {\n this._user = model instanceof UserModel ? model : null;\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n */\n get changePassword(): Href | null {\n const changePasswordLink = this.links.getLinkByKey(\"ChangePassword\");\n\n if (changePasswordLink) {\n return changePasswordLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get changeAvatar(): Href | null {\n const changeAvatarLink = this.links.getLinkByKey(\"ChangeAvatar\");\n\n if (changeAvatarLink) {\n return changeAvatarLink.href;\n }\n\n return null;\n }\n\n // when more than three unsecure links are present (always present: self, contributions and api-docs),\n // the userservice is permitted and thus we have an indication the user is probably\n // logged in\n /**\n */\n get isLoggedIn(): boolean {\n const hasUser = this.user instanceof UserModel;\n\n const UNSECURE_LINK_COUNT = 3;\n return this.links.length > UNSECURE_LINK_COUNT || hasUser;\n }\n\n /**\n */\n set mustChangePassword(mustChangePassword: boolean) {\n this._mustChangePassword = mustChangePassword;\n }\n\n /**\n */\n get mustChangePassword(): boolean {\n return this._mustChangePassword;\n }\n}\n\nexport default UserServicesModel;\n"],"mappings":";;AACA,OAAOA,aAAa,MAAM,uBAAuB;AACjD,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,aAAa,MAAM,wBAAwB;AAOlD;AACA;AACA;AACA,MAAMC,iBAAiB,SAASH,aAAa,CAAC;EAAAI,YAAA;IAAA,SAAAC,SAAA;IAAAC,eAAA;IAAAA,eAAA,8BAEb,KAAK;EAAA;EAEpC;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,cAAc;EACvB;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,mBAAmB;EAC5B;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aAAa,CAACC,YAAY,KAAK,eAAe;EAEvD;;EAEA;AACF;EACEC,yBAAyBA,CAAA,EAAqB;IAC5C,MAAMC,QAAQ,GAAG,IAAI,CAACC,QAAQ;IAC9B,OAAOD,QAAQ,GAAG,CAACA,QAAQ,CAAC,GAAG,EAAE;EACnC;;EAEA;AACF;EACEE,cAAcA,CAACC,MAA6B,EAAEC,MAA4B,EAAE;IAC1E,IAAI,CAACC,kBAAkB,GAAGC,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"UserServicesModel.js","names":["ResourceModel","UserModel","ErrorResponse","UserServicesModel","constructor","arguments","_defineProperty","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userData","userLink","setChildModels","models","errors","mustChangePassword","Array","isArray","some","error","isChangePassword","user","_findInstanceProperty","call","model","links","getLinkByKey","_user","label","getContribution","changePassword","changePasswordLink","href","changeAvatar","changeAvatarLink","isLoggedIn","hasUser","UNSECURE_LINK_COUNT","length","_mustChangePassword"],"sources":["../../../src/models/user/UserServicesModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport UserModel from \"../user/UserModel\";\nimport ErrorResponse from \"../error/ErrorResponse\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type Href from \"../href/Href\";\n\n/**\n * UserServicesModel model\n */\nclass UserServicesModel extends ResourceModel {\n _user: ?UserModel;\n _mustChangePassword: boolean = false;\n\n /**\n */\n get type(): string {\n return \"UserServices\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"UserServicesModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"user_services\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userData = this.userLink;\n return userData ? [userData] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this.mustChangePassword = Array.isArray(errors)\n ? (errors.some((error) => error.isChangePassword) ?? false)\n : false;\n this.user = models.find((model) => model.type === \"User\");\n }\n\n /**\n */\n get userLink(): LinkModel | null {\n return this.links.getLinkByKey(\"Userdata\");\n }\n\n /**\n * return the user model for the current user\n */\n get user(): UserModel | null {\n return this._user || null;\n }\n\n /**\n * Set user data\n */\n set user(model: ?ModularUIModel) {\n this._user = model instanceof UserModel ? model : null;\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n */\n get changePassword(): Href | null {\n const changePasswordLink = this.links.getLinkByKey(\"ChangePassword\");\n\n if (changePasswordLink) {\n return changePasswordLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get changeAvatar(): Href | null {\n const changeAvatarLink = this.links.getLinkByKey(\"ChangeAvatar\");\n\n if (changeAvatarLink) {\n return changeAvatarLink.href;\n }\n\n return null;\n }\n\n // when more than three unsecure links are present (always present: self, contributions and api-docs),\n // the userservice is permitted and thus we have an indication the user is probably\n // logged in\n /**\n */\n get isLoggedIn(): boolean {\n const hasUser = this.user instanceof UserModel;\n\n const UNSECURE_LINK_COUNT = 3;\n return this.links.length > UNSECURE_LINK_COUNT || hasUser;\n }\n\n /**\n */\n set mustChangePassword(mustChangePassword: boolean) {\n this._mustChangePassword = mustChangePassword;\n }\n\n /**\n */\n get mustChangePassword(): boolean {\n return this._m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,7 +27,7 @@ const useModularUI = function (modelKey, url) {
|
|
|
27
27
|
removeOnUnmount: false
|
|
28
28
|
};
|
|
29
29
|
const dispatch = (0, _reactRedux.useDispatch)();
|
|
30
|
-
const href = url
|
|
30
|
+
const href = url?.toString() || "";
|
|
31
31
|
const key = useKeyForHook(modelKey, href);
|
|
32
32
|
const prevOptions = (0, _react.useRef)(options);
|
|
33
33
|
const prevHref = (0, _react.useRef)(href);
|
|
@@ -36,7 +36,7 @@ const useModularUI = function (modelKey, url) {
|
|
|
36
36
|
(0, _useDeepCompareEffect.default)(() => {
|
|
37
37
|
// prevent reloads when previous option had the isReload, but the new options not
|
|
38
38
|
const isOldReload = prevHref.current === href && prevOptions.current.isReload && !options.isReload;
|
|
39
|
-
if (!isOldReload) {
|
|
39
|
+
if (href !== "" && !isOldReload) {
|
|
40
40
|
dispatch((0, _ModularUIActions.loadModularUI)(key, href, options));
|
|
41
41
|
}
|
|
42
42
|
prevOptions.current = options;
|
|
@@ -34,7 +34,7 @@ export const useModularUI = (
|
|
|
34
34
|
},
|
|
35
35
|
): any => {
|
|
36
36
|
const dispatch = useDispatch();
|
|
37
|
-
const href = url
|
|
37
|
+
const href = url?.toString() || "";
|
|
38
38
|
const key = useKeyForHook(modelKey, href);
|
|
39
39
|
|
|
40
40
|
const prevOptions = useRef(options);
|
|
@@ -48,7 +48,7 @@ export const useModularUI = (
|
|
|
48
48
|
prevOptions.current.isReload &&
|
|
49
49
|
!options.isReload;
|
|
50
50
|
|
|
51
|
-
if (!isOldReload) {
|
|
51
|
+
if (href !== "" && !isOldReload) {
|
|
52
52
|
dispatch(loadModularUI(key, href, options));
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -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","useSelector","state","modularui","exports"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\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 type 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 `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\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 = url
|
|
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","useSelector","state","modularui","exports"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\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 type 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 `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\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 = url?.toString() || \"\";\n const key = useKeyForHook(modelKey, href);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\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 if (href !== \"\" && !isOldReload) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n }, [key, href, options]);\n\n const { removeOnUnmount = false } = options;\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(key));\n }\n };\n }, [dispatch, key, removeOnUnmount]);\n\n // retrieve current model from modularui reducer\n return useSelector((state) => {\n return state.modularui[key];\n });\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAKA,IAAAI,qBAAA,GAAAC,sBAAA,CAAAL,OAAA;AAEA,IAAAM,QAAA,GAAAN,OAAA;AAKA;AACA;AACA,MAAMO,aAAa,GAAGA,CAACC,QAAgB,EAAEC,GAAW,KAAK;EACvD,MAAMC,MAAM,GAAG,IAAAC,kBAAS,EAAC,CAAC;EAC1B,OAAO,GAAGH,QAAQ,IAAIC,GAAG,CAACG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAKF,MAAM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AAC,CAAC;MACjC;IACF,CAAC;EACH,CAAC,EAAE,CAACJ,QAAQ,EAAEI,GAAG,EAAEL,eAAe,CAAC,CAAC;;EAEpC;EACA,OAAO,IAAAgB,uBAAW,EAAEC,KAAK,IAAK;IAC5B,OAAOA,KAAK,CAACC,SAAS,CAACb,GAAG,CAAC;EAC7B,CAAC,CAAC;AACJ,CAAC;AAACc,OAAA,CAAA3B,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -19,9 +19,6 @@ const useModularUIBasic = function (key, href) {
|
|
|
19
19
|
forceTargetModel: false
|
|
20
20
|
};
|
|
21
21
|
const location = (0, _useRouter.useLocation)();
|
|
22
|
-
if (!href) {
|
|
23
|
-
throw new _exceptions.IllegalArgumentException("Missing href");
|
|
24
|
-
}
|
|
25
22
|
const useModularUIOptions = {
|
|
26
23
|
targetModel: undefined,
|
|
27
24
|
forceTargetModel: undefined,
|
|
@@ -3,7 +3,7 @@ import { useModularUI } from "./useModularUI";
|
|
|
3
3
|
|
|
4
4
|
import { useLocation } from "./useRouter";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { IllegalStateException } from "../exceptions";
|
|
7
7
|
|
|
8
8
|
import type { ModularUIModel, Href } from "../models";
|
|
9
9
|
|
|
@@ -25,9 +25,6 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
25
25
|
},
|
|
26
26
|
): T | null => {
|
|
27
27
|
const location = useLocation();
|
|
28
|
-
if (!href) {
|
|
29
|
-
throw new IllegalArgumentException("Missing href");
|
|
30
|
-
}
|
|
31
28
|
|
|
32
29
|
const useModularUIOptions = {
|
|
33
30
|
targetModel: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIBasic.js","names":["_useModularUI","require","_useRouter","_exceptions","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useLocation","
|
|
1
|
+
{"version":3,"file":"useModularUIBasic.js","names":["_useModularUI","require","_useRouter","_exceptions","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useLocation","useModularUIOptions","isReload","state","reload","_startsWith","default","pathname","call","toString","modularUI","useModularUI","model","isCorrectModel","some","expectedModel","type","console","error","IllegalStateException","exports"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\ntype UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: 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\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\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, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n if (options.expectedModels.length > 0) {\n const isCorrectModel = options.expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", options.expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n\n return null;\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAUA;AACA;AACO,MAA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,CAACF,cAAc,EAAE;QACnBI,OAAO,CAACC,KAAK,CAACR,SAAS,EAAE,oBAAoB,EAAElB,OAAO,CAACI,cAAc,CAAC;QACtE,MAAM,IAAIuB,iCAAqB,CAAC,mCAAmC,CAAC;MACtE;IACF;IAEA,OAAOP,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC;AAACQ,OAAA,CAAAhC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -257,11 +257,25 @@ class ConceptDetailModel extends _ResourceModel.default {
|
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
/**
|
|
260
|
-
* Retrieve entrydate
|
|
260
|
+
* Retrieve entrydate
|
|
261
261
|
*/
|
|
262
262
|
get entryDate() {
|
|
263
263
|
return (0, _filter.default)(this.data)?.[_Constants.TIMEVERSION_FILTER_NAME]?.value ?? null;
|
|
264
264
|
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept
|
|
268
|
+
*/
|
|
269
|
+
isOfConceptType(conceptTypeId) {
|
|
270
|
+
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
275
|
+
*/
|
|
276
|
+
hasMetamodelIdInConceptTypeHierarchy(metamodelId) {
|
|
277
|
+
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
278
|
+
}
|
|
265
279
|
}
|
|
266
280
|
exports.default = ConceptDetailModel;
|
|
267
281
|
//# sourceMappingURL=ConceptDetailModel.js.map
|
|
@@ -319,9 +319,23 @@ export default class ConceptDetailModel extends ResourceModel {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
/**
|
|
322
|
-
* Retrieve entrydate
|
|
322
|
+
* Retrieve entrydate
|
|
323
323
|
*/
|
|
324
324
|
get entryDate(): string | null {
|
|
325
325
|
return this.data.filter?.[TIMEVERSION_FILTER_NAME]?.value ?? null;
|
|
326
326
|
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept
|
|
330
|
+
*/
|
|
331
|
+
isOfConceptType(conceptTypeId: string): boolean {
|
|
332
|
+
return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
|
|
337
|
+
*/
|
|
338
|
+
hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean {
|
|
339
|
+
return this.conceptType?.hasMetamodelIdInHierarchy(metamodelId) ?? false;
|
|
340
|
+
}
|
|
327
341
|
}
|