@beinformed/ui 1.50.1 → 1.50.3
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 +14 -0
- package/esm/models/content/SubSectionModel.js +8 -0
- package/esm/models/content/SubSectionModel.js.map +1 -1
- package/esm/redux/_modularui/ModularUIConnector.js +21 -2
- package/esm/redux/_modularui/ModularUIConnector.js.map +1 -1
- package/lib/models/content/SubSectionModel.js +8 -0
- package/lib/models/content/SubSectionModel.js.flow +9 -0
- package/lib/models/content/SubSectionModel.js.map +1 -1
- package/lib/models/content/__tests__/ContentModel.spec.js.flow +22 -0
- package/lib/redux/_modularui/ModularUIConnector.js +21 -2
- package/lib/redux/_modularui/ModularUIConnector.js.flow +30 -2
- package/lib/redux/_modularui/ModularUIConnector.js.map +1 -1
- package/package.json +1 -1
- package/src/models/content/SubSectionModel.js +9 -0
- package/src/models/content/__tests__/ContentModel.spec.js +22 -0
- package/src/models/content/__tests__/content-with-subsections2.json +79 -0
- package/src/redux/_modularui/ModularUIConnector.js +30 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.50.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.50.2...v1.50.3) (2024-07-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **connector:** patch updateModel fetch property to updateHandler for modularui connector ([f4cb62d](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/f4cb62dc77d1504ae0e7bfc454146768c5100091))
|
|
11
|
+
|
|
12
|
+
## [1.50.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.50.1...v1.50.2) (2024-07-17)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **content:** handle incorrect relatedConcepts links ([265ee33](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/265ee33db296149766dac6d94e57963953c05dd2))
|
|
18
|
+
|
|
5
19
|
## [1.50.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.50.0...v1.50.1) (2024-07-08)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
2
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
3
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
3
4
|
import { createHashFromHref } from "../../utils/helpers/createHash";
|
|
4
5
|
import BaseModel from "../base/BaseModel";
|
|
5
6
|
import LinkCollection from "../links/LinkCollection";
|
|
@@ -110,9 +111,16 @@ export default class SubSectionModel extends BaseModel {
|
|
|
110
111
|
get relatedConceptsHref() {
|
|
111
112
|
const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
|
|
112
113
|
if (relatedConceptsLink) {
|
|
114
|
+
var _context2;
|
|
113
115
|
const {
|
|
114
116
|
href
|
|
115
117
|
} = relatedConceptsLink;
|
|
118
|
+
if (_includesInstanceProperty(_context2 = href.hash).call(_context2, "/relatedConcepts")) {
|
|
119
|
+
var _context3;
|
|
120
|
+
const firstPart = href.path.substring(0, href.path.lastIndexOf("/"));
|
|
121
|
+
href.path = firstPart + "/" + href.hash;
|
|
122
|
+
href.hash = _includesInstanceProperty(_context3 = href.hash).call(_context3, "#") ? href.hash.substring(href.hash.indexOf("#")) : "";
|
|
123
|
+
}
|
|
116
124
|
href.setReferenceHash(this.referenceHash);
|
|
117
125
|
return href;
|
|
118
126
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubSectionModel.js","names":["createHashFromHref","BaseModel","LinkCollection","Href","LinkModel","retrieveText","SubSectionModel","constructor","data","_defineProperty","referred","id","_id","key","body","getData","number","label","subSections","_context","_mapInstanceProperty","call","subSection","links","_links","contributions","selflink","getLinkByKey","selfhref","href","relatedConceptsHrefs","hrefs","relatedConceptsHref","push","forEach","relatedConceptsLink","setReferenceHash","referenceHash","getReferredSections","sections","referredChilds"],"sources":["../../../src/models/content/SubSectionModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n const body = this.getData(\"body\", \"\");\n return retrieveText(body);\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection),\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n const { href } = relatedConceptsLink;\n href.setReferenceHash(this.referenceHash);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SubSectionModel.js","names":["createHashFromHref","BaseModel","LinkCollection","Href","LinkModel","retrieveText","SubSectionModel","constructor","data","_defineProperty","referred","id","_id","key","body","getData","number","label","subSections","_context","_mapInstanceProperty","call","subSection","links","_links","contributions","selflink","getLinkByKey","selfhref","href","relatedConceptsHrefs","hrefs","relatedConceptsHref","push","forEach","relatedConceptsLink","_context2","_includesInstanceProperty","hash","_context3","firstPart","path","substring","lastIndexOf","indexOf","setReferenceHash","referenceHash","getReferredSections","sections","referredChilds"],"sources":["../../../src/models/content/SubSectionModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n const body = this.getData(\"body\", \"\");\n return retrieveText(body);\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection),\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n const { href } = relatedConceptsLink;\n\n if (href.hash.includes(\"/relatedConcepts\")) {\n const firstPart = href.path.substring(0, href.path.lastIndexOf(\"/\"));\n href.path = firstPart + \"/\" + href.hash;\n href.hash = href.hash.includes(\"#\")\n ? href.hash.substring(href.hash.indexOf(\"#\"))\n : \"\";\n }\n\n href.setReferenceHash(this.referenceHash);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"mappings":";;;AACA,SAASA,kBAAkB,QAAQ,gCAAgC;AAEnE,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,cAAc,MAAM,yBAAyB;AACpD,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,SAASC,YAAY,QAAQ,aAAa;;AAE1C;AACA;AACA;AACA,eAAe,MAAMC,eAAe,SAASL,SAAS,CAAC;EAGrD;AACF;EACEM,WAAWA,CAACC,IAAY,EAAE;IACxB,KAAK,CAACA,IAAI,EAAE,CAAC,CAAC,CAAC;IAACC,eAAA;EAClB;;EAEA;AACF;EACE,IAAIC,QAAQA,CAAA,EAAY;IACtB,OAAO,IAAI,CAACF,IAAI,CAACE,QAAQ;EAC3B;;EAEA;AACF;EACE,IAAIC,EAAEA,CAAA,EAAW;IACf,OAAO,IAAI,CAACH,IAAI,CAACG,EAAE,IAAI,IAAI,CAACH,IAAI,CAACI,GAAG;EACtC;;EAEA;AACF;AACA;EACE,IAAIC,GAAGA,CAAA,EAAY;IACjB,OAAO,IAAI,CAACF,EAAE;EAChB;;EAEA;AACF;AACA;EACE,IAAIG,IAAIA,CAAA,EAAW;IACjB,MAAMA,IAAI,GAAG,IAAI,CAACC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IACrC,OAAOV,YAAY,CAACS,IAAI,CAAC;EAC3B;;EAEA;AACF;AACA;EACE,IAAIE,MAAMA,CAAA,EAAkB;IAC1B,OAAO,IAAI,CAACR,IAAI,CAACQ,MAAM,IAAI,IAAI;EACjC;;EAEA;AACF;AACA;EACE,IAAIC,KAAKA,CAAA,EAAY;IACnB,OAAO,IAA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U,CAAC;MAC3B;MAEA,MAAM2B,cAAc,GAAG3B,UAAU,CAACyB,mBAAmB,CAAC,CAAC;MACvDC,QAAQ,CAACf,IAAI,CAAC,GAAGgB,cAAc,CAAC;IAClC;IAEA,OAAOD,QAAQ;EACjB;AACF","ignoreList":[]}
|
|
@@ -7,7 +7,26 @@ import { getDisplayName } from "../../react/utils";
|
|
|
7
7
|
import { useUrl, useReload } from "./ModularUIUtils";
|
|
8
8
|
import { useModularUI } from "../../hooks/useModularUI";
|
|
9
9
|
import { useLocale } from "../../hooks/useI18n";
|
|
10
|
+
import FormModel from "../../models/form/FormModel";
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
const patchUpdateModelOption = oldOptions => {
|
|
13
|
+
if ("updateModel" in oldOptions && oldOptions.updateModel instanceof FormModel) {
|
|
14
|
+
return {
|
|
15
|
+
...oldOptions,
|
|
16
|
+
updateHandler: newModel => {
|
|
17
|
+
if (newModel instanceof FormModel) {
|
|
18
|
+
// $FLowFixMe
|
|
19
|
+
const clonedModel = oldOptions.updateModel.clone();
|
|
20
|
+
clonedModel.update(newModel);
|
|
21
|
+
return clonedModel;
|
|
22
|
+
}
|
|
23
|
+
return newModel;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return oldOptions;
|
|
28
|
+
};
|
|
29
|
+
|
|
11
30
|
/**
|
|
12
31
|
*/
|
|
13
32
|
const modularUIConnector = function (name, resource) {
|
|
@@ -42,7 +61,7 @@ const modularUIConnector = function (name, resource) {
|
|
|
42
61
|
// Provide connected models with a fetchModularUI method to be able
|
|
43
62
|
// to run the loadModularUI action from a handler / callback in the component
|
|
44
63
|
const handleFetch = (href, fetchOptions) => {
|
|
45
|
-
dispatch(loadModularUI(modelKey, href, fetchOptions));
|
|
64
|
+
dispatch(loadModularUI(modelKey, href, patchUpdateModelOption(fetchOptions)));
|
|
46
65
|
};
|
|
47
66
|
|
|
48
67
|
// Check if current model needs a reload
|
|
@@ -51,7 +70,7 @@ const modularUIConnector = function (name, resource) {
|
|
|
51
70
|
useEffect(() => {
|
|
52
71
|
if (doReload) {
|
|
53
72
|
dispatch(loadModularUI(modelKey, url, {
|
|
54
|
-
...otherOptions,
|
|
73
|
+
...patchUpdateModelOption(otherOptions),
|
|
55
74
|
isReload: true
|
|
56
75
|
}));
|
|
57
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIConnector.js","names":["useEffect","useDispatch","useLocation","loadModularUI","reloadModel","removeModelByKey","Href","getDisplayName","useUrl","useReload","useModularUI","useLocale","jsx","_jsx","modularUIConnector","name","resource","options","arguments","length","undefined","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","location","url","displayName","contextId","modelEntry","modelKey","model","connectKey","handleManualReload","reloadOptions","handleFetch","href","fetchOptions","reload","state","doReload","isReload","locale","newProps","status","lastModification","hasModel","Boolean","fetchModularUI"],"sources":["../../../src/redux/_modularui/ModularUIConnector.js"],"sourcesContent":["// @flow\nimport { useEffect } from \"react\";\nimport { useDispatch } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport {\n loadModularUI,\n reloadModel,\n removeModelByKey,\n} from \"./ModularUIActions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl, useReload } from \"./ModularUIUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\nimport { useLocale } from \"../../hooks/useI18n\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { Location } from \"react-router\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { ModularUIOptions } from \"./types\";\n\nexport type InjectedProps = {\n +modelKey: string,\n +location: Location,\n +status: string | null,\n +lastModification: number | null,\n +hasModel: boolean,\n +locale: string,\n +fetchModularUI: (href: string | Href, fetchOptions: Object) => void,\n +reloadModel: (model: ModularUIModel, options: Object) => void,\n +data?: ?ModularUIModel,\n};\n\n/**\n */\nconst modularUIConnector = (\n name: string,\n resource: string | Function,\n options: ModularUIOptions = { propName: \"data\", removeOnUnmount: false },\n): ((Component: ComponentType<any>) => (props: any) => Node) => {\n const {\n propName = \"data\",\n removeOnUnmount = false,\n ...otherOptions\n } = options;\n\n return (Component: ComponentType<any>) => {\n const WrappedComponent = (props: any) => {\n const dispatch = useDispatch();\n const location = useLocation();\n\n const url = useUrl(resource, { location, ...props });\n const displayName = getDisplayName(Component, name, props.contextId);\n\n // Load the model through the useModUI hook\n const modelEntry = useModularUI(displayName, url, otherOptions);\n const modelKey = modelEntry?.model?.connectKey;\n\n // handle manual reload of model\n const handleManualReload = (\n model: ModularUIModel,\n reloadOptions?: Object,\n ) => {\n dispatch(reloadModel(model, reloadOptions));\n };\n\n // Provide connected models with a fetchModularUI method to be able\n // to run the loadModularUI action from a handler / callback in the component\n const handleFetch = (href: string | Href, fetchOptions: Object) => {\n dispatch(loadModularUI(modelKey, href, fetchOptions));\n };\n\n // Check if current model needs a reload\n const reload = location?.state?.reload ?? 0;\n const doReload = useReload(modelEntry, reload);\n useEffect(() => {\n if (doReload) {\n dispatch(\n loadModularUI(modelKey, url, {
|
|
1
|
+
{"version":3,"file":"ModularUIConnector.js","names":["useEffect","useDispatch","useLocation","loadModularUI","reloadModel","removeModelByKey","Href","getDisplayName","useUrl","useReload","useModularUI","useLocale","FormModel","jsx","_jsx","patchUpdateModelOption","oldOptions","updateModel","updateHandler","newModel","clonedModel","clone","update","modularUIConnector","name","resource","options","arguments","length","undefined","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","location","url","displayName","contextId","modelEntry","modelKey","model","connectKey","handleManualReload","reloadOptions","handleFetch","href","fetchOptions","reload","state","doReload","isReload","locale","newProps","status","lastModification","hasModel","Boolean","fetchModularUI"],"sources":["../../../src/redux/_modularui/ModularUIConnector.js"],"sourcesContent":["// @flow\nimport { useEffect } from \"react\";\nimport { useDispatch } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport {\n loadModularUI,\n reloadModel,\n removeModelByKey,\n} from \"./ModularUIActions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl, useReload } from \"./ModularUIUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\nimport { useLocale } from \"../../hooks/useI18n\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { Location } from \"react-router\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { ModularUIOptions } from \"./types\";\nimport FormModel from \"../../models/form/FormModel\";\n\nexport type InjectedProps = {\n +modelKey: string,\n +location: Location,\n +status: string | null,\n +lastModification: number | null,\n +hasModel: boolean,\n +locale: string,\n +fetchModularUI: (href: string | Href, fetchOptions: Object) => void,\n +reloadModel: (model: ModularUIModel, options: Object) => void,\n +data?: ?ModularUIModel,\n};\n\nconst patchUpdateModelOption = (oldOptions: Object) => {\n if (\n \"updateModel\" in oldOptions &&\n oldOptions.updateModel instanceof FormModel\n ) {\n return {\n ...oldOptions,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n // $FLowFixMe\n const clonedModel: FormModel = oldOptions.updateModel.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n };\n }\n\n return oldOptions;\n};\n\n/**\n */\nconst modularUIConnector = (\n name: string,\n resource: string | Function,\n options: ModularUIOptions = { propName: \"data\", removeOnUnmount: false },\n): ((Component: ComponentType<any>) => (props: any) => Node) => {\n const {\n propName = \"data\",\n removeOnUnmount = false,\n ...otherOptions\n } = options;\n\n return (Component: ComponentType<any>) => {\n const WrappedComponent = (props: any) => {\n const dispatch = useDispatch();\n const location = useLocation();\n\n const url = useUrl(resource, { location, ...props });\n const displayName = getDisplayName(Component, name, props.contextId);\n\n // Load the model through the useModUI hook\n const modelEntry = useModularUI(displayName, url, otherOptions);\n const modelKey = modelEntry?.model?.connectKey;\n\n // handle manual reload of model\n const handleManualReload = (\n model: ModularUIModel,\n reloadOptions?: Object,\n ) => {\n dispatch(reloadModel(model, reloadOptions));\n };\n\n // Provide connected models with a fetchModularUI method to be able\n // to run the loadModularUI action from a handler / callback in the component\n const handleFetch = (href: string | Href, fetchOptions: Object) => {\n dispatch(\n loadModularUI(modelKey, href, patchUpdateModelOption(fetchOptions)),\n );\n };\n\n // Check if current model needs a reload\n const reload = location?.state?.reload ?? 0;\n const doReload = useReload(modelEntry, reload);\n useEffect(() => {\n if (doReload) {\n dispatch(\n loadModularUI(modelKey, url, {\n ...patchUpdateModelOption(otherOptions),\n isReload: true,\n }),\n );\n }\n }, [dispatch, doReload, url, modelKey]);\n\n // Remove model when hoc unloads\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(modelKey));\n }\n };\n }, [dispatch, modelKey]);\n\n // Create new properties object to inject modularui properties to own props\n const locale = useLocale();\n const newProps: InjectedProps = {\n modelKey,\n [propName]: modelEntry ? modelEntry.model : null,\n location,\n status: modelEntry ? modelEntry.status : null,\n lastModification: modelEntry ? modelEntry.lastModification : null,\n hasModel: Boolean(modelEntry),\n locale,\n fetchModularUI: handleFetch,\n reloadModel: handleManualReload,\n };\n\n return <Component {...props} {...newProps} />;\n };\n\n WrappedComponent.displayName = `BI.modularui(${getDisplayName(\n WrappedComponent,\n name,\n )}`;\n\n return WrappedComponent;\n };\n};\n\nexport default modularUIConnector;\n"],"mappings":"AACA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASC,WAAW,QAAQ,cAAc;AAE1C,SACEC,aAAa,EACbC,WAAW,EACXC,gBAAgB,QACX,oBAAoB;AAE3B,OAAOC,IAAI,MAAM,wBAAwB;AACzC,SAASC,cAAc,QAAQ,mBAAmB;AAElD,SAASC,MAAM,EAAEC,SAAS,QAAQ,kBAAkB;AACpD,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,SAAS,QAAQ,qBAAqB;AAM/C,OAAOC,SAAS,MAAM,6BAA6B;AAAC,SAAAC,GAAA,IAA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AAEf,UAAU,GAAGA,UAAU,CAACe,MAAM,GAAG,IAAI;QAC7CC,gBAAgB,EAAEhB,UAAU,GAAGA,UAAU,CAACgB,gBAAgB,GAAG,IAAI;QACjEC,QAAQ,EAAEC,OAAO,CAAClB,UAAU,CAAC;QAC7Ba,MAAM;QACNM,cAAc,EAAEb,WAAW;QAC3B3C,WAAW,EAAEyC;MACf,CAAC;MAED,oBAAO/B,IAAA,CAACmB,SAAS;QAAA,GAAKE,KAAK;QAAA,GAAMoB;MAAQ,CAAG,CAAC;IAC/C,CAAC;IAEDrB,gBAAgB,CAACK,WAAW,GAAG,gBAAgBhC,cAAc,CAC3D2B,gBAAgB,EAChBV,IACF,CAAC,EAAE;IAEH,OAAOU,gBAAgB;EACzB,CAAC;AACH,CAAC;AAED,eAAeX,kBAAkB","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
9
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
10
11
|
var _createHash = require("../../utils/helpers/createHash");
|
|
11
12
|
var _BaseModel = _interopRequireDefault(require("../base/BaseModel"));
|
|
@@ -116,9 +117,16 @@ class SubSectionModel extends _BaseModel.default {
|
|
|
116
117
|
get relatedConceptsHref() {
|
|
117
118
|
const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
|
|
118
119
|
if (relatedConceptsLink) {
|
|
120
|
+
var _context2;
|
|
119
121
|
const {
|
|
120
122
|
href
|
|
121
123
|
} = relatedConceptsLink;
|
|
124
|
+
if ((0, _includes.default)(_context2 = href.hash).call(_context2, "/relatedConcepts")) {
|
|
125
|
+
var _context3;
|
|
126
|
+
const firstPart = href.path.substring(0, href.path.lastIndexOf("/"));
|
|
127
|
+
href.path = firstPart + "/" + href.hash;
|
|
128
|
+
href.hash = (0, _includes.default)(_context3 = href.hash).call(_context3, "#") ? href.hash.substring(href.hash.indexOf("#")) : "";
|
|
129
|
+
}
|
|
122
130
|
href.setReferenceHash(this.referenceHash);
|
|
123
131
|
return href;
|
|
124
132
|
}
|
|
@@ -122,6 +122,15 @@ export default class SubSectionModel extends BaseModel {
|
|
|
122
122
|
|
|
123
123
|
if (relatedConceptsLink) {
|
|
124
124
|
const { href } = relatedConceptsLink;
|
|
125
|
+
|
|
126
|
+
if (href.hash.includes("/relatedConcepts")) {
|
|
127
|
+
const firstPart = href.path.substring(0, href.path.lastIndexOf("/"));
|
|
128
|
+
href.path = firstPart + "/" + href.hash;
|
|
129
|
+
href.hash = href.hash.includes("#")
|
|
130
|
+
? href.hash.substring(href.hash.indexOf("#"))
|
|
131
|
+
: "";
|
|
132
|
+
}
|
|
133
|
+
|
|
125
134
|
href.setReferenceHash(this.referenceHash);
|
|
126
135
|
return href;
|
|
127
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubSectionModel.js","names":["_createHash","require","_BaseModel","_interopRequireDefault","_LinkCollection","_Href","_LinkModel","_utils","SubSectionModel","BaseModel","constructor","data","_defineProperty2","default","referred","id","_id","key","body","getData","retrieveText","number","label","subSections","_context","_map","call","subSection","links","_links","LinkCollection","contributions","selflink","getLinkByKey","selfhref","href","relatedConceptsHrefs","hrefs","relatedConceptsHref","push","forEach","relatedConceptsLink","setReferenceHash","referenceHash","Href","createHashFromHref","getReferredSections","sections","referredChilds","exports"],"sources":["../../../src/models/content/SubSectionModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n const body = this.getData(\"body\", \"\");\n return retrieveText(body);\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection),\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n const { href } = relatedConceptsLink;\n href.setReferenceHash(this.referenceHash);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SubSectionModel.js","names":["_createHash","require","_BaseModel","_interopRequireDefault","_LinkCollection","_Href","_LinkModel","_utils","SubSectionModel","BaseModel","constructor","data","_defineProperty2","default","referred","id","_id","key","body","getData","retrieveText","number","label","subSections","_context","_map","call","subSection","links","_links","LinkCollection","contributions","selflink","getLinkByKey","selfhref","href","relatedConceptsHrefs","hrefs","relatedConceptsHref","push","forEach","relatedConceptsLink","_context2","_includes","hash","_context3","firstPart","path","substring","lastIndexOf","indexOf","setReferenceHash","referenceHash","Href","createHashFromHref","getReferredSections","sections","referredChilds","exports"],"sources":["../../../src/models/content/SubSectionModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n const body = this.getData(\"body\", \"\");\n return retrieveText(body);\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection),\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n const { href } = relatedConceptsLink;\n\n if (href.hash.includes(\"/relatedConcepts\")) {\n const firstPart = href.path.substring(0, href.path.lastIndexOf(\"/\"));\n href.path = firstPart + \"/\" + href.hash;\n href.hash = href.hash.includes(\"#\")\n ? href.hash.substring(href.hash.indexOf(\"#\"))\n : \"\";\n }\n\n href.setReferenceHash(this.referenceHash);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"mappings":";;;;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,KAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,UAAA,GAAAH,sB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|
|
7
7
|
import content from "./content.json";
|
|
8
8
|
import contentWithSubsections from "./content-with-subsections.json";
|
|
9
|
+
import contentWithSubsections2 from "./content-with-subsections2.json";
|
|
9
10
|
import contentWithChildsections from "./content-with-childsections.json";
|
|
10
11
|
import ContentLinkModel from "../ContentLinkModel";
|
|
11
12
|
|
|
@@ -118,6 +119,27 @@ describe("contentmodel", () => {
|
|
|
118
119
|
);
|
|
119
120
|
});
|
|
120
121
|
|
|
122
|
+
it("can handle content service with subsections and correct related concepts", () => {
|
|
123
|
+
const response = ModularUIResponse.create({
|
|
124
|
+
key: "contentmodel",
|
|
125
|
+
data: contentWithSubsections2,
|
|
126
|
+
contributions,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const contentModel = new ContentModel(response);
|
|
130
|
+
expect(contentModel.relatedConceptsHrefs).toHaveLength(3);
|
|
131
|
+
|
|
132
|
+
expect(contentModel.relatedConceptsHrefs[0].toString()).toBe(
|
|
133
|
+
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1/relatedConcepts?entryDate=2024-07-17",
|
|
134
|
+
);
|
|
135
|
+
expect(contentModel.relatedConceptsHrefs[1].toString()).toBe(
|
|
136
|
+
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1a/relatedConcepts",
|
|
137
|
+
);
|
|
138
|
+
expect(contentModel.relatedConceptsHrefs[2].toString()).toBe(
|
|
139
|
+
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1b/relatedConcepts",
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
121
143
|
it("can handle content service with subsections", () => {
|
|
122
144
|
const response = ModularUIResponse.create({
|
|
123
145
|
key: "contentmodel",
|
|
@@ -14,7 +14,26 @@ var _utils = require("../../react/utils");
|
|
|
14
14
|
var _ModularUIUtils = require("./ModularUIUtils");
|
|
15
15
|
var _useModularUI = require("../../hooks/useModularUI");
|
|
16
16
|
var _useI18n = require("../../hooks/useI18n");
|
|
17
|
+
var _FormModel = _interopRequireDefault(require("../../models/form/FormModel"));
|
|
17
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
const patchUpdateModelOption = oldOptions => {
|
|
20
|
+
if ("updateModel" in oldOptions && oldOptions.updateModel instanceof _FormModel.default) {
|
|
21
|
+
return {
|
|
22
|
+
...oldOptions,
|
|
23
|
+
updateHandler: newModel => {
|
|
24
|
+
if (newModel instanceof _FormModel.default) {
|
|
25
|
+
// $FLowFixMe
|
|
26
|
+
const clonedModel = oldOptions.updateModel.clone();
|
|
27
|
+
clonedModel.update(newModel);
|
|
28
|
+
return clonedModel;
|
|
29
|
+
}
|
|
30
|
+
return newModel;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return oldOptions;
|
|
35
|
+
};
|
|
36
|
+
|
|
18
37
|
/**
|
|
19
38
|
*/
|
|
20
39
|
const modularUIConnector = function (name, resource) {
|
|
@@ -49,7 +68,7 @@ const modularUIConnector = function (name, resource) {
|
|
|
49
68
|
// Provide connected models with a fetchModularUI method to be able
|
|
50
69
|
// to run the loadModularUI action from a handler / callback in the component
|
|
51
70
|
const handleFetch = (href, fetchOptions) => {
|
|
52
|
-
dispatch((0, _ModularUIActions.loadModularUI)(modelKey, href, fetchOptions));
|
|
71
|
+
dispatch((0, _ModularUIActions.loadModularUI)(modelKey, href, patchUpdateModelOption(fetchOptions)));
|
|
53
72
|
};
|
|
54
73
|
|
|
55
74
|
// Check if current model needs a reload
|
|
@@ -58,7 +77,7 @@ const modularUIConnector = function (name, resource) {
|
|
|
58
77
|
(0, _react.useEffect)(() => {
|
|
59
78
|
if (doReload) {
|
|
60
79
|
dispatch((0, _ModularUIActions.loadModularUI)(modelKey, url, {
|
|
61
|
-
...otherOptions,
|
|
80
|
+
...patchUpdateModelOption(otherOptions),
|
|
62
81
|
isReload: true
|
|
63
82
|
}));
|
|
64
83
|
}
|
|
@@ -20,6 +20,7 @@ import type { ComponentType, Node } from "react";
|
|
|
20
20
|
import type { Location } from "react-router";
|
|
21
21
|
import type { ModularUIModel } from "../../models/types";
|
|
22
22
|
import type { ModularUIOptions } from "./types";
|
|
23
|
+
import FormModel from "../../models/form/FormModel";
|
|
23
24
|
|
|
24
25
|
export type InjectedProps = {
|
|
25
26
|
+modelKey: string,
|
|
@@ -33,6 +34,28 @@ export type InjectedProps = {
|
|
|
33
34
|
+data?: ?ModularUIModel,
|
|
34
35
|
};
|
|
35
36
|
|
|
37
|
+
const patchUpdateModelOption = (oldOptions: Object) => {
|
|
38
|
+
if (
|
|
39
|
+
"updateModel" in oldOptions &&
|
|
40
|
+
oldOptions.updateModel instanceof FormModel
|
|
41
|
+
) {
|
|
42
|
+
return {
|
|
43
|
+
...oldOptions,
|
|
44
|
+
updateHandler: (newModel: ModularUIModel): ModularUIModel => {
|
|
45
|
+
if (newModel instanceof FormModel) {
|
|
46
|
+
// $FLowFixMe
|
|
47
|
+
const clonedModel: FormModel = oldOptions.updateModel.clone();
|
|
48
|
+
clonedModel.update(newModel);
|
|
49
|
+
return clonedModel;
|
|
50
|
+
}
|
|
51
|
+
return newModel;
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return oldOptions;
|
|
57
|
+
};
|
|
58
|
+
|
|
36
59
|
/**
|
|
37
60
|
*/
|
|
38
61
|
const modularUIConnector = (
|
|
@@ -69,7 +92,9 @@ const modularUIConnector = (
|
|
|
69
92
|
// Provide connected models with a fetchModularUI method to be able
|
|
70
93
|
// to run the loadModularUI action from a handler / callback in the component
|
|
71
94
|
const handleFetch = (href: string | Href, fetchOptions: Object) => {
|
|
72
|
-
dispatch(
|
|
95
|
+
dispatch(
|
|
96
|
+
loadModularUI(modelKey, href, patchUpdateModelOption(fetchOptions)),
|
|
97
|
+
);
|
|
73
98
|
};
|
|
74
99
|
|
|
75
100
|
// Check if current model needs a reload
|
|
@@ -78,7 +103,10 @@ const modularUIConnector = (
|
|
|
78
103
|
useEffect(() => {
|
|
79
104
|
if (doReload) {
|
|
80
105
|
dispatch(
|
|
81
|
-
loadModularUI(modelKey, url, {
|
|
106
|
+
loadModularUI(modelKey, url, {
|
|
107
|
+
...patchUpdateModelOption(otherOptions),
|
|
108
|
+
isReload: true,
|
|
109
|
+
}),
|
|
82
110
|
);
|
|
83
111
|
}
|
|
84
112
|
}, [dispatch, doReload, url, modelKey]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIConnector.js","names":["_react","require","_reactRedux","_reactRouter","_ModularUIActions","_Href","_interopRequireDefault","_utils","_ModularUIUtils","_useModularUI","_useI18n","_jsxRuntime","modularUIConnector","name","resource","options","arguments","length","undefined","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","useDispatch","location","useLocation","url","useUrl","displayName","getDisplayName","contextId","modelEntry","useModularUI","modelKey","model","connectKey","handleManualReload","reloadOptions","reloadModel","handleFetch","href","fetchOptions","loadModularUI","reload","state","doReload","useReload","useEffect","isReload","removeModelByKey","locale","useLocale","newProps","status","lastModification","hasModel","Boolean","fetchModularUI","jsx","_default","exports","default"],"sources":["../../../src/redux/_modularui/ModularUIConnector.js"],"sourcesContent":["// @flow\nimport { useEffect } from \"react\";\nimport { useDispatch } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport {\n loadModularUI,\n reloadModel,\n removeModelByKey,\n} from \"./ModularUIActions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl, useReload } from \"./ModularUIUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\nimport { useLocale } from \"../../hooks/useI18n\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { Location } from \"react-router\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { ModularUIOptions } from \"./types\";\n\nexport type InjectedProps = {\n +modelKey: string,\n +location: Location,\n +status: string | null,\n +lastModification: number | null,\n +hasModel: boolean,\n +locale: string,\n +fetchModularUI: (href: string | Href, fetchOptions: Object) => void,\n +reloadModel: (model: ModularUIModel, options: Object) => void,\n +data?: ?ModularUIModel,\n};\n\n/**\n */\nconst modularUIConnector = (\n name: string,\n resource: string | Function,\n options: ModularUIOptions = { propName: \"data\", removeOnUnmount: false },\n): ((Component: ComponentType<any>) => (props: any) => Node) => {\n const {\n propName = \"data\",\n removeOnUnmount = false,\n ...otherOptions\n } = options;\n\n return (Component: ComponentType<any>) => {\n const WrappedComponent = (props: any) => {\n const dispatch = useDispatch();\n const location = useLocation();\n\n const url = useUrl(resource, { location, ...props });\n const displayName = getDisplayName(Component, name, props.contextId);\n\n // Load the model through the useModUI hook\n const modelEntry = useModularUI(displayName, url, otherOptions);\n const modelKey = modelEntry?.model?.connectKey;\n\n // handle manual reload of model\n const handleManualReload = (\n model: ModularUIModel,\n reloadOptions?: Object,\n ) => {\n dispatch(reloadModel(model, reloadOptions));\n };\n\n // Provide connected models with a fetchModularUI method to be able\n // to run the loadModularUI action from a handler / callback in the component\n const handleFetch = (href: string | Href, fetchOptions: Object) => {\n dispatch(loadModularUI(modelKey, href, fetchOptions));\n };\n\n // Check if current model needs a reload\n const reload = location?.state?.reload ?? 0;\n const doReload = useReload(modelEntry, reload);\n useEffect(() => {\n if (doReload) {\n dispatch(\n loadModularUI(modelKey, url, {
|
|
1
|
+
{"version":3,"file":"ModularUIConnector.js","names":["_react","require","_reactRedux","_reactRouter","_ModularUIActions","_Href","_interopRequireDefault","_utils","_ModularUIUtils","_useModularUI","_useI18n","_FormModel","_jsxRuntime","patchUpdateModelOption","oldOptions","updateModel","FormModel","updateHandler","newModel","clonedModel","clone","update","modularUIConnector","name","resource","options","arguments","length","undefined","propName","removeOnUnmount","otherOptions","Component","WrappedComponent","props","dispatch","useDispatch","location","useLocation","url","useUrl","displayName","getDisplayName","contextId","modelEntry","useModularUI","modelKey","model","connectKey","handleManualReload","reloadOptions","reloadModel","handleFetch","href","fetchOptions","loadModularUI","reload","state","doReload","useReload","useEffect","isReload","removeModelByKey","locale","useLocale","newProps","status","lastModification","hasModel","Boolean","fetchModularUI","jsx","_default","exports","default"],"sources":["../../../src/redux/_modularui/ModularUIConnector.js"],"sourcesContent":["// @flow\nimport { useEffect } from \"react\";\nimport { useDispatch } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport {\n loadModularUI,\n reloadModel,\n removeModelByKey,\n} from \"./ModularUIActions\";\n\nimport Href from \"../../models/href/Href\";\nimport { getDisplayName } from \"../../react/utils\";\n\nimport { useUrl, useReload } from \"./ModularUIUtils\";\nimport { useModularUI } from \"../../hooks/useModularUI\";\nimport { useLocale } from \"../../hooks/useI18n\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { Location } from \"react-router\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { ModularUIOptions } from \"./types\";\nimport FormModel from \"../../models/form/FormModel\";\n\nexport type InjectedProps = {\n +modelKey: string,\n +location: Location,\n +status: string | null,\n +lastModification: number | null,\n +hasModel: boolean,\n +locale: string,\n +fetchModularUI: (href: string | Href, fetchOptions: Object) => void,\n +reloadModel: (model: ModularUIModel, options: Object) => void,\n +data?: ?ModularUIModel,\n};\n\nconst patchUpdateModelOption = (oldOptions: Object) => {\n if (\n \"updateModel\" in oldOptions &&\n oldOptions.updateModel instanceof FormModel\n ) {\n return {\n ...oldOptions,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n // $FLowFixMe\n const clonedModel: FormModel = oldOptions.updateModel.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n };\n }\n\n return oldOptions;\n};\n\n/**\n */\nconst modularUIConnector = (\n name: string,\n resource: string | Function,\n options: ModularUIOptions = { propName: \"data\", removeOnUnmount: false },\n): ((Component: ComponentType<any>) => (props: any) => Node) => {\n const {\n propName = \"data\",\n removeOnUnmount = false,\n ...otherOptions\n } = options;\n\n return (Component: ComponentType<any>) => {\n const WrappedComponent = (props: any) => {\n const dispatch = useDispatch();\n const location = useLocation();\n\n const url = useUrl(resource, { location, ...props });\n const displayName = getDisplayName(Component, name, props.contextId);\n\n // Load the model through the useModUI hook\n const modelEntry = useModularUI(displayName, url, otherOptions);\n const modelKey = modelEntry?.model?.connectKey;\n\n // handle manual reload of model\n const handleManualReload = (\n model: ModularUIModel,\n reloadOptions?: Object,\n ) => {\n dispatch(reloadModel(model, reloadOptions));\n };\n\n // Provide connected models with a fetchModularUI method to be able\n // to run the loadModularUI action from a handler / callback in the component\n const handleFetch = (href: string | Href, fetchOptions: Object) => {\n dispatch(\n loadModularUI(modelKey, href, patchUpdateModelOption(fetchOptions)),\n );\n };\n\n // Check if current model needs a reload\n const reload = location?.state?.reload ?? 0;\n const doReload = useReload(modelEntry, reload);\n useEffect(() => {\n if (doReload) {\n dispatch(\n loadModularUI(modelKey, url, {\n ...patchUpdateModelOption(otherOptions),\n isReload: true,\n }),\n );\n }\n }, [dispatch, doReload, url, modelKey]);\n\n // Remove model when hoc unloads\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(modelKey));\n }\n };\n }, [dispatch, modelKey]);\n\n // Create new properties object to inject modularui properties to own props\n const locale = useLocale();\n const newProps: InjectedProps = {\n modelKey,\n [propName]: modelEntry ? modelEntry.model : null,\n location,\n status: modelEntry ? modelEntry.status : null,\n lastModification: modelEntry ? modelEntry.lastModification : null,\n hasModel: Boolean(modelEntry),\n locale,\n fetchModularUI: handleFetch,\n reloadModel: handleManualReload,\n };\n\n return <Component {...props} {...newProps} />;\n };\n\n WrappedComponent.displayName = `BI.modularui(${getDisplayName(\n WrappedComponent,\n name,\n )}`;\n\n return WrappedComponent;\n };\n};\n\nexport default modularUIConnector;\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IA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ACd,OAAO,MAAM;UACX,IAAI9B,eAAe,EAAE;YACnBK,QAAQ,CAAC,IAAA2B,kCAAgB,EAAChB,QAAQ,CAAC,CAAC;UACtC;QACF,CAAC;MACH,CAAC,EAAE,CAACX,QAAQ,EAAEW,QAAQ,CAAC,CAAC;;MAExB;MACA,MAAMiB,MAAM,GAAG,IAAAC,kBAAS,EAAC,CAAC;MAC1B,MAAMC,QAAuB,GAAG;QAC9BnB,QAAQ;QACR,CAACjB,QAAQ,GAAGe,UAAU,GAAGA,UAAU,CAACG,KAAK,GAAG,IAAI;QAChDV,QAAQ;QACR6B,MAAM,EAAEtB,UAAU,GAAGA,UAAU,CAACsB,MAAM,GAAG,IAAI;QAC7CC,gBAAgB,EAAEvB,UAAU,GAAGA,UAAU,CAACuB,gBAAgB,GAAG,IAAI;QACjEC,QAAQ,EAAEC,OAAO,CAACzB,UAAU,CAAC;QAC7BmB,MAAM;QACNO,cAAc,EAAElB,WAAW;QAC3BD,WAAW,EAAEF;MACf,CAAC;MAED,oBAAO,IAAArC,WAAA,CAAA2D,GAAA,EAACvC,SAAS;QAAA,GAAKE,KAAK;QAAA,GAAM+B;MAAQ,CAAG,CAAC;IAC/C,CAAC;IAEDhC,gBAAgB,CAACQ,WAAW,GAAG,gBAAgB,IAAAC,qBAAc,EAC3DT,gBAAgB,EAChBV,IACF,CAAC,EAAE;IAEH,OAAOU,gBAAgB;EACzB,CAAC;AACH,CAAC;AAAC,IAAAuC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEapD,kBAAkB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -122,6 +122,15 @@ export default class SubSectionModel extends BaseModel {
|
|
|
122
122
|
|
|
123
123
|
if (relatedConceptsLink) {
|
|
124
124
|
const { href } = relatedConceptsLink;
|
|
125
|
+
|
|
126
|
+
if (href.hash.includes("/relatedConcepts")) {
|
|
127
|
+
const firstPart = href.path.substring(0, href.path.lastIndexOf("/"));
|
|
128
|
+
href.path = firstPart + "/" + href.hash;
|
|
129
|
+
href.hash = href.hash.includes("#")
|
|
130
|
+
? href.hash.substring(href.hash.indexOf("#"))
|
|
131
|
+
: "";
|
|
132
|
+
}
|
|
133
|
+
|
|
125
134
|
href.setReferenceHash(this.referenceHash);
|
|
126
135
|
return href;
|
|
127
136
|
}
|
|
@@ -6,6 +6,7 @@ import contributions from "./contributions.json";
|
|
|
6
6
|
|
|
7
7
|
import content from "./content.json";
|
|
8
8
|
import contentWithSubsections from "./content-with-subsections.json";
|
|
9
|
+
import contentWithSubsections2 from "./content-with-subsections2.json";
|
|
9
10
|
import contentWithChildsections from "./content-with-childsections.json";
|
|
10
11
|
import ContentLinkModel from "../ContentLinkModel";
|
|
11
12
|
|
|
@@ -118,6 +119,27 @@ describe("contentmodel", () => {
|
|
|
118
119
|
);
|
|
119
120
|
});
|
|
120
121
|
|
|
122
|
+
it("can handle content service with subsections and correct related concepts", () => {
|
|
123
|
+
const response = ModularUIResponse.create({
|
|
124
|
+
key: "contentmodel",
|
|
125
|
+
data: contentWithSubsections2,
|
|
126
|
+
contributions,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const contentModel = new ContentModel(response);
|
|
130
|
+
expect(contentModel.relatedConceptsHrefs).toHaveLength(3);
|
|
131
|
+
|
|
132
|
+
expect(contentModel.relatedConceptsHrefs[0].toString()).toBe(
|
|
133
|
+
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1/relatedConcepts?entryDate=2024-07-17",
|
|
134
|
+
);
|
|
135
|
+
expect(contentModel.relatedConceptsHrefs[1].toString()).toBe(
|
|
136
|
+
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1a/relatedConcepts",
|
|
137
|
+
);
|
|
138
|
+
expect(contentModel.relatedConceptsHrefs[2].toString()).toBe(
|
|
139
|
+
"/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1b/relatedConcepts",
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
121
143
|
it("can handle content service with subsections", () => {
|
|
122
144
|
const response = ModularUIResponse.create({
|
|
123
145
|
key: "contentmodel",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"section": {
|
|
3
|
+
"_id": "Chapter5_1",
|
|
4
|
+
"label": "Eligibility Criteria",
|
|
5
|
+
"number": "5.1",
|
|
6
|
+
"body": "<p>Applications will need to meet the following eligibility criteria:</p>",
|
|
7
|
+
"subSections": [
|
|
8
|
+
{
|
|
9
|
+
"_id": "Chapter5_1a",
|
|
10
|
+
"number": "a.",
|
|
11
|
+
"body": "<p>The research project can be classified as innovative. This includes innovation levels 2 and 3 as described in Annex A.</p>",
|
|
12
|
+
"_links": {
|
|
13
|
+
"self": {
|
|
14
|
+
"href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1#Chapter5_1a"
|
|
15
|
+
},
|
|
16
|
+
"api_doc": {
|
|
17
|
+
"href": "/api-docs/v3/content/(content-identifier)/(section-identifier)"
|
|
18
|
+
},
|
|
19
|
+
"contributions": {
|
|
20
|
+
"href": "/contributions/content/(content-identifier)/(section-identifier)"
|
|
21
|
+
},
|
|
22
|
+
"relatedConcepts": {
|
|
23
|
+
"href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1#Chapter5_1a/relatedConcepts"
|
|
24
|
+
},
|
|
25
|
+
"content": {
|
|
26
|
+
"href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"_id": "Chapter5_1b",
|
|
32
|
+
"number": "b.",
|
|
33
|
+
"body": "<p>The research project contributes to open source, which includes the following projects:</p>",
|
|
34
|
+
"subSections": [],
|
|
35
|
+
"_links": {
|
|
36
|
+
"self": {
|
|
37
|
+
"href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1#Chapter5_1b"
|
|
38
|
+
},
|
|
39
|
+
"api_doc": {
|
|
40
|
+
"href": "/api-docs/v3/content/(content-identifier)/(section-identifier)"
|
|
41
|
+
},
|
|
42
|
+
"contributions": {
|
|
43
|
+
"href": "/contributions/content/(content-identifier)/(section-identifier)"
|
|
44
|
+
},
|
|
45
|
+
"relatedConcepts": {
|
|
46
|
+
"href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1#Chapter5_1b/relatedConcepts"
|
|
47
|
+
},
|
|
48
|
+
"content": {
|
|
49
|
+
"href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"_links": {
|
|
55
|
+
"self": {
|
|
56
|
+
"href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1"
|
|
57
|
+
},
|
|
58
|
+
"api_doc": {
|
|
59
|
+
"href": "/api-docs/v3/content/(content-identifier)/(section-identifier)"
|
|
60
|
+
},
|
|
61
|
+
"contributions": {
|
|
62
|
+
"href": "/contributions/content/(content-identifier)/(section-identifier)"
|
|
63
|
+
},
|
|
64
|
+
"relatedConcepts": {
|
|
65
|
+
"href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1/relatedConcepts"
|
|
66
|
+
},
|
|
67
|
+
"content": {
|
|
68
|
+
"href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"filter": {
|
|
72
|
+
"entryDate": {
|
|
73
|
+
"param": "entryDate",
|
|
74
|
+
"name": "entryDate",
|
|
75
|
+
"value": "2024-07-17"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -20,6 +20,7 @@ import type { ComponentType, Node } from "react";
|
|
|
20
20
|
import type { Location } from "react-router";
|
|
21
21
|
import type { ModularUIModel } from "../../models/types";
|
|
22
22
|
import type { ModularUIOptions } from "./types";
|
|
23
|
+
import FormModel from "../../models/form/FormModel";
|
|
23
24
|
|
|
24
25
|
export type InjectedProps = {
|
|
25
26
|
+modelKey: string,
|
|
@@ -33,6 +34,28 @@ export type InjectedProps = {
|
|
|
33
34
|
+data?: ?ModularUIModel,
|
|
34
35
|
};
|
|
35
36
|
|
|
37
|
+
const patchUpdateModelOption = (oldOptions: Object) => {
|
|
38
|
+
if (
|
|
39
|
+
"updateModel" in oldOptions &&
|
|
40
|
+
oldOptions.updateModel instanceof FormModel
|
|
41
|
+
) {
|
|
42
|
+
return {
|
|
43
|
+
...oldOptions,
|
|
44
|
+
updateHandler: (newModel: ModularUIModel): ModularUIModel => {
|
|
45
|
+
if (newModel instanceof FormModel) {
|
|
46
|
+
// $FLowFixMe
|
|
47
|
+
const clonedModel: FormModel = oldOptions.updateModel.clone();
|
|
48
|
+
clonedModel.update(newModel);
|
|
49
|
+
return clonedModel;
|
|
50
|
+
}
|
|
51
|
+
return newModel;
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return oldOptions;
|
|
57
|
+
};
|
|
58
|
+
|
|
36
59
|
/**
|
|
37
60
|
*/
|
|
38
61
|
const modularUIConnector = (
|
|
@@ -69,7 +92,9 @@ const modularUIConnector = (
|
|
|
69
92
|
// Provide connected models with a fetchModularUI method to be able
|
|
70
93
|
// to run the loadModularUI action from a handler / callback in the component
|
|
71
94
|
const handleFetch = (href: string | Href, fetchOptions: Object) => {
|
|
72
|
-
dispatch(
|
|
95
|
+
dispatch(
|
|
96
|
+
loadModularUI(modelKey, href, patchUpdateModelOption(fetchOptions)),
|
|
97
|
+
);
|
|
73
98
|
};
|
|
74
99
|
|
|
75
100
|
// Check if current model needs a reload
|
|
@@ -78,7 +103,10 @@ const modularUIConnector = (
|
|
|
78
103
|
useEffect(() => {
|
|
79
104
|
if (doReload) {
|
|
80
105
|
dispatch(
|
|
81
|
-
loadModularUI(modelKey, url, {
|
|
106
|
+
loadModularUI(modelKey, url, {
|
|
107
|
+
...patchUpdateModelOption(otherOptions),
|
|
108
|
+
isReload: true,
|
|
109
|
+
}),
|
|
82
110
|
);
|
|
83
111
|
}
|
|
84
112
|
}, [dispatch, doReload, url, modelKey]);
|