@beinformed/ui 1.62.2 → 1.62.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/esm/hooks/__tests__/useModelCatalog.spec.js.flow +19 -0
- package/esm/hooks/useModelCatalog.d.ts +1 -0
- package/esm/hooks/useModelCatalog.js +22 -2
- package/esm/hooks/useModelCatalog.js.flow +31 -3
- package/esm/hooks/useModelCatalog.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.d.ts +4 -0
- package/esm/models/concepts/SourceReferenceModel.js +7 -0
- package/esm/models/concepts/SourceReferenceModel.js.flow +12 -0
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/content/ContentLinkModel.d.ts +9 -0
- package/esm/models/content/ContentLinkModel.js +39 -6
- package/esm/models/content/ContentLinkModel.js.flow +48 -6
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/__tests__/ContentLinkModel.spec.js.flow +48 -0
- package/lib/hooks/useModelCatalog.d.ts +1 -0
- package/lib/hooks/useModelCatalog.js +24 -3
- package/lib/hooks/useModelCatalog.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.d.ts +4 -0
- package/lib/models/concepts/SourceReferenceModel.js +7 -0
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.d.ts +9 -0
- package/lib/models/content/ContentLinkModel.js +39 -6
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/__tests__/useModelCatalog.spec.js +19 -0
- package/src/hooks/useModelCatalog.js +31 -3
- package/src/models/concepts/SourceReferenceModel.js +12 -0
- package/src/models/content/ContentLinkModel.js +48 -6
- package/src/models/content/__tests__/ContentLinkModel.spec.js +48 -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.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.3...v1.62.4) (2025-06-05)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **content-link:** add content and section hrefs ([13e85e3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/13e85e3698b4d22f3fc41e4f53f0dff43dfe566e))
|
|
11
|
+
|
|
12
|
+
## [1.62.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.2...v1.62.3) (2025-06-05)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **content:** add useCompleteSource to handle complete=true on toc ([64d39c4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/64d39c49ff732afc0401e33c10008e0be447fbb8))
|
|
18
|
+
|
|
5
19
|
## [1.62.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.1...v1.62.2) (2025-06-04)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
useContentTOC,
|
|
22
22
|
useModelCatalog,
|
|
23
23
|
useContentType,
|
|
24
|
+
useCompleteSource,
|
|
24
25
|
} from "../useModelCatalog";
|
|
25
26
|
import { DateUtil } from "../../utils";
|
|
26
27
|
|
|
@@ -149,6 +150,24 @@ describe("modelcatalog hooks", () => {
|
|
|
149
150
|
);
|
|
150
151
|
});
|
|
151
152
|
|
|
153
|
+
// eslint-disable-next-line jest/expect-expect
|
|
154
|
+
it("useCompleteSource", () => {
|
|
155
|
+
assertTargetModel(
|
|
156
|
+
() => useCompleteSource("/contentdetail"),
|
|
157
|
+
"content",
|
|
158
|
+
"/content/contentdetail?complete=true&entryDate=" + DateUtil.now(),
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// eslint-disable-next-line jest/expect-expect
|
|
163
|
+
it("useCompleteSource 2", () => {
|
|
164
|
+
assertTargetModel(
|
|
165
|
+
() => useCompleteSource("/contentdetail?complete=false"),
|
|
166
|
+
"content",
|
|
167
|
+
"/content/contentdetail?complete=true&entryDate=" + DateUtil.now(),
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
|
|
152
171
|
// eslint-disable-next-line jest/expect-expect
|
|
153
172
|
it("useContentType", () => {
|
|
154
173
|
assertTargetModel(
|
|
@@ -11,6 +11,7 @@ export function useConceptDetail(concept: string | Href, key?: string, options?:
|
|
|
11
11
|
export function useContentIndex(href: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentIndexModel>): ContentIndexModel | null;
|
|
12
12
|
export function useContentTOC(content: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentTOCModel>): ContentTOCModel | null;
|
|
13
13
|
export function useContent(content: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentModel>): (ContentModel | (ContentTOCModel | null)) | null;
|
|
14
|
+
export function useCompleteSource(content: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentModel>): (ContentModel | (ContentTOCModel | null)) | null;
|
|
14
15
|
export function useContentType(contentType: string | Href, key?: string, options?: UseModularUIBasicOptions<ContentTypeModel>): ContentTypeModel | null;
|
|
15
16
|
export function useConceptSearch(filters: SearchFilter, key?: string, options?: UseModularUIBasicOptions<ConceptIndexModel>): ConceptIndexModel | null;
|
|
16
17
|
export function useContentSearch(filters: SearchFilter, key?: string, options?: UseModularUIBasicOptions<ContentIndexModel>): ContentIndexModel | null;
|
|
@@ -13,6 +13,7 @@ import { useModularUIBasic } from "./useModularUIBasic";
|
|
|
13
13
|
import { ContentTypeModel } from "../models";
|
|
14
14
|
import { getEntryDate } from "../redux/selectors/modelcatalog";
|
|
15
15
|
import { updateEntryDate } from "../redux/actions/ModelCatalog";
|
|
16
|
+
import Href from "../models/href/Href";
|
|
16
17
|
/**
|
|
17
18
|
*/
|
|
18
19
|
export const useModelCatalog = options => useModularUIBasic("modelcatalog", "/modelcatalog", {
|
|
@@ -76,7 +77,7 @@ export const useContentTOC = function (content) {
|
|
|
76
77
|
entryDate
|
|
77
78
|
} = useEntryDate();
|
|
78
79
|
const location = useLocation();
|
|
79
|
-
const href = createHref("content", content, entryDate, location, []);
|
|
80
|
+
const href = createHref("content", content, entryDate, location, ["complete"]);
|
|
80
81
|
return useModularUIBasic(key, href, {
|
|
81
82
|
expectedModels: ["ContentTOC"],
|
|
82
83
|
targetModel: ContentTOCModel,
|
|
@@ -93,7 +94,26 @@ export const useContent = function (content) {
|
|
|
93
94
|
entryDate
|
|
94
95
|
} = useEntryDate();
|
|
95
96
|
const location = useLocation();
|
|
96
|
-
const href = createHref("content", content, entryDate, location, []);
|
|
97
|
+
const href = createHref("content", content, entryDate, location, ["complete"]);
|
|
98
|
+
return useModularUIBasic(key, href, {
|
|
99
|
+
expectedModels: ["Content", "ContentTOC"],
|
|
100
|
+
...options
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
*/
|
|
106
|
+
export const useCompleteSource = function (content) {
|
|
107
|
+
let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "content";
|
|
108
|
+
let options = arguments.length > 2 ? arguments[2] : undefined;
|
|
109
|
+
const {
|
|
110
|
+
entryDate
|
|
111
|
+
} = useEntryDate();
|
|
112
|
+
const location = useLocation();
|
|
113
|
+
let contentHref = new Href(content);
|
|
114
|
+
contentHref.removeParameter("complete");
|
|
115
|
+
contentHref.addParameter("complete", "true");
|
|
116
|
+
const href = createHref("content", contentHref, entryDate, location, ["complete"]);
|
|
97
117
|
return useModularUIBasic(key, href, {
|
|
98
118
|
expectedModels: ["Content", "ContentTOC"],
|
|
99
119
|
...options
|
|
@@ -18,7 +18,7 @@ import { ContentTypeModel } from "../models";
|
|
|
18
18
|
import { getEntryDate } from "../redux/selectors/modelcatalog";
|
|
19
19
|
import { updateEntryDate } from "../redux/actions/ModelCatalog";
|
|
20
20
|
|
|
21
|
-
import
|
|
21
|
+
import Href from "../models/href/Href";
|
|
22
22
|
import type { UseModularUIBasicOptions } from "./useModularUIBasic";
|
|
23
23
|
import type { UpdateEntryDateAction } from "../redux";
|
|
24
24
|
export type SearchFilter = {
|
|
@@ -108,7 +108,9 @@ export const useContentTOC = (
|
|
|
108
108
|
const { entryDate } = useEntryDate();
|
|
109
109
|
const location = useLocation();
|
|
110
110
|
|
|
111
|
-
const href = createHref("content", content, entryDate, location, [
|
|
111
|
+
const href = createHref("content", content, entryDate, location, [
|
|
112
|
+
"complete",
|
|
113
|
+
]);
|
|
112
114
|
|
|
113
115
|
return useModularUIBasic(key, href, {
|
|
114
116
|
expectedModels: ["ContentTOC"],
|
|
@@ -127,7 +129,33 @@ export const useContent = (
|
|
|
127
129
|
const { entryDate } = useEntryDate();
|
|
128
130
|
const location = useLocation();
|
|
129
131
|
|
|
130
|
-
const href = createHref("content", content, entryDate, location, [
|
|
132
|
+
const href = createHref("content", content, entryDate, location, [
|
|
133
|
+
"complete",
|
|
134
|
+
]);
|
|
135
|
+
|
|
136
|
+
return useModularUIBasic(key, href, {
|
|
137
|
+
expectedModels: ["Content", "ContentTOC"],
|
|
138
|
+
...options,
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
*/
|
|
144
|
+
export const useCompleteSource = (
|
|
145
|
+
content: string | Href,
|
|
146
|
+
key?: string = "content",
|
|
147
|
+
options?: UseModularUIBasicOptions<ContentModel>,
|
|
148
|
+
): ?ContentModel | ?ContentTOCModel => {
|
|
149
|
+
const { entryDate } = useEntryDate();
|
|
150
|
+
const location = useLocation();
|
|
151
|
+
|
|
152
|
+
let contentHref = new Href(content);
|
|
153
|
+
contentHref.removeParameter("complete");
|
|
154
|
+
contentHref.addParameter("complete", "true");
|
|
155
|
+
|
|
156
|
+
const href = createHref("content", contentHref, entryDate, location, [
|
|
157
|
+
"complete",
|
|
158
|
+
]);
|
|
131
159
|
|
|
132
160
|
return useModularUIBasic(key, href, {
|
|
133
161
|
expectedModels: ["Content", "ContentTOC"],
|
|
@@ -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","useModelCatalog","options","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","entryDate","useEntryDate","url","setParameter","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","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 type 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\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\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,UAAU,EAAEC,gBAAgB,QAAQ,6BAA6B;AAE1E,OAAOC,iBAAiB,MAAM,0CAA0C;AACxE,OAAOC,iBAAiB,MAAM,sCAAsC;AACpE,OAAOC,kBAAkB,MAAM,uCAAuC;AACtE,SAASC,OAAO,IAAIC,qBAAqB,QAAQ,0CAA0C;AAC3F,OAAOC,iBAAiB,MAAM,qCAAqC;AACnE,OAAOC,eAAe,MAAM,mCAAmC;AAC/D,OAAOC,YAAY,MAAM,gCAAgC;AAEzD,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,gBAAgB,QAAQ,WAAW;AAE5C,SAASC,YAAY,QAAQ,iCAAiC;AAC9D,SAASC,eAAe,QAAQ,+BAA+B;AAa/D;AACA;AACA,OAAO,MAAMC,eAAe,GAC1BC,OAAqD,IAErDL,iBAAiB,CAAC,cAAc,EAAE,eAAe,EAAE;EACjDM,cAAc,EAAE,CAAC,cAAc,CAAC;EAChCC,WAAW,EAAEf,iBAAiB;EAC9B,GAAGa;AACL,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMG,eAAe,GAAG,SAAAA,CAC7BC,IAAmB,EAGI;EAAA,IAFvBC,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,cAAc;EAAA,IAC7BN,OAAqD,GAAAM,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAM;IAAEC;EAAU,CAAC,GAAGC,YAAY,CAAC,CAAC;EACpC,MAAMC,GAAG,GAAGzB,gBAAgB,CAACkB,IAAI,E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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,UAAU,EAAEC,gBAAgB,QAAQ,6BAA6B;AAE1E,OAAOC,iBAAiB,MAAM,0CAA0C;AACxE,OAAOC,iBAAiB,MAAM,sCAAsC;AACpE,OAAOC,kBAAkB,MAAM,uCAAuC;AACtE,SAASC,OAAO,IAAIC,qBAAqB,QAAQ,0CAA0C;AAC3F,OAAOC,iBAAiB,MAAM,qCAAqC;AACnE,OAAOC,eAAe,MAAM,mCAAmC;AAC/D,OAAOC,YAAY,MAAM,gCAAgC;AAEzD,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,gBAAgB,QAAQ,WAAW;AAE5C,SAASC,YAAY,QAAQ,iCAAiC;AAC9D,SAASC,eAAe,QAAQ,+BAA+B;AAE/D,OAAOC,IAAI,MAAM,qBAAqB;AAWtC;AACA;AACA,OAAO,MAAMC,eAAe,GAC1BC,OAAqD,IAErDN,iBAAiB,CAAC,cAAc,EAAE,eAAe,EAAE;EACjDO,cAAc,EAAE,CAAC,cAAc,CAAC;EAChCC,WAAW,EAAEhB,iBAAiB;EAC9B,GAAGc;AACL,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMG,eAAe,GAAG,SAAAA,CAC7BC,IAAmB,EAG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|
13
|
+
get links(): LinkCollection;
|
|
11
14
|
/**
|
|
12
15
|
*/
|
|
13
16
|
get link(): ContentLinkModel;
|
|
@@ -39,6 +42,7 @@ declare class SourceReferenceModel {
|
|
|
39
42
|
get fragment(): SectionFragment | void;
|
|
40
43
|
}
|
|
41
44
|
import { ModelOptions } from "../types";
|
|
45
|
+
import LinkCollection from "../links/LinkCollection";
|
|
42
46
|
import ContentLinkModel from "../content/ContentLinkModel";
|
|
43
47
|
import Href from "../href/Href";
|
|
44
48
|
import { SectionFragment } from "../types";
|
|
@@ -3,6 +3,7 @@ import { createHashFromHref } from "../../utils/helpers/createHash";
|
|
|
3
3
|
import ContentLinkModel from "../content/ContentLinkModel";
|
|
4
4
|
import Href from "../href/Href";
|
|
5
5
|
import { getBasePathModularUI } from "../../constants";
|
|
6
|
+
import LinkCollection from "../links/LinkCollection";
|
|
6
7
|
/**
|
|
7
8
|
*/
|
|
8
9
|
class SourceReferenceModel {
|
|
@@ -22,6 +23,12 @@ class SourceReferenceModel {
|
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
/**
|
|
27
|
+
*/
|
|
28
|
+
get links() {
|
|
29
|
+
return new LinkCollection(this._sourceReference._links, null, this._modelOptions);
|
|
30
|
+
}
|
|
31
|
+
|
|
25
32
|
/**
|
|
26
33
|
*/
|
|
27
34
|
get link() {
|
|
@@ -4,6 +4,8 @@ import { createHashFromHref } from "../../utils/helpers/createHash";
|
|
|
4
4
|
import ContentLinkModel from "../content/ContentLinkModel";
|
|
5
5
|
import Href from "../href/Href";
|
|
6
6
|
import { getBasePathModularUI } from "../../constants";
|
|
7
|
+
|
|
8
|
+
import LinkCollection from "../links/LinkCollection";
|
|
7
9
|
import type { ModelOptions, SectionFragment } from "../types";
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -28,6 +30,16 @@ class SourceReferenceModel {
|
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
/**
|
|
34
|
+
*/
|
|
35
|
+
get links(): LinkCollection {
|
|
36
|
+
return new LinkCollection(
|
|
37
|
+
this._sourceReference._links,
|
|
38
|
+
null,
|
|
39
|
+
this._modelOptions,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
/**
|
|
32
44
|
*/
|
|
33
45
|
get link(): ContentLinkModel {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceReferenceModel.js","names":["createHashFromHref","ContentLinkModel","Href","getBasePathModularUI","SourceReferenceModel","constructor","sourceReference","entryDate","arguments","length","undefined","modelOptions","_defineProperty","_sourceReference","_entryDate","_modelOptions","origin","contextPath","link","section","sectionId","
|
|
1
|
+
{"version":3,"file":"SourceReferenceModel.js","names":["createHashFromHref","ContentLinkModel","Href","getBasePathModularUI","LinkCollection","SourceReferenceModel","constructor","sourceReference","entryDate","arguments","length","undefined","modelOptions","_defineProperty","_sourceReference","_entryDate","_modelOptions","origin","contextPath","links","_links","link","section","sectionId","self","href","replace","content","selfhref","type","label","sourceLabel","sourceAbbreviation","referenceHash","fragment","sectionFragment"],"sources":["../../../src/models/concepts/SourceReferenceModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport ContentLinkModel from \"../content/ContentLinkModel\";\nimport Href from \"../href/Href\";\nimport { getBasePathModularUI } from \"../../constants\";\n\nimport LinkCollection from \"../links/LinkCollection\";\nimport type { ModelOptions, SectionFragment } from \"../types\";\n\n/**\n */\nclass SourceReferenceModel {\n _sourceReference: Object;\n _entryDate: ?ISO_DATE;\n _modelOptions: ModelOptions;\n\n /**\n */\n constructor(\n sourceReference: Object,\n entryDate: ?ISO_DATE = null,\n modelOptions?: ModelOptions,\n ) {\n this._sourceReference = sourceReference;\n this._entryDate = entryDate;\n this._modelOptions = modelOptions || {\n origin: \"\",\n contextPath: getBasePathModularUI(),\n };\n }\n\n /**\n */\n get links(): LinkCollection {\n return new LinkCollection(\n this._sourceReference._links,\n null,\n this._modelOptions,\n );\n }\n\n /**\n */\n get link(): ContentLinkModel {\n const section =\n this.sectionId ||\n this._sourceReference._links.self.href.replace(\n `${this._sourceReference._links.content.href}/`,\n \"\",\n );\n\n return new ContentLinkModel(\n {\n ...this._sourceReference,\n section,\n },\n this._entryDate,\n this._modelOptions,\n );\n }\n\n /**\n */\n get selfhref(): Href {\n return this.link.selfhref;\n }\n\n /**\n */\n get type(): string {\n return this._sourceReference.type;\n }\n\n /**\n */\n get label(): string {\n return this._sourceReference.label;\n }\n\n /**\n */\n get sourceLabel(): string {\n return this._sourceReference.sourceLabel;\n }\n\n /**\n *\n */\n get sourceAbbreviation(): string {\n return this._sourceReference.sourceAbbreviation;\n }\n\n /**\n */\n get referenceHash(): number {\n return createHashFromHref(this.selfhref);\n }\n\n /**\n */\n get sectionId(): string {\n return this._sourceReference.sectionId;\n }\n\n /**\n *\n */\n get fragment(): SectionFragment | void {\n return this._sourceReference.sectionFragment;\n }\n}\n\nexport default SourceReferenceModel;\n"],"mappings":";AACA,SAASA,kBAAkB,QAAQ,gCAAgC;AAEnE,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,IAAI,MAAM,cAAc;AAC/B,SAASC,oBAAoB,QAAQ,iBAAiB;AAEtD,OAAOC,cAAc,MAAM,yBAAyB;AAGpD;AACA;AACA,MAAMC,oBAAoB,CAAC;EAKzB;AACF;EACEC,WAAWA,CACTC,eAAuB,EAGvB;IAAA,IAFAC,SAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;IAAA,IAC3BG,YAA2B,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAAAE,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAE3B,IAAI,CAACC,gBAAgB,GAAGP,eAAe;IACvC,IAAI,CAACQ,UAAU,GAAGP,SAAS;IAC3B,IAAI,CAACQ,aAAa,GAAGJ,YAAY,IAAI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AEA;AACF;EACE,IAAIL,SAASA,CAAA,EAAW;IACtB,OAAO,IAAI,CAACT,gBAAgB,CAACS,SAAS;EACxC;;EAEA;AACF;AACA;EACE,IAAIW,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAACpB,gBAAgB,CAACqB,eAAe;EAC9C;AACF;AAEA,eAAe9B,oBAAoB","ignoreList":[]}
|
|
@@ -42,6 +42,9 @@ export default class ContentLinkModel extends BaseModel {
|
|
|
42
42
|
*
|
|
43
43
|
*/
|
|
44
44
|
get abbreviation(): string | null;
|
|
45
|
+
/**
|
|
46
|
+
*/
|
|
47
|
+
get section(): string | null;
|
|
45
48
|
/**
|
|
46
49
|
*/
|
|
47
50
|
createEncodedHref(): Href;
|
|
@@ -58,6 +61,12 @@ export default class ContentLinkModel extends BaseModel {
|
|
|
58
61
|
* Get self link of model
|
|
59
62
|
*/
|
|
60
63
|
get selflink(): LinkModel;
|
|
64
|
+
/**
|
|
65
|
+
*/
|
|
66
|
+
get contentHref(): Href;
|
|
67
|
+
/**
|
|
68
|
+
*/
|
|
69
|
+
get sectionHref(): Href | null;
|
|
61
70
|
/**
|
|
62
71
|
* Self href of concept
|
|
63
72
|
*/
|
|
@@ -97,16 +97,22 @@ export default class ContentLinkModel extends BaseModel {
|
|
|
97
97
|
return this.getData("abbreviation") || this.getData("sourceAbbreviation");
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
*/
|
|
102
|
+
get section() {
|
|
103
|
+
return this.data.section;
|
|
104
|
+
}
|
|
105
|
+
|
|
100
106
|
/**
|
|
101
107
|
*/
|
|
102
108
|
createEncodedHref() {
|
|
103
109
|
const startURI = "/content/";
|
|
104
110
|
const selfHref = new Href(this.data._links.self.href, "", this.modelOptions);
|
|
105
111
|
const href = selfHref.path;
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${
|
|
112
|
+
const sourceId = this.section ? href.substring(startURI.length, href.lastIndexOf("/")) : href.substring(startURI.length);
|
|
113
|
+
if (this.section != null) {
|
|
114
|
+
const encodedSection = encodeURIComponent(this.section);
|
|
115
|
+
selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${encodedSection}`;
|
|
110
116
|
} else {
|
|
111
117
|
selfHref.path = `${startURI}${encodeURIComponent(sourceId)}`;
|
|
112
118
|
}
|
|
@@ -145,9 +151,9 @@ export default class ContentLinkModel extends BaseModel {
|
|
|
145
151
|
if (this.links.hasLinkByKey("content")) {
|
|
146
152
|
selflink = this.links.getLinkByKey("content");
|
|
147
153
|
}
|
|
148
|
-
if (
|
|
154
|
+
if (this.section != null && selflink && !_endsWithInstanceProperty(_context = selflink.href.path).call(_context, encodeURIComponent(this.section))) {
|
|
149
155
|
selflink.href.addParameter("complete", "true");
|
|
150
|
-
selflink.href.hash = this.
|
|
156
|
+
selflink.href.hash = this.section || "";
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
159
|
if (selflink === null) {
|
|
@@ -163,6 +169,33 @@ export default class ContentLinkModel extends BaseModel {
|
|
|
163
169
|
return selflink;
|
|
164
170
|
}
|
|
165
171
|
|
|
172
|
+
/**
|
|
173
|
+
*/
|
|
174
|
+
get contentHref() {
|
|
175
|
+
let href = this.data._links.self.href;
|
|
176
|
+
if (this.data._links.content) {
|
|
177
|
+
href = new Href(this.data._links.content.href);
|
|
178
|
+
} else if (this.section) {
|
|
179
|
+
const section = encodeURIComponent(this.section);
|
|
180
|
+
if (_endsWithInstanceProperty(href).call(href, section)) {
|
|
181
|
+
href = href.substring(0, href.lastIndexOf("/" + section));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return new Href(href).addParameter("complete", "true").addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
*/
|
|
189
|
+
get sectionHref() {
|
|
190
|
+
const section = this.section;
|
|
191
|
+
if (section) {
|
|
192
|
+
const contentHref = this.contentHref;
|
|
193
|
+
const sectionHref = new Href(contentHref.path + "/" + encodeURIComponent(this.data.section));
|
|
194
|
+
return sectionHref.addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);
|
|
195
|
+
}
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
|
|
166
199
|
/**
|
|
167
200
|
* Self href of concept
|
|
168
201
|
*/
|
|
@@ -116,6 +116,12 @@ export default class ContentLinkModel
|
|
|
116
116
|
return this.getData("abbreviation") || this.getData("sourceAbbreviation");
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
*/
|
|
121
|
+
get section(): string | null {
|
|
122
|
+
return this.data.section;
|
|
123
|
+
}
|
|
124
|
+
|
|
119
125
|
/**
|
|
120
126
|
*/
|
|
121
127
|
createEncodedHref(): Href {
|
|
@@ -127,13 +133,13 @@ export default class ContentLinkModel
|
|
|
127
133
|
);
|
|
128
134
|
const href = selfHref.path;
|
|
129
135
|
|
|
130
|
-
const
|
|
131
|
-
const sourceId = section
|
|
136
|
+
const sourceId = this.section
|
|
132
137
|
? href.substring(startURI.length, href.lastIndexOf("/"))
|
|
133
138
|
: href.substring(startURI.length);
|
|
134
139
|
|
|
135
|
-
if (section) {
|
|
136
|
-
|
|
140
|
+
if (this.section != null) {
|
|
141
|
+
const encodedSection = encodeURIComponent(this.section);
|
|
142
|
+
selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${encodedSection}`;
|
|
137
143
|
} else {
|
|
138
144
|
selfHref.path = `${startURI}${encodeURIComponent(sourceId)}`;
|
|
139
145
|
}
|
|
@@ -183,9 +189,13 @@ export default class ContentLinkModel
|
|
|
183
189
|
selflink = this.links.getLinkByKey("content");
|
|
184
190
|
}
|
|
185
191
|
|
|
186
|
-
if (
|
|
192
|
+
if (
|
|
193
|
+
this.section != null &&
|
|
194
|
+
selflink &&
|
|
195
|
+
!selflink.href.path.endsWith(encodeURIComponent(this.section))
|
|
196
|
+
) {
|
|
187
197
|
selflink.href.addParameter("complete", "true");
|
|
188
|
-
selflink.href.hash = this.
|
|
198
|
+
selflink.href.hash = this.section || "";
|
|
189
199
|
}
|
|
190
200
|
}
|
|
191
201
|
|
|
@@ -208,6 +218,38 @@ export default class ContentLinkModel
|
|
|
208
218
|
return selflink;
|
|
209
219
|
}
|
|
210
220
|
|
|
221
|
+
/**
|
|
222
|
+
*/
|
|
223
|
+
get contentHref(): Href {
|
|
224
|
+
let href = this.data._links.self.href;
|
|
225
|
+
if (this.data._links.content) {
|
|
226
|
+
href = new Href(this.data._links.content.href);
|
|
227
|
+
} else if (this.section) {
|
|
228
|
+
const section = encodeURIComponent(this.section);
|
|
229
|
+
if (href.endsWith(section)) {
|
|
230
|
+
href = href.substring(0, href.lastIndexOf("/" + section));
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return new Href(href)
|
|
235
|
+
.addParameter("complete", "true")
|
|
236
|
+
.addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
*/
|
|
241
|
+
get sectionHref(): Href | null {
|
|
242
|
+
const section = this.section;
|
|
243
|
+
if (section) {
|
|
244
|
+
const contentHref = this.contentHref;
|
|
245
|
+
const sectionHref = new Href(
|
|
246
|
+
contentHref.path + "/" + encodeURIComponent(this.data.section),
|
|
247
|
+
);
|
|
248
|
+
return sectionHref.addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
|
|
211
253
|
/**
|
|
212
254
|
* Self href of concept
|
|
213
255
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentLinkModel.js","names":["BaseModel","Href","LinkModel","ContentTypeModel","TIMEVERSION_FILTER_NAME","getSetting","LinkCollection","ContentLinkModel","constructor","data","entryDate","arguments","length","undefined","modelOptions","_defineProperty","_entryDate","getInitialChildModelLinks","contentTypeLink","isCacheable","setChildModels","models","href","contentTypeModel","_findInstanceProperty","call","model","selfhref","equalsWithParameters","type","contentType","_contentType","key","getData","label","sourceLabel","abbreviation","createEncodedHref","startURI","selfHref","_links","self","path","section","sourceId","substring","lastIndexOf","encodeURIComponent","encodedHref","addParameter","links","Array","isArray","selflink","getLinkByKey","_context","hasLinkByKey","_endsWithInstanceProperty","hash","Error","state","fragment","subSectionID","contentTypeHref","sectionFragment","items","_items"],"sources":["../../../src/models/content/ContentLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\n\nimport LinkCollection from \"../links/LinkCollection\";\n\nimport type {\n ModularUIModel,\n IModelWithChildModels,\n ModelOptions,\n SectionFragment,\n} from \"../types\";\n\n/**\n * Link to a concept\n */\nexport default class ContentLinkModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _links: ?LinkCollection;\n _entryDate: ?ISO_DATE;\n _contentType: ContentTypeModel | null = null;\n _items: Array<ContentLinkModel>;\n\n /**\n */\n constructor(\n data: Object,\n entryDate: ?ISO_DATE = null,\n modelOptions?: ModelOptions,\n ) {\n super(data, {}, modelOptions);\n\n this._entryDate = entryDate;\n }\n\n /**\n */\n // $FlowFixMe[method-unbinding]\n getInitialChildModelLinks(): Array<LinkModel> {\n if (this.contentTypeLink) {\n this.contentTypeLink.isCacheable = true;\n return [this.contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n // $FlowFixMe[method-unbinding]\n setChildModels(models: Array<ModularUIModel>) {\n if (this.contentTypeLink) {\n const href = this.contentTypeLink.href;\n const contentTypeModel = models.find((model) =>\n model.selfhref.equalsWithParameters(href),\n );\n\n if (contentTypeModel?.type === \"ContentType\") {\n this.contentType = contentTypeModel;\n }\n }\n }\n\n /**\n * Retrieve content type\n */\n get contentType(): ?ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n * Set concept type\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n */\n set entryDate(entryDate: ISO_DATE) {\n this._entryDate = entryDate;\n }\n\n /**\n * Retrieve key\n */\n get key(): string {\n return this.getData(\"_id\", \"\");\n }\n\n /**\n * Retrieve label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Retrieve the label of the source a link to a section belongs to\n */\n get sourceLabel(): string | null {\n return this.getData(\"sourceLabel\");\n }\n\n /**\n *\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\") || this.getData(\"sourceAbbreviation\");\n }\n\n /**\n */\n createEncodedHref(): Href {\n const startURI = \"/content/\";\n const selfHref = new Href(\n this.data._links.self.href,\n \"\",\n this.modelOptions,\n );\n const href = selfHref.path;\n\n const section = this.data.section;\n const sourceId = section\n ? href.substring(startURI.length, href.lastIndexOf(\"/\"))\n : href.substring(startURI.length);\n\n if (section) {\n selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${encodeURIComponent(section)}`;\n } else {\n selfHref.path = `${startURI}${encodeURIComponent(sourceId)}`;\n }\n\n return selfHref;\n }\n\n /**\n * Encode the content-identifier of the path to the content resource.\n * This makes it a single uri part, which can be used on routes to make nested routes\n */\n get encodedHref(): Href {\n const href = this.createEncodedHref();\n\n if (this._entryDate !== null) {\n return href.addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);\n }\n\n return href;\n }\n\n /**\n * Getting the links of the resource\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n Array.isArray(this.data._links)\n ? this.data._links[0]\n : this.data._links,\n null,\n this.modelOptions,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel {\n let selflink = this.links.getLinkByKey(\"self\");\n\n if (getSetting(\"COMPLETE_SOURCE\", false)) {\n if (this.links.hasLinkByKey(\"content\")) {\n selflink = this.links.getLinkByKey(\"content\");\n }\n\n if (selflink != null && !selflink.href.path.endsWith(this.data.section)) {\n selflink.href.addParameter(\"complete\", \"true\");\n selflink.href.hash = this.data.section;\n }\n }\n\n if (selflink === null) {\n throw new Error(\n `Could not find self link for ${\n this.key === null ? \"unknown\" : this.key\n }`,\n );\n }\n\n if (!selflink.href.state) {\n selflink.href.state = {\n fragment: this.fragment,\n };\n } else {\n selflink.href.state.fragment = this.fragment;\n }\n\n return selflink;\n }\n\n /**\n * Self href of concept\n */\n get selfhref(): Href {\n if (this._entryDate !== null) {\n return this.selflink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this._entryDate,\n );\n }\n\n return this.selflink.href;\n }\n\n /**\n */\n get subSectionID(): string {\n return this.selfhref.hash;\n }\n\n /**\n */\n get contentTypeLink(): LinkModel | null {\n return this.links.getLinkByKey(\"contenttype\");\n }\n\n /**\n * Concept type href of concept\n */\n get contentTypeHref(): Href | null {\n if (this.contentTypeLink) {\n return this.contentTypeLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get fragment(): SectionFragment | void {\n return this.data.sectionFragment;\n }\n\n /**\n * Children of link model in TOC\n */\n set items(items: Array<ContentLinkModel>) {\n this._items = items;\n }\n\n /**\n */\n get items(): Array<ContentLinkModel> {\n return this._items;\n }\n}\n"],"mappings":";;;AACA,OAAOA,SAAS,MAAM,mBAAmB;AACzC,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,UAAU,QAAQ,0BAA0B;AAErD,OAAOC,cAAc,MAAM,yBAAyB;AASpD;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAC3BP,SAAS,CAEnB;EAME;AACF;EACEQ,WAAWA,CACTC,IAAY,EAGZ;IAAA,IAFAC,SAAoB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AAC7C,eAAe,EAAE;MACxB,OAAO,IAAI,CAACA,eAAe,CAACI,IAAI;IAClC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAIuC,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAACpD,IAAI,CAACuD,eAAe;EAClC;;EAEA;AACF;AACA;EACE,IAAIC,KAAKA,CAACA,KAA8B,EAAE;IACxC,IAAI,CAACC,MAAM,GAAGD,KAAK;EACrB;;EAEA;AACF;EACE,IAAIA,KAAKA,CAAA,EAA4B;IACnC,OAAO,IAAI,CAACC,MAAM;EACpB;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ContentLinkModel.js","names":["BaseModel","Href","LinkModel","ContentTypeModel","TIMEVERSION_FILTER_NAME","getSetting","LinkCollection","ContentLinkModel","constructor","data","entryDate","arguments","length","undefined","modelOptions","_defineProperty","_entryDate","getInitialChildModelLinks","contentTypeLink","isCacheable","setChildModels","models","href","contentTypeModel","_findInstanceProperty","call","model","selfhref","equalsWithParameters","type","contentType","_contentType","key","getData","label","sourceLabel","abbreviation","section","createEncodedHref","startURI","selfHref","_links","self","path","sourceId","substring","lastIndexOf","encodedSection","encodeURIComponent","encodedHref","addParameter","links","Array","isArray","selflink","getLinkByKey","_context","hasLinkByKey","_endsWithInstanceProperty","hash","Error","state","fragment","contentHref","content","sectionHref","subSectionID","contentTypeHref","sectionFragment","items","_items"],"sources":["../../../src/models/content/ContentLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\n\nimport LinkCollection from \"../links/LinkCollection\";\n\nimport type {\n ModularUIModel,\n IModelWithChildModels,\n ModelOptions,\n SectionFragment,\n} from \"../types\";\n\n/**\n * Link to a concept\n */\nexport default class ContentLinkModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _links: ?LinkCollection;\n _entryDate: ?ISO_DATE;\n _contentType: ContentTypeModel | null = null;\n _items: Array<ContentLinkModel>;\n\n /**\n */\n constructor(\n data: Object,\n entryDate: ?ISO_DATE = null,\n modelOptions?: ModelOptions,\n ) {\n super(data, {}, modelOptions);\n\n this._entryDate = entryDate;\n }\n\n /**\n */\n // $FlowFixMe[method-unbinding]\n getInitialChildModelLinks(): Array<LinkModel> {\n if (this.contentTypeLink) {\n this.contentTypeLink.isCacheable = true;\n return [this.contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n // $FlowFixMe[method-unbinding]\n setChildModels(models: Array<ModularUIModel>) {\n if (this.contentTypeLink) {\n const href = this.contentTypeLink.href;\n const contentTypeModel = models.find((model) =>\n model.selfhref.equalsWithParameters(href),\n );\n\n if (contentTypeModel?.type === \"ContentType\") {\n this.contentType = contentTypeModel;\n }\n }\n }\n\n /**\n * Retrieve content type\n */\n get contentType(): ?ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n * Set concept type\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n */\n set entryDate(entryDate: ISO_DATE) {\n this._entryDate = entryDate;\n }\n\n /**\n * Retrieve key\n */\n get key(): string {\n return this.getData(\"_id\", \"\");\n }\n\n /**\n * Retrieve label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Retrieve the label of the source a link to a section belongs to\n */\n get sourceLabel(): string | null {\n return this.getData(\"sourceLabel\");\n }\n\n /**\n *\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\") || this.getData(\"sourceAbbreviation\");\n }\n\n /**\n */\n get section(): string | null {\n return this.data.section;\n }\n\n /**\n */\n createEncodedHref(): Href {\n const startURI = \"/content/\";\n const selfHref = new Href(\n this.data._links.self.href,\n \"\",\n this.modelOptions,\n );\n const href = selfHref.path;\n\n const sourceId = this.section\n ? href.substring(startURI.length, href.lastIndexOf(\"/\"))\n : href.substring(startURI.length);\n\n if (this.section != null) {\n const encodedSection = encodeURIComponent(this.section);\n selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${encodedSection}`;\n } else {\n selfHref.path = `${startURI}${encodeURIComponent(sourceId)}`;\n }\n\n return selfHref;\n }\n\n /**\n * Encode the content-identifier of the path to the content resource.\n * This makes it a single uri part, which can be used on routes to make nested routes\n */\n get encodedHref(): Href {\n const href = this.createEncodedHref();\n\n if (this._entryDate !== null) {\n return href.addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);\n }\n\n return href;\n }\n\n /**\n * Getting the links of the resource\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n Array.isArray(this.data._links)\n ? this.data._links[0]\n : this.data._links,\n null,\n this.modelOptions,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel {\n let selflink = this.links.getLinkByKey(\"self\");\n\n if (getSetting(\"COMPLETE_SOURCE\", false)) {\n if (this.links.hasLinkByKey(\"content\")) {\n selflink = this.links.getLinkByKey(\"content\");\n }\n\n if (\n this.section != null &&\n selflink &&\n !selflink.href.path.endsWith(encodeURIComponent(this.section))\n ) {\n selflink.href.addParameter(\"complete\", \"true\");\n selflink.href.hash = this.section || \"\";\n }\n }\n\n if (selflink === null) {\n throw new Error(\n `Could not find self link for ${\n this.key === null ? \"unknown\" : this.key\n }`,\n );\n }\n\n if (!selflink.href.state) {\n selflink.href.state = {\n fragment: this.fragment,\n };\n } else {\n selflink.href.state.fragment = this.fragment;\n }\n\n return selflink;\n }\n\n /**\n */\n get contentHref(): Href {\n let href = this.data._links.self.href;\n if (this.data._links.content) {\n href = new Href(this.data._links.content.href);\n } else if (this.section) {\n const section = encodeURIComponent(this.section);\n if (href.endsWith(section)) {\n href = href.substring(0, href.lastIndexOf(\"/\" + section));\n }\n }\n\n return new Href(href)\n .addParameter(\"complete\", \"true\")\n .addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);\n }\n\n /**\n */\n get sectionHref(): Href | null {\n const section = this.section;\n if (section) {\n const contentHref = this.contentHref;\n const sectionHref = new Href(\n contentHref.path + \"/\" + encodeURIComponent(this.data.section),\n );\n return sectionHref.addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);\n }\n return null;\n }\n\n /**\n * Self href of concept\n */\n get selfhref(): Href {\n if (this._entryDate !== null) {\n return this.selflink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this._entryDate,\n );\n }\n\n return this.selflink.href;\n }\n\n /**\n */\n get subSectionID(): string {\n return this.selfhref.hash;\n }\n\n /**\n */\n get contentTypeLink(): LinkModel | null {\n return this.links.getLinkByKey(\"contenttype\");\n }\n\n /**\n * Concept type href of concept\n */\n get contentTypeHref(): Href | null {\n if (this.contentTypeLink) {\n return this.contentTypeLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get fragment(): SectionFragment | void {\n return this.data.sectionFragment;\n }\n\n /**\n * Children of link model in TOC\n */\n set items(items: Array<ContentLinkModel>) {\n this._items = items;\n }\n\n /**\n */\n get items(): Array<ContentLinkModel> {\n return this._items;\n }\n}\n"],"mappings":";;;AACA,OAAOA,SAAS,MAAM,mBAAmB;AACzC,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,UAAU,QAAQ,0BAA0B;AAErD,OAAOC,cAAc,MAAM,yBAAyB;AASpD;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAC3BP,SAAS,CAEnB;EAME;AACF;EACEQ,WAAWA,CACTC,IAAY,EAGZ;IAAA,IAFAC,SAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;IAAA,IAC3BG,YAA2B,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA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AACA,eAAe,CAACI,IAAI;IAClC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAIwC,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAACrD,IAAI,CAAC2D,eAAe;EAClC;;EAEA;AACF;AACA;EACE,IAAIC,KAAKA,CAACA,KAA8B,EAAE;IACxC,IAAI,CAACC,MAAM,GAAGD,KAAK;EACrB;;EAEA;AACF;EACE,IAAIA,KAAKA,CAAA,EAA4B;IACnC,OAAO,IAAI,CAACC,MAAM;EACpB;AACF","ignoreList":[]}
|
|
@@ -30,6 +30,11 @@ describe("content link model", () => {
|
|
|
30
30
|
expect(contentLinkModel.encodedHref.toString()).toBe(
|
|
31
31
|
"/content/Content%2FSources%2FFormal%2FAnother%2520formal%2520content.formalsource",
|
|
32
32
|
);
|
|
33
|
+
|
|
34
|
+
expect(contentLinkModel.contentHref.toString()).toBe(
|
|
35
|
+
"/content/Content/Sources/Formal/Another%20formal%20content.formalsource?complete=true",
|
|
36
|
+
);
|
|
37
|
+
expect(contentLinkModel.sectionHref).toBe(null);
|
|
33
38
|
});
|
|
34
39
|
|
|
35
40
|
it("can handle href to source section", () => {
|
|
@@ -51,6 +56,44 @@ describe("content link model", () => {
|
|
|
51
56
|
expect(contentLinkModel.encodedHref.toString()).toBe(
|
|
52
57
|
"/content/Content%2FSources%2FFormal%2FAnother%2520formal%2520content.formalsource/section-id.%3A-",
|
|
53
58
|
);
|
|
59
|
+
|
|
60
|
+
expect(contentLinkModel.contentHref.toString()).toBe(
|
|
61
|
+
"/content/Content/Sources/Formal/Another%20formal%20content.formalsource?complete=true",
|
|
62
|
+
);
|
|
63
|
+
expect(contentLinkModel.sectionHref.toString()).toBe(
|
|
64
|
+
"/content/Content/Sources/Formal/Another%20formal%20content.formalsource/section-id.%3A-",
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("can handle href to source section with content href", () => {
|
|
69
|
+
const contentLinkModel = new ContentLinkModel({
|
|
70
|
+
_links: {
|
|
71
|
+
self: {
|
|
72
|
+
href: "/content/Content/Sources/Formal/Another%20formal%20content.formalsource/section-id.%3A-",
|
|
73
|
+
},
|
|
74
|
+
content: {
|
|
75
|
+
href: "/content/Content/Sources/Formal/Another%20formal%20content.formalsource",
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
_id: "section-id.:-",
|
|
79
|
+
label: "Another formal content Section",
|
|
80
|
+
section: "section-id.:-",
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
expect(contentLinkModel).toBeInstanceOf(ContentLinkModel);
|
|
84
|
+
expect(contentLinkModel.selfhref.toString()).toBe(
|
|
85
|
+
"/content/Content/Sources/Formal/Another%20formal%20content.formalsource/section-id.%3A-",
|
|
86
|
+
);
|
|
87
|
+
expect(contentLinkModel.encodedHref.toString()).toBe(
|
|
88
|
+
"/content/Content%2FSources%2FFormal%2FAnother%2520formal%2520content.formalsource/section-id.%3A-",
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
expect(contentLinkModel.contentHref.toString()).toBe(
|
|
92
|
+
"/content/Content/Sources/Formal/Another%20formal%20content.formalsource?complete=true",
|
|
93
|
+
);
|
|
94
|
+
expect(contentLinkModel.sectionHref.toString()).toBe(
|
|
95
|
+
"/content/Content/Sources/Formal/Another%20formal%20content.formalsource/section-id.%3A-",
|
|
96
|
+
);
|
|
54
97
|
});
|
|
55
98
|
|
|
56
99
|
it("can handle href to source with hash", () => {
|
|
@@ -77,5 +120,10 @@ describe("content link model", () => {
|
|
|
77
120
|
expect(contentLinkModel.encodedHref.toString()).toBe(
|
|
78
121
|
"/content/Content%2FSources%2FFormal%2FAnother%2520formal%2520content.formalsource",
|
|
79
122
|
);
|
|
123
|
+
|
|
124
|
+
expect(contentLinkModel.contentHref.toString()).toBe(
|
|
125
|
+
"/content/Content/Sources/Formal/Another%20formal%20content.formalsource?complete=true",
|
|
126
|
+
);
|
|
127
|
+
expect(contentLinkModel.sectionHref).toBe(null);
|
|
80
128
|
});
|
|
81
129
|
});
|