@beinformed/ui 1.50.1 → 1.50.2

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 CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.50.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.50.1...v1.50.2) (2024-07-17)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **content:** handle incorrect relatedConcepts links ([265ee33](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/265ee33db296149766dac6d94e57963953c05dd2))
11
+
5
12
  ## [1.50.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.50.0...v1.50.1) (2024-07-08)
6
13
 
7
14
 
@@ -1,5 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
2
2
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
3
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
4
  import { createHashFromHref } from "../../utils/helpers/createHash";
4
5
  import BaseModel from "../base/BaseModel";
5
6
  import LinkCollection from "../links/LinkCollection";
@@ -110,9 +111,16 @@ export default class SubSectionModel extends BaseModel {
110
111
  get relatedConceptsHref() {
111
112
  const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
112
113
  if (relatedConceptsLink) {
114
+ var _context2;
113
115
  const {
114
116
  href
115
117
  } = relatedConceptsLink;
118
+ if (_includesInstanceProperty(_context2 = href.hash).call(_context2, "/relatedConcepts")) {
119
+ var _context3;
120
+ const firstPart = href.path.substring(0, href.path.lastIndexOf("/"));
121
+ href.path = firstPart + "/" + href.hash;
122
+ href.hash = _includesInstanceProperty(_context3 = href.hash).call(_context3, "#") ? href.hash.substring(href.hash.indexOf("#")) : "";
123
+ }
116
124
  href.setReferenceHash(this.referenceHash);
117
125
  return href;
118
126
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SubSectionModel.js","names":["createHashFromHref","BaseModel","LinkCollection","Href","LinkModel","retrieveText","SubSectionModel","constructor","data","_defineProperty","referred","id","_id","key","body","getData","number","label","subSections","_context","_mapInstanceProperty","call","subSection","links","_links","contributions","selflink","getLinkByKey","selfhref","href","relatedConceptsHrefs","hrefs","relatedConceptsHref","push","forEach","relatedConceptsLink","setReferenceHash","referenceHash","getReferredSections","sections","referredChilds"],"sources":["../../../src/models/content/SubSectionModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n const body = this.getData(\"body\", \"\");\n return retrieveText(body);\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection),\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n const { href } = relatedConceptsLink;\n href.setReferenceHash(this.referenceHash);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"mappings":";;AACA,SAASA,kBAAkB,QAAQ,gCAAgC;AAEnE,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,cAAc,MAAM,yBAAyB;AACpD,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,SAASC,YAAY,QAAQ,aAAa;;AAE1C;AACA;AACA;AACA,eAAe,MAAMC,eAAe,SAASL,SAAS,CAAC;EAGrD;AACF;EACEM,WAAWA,CAACC,IAAY,EAAE;IACxB,KAAK,CAACA,IAAI,EAAE,CAAC,CAAC,CAAC;IAACC,eAAA;EAClB;;EAEA;AACF;EACE,IAAIC,QAAQA,CAAA,EAAY;IACtB,OAAO,IAAI,CAACF,IAAI,CAACE,QAAQ;EAC3B;;EAEA;AACF;EACE,IAAIC,EAAEA,CAAA,EAAW;IACf,OAAO,IAAI,CA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,cAAc,CAAC;IAClC;IAEA,OAAOD,QAAQ;EACjB;AACF","ignoreList":[]}
1
+ {"version":3,"file":"SubSectionModel.js","names":["createHashFromHref","BaseModel","LinkCollection","Href","LinkModel","retrieveText","SubSectionModel","constructor","data","_defineProperty","referred","id","_id","key","body","getData","number","label","subSections","_context","_mapInstanceProperty","call","subSection","links","_links","contributions","selflink","getLinkByKey","selfhref","href","relatedConceptsHrefs","hrefs","relatedConceptsHref","push","forEach","relatedConceptsLink","_context2","_includesInstanceProperty","hash","_context3","firstPart","path","substring","lastIndexOf","indexOf","setReferenceHash","referenceHash","getReferredSections","sections","referredChilds"],"sources":["../../../src/models/content/SubSectionModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n const body = this.getData(\"body\", \"\");\n return retrieveText(body);\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection),\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n const { href } = relatedConceptsLink;\n\n if (href.hash.includes(\"/relatedConcepts\")) {\n const firstPart = href.path.substring(0, href.path.lastIndexOf(\"/\"));\n href.path = firstPart + \"/\" + href.hash;\n href.hash = href.hash.includes(\"#\")\n ? href.hash.substring(href.hash.indexOf(\"#\"))\n : \"\";\n }\n\n href.setReferenceHash(this.referenceHash);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"mappings":";;;AACA,SAASA,kBAAkB,QAAQ,gCAAgC;AAEnE,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,cAAc,MAAM,yBAAyB;AACpD,OAAOC,IAAI,MAAM,cAAc;AAC/B,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,SAASC,YAAY,QAAQ,aAAa;;AAE1C;AACA;AACA;AACA,eAAe,MAAMC,eAAe,SAASL,SAAS,CAAC;EAGrD;AACF;EACEM,WAAWA,CAACC,IAAY,EAAE;IACxB,KAAK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BAAA,CAAAE,SAAA,GAAAV,IAAI,CAACS,IAAI,EAAAjB,IAAA,CAAAkB,SAAA,EAAU,GAAG,CAAC,GAC/BV,IAAI,CAACS,IAAI,CAACI,SAAS,CAACb,IAAI,CAACS,IAAI,CAACM,OAAO,CAAC,GAAG,CAAC,CAAC,GAC3C,EAAE;MACR;MAEAf,IAAI,CAACgB,gBAAgB,CAAC,IAAI,CAACC,aAAa,CAAC;MACzC,OAAOjB,IAAI;IACb;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAIiB,aAAaA,CAAA,EAAW;IAC1B,MAAMlB,QAAQ,GAAG,IAAI,CAACA,QAAQ,IAAI,IAAIzB,IAAI,CAAC,CAAC;IAC5C,OAAOH,kBAAkB,CAAC4B,QAAQ,CAAC;EACrC;;EAEA;AACF;EACEmB,mBAAmBA,CAAA,EAA2B;IAC5C,MAAMC,QAAQ,GAAG,EAAE;IAEnB,KAAK,MAAM1B,UAAU,IAAI,IAAI,CAACJ,WAAW,EAAE;MACzC,IAAII,UAAU,CAACZ,QAAQ,EAAE;QACvBsC,QAAQ,CAACf,IAAI,CAACX,UAAU,CAAC;MAC3B;MAEA,MAAM2B,cAAc,GAAG3B,UAAU,CAACyB,mBAAmB,CAAC,CAAC;MACvDC,QAAQ,CAACf,IAAI,CAAC,GAAGgB,cAAc,CAAC;IAClC;IAEA,OAAOD,QAAQ;EACjB;AACF","ignoreList":[]}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
9
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
9
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
10
11
  var _createHash = require("../../utils/helpers/createHash");
11
12
  var _BaseModel = _interopRequireDefault(require("../base/BaseModel"));
@@ -116,9 +117,16 @@ class SubSectionModel extends _BaseModel.default {
116
117
  get relatedConceptsHref() {
117
118
  const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
118
119
  if (relatedConceptsLink) {
120
+ var _context2;
119
121
  const {
120
122
  href
121
123
  } = relatedConceptsLink;
124
+ if ((0, _includes.default)(_context2 = href.hash).call(_context2, "/relatedConcepts")) {
125
+ var _context3;
126
+ const firstPart = href.path.substring(0, href.path.lastIndexOf("/"));
127
+ href.path = firstPart + "/" + href.hash;
128
+ href.hash = (0, _includes.default)(_context3 = href.hash).call(_context3, "#") ? href.hash.substring(href.hash.indexOf("#")) : "";
129
+ }
122
130
  href.setReferenceHash(this.referenceHash);
123
131
  return href;
124
132
  }
@@ -122,6 +122,15 @@ export default class SubSectionModel extends BaseModel {
122
122
 
123
123
  if (relatedConceptsLink) {
124
124
  const { href } = relatedConceptsLink;
125
+
126
+ if (href.hash.includes("/relatedConcepts")) {
127
+ const firstPart = href.path.substring(0, href.path.lastIndexOf("/"));
128
+ href.path = firstPart + "/" + href.hash;
129
+ href.hash = href.hash.includes("#")
130
+ ? href.hash.substring(href.hash.indexOf("#"))
131
+ : "";
132
+ }
133
+
125
134
  href.setReferenceHash(this.referenceHash);
126
135
  return href;
127
136
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SubSectionModel.js","names":["_createHash","require","_BaseModel","_interopRequireDefault","_LinkCollection","_Href","_LinkModel","_utils","SubSectionModel","BaseModel","constructor","data","_defineProperty2","default","referred","id","_id","key","body","getData","retrieveText","number","label","subSections","_context","_map","call","subSection","links","_links","LinkCollection","contributions","selflink","getLinkByKey","selfhref","href","relatedConceptsHrefs","hrefs","relatedConceptsHref","push","forEach","relatedConceptsLink","setReferenceHash","referenceHash","Href","createHashFromHref","getReferredSections","sections","referredChilds","exports"],"sources":["../../../src/models/content/SubSectionModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n const body = this.getData(\"body\", \"\");\n return retrieveText(body);\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection),\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n const { href } = relatedConceptsLink;\n href.setReferenceHash(this.referenceHash);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,KAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,UAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEA;AACA;AACA;AACe,MAAMO,eAAe,SAASC,kBAAS,CAAC;EAGrD;AACF;EACEC,WAAWA,CAACC,IAAY,EAAE;IACxB,KAAK,CAACA,IAAI,EAAE,CAAC,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;EAClB;;EAEA;AACF;EACE,IAAIC,QAAQA,CAAA,EAAY;IACtB,OAAO,IAAI,CAACH,IAAI,CAACG,QAAQ;EAC3B;;EAEA;AACF;EACE,IAAIC,EAAEA,CAAA,EAAW;IACf,OAAO,IAAI,CAACJ,IAAI,CAACI,EAAE,IAAI,IAAI,CAACJ,IAAI,CAACK,GAAG;EACtC;;EAEA;AACF;AACA;EACE,IAAIC,GAAGA,CAAA,EAAY;IACjB,OAAO,IAAI,CAACF,EAAE;EAChB;;EAEA;AACF;AACA;EACE,IAAIG,IAAIA,CAAA,EAAW;IACjB,MAAMA,IAAI,GAAG,IAAI,CAACC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IACrC,OAAO,IAAAC,mBAAY,EAACF,IAAI,CAAC;EAC3B;;EAEA;AACF;AACA;EACE,IAAIG,MAAMA,CAAA,EAAkB;IAC1B,OAAO,IAAI,CAACV,IAAI,CAACU,MAAM,IAAI,IAA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EF,OAAOC,KAAK;EACd;;EAEA;AACF;AACA;EACE,IAAIC,mBAAmBA,CAAA,EAAgB;IACrC,MAAMG,mBAAmB,GAAG,IAAI,CAACb,KAAK,CAACK,YAAY,CAAC,iBAAiB,CAAC;IAEtE,IAAIQ,mBAAmB,EAAE;MACvB,MAAM;QAAEN;MAAK,CAAC,GAAGM,mBAAmB;MACpCN,IAAI,CAACO,gBAAgB,CAAC,IAAI,CAACC,aAAa,CAAC;MACzC,OAAOR,IAAI;IACb;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAIQ,aAAaA,CAAA,EAAW;IAC1B,MAAMT,QAAQ,GAAG,IAAI,CAACA,QAAQ,IAAI,IAAIU,aAAI,CAAC,CAAC;IAC5C,OAAO,IAAAC,8BAAkB,EAACX,QAAQ,CAAC;EACrC;;EAEA;AACF;EACEY,mBAAmBA,CAAA,EAA2B;IAC5C,MAAMC,QAAQ,GAAG,EAAE;IAEnB,KAAK,MAAMpB,UAAU,IAAI,IAAI,CAACJ,WAAW,EAAE;MACzC,IAAII,UAAU,CAACb,QAAQ,EAAE;QACvBiC,QAAQ,CAACR,IAAI,CAACZ,UAAU,CAAC;MAC3B;MAEA,MAAMqB,cAAc,GAAGrB,UAAU,CAACmB,mBAAmB,CAAC,CAAC;MACvDC,QAAQ,CAACR,IAAI,CAAC,GAAGS,cAAc,CAAC;IAClC;IAEA,OAAOD,QAAQ;EACjB;AACF;AAACE,OAAA,CAAApC,OAAA,GAAAL,eAAA","ignoreList":[]}
1
+ {"version":3,"file":"SubSectionModel.js","names":["_createHash","require","_BaseModel","_interopRequireDefault","_LinkCollection","_Href","_LinkModel","_utils","SubSectionModel","BaseModel","constructor","data","_defineProperty2","default","referred","id","_id","key","body","getData","retrieveText","number","label","subSections","_context","_map","call","subSection","links","_links","LinkCollection","contributions","selflink","getLinkByKey","selfhref","href","relatedConceptsHrefs","hrefs","relatedConceptsHref","push","forEach","relatedConceptsLink","_context2","_includes","hash","_context3","firstPart","path","substring","lastIndexOf","indexOf","setReferenceHash","referenceHash","Href","createHashFromHref","getReferredSections","sections","referredChilds","exports"],"sources":["../../../src/models/content/SubSectionModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n const body = this.getData(\"body\", \"\");\n return retrieveText(body);\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection),\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n const { href } = relatedConceptsLink;\n\n if (href.hash.includes(\"/relatedConcepts\")) {\n const firstPart = href.path.substring(0, href.path.lastIndexOf(\"/\"));\n href.path = firstPart + \"/\" + href.hash;\n href.hash = href.hash.includes(\"#\")\n ? href.hash.substring(href.hash.indexOf(\"#\"))\n : \"\";\n }\n\n href.setReferenceHash(this.referenceHash);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"mappings":";;;;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,eAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,KAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,UAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEA;AACA;AACA;AACe,MAAMO,eAAe,SAASC,kBAAS,CAAC;EAGrD;AACF;EACEC,WAAWA,CAACC,IAAY,EAAE;IACxB,KAAK,CAACA,IAAI,EAAE,CAAC,CAAC,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;EAClB;;EAEA;AACF;EACE,IAAIC,QAAQA,CAAA,EAAY;IACtB,OAAO,IAAI,CAACH,IAAI,CAACG,QAAQ;EAC3B;;EAEA;AACF;EACE,IAAIC,EAAEA,CAAA,EAAW;IACf,OAAO,IAAI,CAACJ,IAAI,CAACI,EAAE,IAAI,IAAI,CAACJ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C,CAAC,GAC3C,EAAE;MACR;MAEAf,IAAI,CAACgB,gBAAgB,CAAC,IAAI,CAACC,aAAa,CAAC;MACzC,OAAOjB,IAAI;IACb;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAIiB,aAAaA,CAAA,EAAW;IAC1B,MAAMlB,QAAQ,GAAG,IAAI,CAACA,QAAQ,IAAI,IAAImB,aAAI,CAAC,CAAC;IAC5C,OAAO,IAAAC,8BAAkB,EAACpB,QAAQ,CAAC;EACrC;;EAEA;AACF;EACEqB,mBAAmBA,CAAA,EAA2B;IAC5C,MAAMC,QAAQ,GAAG,EAAE;IAEnB,KAAK,MAAM7B,UAAU,IAAI,IAAI,CAACJ,WAAW,EAAE;MACzC,IAAII,UAAU,CAACb,QAAQ,EAAE;QACvB0C,QAAQ,CAACjB,IAAI,CAACZ,UAAU,CAAC;MAC3B;MAEA,MAAM8B,cAAc,GAAG9B,UAAU,CAAC4B,mBAAmB,CAAC,CAAC;MACvDC,QAAQ,CAACjB,IAAI,CAAC,GAAGkB,cAAc,CAAC;IAClC;IAEA,OAAOD,QAAQ;EACjB;AACF;AAACE,OAAA,CAAA7C,OAAA,GAAAL,eAAA","ignoreList":[]}
@@ -6,6 +6,7 @@ import contributions from "./contributions.json";
6
6
 
7
7
  import content from "./content.json";
8
8
  import contentWithSubsections from "./content-with-subsections.json";
9
+ import contentWithSubsections2 from "./content-with-subsections2.json";
9
10
  import contentWithChildsections from "./content-with-childsections.json";
10
11
  import ContentLinkModel from "../ContentLinkModel";
11
12
 
@@ -118,6 +119,27 @@ describe("contentmodel", () => {
118
119
  );
119
120
  });
120
121
 
122
+ it("can handle content service with subsections and correct related concepts", () => {
123
+ const response = ModularUIResponse.create({
124
+ key: "contentmodel",
125
+ data: contentWithSubsections2,
126
+ contributions,
127
+ });
128
+
129
+ const contentModel = new ContentModel(response);
130
+ expect(contentModel.relatedConceptsHrefs).toHaveLength(3);
131
+
132
+ expect(contentModel.relatedConceptsHrefs[0].toString()).toBe(
133
+ "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1/relatedConcepts?entryDate=2024-07-17",
134
+ );
135
+ expect(contentModel.relatedConceptsHrefs[1].toString()).toBe(
136
+ "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1a/relatedConcepts",
137
+ );
138
+ expect(contentModel.relatedConceptsHrefs[2].toString()).toBe(
139
+ "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1b/relatedConcepts",
140
+ );
141
+ });
142
+
121
143
  it("can handle content service with subsections", () => {
122
144
  const response = ModularUIResponse.create({
123
145
  key: "contentmodel",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.50.1",
3
+ "version": "1.50.2",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -122,6 +122,15 @@ export default class SubSectionModel extends BaseModel {
122
122
 
123
123
  if (relatedConceptsLink) {
124
124
  const { href } = relatedConceptsLink;
125
+
126
+ if (href.hash.includes("/relatedConcepts")) {
127
+ const firstPart = href.path.substring(0, href.path.lastIndexOf("/"));
128
+ href.path = firstPart + "/" + href.hash;
129
+ href.hash = href.hash.includes("#")
130
+ ? href.hash.substring(href.hash.indexOf("#"))
131
+ : "";
132
+ }
133
+
125
134
  href.setReferenceHash(this.referenceHash);
126
135
  return href;
127
136
  }
@@ -6,6 +6,7 @@ import contributions from "./contributions.json";
6
6
 
7
7
  import content from "./content.json";
8
8
  import contentWithSubsections from "./content-with-subsections.json";
9
+ import contentWithSubsections2 from "./content-with-subsections2.json";
9
10
  import contentWithChildsections from "./content-with-childsections.json";
10
11
  import ContentLinkModel from "../ContentLinkModel";
11
12
 
@@ -118,6 +119,27 @@ describe("contentmodel", () => {
118
119
  );
119
120
  });
120
121
 
122
+ it("can handle content service with subsections and correct related concepts", () => {
123
+ const response = ModularUIResponse.create({
124
+ key: "contentmodel",
125
+ data: contentWithSubsections2,
126
+ contributions,
127
+ });
128
+
129
+ const contentModel = new ContentModel(response);
130
+ expect(contentModel.relatedConceptsHrefs).toHaveLength(3);
131
+
132
+ expect(contentModel.relatedConceptsHrefs[0].toString()).toBe(
133
+ "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1/relatedConcepts?entryDate=2024-07-17",
134
+ );
135
+ expect(contentModel.relatedConceptsHrefs[1].toString()).toBe(
136
+ "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1a/relatedConcepts",
137
+ );
138
+ expect(contentModel.relatedConceptsHrefs[2].toString()).toBe(
139
+ "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1b/relatedConcepts",
140
+ );
141
+ });
142
+
121
143
  it("can handle content service with subsections", () => {
122
144
  const response = ModularUIResponse.create({
123
145
  key: "contentmodel",
@@ -0,0 +1,79 @@
1
+ {
2
+ "section": {
3
+ "_id": "Chapter5_1",
4
+ "label": "Eligibility Criteria",
5
+ "number": "5.1",
6
+ "body": "<p>Applications will need to meet the following eligibility criteria:</p>",
7
+ "subSections": [
8
+ {
9
+ "_id": "Chapter5_1a",
10
+ "number": "a.",
11
+ "body": "<p>The research project can be classified as innovative. This includes innovation levels 2 and 3 as described in Annex A.</p>",
12
+ "_links": {
13
+ "self": {
14
+ "href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1#Chapter5_1a"
15
+ },
16
+ "api_doc": {
17
+ "href": "/api-docs/v3/content/(content-identifier)/(section-identifier)"
18
+ },
19
+ "contributions": {
20
+ "href": "/contributions/content/(content-identifier)/(section-identifier)"
21
+ },
22
+ "relatedConcepts": {
23
+ "href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1#Chapter5_1a/relatedConcepts"
24
+ },
25
+ "content": {
26
+ "href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource"
27
+ }
28
+ }
29
+ },
30
+ {
31
+ "_id": "Chapter5_1b",
32
+ "number": "b.",
33
+ "body": "<p>The research project contributes to open source, which includes the following projects:</p>",
34
+ "subSections": [],
35
+ "_links": {
36
+ "self": {
37
+ "href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1#Chapter5_1b"
38
+ },
39
+ "api_doc": {
40
+ "href": "/api-docs/v3/content/(content-identifier)/(section-identifier)"
41
+ },
42
+ "contributions": {
43
+ "href": "/contributions/content/(content-identifier)/(section-identifier)"
44
+ },
45
+ "relatedConcepts": {
46
+ "href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1#Chapter5_1b/relatedConcepts"
47
+ },
48
+ "content": {
49
+ "href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource"
50
+ }
51
+ }
52
+ }
53
+ ],
54
+ "_links": {
55
+ "self": {
56
+ "href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1"
57
+ },
58
+ "api_doc": {
59
+ "href": "/api-docs/v3/content/(content-identifier)/(section-identifier)"
60
+ },
61
+ "contributions": {
62
+ "href": "/contributions/content/(content-identifier)/(section-identifier)"
63
+ },
64
+ "relatedConcepts": {
65
+ "href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource/Chapter5_1/relatedConcepts"
66
+ },
67
+ "content": {
68
+ "href": "/content/bundle-nl.government.grant.funding.agreement.source/Grant%20Funding%20Agreement/Grant%20Funding%20Agreement.formalsource"
69
+ }
70
+ },
71
+ "filter": {
72
+ "entryDate": {
73
+ "param": "entryDate",
74
+ "name": "entryDate",
75
+ "value": "2024-07-17"
76
+ }
77
+ }
78
+ }
79
+ }