@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.
Files changed (30) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/esm/hooks/__tests__/useModelCatalog.spec.js.flow +19 -0
  3. package/esm/hooks/useModelCatalog.d.ts +1 -0
  4. package/esm/hooks/useModelCatalog.js +22 -2
  5. package/esm/hooks/useModelCatalog.js.flow +31 -3
  6. package/esm/hooks/useModelCatalog.js.map +1 -1
  7. package/esm/models/concepts/SourceReferenceModel.d.ts +4 -0
  8. package/esm/models/concepts/SourceReferenceModel.js +7 -0
  9. package/esm/models/concepts/SourceReferenceModel.js.flow +12 -0
  10. package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
  11. package/esm/models/content/ContentLinkModel.d.ts +9 -0
  12. package/esm/models/content/ContentLinkModel.js +39 -6
  13. package/esm/models/content/ContentLinkModel.js.flow +48 -6
  14. package/esm/models/content/ContentLinkModel.js.map +1 -1
  15. package/esm/models/content/__tests__/ContentLinkModel.spec.js.flow +48 -0
  16. package/lib/hooks/useModelCatalog.d.ts +1 -0
  17. package/lib/hooks/useModelCatalog.js +24 -3
  18. package/lib/hooks/useModelCatalog.js.map +1 -1
  19. package/lib/models/concepts/SourceReferenceModel.d.ts +4 -0
  20. package/lib/models/concepts/SourceReferenceModel.js +7 -0
  21. package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
  22. package/lib/models/content/ContentLinkModel.d.ts +9 -0
  23. package/lib/models/content/ContentLinkModel.js +39 -6
  24. package/lib/models/content/ContentLinkModel.js.map +1 -1
  25. package/package.json +3 -3
  26. package/src/hooks/__tests__/useModelCatalog.spec.js +19 -0
  27. package/src/hooks/useModelCatalog.js +31 -3
  28. package/src/models/concepts/SourceReferenceModel.js +12 -0
  29. package/src/models/content/ContentLinkModel.js +48 -6
  30. package/src/models/content/__tests__/ContentLinkModel.spec.js +48 -0
@@ -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;
@@ -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 = void 0;
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;
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");
@@ -20,6 +20,7 @@ var _useModularUIBasic = require("./useModularUIBasic");
20
20
  var _models = require("../models");
21
21
  var _modelcatalog = require("../redux/selectors/modelcatalog");
22
22
  var _ModelCatalog = require("../redux/actions/ModelCatalog");
23
+ var _Href = _interopRequireDefault(require("../models/href/Href"));
23
24
  /**
24
25
  */
25
26
  const useModelCatalog = options => (0, _useModularUIBasic.useModularUIBasic)("modelcatalog", "/modelcatalog", {
@@ -87,7 +88,7 @@ const useContentTOC = function (content) {
87
88
  entryDate
88
89
  } = useEntryDate();
89
90
  const location = (0, _useRouter.useLocation)();
90
- const href = (0, _createHref.createHref)("content", content, entryDate, location, []);
91
+ const href = (0, _createHref.createHref)("content", content, entryDate, location, ["complete"]);
91
92
  return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
92
93
  expectedModels: ["ContentTOC"],
93
94
  targetModel: _ContentTOCModel.default,
@@ -105,7 +106,7 @@ const useContent = function (content) {
105
106
  entryDate
106
107
  } = useEntryDate();
107
108
  const location = (0, _useRouter.useLocation)();
108
- const href = (0, _createHref.createHref)("content", content, entryDate, location, []);
109
+ const href = (0, _createHref.createHref)("content", content, entryDate, location, ["complete"]);
109
110
  return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
110
111
  expectedModels: ["Content", "ContentTOC"],
111
112
  ...options
@@ -115,6 +116,26 @@ const useContent = function (content) {
115
116
  /**
116
117
  */
117
118
  exports.useContent = useContent;
119
+ const useCompleteSource = function (content) {
120
+ let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "content";
121
+ let options = arguments.length > 2 ? arguments[2] : undefined;
122
+ const {
123
+ entryDate
124
+ } = useEntryDate();
125
+ const location = (0, _useRouter.useLocation)();
126
+ let contentHref = new _Href.default(content);
127
+ contentHref.removeParameter("complete");
128
+ contentHref.addParameter("complete", "true");
129
+ const href = (0, _createHref.createHref)("content", contentHref, entryDate, location, ["complete"]);
130
+ return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
131
+ expectedModels: ["Content", "ContentTOC"],
132
+ ...options
133
+ });
134
+ };
135
+
136
+ /**
137
+ */
138
+ exports.useCompleteSource = useCompleteSource;
118
139
  const useContentType = function (contentType) {
119
140
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttypes";
120
141
  let options = arguments.length > 2 ? arguments[2] : undefined;
@@ -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","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","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 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,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;AAaA;AACA;AACO,MAAMe,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,IAC7BT,OAAqD,GAAAS,SAAA,CAAA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CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAMJ,IAAI,GAAGyB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOX,eAAe,CAAChB,IAAI,EAAEC,GAAG,EAAER,OAAO,CAAC;AAC5C,CAAC;;AAED;AACA;AACA;AAFAK,OAAA,CAAAyC,gBAAA,GAAAA,gBAAA;AAGO,MAAMjC,YAAY,GAAGA,CAAA,KAGtB;EACJ,MAAMkC,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAC9B,MAAMpC,SAAS,GAAG,IAAAqC,uBAAW,EAACC,0BAAY,CAAC;EAE3C,OAAO;IACLtC,SAAS;IACTuC,YAAY,EAAGvC,SAAmB,IAAKmC,QAAQ,CAAC,IAAAK,6BAAe,EAACxC,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"],"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;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_DATE | null;
10
10
  _modelOptions: ModelOptions;
11
+ /**
12
+ */
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";
@@ -10,6 +10,7 @@ var _createHash = require("../../utils/helpers/createHash");
10
10
  var _ContentLinkModel = _interopRequireDefault(require("../content/ContentLinkModel"));
11
11
  var _Href = _interopRequireDefault(require("../href/Href"));
12
12
  var _constants = require("../../constants");
13
+ var _LinkCollection = _interopRequireDefault(require("../links/LinkCollection"));
13
14
  /**
14
15
  */
15
16
  class SourceReferenceModel {
@@ -29,6 +30,12 @@ class SourceReferenceModel {
29
30
  };
30
31
  }
31
32
 
33
+ /**
34
+ */
35
+ get links() {
36
+ return new _LinkCollection.default(this._sourceReference._links, null, this._modelOptions);
37
+ }
38
+
32
39
  /**
33
40
  */
34
41
  get link() {
@@ -1 +1 @@
1
- {"version":3,"file":"SourceReferenceModel.js","names":["_createHash","require","_ContentLinkModel","_interopRequireDefault","_Href","_constants","SourceReferenceModel","constructor","sourceReference","entryDate","arguments","length","undefined","modelOptions","_defineProperty2","default","_sourceReference","_entryDate","_modelOptions","origin","contextPath","getBasePathModularUI","link","section","sectionId","_links","self","href","replace","content","ContentLinkModel","selfhref","type","label","sourceLabel","sourceAbbreviation","referenceHash","createHashFromHref","fragment","sectionFragment","_default","exports"],"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\";\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 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,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAGA;AACA;AACA,MAAMK,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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BAAkB;EACjD;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAW;IAC1B,OAAO,IAAAC,8BAAkB,EAAC,IAAI,CAACN,QAAQ,CAAC;EAC1C;;EAEA;AACF;EACE,IAAIP,SAASA,CAAA,EAAW;IACtB,OAAO,IAAI,CAACR,gBAAgB,CAACQ,SAAS;EACxC;;EAEA;AACF;AACA;EACE,IAAIc,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAACtB,gBAAgB,CAACuB,eAAe;EAC9C;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1B,OAAA,GAEcT,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"SourceReferenceModel.js","names":["_createHash","require","_ContentLinkModel","_interopRequireDefault","_Href","_constants","_LinkCollection","SourceReferenceModel","constructor","sourceReference","entryDate","arguments","length","undefined","modelOptions","_defineProperty2","default","_sourceReference","_entryDate","_modelOptions","origin","contextPath","getBasePathModularUI","links","LinkCollection","_links","link","section","sectionId","self","href","replace","content","ContentLinkModel","selfhref","type","label","sourceLabel","sourceAbbreviation","referenceHash","createHashFromHref","fragment","sectionFragment","_default","exports"],"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,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,IAAAK,eAAA,GAAAH,sBAAA,CAAAF,OAAA;AAGA;AACA;AACA,MAAMM,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;IAAA,IAAAE,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;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AACqB,kBAAkB;EACjD;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAW;IAC1B,OAAO,IAAAC,8BAAkB,EAAC,IAAI,CAACN,QAAQ,CAAC;EAC1C;;EAEA;AACF;EACE,IAAIN,SAASA,CAAA,EAAW;IACtB,OAAO,IAAI,CAACX,gBAAgB,CAACW,SAAS;EACxC;;EAEA;AACF;AACA;EACE,IAAIa,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAACxB,gBAAgB,CAACyB,eAAe;EAC9C;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA5B,OAAA,GAEcT,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
  */
@@ -104,16 +104,22 @@ class ContentLinkModel extends _BaseModel.default {
104
104
  return this.getData("abbreviation") || this.getData("sourceAbbreviation");
105
105
  }
106
106
 
107
+ /**
108
+ */
109
+ get section() {
110
+ return this.data.section;
111
+ }
112
+
107
113
  /**
108
114
  */
109
115
  createEncodedHref() {
110
116
  const startURI = "/content/";
111
117
  const selfHref = new _Href.default(this.data._links.self.href, "", this.modelOptions);
112
118
  const href = selfHref.path;
113
- const section = this.data.section;
114
- const sourceId = section ? href.substring(startURI.length, href.lastIndexOf("/")) : href.substring(startURI.length);
115
- if (section) {
116
- selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${encodeURIComponent(section)}`;
119
+ const sourceId = this.section ? href.substring(startURI.length, href.lastIndexOf("/")) : href.substring(startURI.length);
120
+ if (this.section != null) {
121
+ const encodedSection = encodeURIComponent(this.section);
122
+ selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${encodedSection}`;
117
123
  } else {
118
124
  selfHref.path = `${startURI}${encodeURIComponent(sourceId)}`;
119
125
  }
@@ -152,9 +158,9 @@ class ContentLinkModel extends _BaseModel.default {
152
158
  if (this.links.hasLinkByKey("content")) {
153
159
  selflink = this.links.getLinkByKey("content");
154
160
  }
155
- if (selflink != null && !(0, _endsWith.default)(_context = selflink.href.path).call(_context, this.data.section)) {
161
+ if (this.section != null && selflink && !(0, _endsWith.default)(_context = selflink.href.path).call(_context, encodeURIComponent(this.section))) {
156
162
  selflink.href.addParameter("complete", "true");
157
- selflink.href.hash = this.data.section;
163
+ selflink.href.hash = this.section || "";
158
164
  }
159
165
  }
160
166
  if (selflink === null) {
@@ -170,6 +176,33 @@ class ContentLinkModel extends _BaseModel.default {
170
176
  return selflink;
171
177
  }
172
178
 
179
+ /**
180
+ */
181
+ get contentHref() {
182
+ let href = this.data._links.self.href;
183
+ if (this.data._links.content) {
184
+ href = new _Href.default(this.data._links.content.href);
185
+ } else if (this.section) {
186
+ const section = encodeURIComponent(this.section);
187
+ if ((0, _endsWith.default)(href).call(href, section)) {
188
+ href = href.substring(0, href.lastIndexOf("/" + section));
189
+ }
190
+ }
191
+ return new _Href.default(href).addParameter("complete", "true").addParameter(_Constants.TIMEVERSION_FILTER_NAME, this._entryDate);
192
+ }
193
+
194
+ /**
195
+ */
196
+ get sectionHref() {
197
+ const section = this.section;
198
+ if (section) {
199
+ const contentHref = this.contentHref;
200
+ const sectionHref = new _Href.default(contentHref.path + "/" + encodeURIComponent(this.data.section));
201
+ return sectionHref.addParameter(_Constants.TIMEVERSION_FILTER_NAME, this._entryDate);
202
+ }
203
+ return null;
204
+ }
205
+
173
206
  /**
174
207
  * Self href of concept
175
208
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ContentLinkModel.js","names":["_BaseModel","_interopRequireDefault","require","_Href","_LinkModel","_ContentTypeModel","_Constants","_Settings","_LinkCollection","ContentLinkModel","BaseModel","constructor","data","entryDate","arguments","length","undefined","modelOptions","_defineProperty2","default","_entryDate","getInitialChildModelLinks","contentTypeLink","isCacheable","setChildModels","models","href","contentTypeModel","_find","call","model","selfhref","equalsWithParameters","type","contentType","_contentType","ContentTypeModel","key","getData","label","sourceLabel","abbreviation","createEncodedHref","startURI","selfHref","Href","_links","self","path","section","sourceId","substring","lastIndexOf","encodeURIComponent","encodedHref","addParameter","TIMEVERSION_FILTER_NAME","links","LinkCollection","Array","isArray","selflink","getLinkByKey","getSetting","_context","hasLinkByKey","_endsWith","hash","Error","state","fragment","subSectionID","contentTypeHref","sectionFragment","items","_items","exports"],"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,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,iBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,UAA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IAAI,CAACyC,QAAQ,CAACnC,IAAI;EAC3B;;EAEA;AACF;EACE,IAAI6C,YAAYA,CAAA,EAAW;IACzB,OAAO,IAAI,CAACxC,QAAQ,CAACoC,IAAI;EAC3B;;EAEA;AACF;EACE,IAAI7C,eAAeA,CAAA,EAAqB;IACtC,OAAO,IAAI,CAACmC,KAAK,CAACK,YAAY,CAAC,aAAa,CAAC;EAC/C;;EAEA;AACF;AACA;EACE,IAAIU,eAAeA,CAAA,EAAgB;IACjC,IAAI,IAAI,CAAClD,eAAe,EAAE;MACxB,OAAO,IAAI,CAACA,eAAe,CAACI,IAAI;IAClC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAI4C,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAAC1D,IAAI,CAAC6D,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;AAACC,OAAA,CAAAzD,OAAA,GAAAV,gBAAA","ignoreList":[]}
1
+ {"version":3,"file":"ContentLinkModel.js","names":["_BaseModel","_interopRequireDefault","require","_Href","_LinkModel","_ContentTypeModel","_Constants","_Settings","_LinkCollection","ContentLinkModel","BaseModel","constructor","data","entryDate","arguments","length","undefined","modelOptions","_defineProperty2","default","_entryDate","getInitialChildModelLinks","contentTypeLink","isCacheable","setChildModels","models","href","contentTypeModel","_find","call","model","selfhref","equalsWithParameters","type","contentType","_contentType","ContentTypeModel","key","getData","label","sourceLabel","abbreviation","section","createEncodedHref","startURI","selfHref","Href","_links","self","path","sourceId","substring","lastIndexOf","encodedSection","encodeURIComponent","encodedHref","addParameter","TIMEVERSION_FILTER_NAME","links","LinkCollection","Array","isArray","selflink","getLinkByKey","getSetting","_context","hasLinkByKey","_endsWith","hash","Error","state","fragment","contentHref","content","sectionHref","subSectionID","contentTypeHref","sectionFragment","items","_items","exports"],"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,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OA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rC,UAAU,CAAC;IAC3E;IACA,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACE,IAAIW,QAAQA,CAAA,EAAS;IACnB,IAAI,IAAI,CAACX,UAAU,KAAK,IAAI,EAAE;MAC5B,OAAO,IAAI,CAAC0C,QAAQ,CAACpC,IAAI,CAAC8B,YAAY,CACpCC,kCAAuB,EACvB,IAAI,CAACrC,UACP,CAAC;IACH;IAEA,OAAO,IAAI,CAAC0C,QAAQ,CAACpC,IAAI;EAC3B;;EAEA;AACF;EACE,IAAIiD,YAAYA,CAAA,EAAW;IACzB,OAAO,IAAI,CAAC5C,QAAQ,CAACqC,IAAI;EAC3B;;EAEA;AACF;EACE,IAAI9C,eAAeA,CAAA,EAAqB;IACtC,OAAO,IAAI,CAACoC,KAAK,CAACK,YAAY,CAAC,aAAa,CAAC;EAC/C;;EAEA;AACF;AACA;EACE,IAAIa,eAAeA,CAAA,EAAgB;IACjC,IAAI,IAAI,CAACtD,eAAe,EAAE;MACxB,OAAO,IAAI,CAACA,eAAe,CAACI,IAAI;IAClC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAI6C,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAAC3D,IAAI,CAACiE,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;AAACC,OAAA,CAAA7D,OAAA,GAAAV,gBAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.62.2",
3
+ "version": "1.62.4",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "https://support.beinformed.com",
@@ -69,7 +69,7 @@
69
69
  "styled-components": "^5.0.0"
70
70
  },
71
71
  "dependencies": {
72
- "@babel/runtime-corejs3": "^7.27.4",
72
+ "@babel/runtime-corejs3": "^7.27.6",
73
73
  "@date-fns/tz": "^1.2.0",
74
74
  "big.js": "^7.0.1",
75
75
  "date-fns": "^4.1.0",
@@ -90,7 +90,7 @@
90
90
  "devDependencies": {
91
91
  "@babel/cli": "^7.27.2",
92
92
  "@babel/core": "^7.27.4",
93
- "@babel/eslint-parser": "^7.27.1",
93
+ "@babel/eslint-parser": "^7.27.5",
94
94
  "@babel/eslint-plugin": "^7.27.1",
95
95
  "@babel/plugin-proposal-class-properties": "^7.18.6",
96
96
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
@@ -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(
@@ -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 type Href from "../models/href/Href";
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"],
@@ -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 {
@@ -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 section = this.data.section;
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
- selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${encodeURIComponent(section)}`;
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 (selflink != null && !selflink.href.path.endsWith(this.data.section)) {
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.data.section;
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
  */