@beinformed/ui 1.62.4 → 1.62.6
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/hooks/useModelCatalog.d.ts +1 -0
- package/esm/hooks/useModelCatalog.js +17 -0
- package/esm/hooks/useModelCatalog.js.flow +18 -0
- package/esm/hooks/useModelCatalog.js.map +1 -1
- package/esm/models/content/ContentTOCModel.d.ts +5 -0
- package/esm/models/content/ContentTOCModel.js +15 -0
- package/esm/models/content/ContentTOCModel.js.flow +15 -0
- package/esm/models/content/ContentTOCModel.js.map +1 -1
- package/esm/models/content/__tests__/Formalsource.spec.js.flow +8 -0
- package/lib/hooks/useModelCatalog.d.ts +1 -0
- package/lib/hooks/useModelCatalog.js +19 -1
- package/lib/hooks/useModelCatalog.js.map +1 -1
- package/lib/models/content/ContentTOCModel.d.ts +5 -0
- package/lib/models/content/ContentTOCModel.js +15 -0
- package/lib/models/content/ContentTOCModel.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useModelCatalog.js +18 -0
- package/src/models/content/ContentTOCModel.js +15 -0
- package/src/models/content/__tests__/Formalsource.spec.js +8 -0
- package/src/models/content/__tests__/formalsource-toc.json +3 -0
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.62.6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.5...v1.62.6) (2025-06-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **related-concepts:** add separate hook for related concepts ([defcc40](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/defcc4088819564bdcc89bebdb78ca68b2be916a))
|
|
11
|
+
|
|
12
|
+
## [1.62.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.4...v1.62.5) (2025-06-06)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **content-toc:** add related concepts href ([090b237](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/090b237591dd7f8499aa1624f4e7b24cec0e9c98))
|
|
18
|
+
|
|
5
19
|
## [1.62.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.3...v1.62.4) (2025-06-05)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -19,6 +19,7 @@ export function useEntryDate(): ({
|
|
|
19
19
|
entryDate: ISO_DATE;
|
|
20
20
|
setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction;
|
|
21
21
|
});
|
|
22
|
+
export function useRelatedConcepts(href: string | Href, key?: string, options?: UseModularUIBasicOptions<ConceptIndexModel>): ConceptIndexModel | null;
|
|
22
23
|
import { UseModularUIBasicOptions } from "./useModularUIBasic";
|
|
23
24
|
import ModelCatalogModel from "../models/modelcatalog/ModelCatalogModel";
|
|
24
25
|
import Href from "../models/href/Href";
|
|
@@ -179,4 +179,21 @@ export const useEntryDate = () => {
|
|
|
179
179
|
setEntryDate: entryDate => dispatch(updateEntryDate(entryDate))
|
|
180
180
|
};
|
|
181
181
|
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
*/
|
|
185
|
+
export const useRelatedConcepts = function (href) {
|
|
186
|
+
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "relatedconcepts";
|
|
187
|
+
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
188
|
+
const {
|
|
189
|
+
entryDate
|
|
190
|
+
} = useEntryDate();
|
|
191
|
+
const url = filterParameters(href, ["modelcategory"]);
|
|
192
|
+
url.setParameter("entryDate", entryDate);
|
|
193
|
+
return useModularUIBasic(key, url, {
|
|
194
|
+
expectedModels: ["ConceptIndex"],
|
|
195
|
+
targetModel: ConceptIndexModel,
|
|
196
|
+
...options
|
|
197
|
+
});
|
|
198
|
+
};
|
|
182
199
|
//# sourceMappingURL=useModelCatalog.js.map
|
|
@@ -236,3 +236,21 @@ export const useEntryDate = (): ({
|
|
|
236
236
|
setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),
|
|
237
237
|
};
|
|
238
238
|
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
*/
|
|
242
|
+
export const useRelatedConcepts = (
|
|
243
|
+
href: string | Href,
|
|
244
|
+
key?: string = "relatedconcepts",
|
|
245
|
+
options?: UseModularUIBasicOptions<ConceptIndexModel>,
|
|
246
|
+
): ?ConceptIndexModel => {
|
|
247
|
+
const { entryDate } = useEntryDate();
|
|
248
|
+
const url = filterParameters(href, ["modelcategory"]);
|
|
249
|
+
url.setParameter("entryDate", entryDate);
|
|
250
|
+
|
|
251
|
+
return useModularUIBasic(key, url, {
|
|
252
|
+
expectedModels: ["ConceptIndex"],
|
|
253
|
+
targetModel: ConceptIndexModel,
|
|
254
|
+
...options,
|
|
255
|
+
});
|
|
256
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModelCatalog.js","names":["useSelector","useDispatch","useLocation","createHref","filterParameters","ModelCatalogModel","ConceptIndexModel","ConceptDetailModel","default","BusinessScenarioModel","ContentIndexModel","ContentTOCModel","ContentModel","useModularUIBasic","ContentTypeModel","getEntryDate","updateEntryDate","Href","useModelCatalog","options","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","entryDate","useEntryDate","url","setParameter","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","useCompleteSource","contentHref","removeParameter","addParameter","useContentType","contentType","getSearchHref","uri","filters","filterString","_Object$keys","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch","dispatch","setEntryDate"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nimport { getEntryDate } from \"../redux/selectors/modelcatalog\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport Href from \"../models/href/Href\";\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nimport type { UpdateEntryDateAction } from \"../redux\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n modelCategory?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string | Href,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\n \"index\",\n \"label\",\n \"modelcategory\",\n \"type\",\n ]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string | Href,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string | Href,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string | Href,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useCompleteSource = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n let contentHref = new Href(content);\n contentHref.removeParameter(\"complete\");\n contentHref.addParameter(\"complete\", \"true\");\n\n const href = createHref(\"content\", contentHref, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string | Href,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, null, []);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n\n/**\n * Retrieve and update the entrydate for the modelcatalog\n */\nexport const useEntryDate = (): ({\n entryDate: ISO_DATE,\n setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction,\n}) => {\n const dispatch = useDispatch();\n const entryDate = useSelector(getEntryDate);\n\n return {\n entryDate,\n setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),\n };\n};\n"],"mappings":";AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,aAAa;AACtD,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC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MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAAA,IAC9BN,OAAqD,GAAAM,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAMJ,IAAI,GAAGsB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOZ,eAAe,CAACZ,IAAI,EAAEC,GAAG,EAAEL,OAAO,CAAC;AAC5C,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMU,YAAY,GAAGA,CAAA,KAGtB;EACJ,MAAM8B,QAAQ,GAAG1D,WAAW,CAAC,CAAC;EAC9B,MAAM2B,SAAS,GAAG5B,WAAW,CAACe,YAAY,CAAC;EAE3C,OAAO;IACLa,SAAS;IACTgC,YAAY,EAAGhC,SAAmB,IAAK+B,QAAQ,CAAC3C,eAAe,CAACY,SAAS,CAAC;EAC5E,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useModelCatalog.js","names":["useSelector","useDispatch","useLocation","createHref","filterParameters","ModelCatalogModel","ConceptIndexModel","ConceptDetailModel","default","BusinessScenarioModel","ContentIndexModel","ContentTOCModel","ContentModel","useModularUIBasic","ContentTypeModel","getEntryDate","updateEntryDate","Href","useModelCatalog","options","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","entryDate","useEntryDate","url","setParameter","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","useCompleteSource","contentHref","removeParameter","addParameter","useContentType","contentType","getSearchHref","uri","filters","filterString","_Object$keys","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch","dispatch","setEntryDate","useRelatedConcepts"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nimport { getEntryDate } from \"../redux/selectors/modelcatalog\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport Href from \"../models/href/Href\";\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nimport type { UpdateEntryDateAction } from \"../redux\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n modelCategory?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string | Href,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\n \"index\",\n \"label\",\n \"modelcategory\",\n \"type\",\n ]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string | Href,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string | Href,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string | Href,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useCompleteSource = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n let contentHref = new Href(content);\n contentHref.removeParameter(\"complete\");\n contentHref.addParameter(\"complete\", \"true\");\n\n const href = createHref(\"content\", contentHref, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string | Href,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, null, []);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n\n/**\n * Retrieve and update the entrydate for the modelcatalog\n */\nexport const useEntryDate = (): ({\n entryDate: ISO_DATE,\n setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction,\n}) => {\n const dispatch = useDispatch();\n const entryDate = useSelector(getEntryDate);\n\n return {\n entryDate,\n setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),\n };\n};\n\n/**\n */\nexport const useRelatedConcepts = (\n href: string | Href,\n key?: string = \"relatedconcepts\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\"modelcategory\"]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"Concept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,CAAC;IAChCC,WAAW,EAAEf,iBAAiB;IAC9B,GAAGa;EACL,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -17,6 +17,10 @@ export default class ContentTOCModel extends ResourceModel {
|
|
|
17
17
|
/**
|
|
18
18
|
*/
|
|
19
19
|
get abbreviation(): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Get related concepts link
|
|
22
|
+
*/
|
|
23
|
+
get relatedConceptsHref(): Href | null;
|
|
20
24
|
/**
|
|
21
25
|
*/
|
|
22
26
|
get selfContentLink(): ContentLinkModel;
|
|
@@ -47,5 +51,6 @@ import ResourceModel from "../base/ResourceModel";
|
|
|
47
51
|
import ContentTypeModel from "./ContentTypeModel";
|
|
48
52
|
import FilterCollection from "../filters/FilterCollection";
|
|
49
53
|
import { ModularUIModel } from "../types";
|
|
54
|
+
import Href from "../href/Href";
|
|
50
55
|
import ContentLinkModel from "./ContentLinkModel";
|
|
51
56
|
import SectionModel from "./SectionModel";
|
|
@@ -101,6 +101,21 @@ export default class ContentTOCModel extends ResourceModel {
|
|
|
101
101
|
return href;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Get related concepts link
|
|
106
|
+
*/
|
|
107
|
+
get relatedConceptsHref() {
|
|
108
|
+
const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
|
|
109
|
+
if (relatedConceptsLink) {
|
|
110
|
+
const {
|
|
111
|
+
href
|
|
112
|
+
} = relatedConceptsLink;
|
|
113
|
+
href.addParameter("entryDate", this.entryDate);
|
|
114
|
+
return href;
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
104
119
|
/**
|
|
105
120
|
*/
|
|
106
121
|
get selfContentLink() {
|
|
@@ -117,6 +117,21 @@ export default class ContentTOCModel extends ResourceModel {
|
|
|
117
117
|
return href;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Get related concepts link
|
|
122
|
+
*/
|
|
123
|
+
get relatedConceptsHref(): Href | null {
|
|
124
|
+
const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
|
|
125
|
+
|
|
126
|
+
if (relatedConceptsLink) {
|
|
127
|
+
const { href } = relatedConceptsLink;
|
|
128
|
+
href.addParameter("entryDate", this.entryDate);
|
|
129
|
+
return href;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
120
135
|
/**
|
|
121
136
|
*/
|
|
122
137
|
get selfContentLink(): ContentLinkModel {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentTOCModel.js","names":["has","ResourceModel","FilterCollection","ContentLinkModel","ContentTypeModel","Href","SectionModel","TIMEVERSION_FILTER_NAME","getItems","items","entryDate","modelOptions","_mapInstanceProperty","call","item","link","section","_id","sections","ContentTOCModel","constructor","arguments","_defineProperty","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","contentTypeLink","links","getLinkByKey","setChildModels","models","contentType","_findInstanceProperty","model","label","getData","abbreviation","selfhref","href","selflink","filterCollection","forEach","filter","params","param","value","setParameter","name","removeParameter","selfContentLink","_context","categories","_context2","category","_contentType","_filterCollection","_context3","_filterInstanceProperty","_context4","key","_Object$keys","timeversionFilter","getFilterByAttributeKey","attribute","isCompleteSource","completeFilter"],"sources":["../../../src/models/content/ContentTOCModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport Href from \"../href/Href\";\n\nimport SectionModel from \"./SectionModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * Get content items recursively\n */\nconst getItems = (\n items: Array<Object>,\n entryDate: ISO_DATE | null,\n modelOptions?: ModelOptions,\n): Array<ContentLinkModel> =>\n items.map((item) => {\n const link = new ContentLinkModel(\n {\n ...item,\n section: item._id,\n },\n entryDate,\n modelOptions,\n );\n\n if (item.items) {\n link.items = getItems(item.items, entryDate, modelOptions);\n }\n if (item.sections) {\n link.items = getItems(item.sections, entryDate, modelOptions);\n }\n\n return link;\n });\n\n/**\n * Content detail model\n */\nexport default class ContentTOCModel extends ResourceModel {\n _contentType: ContentTypeModel | null = null;\n _filterCollection: FilterCollection;\n\n /**\n */\n get type(): string {\n return \"ContentTOC\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ContentTOCModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return data.contributions?.resourcetype === \"ContentTOC\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const contentTypeLink = this.links.getLinkByKey(\"contenttype\");\n\n if (contentTypeLink) {\n return [contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.contentType = models.find((model) => model.type === \"ContentType\");\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\");\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const href = new Href(this.selflink.href);\n\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n\n return href;\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(this.data, this.entryDate, this.modelOptions);\n }\n\n /**\n * Get sub items of toc\n */\n get items(): Array<ContentLinkModel> {\n if (this.data.items) {\n return getItems(this.data.items, this.entryDate, this.modelOptions);\n }\n\n if (this.data.sections) {\n return getItems(this.data.sections, this.entryDate, this.modelOptions);\n }\n\n return [];\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n if (this.data.sections) {\n return this.data.sections.map(\n (section) =>\n new SectionModel(section, this.entryDate, this.modelOptions),\n );\n }\n return [];\n }\n\n /**\n * get categories of content\n */\n get categories(): Array<ContentLinkModel> {\n if (this.data.categories) {\n return this.data.categories.map(\n (category) => new ContentLinkModel(category, null, this.modelOptions),\n );\n }\n\n return [];\n }\n\n /**\n * Retrieve content type model\n */\n get contentType(): ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n * Retrieve available filters on concept toc\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter.filter((filter) => {\n const [key] = Object.keys(filter);\n return has(this.data?.filter, key);\n }),\n },\n this.modelOptions,\n );\n }\n\n return this._filterCollection;\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): ISO_DATE | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n\n return timeversionFilter?.attribute?.value ?? null;\n }\n\n /**\n */\n get isCompleteSource(): boolean {\n const completeFilter =\n this.filterCollection.getFilterByAttributeKey(\"complete\");\n return completeFilter?.attribute?.value === \"true\";\n }\n}\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,aAAa,MAAM,uBAAuB;AACjD,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,IAAI,MAAM,cAAc;AAE/B,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,SAASC,uBAAuB,QAAQ,2BAA2B;AAKnE;AACA;AACA;AACA,MAAMC,QAAQ,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;MAC3B,IAAI,CAACD,iBAAiB,GAAG,IAAIzD,gBAAgB,CAAA2D,uBAAA,CAC3C,IAAI,CAACnC,IAAI,GACT;QACEoB,MAAM,EAAEe,uBAAA,CAAAD,SAAA,GAAAC,uBAAA,KAAI,CAAClC,aAAa,GAAAd,IAAA,CAAA+C,SAAA,EAAgBd,MAAM,IAAK;UAAA,IAAAgB,SAAA;UACnD,MAAM,CAACC,GAAG,CAAC,GAAGC,YAAA,CAAYlB,MAAM,CAAC;UACjC,OAAO9C,GAAG,EAAA8D,SAAA,GAAC,IAAI,CAACpC,IAAI,qBAAAmC,uBAAA,CAAAC,SAAA,GAAUC,GAAG,CAAC;QACpC,CAAC;MACH,CAAC,EACD,IAAI,CAACpD,YACP,CAAC;IACH;IAEA,OAAO,IAAI,CAACgD,iBAAiB;EAC/B;;EAEA;AACF;AACA;EACE,IAAIjD,SAASA,CAAA,EAAoB;IAC/B,MAAMuD,iBAAiB,GAAG,IAAI,CAACrB,gBAAgB,CAACsB,uBAAuB,CACrE3D,uBACF,CAAC;IAED,OAAO0D,iBAAiB,EAAEE,SAAS,EAAElB,KAAK,IAAI,IAAI;EACpD;;EAEA;AACF;EACE,IAAImB,gBAAgBA,CAAA,EAAY;IAC9B,MAAMC,cAAc,GAClB,IAAI,CAACzB,gBAAgB,CAACsB,uBAAuB,CAAC,UAAU,CAAC;IAC3D,OAAOG,cAAc,EAAEF,SAAS,EAAElB,KAAK,KAAK,MAAM;EACpD;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ContentTOCModel.js","names":["has","ResourceModel","FilterCollection","ContentLinkModel","ContentTypeModel","Href","SectionModel","TIMEVERSION_FILTER_NAME","getItems","items","entryDate","modelOptions","_mapInstanceProperty","call","item","link","section","_id","sections","ContentTOCModel","constructor","arguments","_defineProperty","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","contentTypeLink","links","getLinkByKey","setChildModels","models","contentType","_findInstanceProperty","model","label","getData","abbreviation","selfhref","href","selflink","filterCollection","forEach","filter","params","param","value","setParameter","name","removeParameter","relatedConceptsHref","relatedConceptsLink","addParameter","selfContentLink","_context","categories","_context2","category","_contentType","_filterCollection","_context3","_filterInstanceProperty","_context4","key","_Object$keys","timeversionFilter","getFilterByAttributeKey","attribute","isCompleteSource","completeFilter"],"sources":["../../../src/models/content/ContentTOCModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport Href from \"../href/Href\";\n\nimport SectionModel from \"./SectionModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * Get content items recursively\n */\nconst getItems = (\n items: Array<Object>,\n entryDate: ISO_DATE | null,\n modelOptions?: ModelOptions,\n): Array<ContentLinkModel> =>\n items.map((item) => {\n const link = new ContentLinkModel(\n {\n ...item,\n section: item._id,\n },\n entryDate,\n modelOptions,\n );\n\n if (item.items) {\n link.items = getItems(item.items, entryDate, modelOptions);\n }\n if (item.sections) {\n link.items = getItems(item.sections, entryDate, modelOptions);\n }\n\n return link;\n });\n\n/**\n * Content detail model\n */\nexport default class ContentTOCModel extends ResourceModel {\n _contentType: ContentTypeModel | null = null;\n _filterCollection: FilterCollection;\n\n /**\n */\n get type(): string {\n return \"ContentTOC\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ContentTOCModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return data.contributions?.resourcetype === \"ContentTOC\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const contentTypeLink = this.links.getLinkByKey(\"contenttype\");\n\n if (contentTypeLink) {\n return [contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.contentType = models.find((model) => model.type === \"ContentType\");\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\");\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const href = new Href(this.selflink.href);\n\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n\n return href;\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.addParameter(\"entryDate\", this.entryDate);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(this.data, this.entryDate, this.modelOptions);\n }\n\n /**\n * Get sub items of toc\n */\n get items(): Array<ContentLinkModel> {\n if (this.data.items) {\n return getItems(this.data.items, this.entryDate, this.modelOptions);\n }\n\n if (this.data.sections) {\n return getItems(this.data.sections, this.entryDate, this.modelOptions);\n }\n\n return [];\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n if (this.data.sections) {\n return this.data.sections.map(\n (section) =>\n new SectionModel(section, this.entryDate, this.modelOptions),\n );\n }\n return [];\n }\n\n /**\n * get categories of content\n */\n get categories(): Array<ContentLinkModel> {\n if (this.data.categories) {\n return this.data.categories.map(\n (category) => new ContentLinkModel(category, null, this.modelOptions),\n );\n }\n\n return [];\n }\n\n /**\n * Retrieve content type model\n */\n get contentType(): ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n * Retrieve available filters on concept toc\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter.filter((filter) => {\n const [key] = Object.keys(filter);\n return has(this.data?.filter, key);\n }),\n },\n this.modelOptions,\n );\n }\n\n return this._filterCollection;\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): ISO_DATE | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n\n return timeversionFilter?.attribute?.value ?? null;\n }\n\n /**\n */\n get isCompleteSource(): boolean {\n const completeFilter =\n this.filterCollection.getFilterByAttributeKey(\"complete\");\n return completeFilter?.attribute?.value === \"true\";\n }\n}\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,aAAa,MAAM,uBAAuB;AACjD,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,IAAI,MAAM,cAAc;AAE/B,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,SAASC,uBAAuB,QAAQ,2BAA2B;AAKnE;AACA;AACA;AACA,MAAMC,QAAQ,GAAGA,CACfC,KAAoB,EACpBC,SAA0B,EAC1BC,YAA2B,KAE3BC,oBAAA,CAAAH,KAAK,EAAAI,IAAA,CAALJ,KAAK,EAAMK,IAAI,IAAK;EAClB,MAAMC,IAAI,GAAG,IAAIZ,gBAAgB,CAC/B;IACE,GAAGW,IAAI;IACPE,OAAO,EAAEF,IAAI,CAACG;EAChB,CAAC,EACDP,SAAS,EACTC,YACF,CAAC;EAED,IAAIG,IAAI,CAACL,KAAK,EAAE;IACdM,IAAI,CAACN,KAAK,GAAGD,QAAQ,CAACM,IAAI,CAACL,KAAK,EAAEC,SAAS,EAAEC,YAAY,CAAC;EAC5D;EACA,IAAIG,IAAI,CAACI,QAAQ,EAAE;IACjBH,IAAI,CAACN,KAAK,GAAG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AAAC,uBAAA,KAAI,CAACrC,aAAa,GAAAd,IAAA,CAAAkD,SAAA,EAAgBjB,MAAM,IAAK;UAAA,IAAAmB,SAAA;UACnD,MAAM,CAACC,GAAG,CAAC,GAAGC,YAAA,CAAYrB,MAAM,CAAC;UACjC,OAAO9C,GAAG,EAAAiE,SAAA,GAAC,IAAI,CAACvC,IAAI,qBAAAsC,uBAAA,CAAAC,SAAA,GAAUC,GAAG,CAAC;QACpC,CAAC;MACH,CAAC,EACD,IAAI,CAACvD,YACP,CAAC;IACH;IAEA,OAAO,IAAI,CAACmD,iBAAiB;EAC/B;;EAEA;AACF;AACA;EACE,IAAIpD,SAASA,CAAA,EAAoB;IAC/B,MAAM0D,iBAAiB,GAAG,IAAI,CAACxB,gBAAgB,CAACyB,uBAAuB,CACrE9D,uBACF,CAAC;IAED,OAAO6D,iBAAiB,EAAEE,SAAS,EAAErB,KAAK,IAAI,IAAI;EACpD;;EAEA;AACF;EACE,IAAIsB,gBAAgBA,CAAA,EAAY;IAC9B,MAAMC,cAAc,GAClB,IAAI,CAAC5B,gBAAgB,CAACyB,uBAAuB,CAAC,UAAU,CAAC;IAC3D,OAAOG,cAAc,EAAEF,SAAS,EAAErB,KAAK,KAAK,MAAM;EACpD;AACF","ignoreList":[]}
|
|
@@ -27,6 +27,10 @@ describe("formalsource", () => {
|
|
|
27
27
|
"Grant Funding Agreement - Terms and Conditions",
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
+
expect(tocModel.relatedConceptsHref.toString()).toBe(
|
|
31
|
+
"/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/relatedConcepts?entryDate=2025-05-28",
|
|
32
|
+
);
|
|
33
|
+
|
|
30
34
|
expect(tocModel.items).toHaveLength(6);
|
|
31
35
|
expect(tocModel.items[0].items).toBeUndefined();
|
|
32
36
|
expect(tocModel.items[1].items).toHaveLength(2);
|
|
@@ -64,6 +68,10 @@ describe("formalsource", () => {
|
|
|
64
68
|
expect(completeModel.abbreviation).toBe("GFA-TC-01");
|
|
65
69
|
expect(completeModel.isCompleteSource).toBe(true);
|
|
66
70
|
|
|
71
|
+
expect(completeModel.relatedConceptsHref.toString()).toBe(
|
|
72
|
+
"/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/relatedConcepts?entryDate=2025-05-28",
|
|
73
|
+
);
|
|
74
|
+
|
|
67
75
|
const firstSection = completeModel.sections[0];
|
|
68
76
|
expect(firstSection.selfhref.toString()).toBe(
|
|
69
77
|
"/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/Chapter1",
|
|
@@ -19,6 +19,7 @@ export function useEntryDate(): ({
|
|
|
19
19
|
entryDate: ISO_DATE;
|
|
20
20
|
setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction;
|
|
21
21
|
});
|
|
22
|
+
export function useRelatedConcepts(href: string | Href, key?: string, options?: UseModularUIBasicOptions<ConceptIndexModel>): ConceptIndexModel | null;
|
|
22
23
|
import { UseModularUIBasicOptions } from "./useModularUIBasic";
|
|
23
24
|
import ModelCatalogModel from "../models/modelcatalog/ModelCatalogModel";
|
|
24
25
|
import Href from "../models/href/Href";
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.useModelCatalog = exports.useEntryDate = exports.useContentType = exports.useContentTOC = exports.useContentSearch = exports.useContentIndex = exports.useContent = exports.useConceptSearch = exports.useConceptIndex = exports.useConceptDetail = exports.useCompleteSource = void 0;
|
|
7
|
+
exports.useRelatedConcepts = exports.useModelCatalog = exports.useEntryDate = exports.useContentType = exports.useContentTOC = exports.useContentSearch = exports.useContentIndex = exports.useContent = exports.useConceptSearch = exports.useConceptIndex = exports.useConceptDetail = exports.useCompleteSource = void 0;
|
|
8
8
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
9
9
|
var _reactRedux = require("react-redux");
|
|
10
10
|
var _useRouter = require("./useRouter");
|
|
@@ -196,5 +196,23 @@ const useEntryDate = () => {
|
|
|
196
196
|
setEntryDate: entryDate => dispatch((0, _ModelCatalog.updateEntryDate)(entryDate))
|
|
197
197
|
};
|
|
198
198
|
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
*/
|
|
199
202
|
exports.useEntryDate = useEntryDate;
|
|
203
|
+
const useRelatedConcepts = function (href) {
|
|
204
|
+
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "relatedconcepts";
|
|
205
|
+
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
206
|
+
const {
|
|
207
|
+
entryDate
|
|
208
|
+
} = useEntryDate();
|
|
209
|
+
const url = (0, _createHref.filterParameters)(href, ["modelcategory"]);
|
|
210
|
+
url.setParameter("entryDate", entryDate);
|
|
211
|
+
return (0, _useModularUIBasic.useModularUIBasic)(key, url, {
|
|
212
|
+
expectedModels: ["ConceptIndex"],
|
|
213
|
+
targetModel: _ConceptIndexModel.default,
|
|
214
|
+
...options
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
exports.useRelatedConcepts = useRelatedConcepts;
|
|
200
218
|
//# sourceMappingURL=useModelCatalog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModelCatalog.js","names":["_reactRedux","require","_useRouter","_createHref","_ModelCatalogModel","_interopRequireDefault","_ConceptIndexModel","_ConceptDetailModel","_BusinessScenarioModel","_ContentIndexModel","_ContentTOCModel","_ContentModel","_useModularUIBasic","_models","_modelcatalog","_ModelCatalog","_Href","useModelCatalog","options","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","exports","useConceptIndex","href","key","arguments","length","undefined","entryDate","useEntryDate","url","filterParameters","setParameter","ConceptIndexModel","useConceptDetail","concept","location","useLocation","createHref","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","useCompleteSource","contentHref","Href","removeParameter","addParameter","useContentType","contentType","ContentTypeModel","getSearchHref","uri","filters","filterString","_keys","default","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch","dispatch","useDispatch","useSelector","getEntryDate","setEntryDate","updateEntryDate"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nimport { getEntryDate } from \"../redux/selectors/modelcatalog\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport Href from \"../models/href/Href\";\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nimport type { UpdateEntryDateAction } from \"../redux\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n modelCategory?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string | Href,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\n \"index\",\n \"label\",\n \"modelcategory\",\n \"type\",\n ]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string | Href,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string | Href,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string | Href,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useCompleteSource = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n let contentHref = new Href(content);\n contentHref.removeParameter(\"complete\");\n contentHref.addParameter(\"complete\", \"true\");\n\n const href = createHref(\"content\", contentHref, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string | Href,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, null, []);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n\n/**\n * Retrieve and update the entrydate for the modelcatalog\n */\nexport const useEntryDate = (): ({\n entryDate: ISO_DATE,\n setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction,\n}) => {\n const dispatch = useDispatch();\n const entryDate = useSelector(getEntryDate);\n\n return {\n entryDate,\n setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),\n };\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,kBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,mBAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,sBAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,kBAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AACA,IAAAS,gBAAA,GAAAL,sBAAA,CAAAJ,OAAA;AACA,IAAAU,aAAA,GAAAN,sBAAA,CAAAJ,OAAA;AAEA,IAAAW,kBAAA,GAAAX,OAAA;AACA,IAAAY,OAAA,GAAAZ,OAAA;AAEA,IAAAa,aAAA,GAAAb,OAAA;AACA,IAAAc,aAAA,GAAAd,OAAA;AAEA,IAAAe,KAAA,GAAAX,sBAAA,CAAAJ,OAAA;AAWA;AACA;AACO,MAAMgB,eAAe,GAC1BC,OAAqD,IAErD,IAAAC,oCAAiB,EAAC,cAAc,EAAE,eAAe,EAAE;EACjDC,cAAc,EAAE,CAAC,cAAc,CAAC;EAChCC,WAAW,EAAEC,0BAAiB;EAC9B,GAAGJ;AACL,CAAC,CAAC;;AAEJ;AACA;AADAK,OAAA,CAAAN,eAAA,GAAAA,eAAA;AAEO,MAAMO,eAAe,GAAG,SAAAA,CAC7BC,IAAmB,EAGI;EAAA,IAFvBC,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,cAAc;EAAA,IAC7B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,GAAG,IAAA0C,uBAAW,EAACC,0BAAY,CAAC;EAE3C,OAAO;IACL3C,SAAS;IACT4C,YAAY,EAAG5C,SAAmB,IAAKwC,QAAQ,CAAC,IAAAK,6BAAe,EAAC7C,SAAS,CAAC;EAC5E,CAAC;AACH,CAAC;AAACP,OAAA,CAAAQ,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useModelCatalog.js","names":["_reactRedux","require","_useRouter","_createHref","_ModelCatalogModel","_interopRequireDefault","_ConceptIndexModel","_ConceptDetailModel","_BusinessScenarioModel","_ContentIndexModel","_ContentTOCModel","_ContentModel","_useModularUIBasic","_models","_modelcatalog","_ModelCatalog","_Href","useModelCatalog","options","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","exports","useConceptIndex","href","key","arguments","length","undefined","entryDate","useEntryDate","url","filterParameters","setParameter","ConceptIndexModel","useConceptDetail","concept","location","useLocation","createHref","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","useCompleteSource","contentHref","Href","removeParameter","addParameter","useContentType","contentType","ContentTypeModel","getSearchHref","uri","filters","filterString","_keys","default","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch","dispatch","useDispatch","useSelector","getEntryDate","setEntryDate","updateEntryDate","useRelatedConcepts"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nimport { getEntryDate } from \"../redux/selectors/modelcatalog\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport Href from \"../models/href/Href\";\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nimport type { UpdateEntryDateAction } from \"../redux\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n modelCategory?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string | Href,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\n \"index\",\n \"label\",\n \"modelcategory\",\n \"type\",\n ]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string | Href,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, entryDate, location, []);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string | Href,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string | Href,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n const href = createHref(\"content\", content, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useCompleteSource = (\n content: string | Href,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel | ?ContentTOCModel => {\n const { entryDate } = useEntryDate();\n const location = useLocation();\n\n let contentHref = new Href(content);\n contentHref.removeParameter(\"complete\");\n contentHref.addParameter(\"complete\", \"true\");\n\n const href = createHref(\"content\", contentHref, entryDate, location, [\n \"complete\",\n ]);\n\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\", \"ContentTOC\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string | Href,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, null, []);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n\n/**\n * Retrieve and update the entrydate for the modelcatalog\n */\nexport const useEntryDate = (): ({\n entryDate: ISO_DATE,\n setEntryDate: (entryDate: ISO_DATE) => UpdateEntryDateAction,\n}) => {\n const dispatch = useDispatch();\n const entryDate = useSelector(getEntryDate);\n\n return {\n entryDate,\n setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),\n };\n};\n\n/**\n */\nexport const useRelatedConcepts = (\n href: string | Href,\n key?: string = \"relatedconcepts\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const { entryDate } = useEntryDate();\n const url = filterParameters(href, [\"modelcategory\"]);\n url.setParameter(\"entryDate\", entryDate);\n\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,kBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,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AF,SAAA,MAAG,iBAAiB;EAAA,IAChCT,OAAqD,GAAAS,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAM;IAAEC;EAAU,CAAC,GAAGC,YAAY,CAAC,CAAC;EACpC,MAAMC,GAAG,GAAG,IAAAC,4BAAgB,EAACR,IAAI,EAAE,CAAC,eAAe,CAAC,CAAC;EACrDO,GAAG,CAACE,YAAY,CAAC,WAAW,EAAEJ,SAAS,CAAC;EAExC,OAAO,IAAAX,oCAAiB,EAACO,GAAG,EAAEM,GAAG,EAAE;IACjCZ,cAAc,EAAE,CAAC,cAAc,CAAC;IAChCC,WAAW,EAAEc,0BAAiB;IAC9B,GAAGjB;EACL,CAAC,CAAC;AACJ,CAAC;AAACK,OAAA,CAAAqD,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -17,6 +17,10 @@ export default class ContentTOCModel extends ResourceModel {
|
|
|
17
17
|
/**
|
|
18
18
|
*/
|
|
19
19
|
get abbreviation(): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Get related concepts link
|
|
22
|
+
*/
|
|
23
|
+
get relatedConceptsHref(): Href | null;
|
|
20
24
|
/**
|
|
21
25
|
*/
|
|
22
26
|
get selfContentLink(): ContentLinkModel;
|
|
@@ -47,5 +51,6 @@ import ResourceModel from "../base/ResourceModel";
|
|
|
47
51
|
import ContentTypeModel from "./ContentTypeModel";
|
|
48
52
|
import FilterCollection from "../filters/FilterCollection";
|
|
49
53
|
import { ModularUIModel } from "../types";
|
|
54
|
+
import Href from "../href/Href";
|
|
50
55
|
import ContentLinkModel from "./ContentLinkModel";
|
|
51
56
|
import SectionModel from "./SectionModel";
|
|
@@ -108,6 +108,21 @@ class ContentTOCModel extends _ResourceModel.default {
|
|
|
108
108
|
return href;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Get related concepts link
|
|
113
|
+
*/
|
|
114
|
+
get relatedConceptsHref() {
|
|
115
|
+
const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
|
|
116
|
+
if (relatedConceptsLink) {
|
|
117
|
+
const {
|
|
118
|
+
href
|
|
119
|
+
} = relatedConceptsLink;
|
|
120
|
+
href.addParameter("entryDate", this.entryDate);
|
|
121
|
+
return href;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
|
|
111
126
|
/**
|
|
112
127
|
*/
|
|
113
128
|
get selfContentLink() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentTOCModel.js","names":["_objects","require","_ResourceModel","_interopRequireDefault","_FilterCollection","_ContentLinkModel","_ContentTypeModel","_Href","_SectionModel","_Constants","getItems","items","entryDate","modelOptions","_map","default","call","item","link","ContentLinkModel","section","_id","sections","ContentTOCModel","ResourceModel","constructor","arguments","_defineProperty2","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","contentTypeLink","links","getLinkByKey","setChildModels","models","contentType","_find","model","label","getData","abbreviation","selfhref","href","Href","selflink","filterCollection","forEach","filter","params","param","value","setParameter","name","removeParameter","selfContentLink","_context","SectionModel","categories","_context2","category","_contentType","ContentTypeModel","_filterCollection","_context3","FilterCollection","_filter","_context4","key","_keys","has","timeversionFilter","getFilterByAttributeKey","TIMEVERSION_FILTER_NAME","attribute","isCompleteSource","completeFilter","exports"],"sources":["../../../src/models/content/ContentTOCModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport Href from \"../href/Href\";\n\nimport SectionModel from \"./SectionModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * Get content items recursively\n */\nconst getItems = (\n items: Array<Object>,\n entryDate: ISO_DATE | null,\n modelOptions?: ModelOptions,\n): Array<ContentLinkModel> =>\n items.map((item) => {\n const link = new ContentLinkModel(\n {\n ...item,\n section: item._id,\n },\n entryDate,\n modelOptions,\n );\n\n if (item.items) {\n link.items = getItems(item.items, entryDate, modelOptions);\n }\n if (item.sections) {\n link.items = getItems(item.sections, entryDate, modelOptions);\n }\n\n return link;\n });\n\n/**\n * Content detail model\n */\nexport default class ContentTOCModel extends ResourceModel {\n _contentType: ContentTypeModel | null = null;\n _filterCollection: FilterCollection;\n\n /**\n */\n get type(): string {\n return \"ContentTOC\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ContentTOCModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return data.contributions?.resourcetype === \"ContentTOC\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const contentTypeLink = this.links.getLinkByKey(\"contenttype\");\n\n if (contentTypeLink) {\n return [contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.contentType = models.find((model) => model.type === \"ContentType\");\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\");\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const href = new Href(this.selflink.href);\n\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n\n return href;\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(this.data, this.entryDate, this.modelOptions);\n }\n\n /**\n * Get sub items of toc\n */\n get items(): Array<ContentLinkModel> {\n if (this.data.items) {\n return getItems(this.data.items, this.entryDate, this.modelOptions);\n }\n\n if (this.data.sections) {\n return getItems(this.data.sections, this.entryDate, this.modelOptions);\n }\n\n return [];\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n if (this.data.sections) {\n return this.data.sections.map(\n (section) =>\n new SectionModel(section, this.entryDate, this.modelOptions),\n );\n }\n return [];\n }\n\n /**\n * get categories of content\n */\n get categories(): Array<ContentLinkModel> {\n if (this.data.categories) {\n return this.data.categories.map(\n (category) => new ContentLinkModel(category, null, this.modelOptions),\n );\n }\n\n return [];\n }\n\n /**\n * Retrieve content type model\n */\n get contentType(): ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n * Retrieve available filters on concept toc\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter.filter((filter) => {\n const [key] = Object.keys(filter);\n return has(this.data?.filter, key);\n }),\n },\n this.modelOptions,\n );\n }\n\n return this._filterCollection;\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): ISO_DATE | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n\n return timeversionFilter?.attribute?.value ?? null;\n }\n\n /**\n */\n get isCompleteSource(): boolean {\n const completeFilter =\n this.filterCollection.getFilterByAttributeKey(\"complete\");\n return completeFilter?.attribute?.value === \"true\";\n }\n}\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,iBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,iBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,KAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAEA,IAAAO,aAAA,GAAAL,sBAAA,CAAAF,OAAA;A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oreList":[]}
|
|
1
|
+
{"version":3,"file":"ContentTOCModel.js","names":["_objects","require","_ResourceModel","_interopRequireDefault","_FilterCollection","_ContentLinkModel","_ContentTypeModel","_Href","_SectionModel","_Constants","getItems","items","entryDate","modelOptions","_map","default","call","item","link","ContentLinkModel","section","_id","sections","ContentTOCModel","ResourceModel","constructor","arguments","_defineProperty2","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","contentTypeLink","links","getLinkByKey","setChildModels","models","contentType","_find","model","label","getData","abbreviation","selfhref","href","Href","selflink","filterCollection","forEach","filter","params","param","value","setParameter","name","removeParameter","relatedConceptsHref","relatedConceptsLink","addParameter","selfContentLink","_context","SectionModel","categories","_context2","category","_contentType","ContentTypeModel","_filterCollection","_context3","FilterCollection","_filter","_context4","key","_keys","has","timeversionFilter","getFilterByAttributeKey","TIMEVERSION_FILTER_NAME","attribute","isCompleteSource","completeFilter","exports"],"sources":["../../../src/models/content/ContentTOCModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport Href from \"../href/Href\";\n\nimport SectionModel from \"./SectionModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * Get content items recursively\n */\nconst getItems = (\n items: Array<Object>,\n entryDate: ISO_DATE | null,\n modelOptions?: ModelOptions,\n): Array<ContentLinkModel> =>\n items.map((item) => {\n const link = new ContentLinkModel(\n {\n ...item,\n section: item._id,\n },\n entryDate,\n modelOptions,\n );\n\n if (item.items) {\n link.items = getItems(item.items, entryDate, modelOptions);\n }\n if (item.sections) {\n link.items = getItems(item.sections, entryDate, modelOptions);\n }\n\n return link;\n });\n\n/**\n * Content detail model\n */\nexport default class ContentTOCModel extends ResourceModel {\n _contentType: ContentTypeModel | null = null;\n _filterCollection: FilterCollection;\n\n /**\n */\n get type(): string {\n return \"ContentTOC\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ContentTOCModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return data.contributions?.resourcetype === \"ContentTOC\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const contentTypeLink = this.links.getLinkByKey(\"contenttype\");\n\n if (contentTypeLink) {\n return [contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.contentType = models.find((model) => model.type === \"ContentType\");\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\");\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const href = new Href(this.selflink.href);\n\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n\n return href;\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.addParameter(\"entryDate\", this.entryDate);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(this.data, this.entryDate, this.modelOptions);\n }\n\n /**\n * Get sub items of toc\n */\n get items(): Array<ContentLinkModel> {\n if (this.data.items) {\n return getItems(this.data.items, this.entryDate, this.modelOptions);\n }\n\n if (this.data.sections) {\n return getItems(this.data.sections, this.entryDate, this.modelOptions);\n }\n\n return [];\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n if (this.data.sections) {\n return this.data.sections.map(\n (section) =>\n new SectionModel(section, this.entryDate, this.modelOptions),\n );\n }\n return [];\n }\n\n /**\n * get categories of content\n */\n get categories(): Array<ContentLinkModel> {\n if (this.data.categories) {\n return this.data.categories.map(\n (category) => new ContentLinkModel(category, null, this.modelOptions),\n );\n }\n\n return [];\n }\n\n /**\n * Retrieve content type model\n */\n get contentType(): ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n * Retrieve available filters on concept toc\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter.filter((filter) => {\n const [key] = Object.keys(filter);\n return has(this.data?.filter, key);\n }),\n },\n this.modelOptions,\n );\n }\n\n return this._filterCollection;\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): ISO_DATE | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n\n return timeversionFilter?.attribute?.value ?? null;\n }\n\n /**\n */\n get isCompleteSource(): boolean {\n const completeFilter =\n this.filterCollection.getFilterByAttributeKey(\"complete\");\n return completeFilter?.attribute?.value === \"true\";\n }\n}\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,iBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,iBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,KAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAEA,IAAAO,aAAA,GAAAL,sBAAA,CAAAF,OAAA;AAEA,IAAAQ,UAAA,GAAAR,OAAA;AAKA;AACA;AACA;AACA,MAAMS,QAAQ,GAAGA,CACfC,KAAoB,E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EACE,IAAI2B,gBAAgBA,CAAA,EAAY;IAC9B,MAAMC,cAAc,GAClB,IAAI,CAACjC,gBAAgB,CAAC6B,uBAAuB,CAAC,UAAU,CAAC;IAC3D,OAAOI,cAAc,EAAEF,SAAS,EAAE1B,KAAK,KAAK,MAAM;EACpD;AACF;AAAC6B,OAAA,CAAArE,OAAA,GAAAQ,eAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -236,3 +236,21 @@ export const useEntryDate = (): ({
|
|
|
236
236
|
setEntryDate: (entryDate: ISO_DATE) => dispatch(updateEntryDate(entryDate)),
|
|
237
237
|
};
|
|
238
238
|
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
*/
|
|
242
|
+
export const useRelatedConcepts = (
|
|
243
|
+
href: string | Href,
|
|
244
|
+
key?: string = "relatedconcepts",
|
|
245
|
+
options?: UseModularUIBasicOptions<ConceptIndexModel>,
|
|
246
|
+
): ?ConceptIndexModel => {
|
|
247
|
+
const { entryDate } = useEntryDate();
|
|
248
|
+
const url = filterParameters(href, ["modelcategory"]);
|
|
249
|
+
url.setParameter("entryDate", entryDate);
|
|
250
|
+
|
|
251
|
+
return useModularUIBasic(key, url, {
|
|
252
|
+
expectedModels: ["ConceptIndex"],
|
|
253
|
+
targetModel: ConceptIndexModel,
|
|
254
|
+
...options,
|
|
255
|
+
});
|
|
256
|
+
};
|
|
@@ -117,6 +117,21 @@ export default class ContentTOCModel extends ResourceModel {
|
|
|
117
117
|
return href;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Get related concepts link
|
|
122
|
+
*/
|
|
123
|
+
get relatedConceptsHref(): Href | null {
|
|
124
|
+
const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
|
|
125
|
+
|
|
126
|
+
if (relatedConceptsLink) {
|
|
127
|
+
const { href } = relatedConceptsLink;
|
|
128
|
+
href.addParameter("entryDate", this.entryDate);
|
|
129
|
+
return href;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
120
135
|
/**
|
|
121
136
|
*/
|
|
122
137
|
get selfContentLink(): ContentLinkModel {
|
|
@@ -27,6 +27,10 @@ describe("formalsource", () => {
|
|
|
27
27
|
"Grant Funding Agreement - Terms and Conditions",
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
+
expect(tocModel.relatedConceptsHref.toString()).toBe(
|
|
31
|
+
"/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/relatedConcepts?entryDate=2025-05-28",
|
|
32
|
+
);
|
|
33
|
+
|
|
30
34
|
expect(tocModel.items).toHaveLength(6);
|
|
31
35
|
expect(tocModel.items[0].items).toBeUndefined();
|
|
32
36
|
expect(tocModel.items[1].items).toHaveLength(2);
|
|
@@ -64,6 +68,10 @@ describe("formalsource", () => {
|
|
|
64
68
|
expect(completeModel.abbreviation).toBe("GFA-TC-01");
|
|
65
69
|
expect(completeModel.isCompleteSource).toBe(true);
|
|
66
70
|
|
|
71
|
+
expect(completeModel.relatedConceptsHref.toString()).toBe(
|
|
72
|
+
"/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/relatedConcepts?entryDate=2025-05-28",
|
|
73
|
+
);
|
|
74
|
+
|
|
67
75
|
const firstSection = completeModel.sections[0];
|
|
68
76
|
expect(firstSection.selfhref.toString()).toBe(
|
|
69
77
|
"/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/Chapter1",
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
},
|
|
26
26
|
"contributions": {
|
|
27
27
|
"href": "/contributions/content/(content-identifier)"
|
|
28
|
+
},
|
|
29
|
+
"relatedConcepts": {
|
|
30
|
+
"href": "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/relatedConcepts"
|
|
28
31
|
}
|
|
29
32
|
},
|
|
30
33
|
"label": "Grant Funding Agreement - Terms and Conditions",
|