@beinformed/ui 1.62.3 → 1.62.5

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 (31) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/esm/models/concepts/SourceReferenceModel.d.ts +4 -0
  3. package/esm/models/concepts/SourceReferenceModel.js +7 -0
  4. package/esm/models/concepts/SourceReferenceModel.js.flow +12 -0
  5. package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
  6. package/esm/models/content/ContentLinkModel.d.ts +9 -0
  7. package/esm/models/content/ContentLinkModel.js +39 -6
  8. package/esm/models/content/ContentLinkModel.js.flow +48 -6
  9. package/esm/models/content/ContentLinkModel.js.map +1 -1
  10. package/esm/models/content/ContentTOCModel.d.ts +5 -0
  11. package/esm/models/content/ContentTOCModel.js +15 -0
  12. package/esm/models/content/ContentTOCModel.js.flow +15 -0
  13. package/esm/models/content/ContentTOCModel.js.map +1 -1
  14. package/esm/models/content/__tests__/ContentLinkModel.spec.js.flow +48 -0
  15. package/esm/models/content/__tests__/Formalsource.spec.js.flow +8 -0
  16. package/lib/models/concepts/SourceReferenceModel.d.ts +4 -0
  17. package/lib/models/concepts/SourceReferenceModel.js +7 -0
  18. package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
  19. package/lib/models/content/ContentLinkModel.d.ts +9 -0
  20. package/lib/models/content/ContentLinkModel.js +39 -6
  21. package/lib/models/content/ContentLinkModel.js.map +1 -1
  22. package/lib/models/content/ContentTOCModel.d.ts +5 -0
  23. package/lib/models/content/ContentTOCModel.js +15 -0
  24. package/lib/models/content/ContentTOCModel.js.map +1 -1
  25. package/package.json +3 -3
  26. package/src/models/concepts/SourceReferenceModel.js +12 -0
  27. package/src/models/content/ContentLinkModel.js +48 -6
  28. package/src/models/content/ContentTOCModel.js +15 -0
  29. package/src/models/content/__tests__/ContentLinkModel.spec.js +48 -0
  30. package/src/models/content/__tests__/Formalsource.spec.js +8 -0
  31. package/src/models/content/__tests__/formalsource-toc.json +3 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.62.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.4...v1.62.5) (2025-06-06)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **content-toc:** add related concepts href ([090b237](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/090b237591dd7f8499aa1624f4e7b24cec0e9c98))
11
+
12
+ ## [1.62.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.3...v1.62.4) (2025-06-05)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **content-link:** add content and section hrefs ([13e85e3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/13e85e3698b4d22f3fc41e4f53f0dff43dfe566e))
18
+
5
19
  ## [1.62.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.2...v1.62.3) (2025-06-05)
6
20
 
7
21
 
@@ -8,6 +8,9 @@ declare class SourceReferenceModel {
8
8
  _sourceReference: Object;
9
9
  _entryDate: ISO_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";
@@ -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","_links","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\";\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,SAASA,kBAAkB,QAAQ,gCAAgC;AAEnE,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,IAAI,MAAM,cAAc;AAC/B,SAASC,oBAAoB,QAAQ,iBAAiB;AAGtD;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,gBA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AACP,gBAAgB,CAACO,SAAS;EACxC;;EAEA;AACF;AACA;EACE,IAAIY,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAACnB,gBAAgB,CAACoB,eAAe;EAC9C;AACF;AAEA,eAAe7B,oBAAoB","ignoreList":[]}
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;MACnCK,MAAM,EAAE,EAAE;MACVC,WAAW,EAAEf,oBAAoB,CAAC;IACpC,CAAC;EACH;;EAEA;AACF;EACE,IAAIgB,KAAKA,CAAA,EAAmB;IAC1B,OAAO,IAAIf,cAAc,CACvB,IAAI,CAACU,gBAAgB,CAACM,MAAM,EAC5B,IAAI,EACJ,IAAI,CAACJ,aACP,CAAC;EACH;;EAEA;AACF;EACE,IAA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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 section = this.data.section;
107
- const sourceId = section ? href.substring(startURI.length, href.lastIndexOf("/")) : href.substring(startURI.length);
108
- if (section) {
109
- selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${encodeURIComponent(section)}`;
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 (selflink != null && !_endsWithInstanceProperty(_context = selflink.href.path).call(_context, this.data.section)) {
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.data.section;
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 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
  */
@@ -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,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,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,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,MAAAE,SAAA;IAE3B,KAAK,CAACJ,IAAI,EAAE,CAAC,CA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EA;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":[]}
@@ -17,6 +17,10 @@ export default class ContentTOCModel extends ResourceModel {
17
17
  /**
18
18
  */
19
19
  get abbreviation(): string | null;
20
+ /**
21
+ * Get related concepts link
22
+ */
23
+ get relatedConceptsHref(): Href | null;
20
24
  /**
21
25
  */
22
26
  get selfContentLink(): ContentLinkModel;
@@ -47,5 +51,6 @@ import ResourceModel from "../base/ResourceModel";
47
51
  import ContentTypeModel from "./ContentTypeModel";
48
52
  import FilterCollection from "../filters/FilterCollection";
49
53
  import { ModularUIModel } from "../types";
54
+ import Href from "../href/Href";
50
55
  import ContentLinkModel from "./ContentLinkModel";
51
56
  import SectionModel from "./SectionModel";
@@ -101,6 +101,21 @@ export default class ContentTOCModel extends ResourceModel {
101
101
  return href;
102
102
  }
103
103
 
104
+ /**
105
+ * Get related concepts link
106
+ */
107
+ get relatedConceptsHref() {
108
+ const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
109
+ if (relatedConceptsLink) {
110
+ const {
111
+ href
112
+ } = relatedConceptsLink;
113
+ href.addParameter("entryDate", this.entryDate);
114
+ return href;
115
+ }
116
+ return null;
117
+ }
118
+
104
119
  /**
105
120
  */
106
121
  get selfContentLink() {
@@ -117,6 +117,21 @@ export default class ContentTOCModel extends ResourceModel {
117
117
  return href;
118
118
  }
119
119
 
120
+ /**
121
+ * Get related concepts link
122
+ */
123
+ get relatedConceptsHref(): Href | null {
124
+ const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
125
+
126
+ if (relatedConceptsLink) {
127
+ const { href } = relatedConceptsLink;
128
+ href.addParameter("entryDate", this.entryDate);
129
+ return href;
130
+ }
131
+
132
+ return null;
133
+ }
134
+
120
135
  /**
121
136
  */
122
137
  get selfContentLink(): ContentLinkModel {
@@ -1 +1 @@
1
- {"version":3,"file":"ContentTOCModel.js","names":["has","ResourceModel","FilterCollection","ContentLinkModel","ContentTypeModel","Href","SectionModel","TIMEVERSION_FILTER_NAME","getItems","items","entryDate","modelOptions","_mapInstanceProperty","call","item","link","section","_id","sections","ContentTOCModel","constructor","arguments","_defineProperty","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","contentTypeLink","links","getLinkByKey","setChildModels","models","contentType","_findInstanceProperty","model","label","getData","abbreviation","selfhref","href","selflink","filterCollection","forEach","filter","params","param","value","setParameter","name","removeParameter","selfContentLink","_context","categories","_context2","category","_contentType","_filterCollection","_context3","_filterInstanceProperty","_context4","key","_Object$keys","timeversionFilter","getFilterByAttributeKey","attribute","isCompleteSource","completeFilter"],"sources":["../../../src/models/content/ContentTOCModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport Href from \"../href/Href\";\n\nimport SectionModel from \"./SectionModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * Get content items recursively\n */\nconst getItems = (\n items: Array<Object>,\n entryDate: ISO_DATE | null,\n modelOptions?: ModelOptions,\n): Array<ContentLinkModel> =>\n items.map((item) => {\n const link = new ContentLinkModel(\n {\n ...item,\n section: item._id,\n },\n entryDate,\n modelOptions,\n );\n\n if (item.items) {\n link.items = getItems(item.items, entryDate, modelOptions);\n }\n if (item.sections) {\n link.items = getItems(item.sections, entryDate, modelOptions);\n }\n\n return link;\n });\n\n/**\n * Content detail model\n */\nexport default class ContentTOCModel extends ResourceModel {\n _contentType: ContentTypeModel | null = null;\n _filterCollection: FilterCollection;\n\n /**\n */\n get type(): string {\n return \"ContentTOC\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ContentTOCModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return data.contributions?.resourcetype === \"ContentTOC\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const contentTypeLink = this.links.getLinkByKey(\"contenttype\");\n\n if (contentTypeLink) {\n return [contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.contentType = models.find((model) => model.type === \"ContentType\");\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\");\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const href = new Href(this.selflink.href);\n\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n\n return href;\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(this.data, this.entryDate, this.modelOptions);\n }\n\n /**\n * Get sub items of toc\n */\n get items(): Array<ContentLinkModel> {\n if (this.data.items) {\n return getItems(this.data.items, this.entryDate, this.modelOptions);\n }\n\n if (this.data.sections) {\n return getItems(this.data.sections, this.entryDate, this.modelOptions);\n }\n\n return [];\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n if (this.data.sections) {\n return this.data.sections.map(\n (section) =>\n new SectionModel(section, this.entryDate, this.modelOptions),\n );\n }\n return [];\n }\n\n /**\n * get categories of content\n */\n get categories(): Array<ContentLinkModel> {\n if (this.data.categories) {\n return this.data.categories.map(\n (category) => new ContentLinkModel(category, null, this.modelOptions),\n );\n }\n\n return [];\n }\n\n /**\n * Retrieve content type model\n */\n get contentType(): ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n * Retrieve available filters on concept toc\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter.filter((filter) => {\n const [key] = Object.keys(filter);\n return has(this.data?.filter, key);\n }),\n },\n this.modelOptions,\n );\n }\n\n return this._filterCollection;\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): ISO_DATE | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n\n return timeversionFilter?.attribute?.value ?? null;\n }\n\n /**\n */\n get isCompleteSource(): boolean {\n const completeFilter =\n this.filterCollection.getFilterByAttributeKey(\"complete\");\n return completeFilter?.attribute?.value === \"true\";\n }\n}\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,aAAa,MAAM,uBAAuB;AACjD,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,IAAI,MAAM,cAAc;AAE/B,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,SAASC,uBAAuB,QAAQ,2BAA2B;AAKnE;AACA;AACA;AACA,MAAMC,QAAQ,GAAGA,CACfC,KAAoB,EACpBC,SAA0B,EAC1BC,YAA2B,KAE3BC,oBAAA,CAAAH,KAAK,EAAAI,IAAA,CAALJ,KAAK,EAAMK,IAAI,IAAK;EAClB,MAAMC,IAAI,GAAG,IAAIZ,gBAAgB,CAC/B;IACE,GAAGW,IAAI;IACPE,OAAO,EAAEF,IAAI,CAACG;EAChB,CAAC,EACDP,S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ACnD,MAAM,CAACC,GAAG,CAAC,GAAGC,YAAA,CAAYlB,MAAM,CAAC;UACjC,OAAO9C,GAAG,EAAA8D,SAAA,GAAC,IAAI,CAACpC,IAAI,qBAAAmC,uBAAA,CAAAC,SAAA,GAAUC,GAAG,CAAC;QACpC,CAAC;MACH,CAAC,EACD,IAAI,CAACpD,YACP,CAAC;IACH;IAEA,OAAO,IAAI,CAACgD,iBAAiB;EAC/B;;EAEA;AACF;AACA;EACE,IAAIjD,SAASA,CAAA,EAAoB;IAC/B,MAAMuD,iBAAiB,GAAG,IAAI,CAACrB,gBAAgB,CAACsB,uBAAuB,CACrE3D,uBACF,CAAC;IAED,OAAO0D,iBAAiB,EAAEE,SAAS,EAAElB,KAAK,IAAI,IAAI;EACpD;;EAEA;AACF;EACE,IAAImB,gBAAgBA,CAAA,EAAY;IAC9B,MAAMC,cAAc,GAClB,IAAI,CAACzB,gBAAgB,CAACsB,uBAAuB,CAAC,UAAU,CAAC;IAC3D,OAAOG,cAAc,EAAEF,SAAS,EAAElB,KAAK,KAAK,MAAM;EACpD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ContentTOCModel.js","names":["has","ResourceModel","FilterCollection","ContentLinkModel","ContentTypeModel","Href","SectionModel","TIMEVERSION_FILTER_NAME","getItems","items","entryDate","modelOptions","_mapInstanceProperty","call","item","link","section","_id","sections","ContentTOCModel","constructor","arguments","_defineProperty","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","contentTypeLink","links","getLinkByKey","setChildModels","models","contentType","_findInstanceProperty","model","label","getData","abbreviation","selfhref","href","selflink","filterCollection","forEach","filter","params","param","value","setParameter","name","removeParameter","relatedConceptsHref","relatedConceptsLink","addParameter","selfContentLink","_context","categories","_context2","category","_contentType","_filterCollection","_context3","_filterInstanceProperty","_context4","key","_Object$keys","timeversionFilter","getFilterByAttributeKey","attribute","isCompleteSource","completeFilter"],"sources":["../../../src/models/content/ContentTOCModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport Href from \"../href/Href\";\n\nimport SectionModel from \"./SectionModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * Get content items recursively\n */\nconst getItems = (\n items: Array<Object>,\n entryDate: ISO_DATE | null,\n modelOptions?: ModelOptions,\n): Array<ContentLinkModel> =>\n items.map((item) => {\n const link = new ContentLinkModel(\n {\n ...item,\n section: item._id,\n },\n entryDate,\n modelOptions,\n );\n\n if (item.items) {\n link.items = getItems(item.items, entryDate, modelOptions);\n }\n if (item.sections) {\n link.items = getItems(item.sections, entryDate, modelOptions);\n }\n\n return link;\n });\n\n/**\n * Content detail model\n */\nexport default class ContentTOCModel extends ResourceModel {\n _contentType: ContentTypeModel | null = null;\n _filterCollection: FilterCollection;\n\n /**\n */\n get type(): string {\n return \"ContentTOC\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ContentTOCModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return data.contributions?.resourcetype === \"ContentTOC\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const contentTypeLink = this.links.getLinkByKey(\"contenttype\");\n\n if (contentTypeLink) {\n return [contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.contentType = models.find((model) => model.type === \"ContentType\");\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\");\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const href = new Href(this.selflink.href);\n\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n\n return href;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n const { href } = relatedConceptsLink;\n href.addParameter(\"entryDate\", this.entryDate);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(this.data, this.entryDate, this.modelOptions);\n }\n\n /**\n * Get sub items of toc\n */\n get items(): Array<ContentLinkModel> {\n if (this.data.items) {\n return getItems(this.data.items, this.entryDate, this.modelOptions);\n }\n\n if (this.data.sections) {\n return getItems(this.data.sections, this.entryDate, this.modelOptions);\n }\n\n return [];\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n if (this.data.sections) {\n return this.data.sections.map(\n (section) =>\n new SectionModel(section, this.entryDate, this.modelOptions),\n );\n }\n return [];\n }\n\n /**\n * get categories of content\n */\n get categories(): Array<ContentLinkModel> {\n if (this.data.categories) {\n return this.data.categories.map(\n (category) => new ContentLinkModel(category, null, this.modelOptions),\n );\n }\n\n return [];\n }\n\n /**\n * Retrieve content type model\n */\n get contentType(): ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n * Retrieve available filters on concept toc\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter.filter((filter) => {\n const [key] = Object.keys(filter);\n return has(this.data?.filter, key);\n }),\n },\n this.modelOptions,\n );\n }\n\n return this._filterCollection;\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): ISO_DATE | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n\n return timeversionFilter?.attribute?.value ?? null;\n }\n\n /**\n */\n get isCompleteSource(): boolean {\n const completeFilter =\n this.filterCollection.getFilterByAttributeKey(\"complete\");\n return completeFilter?.attribute?.value === \"true\";\n }\n}\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,aAAa,MAAM,uBAAuB;AACjD,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,IAAI,MAAM,cAAc;AAE/B,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,SAASC,uBAAuB,QAAQ,2BAA2B;AAKnE;AACA;AACA;AACA,MAAMC,QAAQ,GAAGA,CACfC,KAAoB,EACpBC,SAA0B,EAC1BC,YAA2B,KAE3BC,oBAAA,CAAAH,KAAK,EAAAI,IAAA,CAALJ,KAAK,EAAMK,IAAI,IAAK;EAClB,MAAMC,IAAI,GAAG,IAAIZ,gBAAgB,CAC/B;IACE,GAAGW,IAAI;IACPE,OAAO,EAAEF,IAAI,CAACG;EAChB,CAAC,EACDP,SAAS,EACTC,YACF,CAAC;EAED,IAAIG,IAAI,CAACL,KAAK,EAAE;IACdM,IAAI,CAACN,KAAK,GAAGD,QAAQ,CAACM,IAAI,CAACL,KAAK,EAAEC,SAAS,EAAEC,YAAY,CAAC;EAC5D;EACA,IAAIG,IAAI,CAACI,QAAQ,EAAE;IACjBH,IAAI,CAACN,KAAK,GAAGD,QAAQ,CAACM,IAAI,CAACI,QAAQ,EAAER,SAAS,EAAEC,YAAY,CAAC;EAC/D;EAEA,OAAOI,IAAI;AACb,CAAC,CAAC;;AAEJ;AACA;AACA;AACA,eAAe,MAAMI,eAAe,SAASlB,aAAa,CAAC;EAAAmB,YAAA;IAAA,SAAAC,SAAA;IAAAC,eAAA,uBACjB,IAAI;IAAAA,eAAA;EAAA;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SAAA,GAAUC,GAAG,CAAC;QACpC,CAAC;MACH,CAAC,EACD,IAAI,CAACvD,YACP,CAAC;IACH;IAEA,OAAO,IAAI,CAACmD,iBAAiB;EAC/B;;EAEA;AACF;AACA;EACE,IAAIpD,SAASA,CAAA,EAAoB;IAC/B,MAAM0D,iBAAiB,GAAG,IAAI,CAACxB,gBAAgB,CAACyB,uBAAuB,CACrE9D,uBACF,CAAC;IAED,OAAO6D,iBAAiB,EAAEE,SAAS,EAAErB,KAAK,IAAI,IAAI;EACpD;;EAEA;AACF;EACE,IAAIsB,gBAAgBA,CAAA,EAAY;IAC9B,MAAMC,cAAc,GAClB,IAAI,CAAC5B,gBAAgB,CAACyB,uBAAuB,CAAC,UAAU,CAAC;IAC3D,OAAOG,cAAc,EAAEF,SAAS,EAAErB,KAAK,KAAK,MAAM;EACpD;AACF","ignoreList":[]}
@@ -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
  });
@@ -27,6 +27,10 @@ describe("formalsource", () => {
27
27
  "Grant Funding Agreement - Terms and Conditions",
28
28
  );
29
29
 
30
+ expect(tocModel.relatedConceptsHref.toString()).toBe(
31
+ "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/relatedConcepts?entryDate=2025-05-28",
32
+ );
33
+
30
34
  expect(tocModel.items).toHaveLength(6);
31
35
  expect(tocModel.items[0].items).toBeUndefined();
32
36
  expect(tocModel.items[1].items).toHaveLength(2);
@@ -64,6 +68,10 @@ describe("formalsource", () => {
64
68
  expect(completeModel.abbreviation).toBe("GFA-TC-01");
65
69
  expect(completeModel.isCompleteSource).toBe(true);
66
70
 
71
+ expect(completeModel.relatedConceptsHref.toString()).toBe(
72
+ "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/relatedConcepts?entryDate=2025-05-28",
73
+ );
74
+
67
75
  const firstSection = completeModel.sections[0];
68
76
  expect(firstSection.selfhref.toString()).toBe(
69
77
  "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/Chapter1",
@@ -8,6 +8,9 @@ declare class SourceReferenceModel {
8
8
  _sourceReference: Object;
9
9
  _entryDate: ISO_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,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAAA,IAAAE,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAE3B,IAAI,CAACC,gBAAgB,GAAGR,eAAe;IACvC,IAAI,CAACS,UAAU,GAAGR,SAAS;IAC3B,IAAI,CAACS,aAAa,GAAGL,YAAY,IAAI;MACnCM,MAAM,EAAE,EAAE;MACVC,WAAW,EAAE,IAAAC,+BAAoB,EAAC;IACpC,CAAC;EACH;;EAEA;AACF;EACE,IAAIC,IAAIA,CAAA,EAAqB;IAC3B,MAAMC,OAAO,GACX,IAAI,CAACC,SAAS,IACd,IAAI,CAACR,gBAAgB,CAACS,MAAM,CAACC,IAAI,CAACC,IAAI,CAACC,OAAO,CAC5C,GAAG,IAAI,CAACZ,gBAAgB,CAACS,MAAM,CAACI,OAAO,CAACF,IAAI,GAAG,EAC/C,EACF,CAAC;IAEH,OAAO,IAAIG,yBAAgB,CACzB;MACE,GAAG,IAAI,CAACd,gBAAgB;MACxBO;IACF,CAAC,EACD,IAAI,CAACN,UAAU,EACf,IAAI,CAACC,aACP,CAAC;EACH;;EAEA;AACF;EACE,IAAIa,QAAQA,CAAA,EAAS;IACnB,OAAO,IAAI,CAACT,IAAI,CAACS,QAAQ;EAC3B;;EAEA;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,IAAI,CAAChB,gBAAgB,CAACgB,IAAI;EACnC;;EAEA;AACF;EACE,IAAIC,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACjB,gBAAgB,CAACiB,KAAK;EACpC;;EAEA;AACF;EACE,IAAIC,WAAWA,CAAA,EAAW;IACxB,OAAO,IAAI,CAAClB,gBAAgB,CAACkB,WAAW;EAC1C;;EAEA;AACF;AACA;EACE,IAAIC,kBAAkBA,CAAA,EAAW;IAC/B,OAAO,IAAI,CAACnB,gBAAgB,CAACmB,kBAAkB;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,GA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BU;IACF,CAAC,EACD,IAAI,CAACT,UAAU,EACf,IAAI,CAACC,aACP,CAAC;EACH;;EAEA;AACF;EACE,IAAIe,QAAQA,CAAA,EAAS;IACnB,OAAO,IAAI,CAACR,IAAI,CAACQ,QAAQ;EAC3B;;EAEA;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,IAAI,CAAClB,gBAAgB,CAACkB,IAAI;EACnC;;EAEA;AACF;EACE,IAAIC,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACnB,gBAAgB,CAACmB,KAAK;EACpC;;EAEA;AACF;EACE,IAAIC,WAAWA,CAAA,EAAW;IACxB,OAAO,IAAI,CAACpB,gBAAgB,CAACoB,WAAW;EAC1C;;EAEA;AACF;AACA;EACE,IAAIC,kBAAkBA,CAAA,EAAW;IAC/B,OAAO,IAAI,CAACrB,gBAAgB,CAACqB,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,UAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,IAAAM,eAAA,GAAAP,sBAAA,CAAAC,OAAA;AASA;AACA;AACA;AACe,MAAMO,gBAAgB,SAC3BC,kBAAS,CAEnB;EAME;AACF;EACEC,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,MAAAE,SAAA;IAE3B,KAAK,CAACJ,IAAI,EAAE,CAAC,CAAC,EAAEK,YAAY,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,wBAVQ,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAY1C,IAAI,CAACC,UAAU,GAAGP,SAAS;EAC7B;;EAEA;AACF;EACE;EACAQ,yBAAyBA,CAAA,EAAqB;IAC5C,IAAI,IAA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F;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,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,iBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,IAAAM,eAAA,GAAAP,sBAAA,CAAAC,OAAA;AASA;AACA;AACA;AACe,MAAMO,gBAAgB,SAC3BC,kBAAS,CAEnB;EAME;AACF;EACEC,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,MAAAE,SAAA;IAE3B,KAAK,CAACJ,IAAI,EAAE,CAAC,CAAC,EAAEK,YAAY,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,wBAVQ,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OA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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":[]}
@@ -17,6 +17,10 @@ export default class ContentTOCModel extends ResourceModel {
17
17
  /**
18
18
  */
19
19
  get abbreviation(): string | null;
20
+ /**
21
+ * Get related concepts link
22
+ */
23
+ get relatedConceptsHref(): Href | null;
20
24
  /**
21
25
  */
22
26
  get selfContentLink(): ContentLinkModel;
@@ -47,5 +51,6 @@ import ResourceModel from "../base/ResourceModel";
47
51
  import ContentTypeModel from "./ContentTypeModel";
48
52
  import FilterCollection from "../filters/FilterCollection";
49
53
  import { ModularUIModel } from "../types";
54
+ import Href from "../href/Href";
50
55
  import ContentLinkModel from "./ContentLinkModel";
51
56
  import SectionModel from "./SectionModel";
@@ -108,6 +108,21 @@ class ContentTOCModel extends _ResourceModel.default {
108
108
  return href;
109
109
  }
110
110
 
111
+ /**
112
+ * Get related concepts link
113
+ */
114
+ get relatedConceptsHref() {
115
+ const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
116
+ if (relatedConceptsLink) {
117
+ const {
118
+ href
119
+ } = relatedConceptsLink;
120
+ href.addParameter("entryDate", this.entryDate);
121
+ return href;
122
+ }
123
+ return null;
124
+ }
125
+
111
126
  /**
112
127
  */
113
128
  get selfContentLink() {
@@ -1 +1 @@
1
- {"version":3,"file":"ContentTOCModel.js","names":["_objects","require","_ResourceModel","_interopRequireDefault","_FilterCollection","_ContentLinkModel","_ContentTypeModel","_Href","_SectionModel","_Constants","getItems","items","entryDate","modelOptions","_map","default","call","item","link","ContentLinkModel","section","_id","sections","ContentTOCModel","ResourceModel","constructor","arguments","_defineProperty2","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","contentTypeLink","links","getLinkByKey","setChildModels","models","contentType","_find","model","label","getData","abbreviation","selfhref","href","Href","selflink","filterCollection","forEach","filter","params","param","value","setParameter","name","removeParameter","selfContentLink","_context","SectionModel","categories","_context2","category","_contentType","ContentTypeModel","_filterCollection","_context3","FilterCollection","_filter","_context4","key","_keys","has","timeversionFilter","getFilterByAttributeKey","TIMEVERSION_FILTER_NAME","attribute","isCompleteSource","completeFilter","exports"],"sources":["../../../src/models/content/ContentTOCModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport Href from \"../href/Href\";\n\nimport SectionModel from \"./SectionModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * Get content items recursively\n */\nconst getItems = (\n items: Array<Object>,\n entryDate: ISO_DATE | null,\n modelOptions?: ModelOptions,\n): Array<ContentLinkModel> =>\n items.map((item) => {\n const link = new ContentLinkModel(\n {\n ...item,\n section: item._id,\n },\n entryDate,\n modelOptions,\n );\n\n if (item.items) {\n link.items = getItems(item.items, entryDate, modelOptions);\n }\n if (item.sections) {\n link.items = getItems(item.sections, entryDate, modelOptions);\n }\n\n return link;\n });\n\n/**\n * Content detail model\n */\nexport default class ContentTOCModel extends ResourceModel {\n _contentType: ContentTypeModel | null = null;\n _filterCollection: FilterCollection;\n\n /**\n */\n get type(): string {\n return \"ContentTOC\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ContentTOCModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return data.contributions?.resourcetype === \"ContentTOC\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const contentTypeLink = this.links.getLinkByKey(\"contenttype\");\n\n if (contentTypeLink) {\n return [contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.contentType = models.find((model) => model.type === \"ContentType\");\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\");\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const href = new Href(this.selflink.href);\n\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n\n return href;\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(this.data, this.entryDate, this.modelOptions);\n }\n\n /**\n * Get sub items of toc\n */\n get items(): Array<ContentLinkModel> {\n if (this.data.items) {\n return getItems(this.data.items, this.entryDate, this.modelOptions);\n }\n\n if (this.data.sections) {\n return getItems(this.data.sections, this.entryDate, this.modelOptions);\n }\n\n return [];\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n if (this.data.sections) {\n return this.data.sections.map(\n (section) =>\n new SectionModel(section, this.entryDate, this.modelOptions),\n );\n }\n return [];\n }\n\n /**\n * get categories of content\n */\n get categories(): Array<ContentLinkModel> {\n if (this.data.categories) {\n return this.data.categories.map(\n (category) => new ContentLinkModel(category, null, this.modelOptions),\n );\n }\n\n return [];\n }\n\n /**\n * Retrieve content type model\n */\n get contentType(): ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n * Retrieve available filters on concept toc\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter.filter((filter) => {\n const [key] = Object.keys(filter);\n return has(this.data?.filter, key);\n }),\n },\n this.modelOptions,\n );\n }\n\n return this._filterCollection;\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): ISO_DATE | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n\n return timeversionFilter?.attribute?.value ?? null;\n }\n\n /**\n */\n get isCompleteSource(): boolean {\n const completeFilter =\n this.filterCollection.getFilterByAttributeKey(\"complete\");\n return completeFilter?.attribute?.value === \"true\";\n }\n}\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,iBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,iBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,KAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAEA,IAAAO,aAAA,GAAAL,sBAAA,CAAAF,OAAA;AAEA,IAAAQ,UAAA,GAAAR,OAAA;AAKA;AACA;AACA;AACA,MAAMS,QAAQ,GAAGA,CACfC,KAAoB,EACpBC,SAA0B,EAC1BC,YAA2B,KAE3B,IAAAC,IAAA,CAAAC,OAAA,EAAAJ,KAAK,EAAAK,IAAA,CAALL,KAAK,EAAMM,IAAI,IAAK;EAClB,MAAMC,IAAI,GAAG,IAAIC,yBAAgB,CAC/B;IACE,GAAGF,IAAI;IACPG,OAAO,EAAEH,IAAI,CAACI;EAChB,CAAC,EACDT,SAAS,EACTC,YACF,CAAC;EAED,IAAII,IAAI,CAACN,KAAK,EAAE;IACdO,IAAI,CAACP,KAAK,GAAGD,QAAQ,CAACO,IAAI,CAACN,KAAK,EAAEC,SAAS,EAAEC,YAAY,CAAC;EAC5D;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,GAAG,CAAC,GAAG,IAAAC,KAAA,CAAA1D,OAAA,EAAYqC,MAAM,CAAC;UACjC,OAAO,IAAAsB,YAAG,GAAAH,SAAA,GAAC,IAAI,CAACxC,IAAI,yBAAAuC,OAAA,CAAAvD,OAAA,EAAAwD,SAAA,GAAUC,GAAG,CAAC;QACpC,CAAC;MACH,CAAC,EACD,IAAI,CAAC3D,YACP,CAAC;IACH;IAEA,OAAO,IAAI,CAACsD,iBAAiB;EAC/B;;EAEA;AACF;AACA;EACE,IAAIvD,SAASA,CAAA,EAAoB;IAC/B,MAAM+D,iBAAiB,GAAG,IAAI,CAACzB,gBAAgB,CAAC0B,uBAAuB,CACrEC,kCACF,CAAC;IAED,OAAOF,iBAAiB,EAAEG,SAAS,EAAEvB,KAAK,IAAI,IAAI;EACpD;;EAEA;AACF;EACE,IAAIwB,gBAAgBA,CAAA,EAAY;IAC9B,MAAMC,cAAc,GAClB,IAAI,CAAC9B,gBAAgB,CAAC0B,uBAAuB,CAAC,UAAU,CAAC;IAC3D,OAAOI,cAAc,EAAEF,SAAS,EAAEvB,KAAK,KAAK,MAAM;EACpD;AACF;AAAC0B,OAAA,CAAAlE,OAAA,GAAAQ,eAAA","ignoreList":[]}
1
+ {"version":3,"file":"ContentTOCModel.js","names":["_objects","require","_ResourceModel","_interopRequireDefault","_FilterCollection","_ContentLinkModel","_ContentTypeModel","_Href","_SectionModel","_Constants","getItems","items","entryDate","modelOptions","_map","default","call","item","link","ContentLinkModel","section","_id","sections","ContentTOCModel","ResourceModel","constructor","arguments","_defineProperty2","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","contentTypeLink","links","getLinkByKey","setChildModels","models","contentType","_find","model","label","getData","abbreviation","selfhref","href","Href","selflink","filterCollection","forEach","filter","params","param","value","setParameter","name","removeParameter","relatedConceptsHref","relatedConceptsLink","addParameter","selfContentLink","_context","SectionModel","categories","_context2","category","_contentType","ContentTypeModel","_filterCollection","_context3","FilterCollection","_filter","_context4","key","_keys","has","timeversionFilter","getFilterByAttributeKey","TIMEVERSION_FILTER_NAME","attribute","isCompleteSource","completeFilter","exports"],"sources":["../../../src/models/content/ContentTOCModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport Href from \"../href/Href\";\n\nimport SectionModel from \"./SectionModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * Get content items recursively\n */\nconst getItems = (\n items: Array<Object>,\n entryDate: ISO_DATE | null,\n modelOptions?: ModelOptions,\n): Array<ContentLinkModel> =>\n items.map((item) => {\n const link = new ContentLinkModel(\n {\n ...item,\n section: item._id,\n },\n entryDate,\n modelOptions,\n );\n\n if (item.items) {\n link.items = getItems(item.items, entryDate, modelOptions);\n }\n if (item.sections) {\n link.items = getItems(item.sections, entryDate, modelOptions);\n }\n\n return link;\n });\n\n/**\n * Content detail model\n */\nexport default class ContentTOCModel extends ResourceModel {\n _contentType: ContentTypeModel | null = null;\n _filterCollection: FilterCollection;\n\n /**\n */\n get type(): string {\n return \"ContentTOC\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ContentTOCModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return data.contributions?.resourcetype === \"ContentTOC\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const contentTypeLink = this.links.getLinkByKey(\"contenttype\");\n\n if (contentTypeLink) {\n return [contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.contentType = models.find((model) => model.type === \"ContentType\");\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\");\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const href = new Href(this.selflink.href);\n\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n\n return href;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n const { href } = relatedConceptsLink;\n href.addParameter(\"entryDate\", this.entryDate);\n return href;\n }\n\n return null;\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(this.data, this.entryDate, this.modelOptions);\n }\n\n /**\n * Get sub items of toc\n */\n get items(): Array<ContentLinkModel> {\n if (this.data.items) {\n return getItems(this.data.items, this.entryDate, this.modelOptions);\n }\n\n if (this.data.sections) {\n return getItems(this.data.sections, this.entryDate, this.modelOptions);\n }\n\n return [];\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n if (this.data.sections) {\n return this.data.sections.map(\n (section) =>\n new SectionModel(section, this.entryDate, this.modelOptions),\n );\n }\n return [];\n }\n\n /**\n * get categories of content\n */\n get categories(): Array<ContentLinkModel> {\n if (this.data.categories) {\n return this.data.categories.map(\n (category) => new ContentLinkModel(category, null, this.modelOptions),\n );\n }\n\n return [];\n }\n\n /**\n * Retrieve content type model\n */\n get contentType(): ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n * Retrieve available filters on concept toc\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter.filter((filter) => {\n const [key] = Object.keys(filter);\n return has(this.data?.filter, key);\n }),\n },\n this.modelOptions,\n );\n }\n\n return this._filterCollection;\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): ISO_DATE | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n\n return timeversionFilter?.attribute?.value ?? null;\n }\n\n /**\n */\n get isCompleteSource(): boolean {\n const completeFilter =\n this.filterCollection.getFilterByAttributeKey(\"complete\");\n return completeFilter?.attribute?.value === \"true\";\n }\n}\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,iBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,iBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,KAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAEA,IAAAO,aAAA,GAAAL,sBAAA,CAAAF,OAAA;AAEA,IAAAQ,UAAA,GAAAR,OAAA;AAKA;AACA;AACA;AACA,MAAMS,QAAQ,GAAGA,CACfC,KAAoB,EACpBC,SAA0B,EAC1BC,YAA2B,KAE3B,IAAAC,IAAA,CAAAC,OAAA,EAAAJ,KAAK,EAAAK,IAAA,CAALL,KAAK,EAAMM,IAAI,IAAK;EAClB,MAAMC,IAAI,GAAG,IAAIC,yBAAgB,CAC/B;IACE,GAAGF,IAAI;IACPG,OAAO,EAAEH,IAAI,CAACI;EAChB,CAAC,EACDT,SAAS,EACTC,YACF,CAAC;EAED,IAAII,IAAI,CAACN,KAAK,EAAE;IACdO,IAAI,CAACP,KAAK,GAAGD,QAAQ,CAACO,IAAI,CAACN,KAAK,EAAEC,SAAS,EAAEC,YAAY,CAAC;EAC5D;EACA,IAAII,IAAI,CAACK,QAAQ,EAAE;IACjBJ,IAAI,CAACP,KAAK,GAAGD,QAAQ,CAACO,IAAI,CAACK,Q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C3C,IAAI,CAACgB,IAAI,GACT;QACEqB,MAAM,EAAE,IAAAqB,OAAA,CAAA1D,OAAA,EAAAwD,SAAA,OAAAE,OAAA,CAAA1D,OAAA,MAAI,CAACiB,aAAa,GAAAhB,IAAA,CAAAuD,SAAA,EAAgBnB,MAAM,IAAK;UAAA,IAAAsB,SAAA;UACnD,MAAM,CAACC,GAAG,CAAC,GAAG,IAAAC,KAAA,CAAA7D,OAAA,EAAYqC,MAAM,CAAC;UACjC,OAAO,IAAAyB,YAAG,GAAAH,SAAA,GAAC,IAAI,CAAC3C,IAAI,yBAAA0C,OAAA,CAAA1D,OAAA,EAAA2D,SAAA,GAAUC,GAAG,CAAC;QACpC,CAAC;MACH,CAAC,EACD,IAAI,CAAC9D,YACP,CAAC;IACH;IAEA,OAAO,IAAI,CAACyD,iBAAiB;EAC/B;;EAEA;AACF;AACA;EACE,IAAI1D,SAASA,CAAA,EAAoB;IAC/B,MAAMkE,iBAAiB,GAAG,IAAI,CAAC5B,gBAAgB,CAAC6B,uBAAuB,CACrEC,kCACF,CAAC;IAED,OAAOF,iBAAiB,EAAEG,SAAS,EAAE1B,KAAK,IAAI,IAAI;EACpD;;EAEA;AACF;EACE,IAAI2B,gBAAgBA,CAAA,EAAY;IAC9B,MAAMC,cAAc,GAClB,IAAI,CAACjC,gBAAgB,CAAC6B,uBAAuB,CAAC,UAAU,CAAC;IAC3D,OAAOI,cAAc,EAAEF,SAAS,EAAE1B,KAAK,KAAK,MAAM;EACpD;AACF;AAAC6B,OAAA,CAAArE,OAAA,GAAAQ,eAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.62.3",
3
+ "version": "1.62.5",
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",
@@ -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
  */
@@ -117,6 +117,21 @@ export default class ContentTOCModel extends ResourceModel {
117
117
  return href;
118
118
  }
119
119
 
120
+ /**
121
+ * Get related concepts link
122
+ */
123
+ get relatedConceptsHref(): Href | null {
124
+ const relatedConceptsLink = this.links.getLinkByKey("relatedConcepts");
125
+
126
+ if (relatedConceptsLink) {
127
+ const { href } = relatedConceptsLink;
128
+ href.addParameter("entryDate", this.entryDate);
129
+ return href;
130
+ }
131
+
132
+ return null;
133
+ }
134
+
120
135
  /**
121
136
  */
122
137
  get selfContentLink(): ContentLinkModel {
@@ -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
  });
@@ -27,6 +27,10 @@ describe("formalsource", () => {
27
27
  "Grant Funding Agreement - Terms and Conditions",
28
28
  );
29
29
 
30
+ expect(tocModel.relatedConceptsHref.toString()).toBe(
31
+ "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/relatedConcepts?entryDate=2025-05-28",
32
+ );
33
+
30
34
  expect(tocModel.items).toHaveLength(6);
31
35
  expect(tocModel.items[0].items).toBeUndefined();
32
36
  expect(tocModel.items[1].items).toHaveLength(2);
@@ -64,6 +68,10 @@ describe("formalsource", () => {
64
68
  expect(completeModel.abbreviation).toBe("GFA-TC-01");
65
69
  expect(completeModel.isCompleteSource).toBe(true);
66
70
 
71
+ expect(completeModel.relatedConceptsHref.toString()).toBe(
72
+ "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/relatedConcepts?entryDate=2025-05-28",
73
+ );
74
+
67
75
  const firstSection = completeModel.sections[0];
68
76
  expect(firstSection.selfhref.toString()).toBe(
69
77
  "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/Chapter1",
@@ -25,6 +25,9 @@
25
25
  },
26
26
  "contributions": {
27
27
  "href": "/contributions/content/(content-identifier)"
28
+ },
29
+ "relatedConcepts": {
30
+ "href": "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/relatedConcepts"
28
31
  }
29
32
  },
30
33
  "label": "Grant Funding Agreement - Terms and Conditions",