@beinformed/ui 1.62.1 → 1.62.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/esm/models/concepts/ConceptLinkModel.d.ts +4 -7
- package/esm/models/concepts/ConceptLinkModel.js +7 -1
- package/esm/models/concepts/ConceptLinkModel.js.flow +8 -8
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.d.ts +3 -0
- package/esm/models/concepts/SourceReferenceModel.js +7 -1
- package/esm/models/concepts/SourceReferenceModel.js.flow +7 -1
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/concepts/__tests__/RelatedConcepts.spec.js.flow +6 -8
- package/esm/models/concepts/__tests__/SourceReferenceModel.spec.js.flow +3 -3
- package/esm/models/content/ContentLinkModel.js +3 -1
- package/esm/models/content/ContentLinkModel.js.flow +1 -1
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/__tests__/Formalsource.spec.js.flow +30 -0
- package/esm/models/types.d.ts +0 -1
- package/esm/models/types.js.flow +0 -1
- package/esm/models/types.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.d.ts +4 -7
- package/lib/models/concepts/ConceptLinkModel.js +7 -1
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.d.ts +3 -0
- package/lib/models/concepts/SourceReferenceModel.js +7 -1
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.js +3 -1
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/types.d.ts +0 -1
- package/lib/models/types.js.map +1 -1
- package/package.json +1 -1
- package/src/models/concepts/ConceptLinkModel.js +8 -8
- package/src/models/concepts/SourceReferenceModel.js +7 -1
- package/src/models/concepts/__mock__/related_concepts_data.json +871 -755
- package/src/models/concepts/__tests__/RelatedConcepts.spec.js +6 -8
- package/src/models/concepts/__tests__/SourceReferenceModel.spec.js +3 -3
- package/src/models/content/ContentLinkModel.js +1 -1
- package/src/models/content/__tests__/Formalsource.spec.js +30 -0
- package/src/models/types.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
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.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.1...v1.62.2) (2025-06-04)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **content-link:** don't add complete on sections ([413c23a](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/413c23a6a62290969d5628f24ca346d86f13510d))
|
|
11
|
+
* **sources:** update format of fragments on content ([7e38a81](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/7e38a814c83d40816c527215127f4939479d65e3))
|
|
12
|
+
|
|
5
13
|
## [1.62.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.62.0...v1.62.1) (2025-06-04)
|
|
6
14
|
|
|
7
15
|
|
|
@@ -64,6 +64,9 @@ export default class ConceptLinkModel extends BaseModel {
|
|
|
64
64
|
*
|
|
65
65
|
*/
|
|
66
66
|
get modelCategory(): string;
|
|
67
|
+
/**
|
|
68
|
+
*/
|
|
69
|
+
get sectionId(): string;
|
|
67
70
|
/**
|
|
68
71
|
*
|
|
69
72
|
*/
|
|
@@ -75,11 +78,5 @@ import ConceptTypeDetailModel from "./ConceptTypeDetailModel";
|
|
|
75
78
|
import LinkModel from "../links/LinkModel";
|
|
76
79
|
import { ModularUIModel } from "../types";
|
|
77
80
|
import Href from "../href/Href";
|
|
78
|
-
|
|
79
|
-
sectionId: string;
|
|
80
|
-
text: string;
|
|
81
|
-
startOffset: number;
|
|
82
|
-
endOffset: number;
|
|
83
|
-
};
|
|
81
|
+
import { SectionFragment } from "../types";
|
|
84
82
|
import { ModelOptions } from "../types";
|
|
85
|
-
export {};
|
|
@@ -148,11 +148,17 @@ export default class ConceptLinkModel extends BaseModel {
|
|
|
148
148
|
return this.getData("modelCategory");
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
/**
|
|
152
|
+
*/
|
|
153
|
+
get sectionId() {
|
|
154
|
+
return this.data.section?._id;
|
|
155
|
+
}
|
|
156
|
+
|
|
151
157
|
/**
|
|
152
158
|
*
|
|
153
159
|
*/
|
|
154
160
|
get fragment() {
|
|
155
|
-
return this.
|
|
161
|
+
return this.data.section?.fragment;
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
164
|
//# sourceMappingURL=ConceptLinkModel.js.map
|
|
@@ -9,16 +9,10 @@ import type {
|
|
|
9
9
|
IModelWithChildModels,
|
|
10
10
|
ModelOptions,
|
|
11
11
|
ModularUIModel,
|
|
12
|
+
SectionFragment,
|
|
12
13
|
} from "../types";
|
|
13
14
|
import type Href from "../href/Href";
|
|
14
15
|
|
|
15
|
-
type SectionFragment = {
|
|
16
|
-
sectionId: string,
|
|
17
|
-
text: string,
|
|
18
|
-
startOffset: number,
|
|
19
|
-
endOffset: number,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
16
|
/**
|
|
23
17
|
* Link to a concept
|
|
24
18
|
*/
|
|
@@ -199,10 +193,16 @@ export default class ConceptLinkModel
|
|
|
199
193
|
return this.getData("modelCategory");
|
|
200
194
|
}
|
|
201
195
|
|
|
196
|
+
/**
|
|
197
|
+
*/
|
|
198
|
+
get sectionId(): string {
|
|
199
|
+
return this.data.section?._id;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
202
|
/**
|
|
203
203
|
*
|
|
204
204
|
*/
|
|
205
205
|
get fragment(): SectionFragment {
|
|
206
|
-
return this.
|
|
206
|
+
return this.data.section?.fragment;
|
|
207
207
|
}
|
|
208
208
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptLinkModel.js","names":["BaseModel","LinkModel","LinkCollection","ConceptTypeDetailModel","TIMEVERSION_FILTER_NAME","ConceptLinkModel","constructor","data","entryDate","arguments","length","undefined","modelOptions","_defineProperty","_entryDate","getInitialChildModelLinks","conceptTypeLink","isCacheable","setChildModels","models","href","conceptTypeModel","_findInstanceProperty","call","model","selfhref","equalsWithParameters","type","conceptType","_conceptType","key","_id","label","getData","links","_links","Array","isArray","selflink","getLinkByKey","Error","addParameter","concepttypeHref","taxonomyType","asLinkModel","link","create","isOfConceptType","conceptTypeId","modelCategory","fragment"],"sources":["../../../src/models/concepts/ConceptLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport ConceptTypeDetailModel from \"./ConceptTypeDetailModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type {\n IModelWithChildModels,\n ModelOptions,\n ModularUIModel,\n} from \"../types\";\nimport type Href from \"../href/Href\";\n\
|
|
1
|
+
{"version":3,"file":"ConceptLinkModel.js","names":["BaseModel","LinkModel","LinkCollection","ConceptTypeDetailModel","TIMEVERSION_FILTER_NAME","ConceptLinkModel","constructor","data","entryDate","arguments","length","undefined","modelOptions","_defineProperty","_entryDate","getInitialChildModelLinks","conceptTypeLink","isCacheable","setChildModels","models","href","conceptTypeModel","_findInstanceProperty","call","model","selfhref","equalsWithParameters","type","conceptType","_conceptType","key","_id","label","getData","links","_links","Array","isArray","selflink","getLinkByKey","Error","addParameter","concepttypeHref","taxonomyType","asLinkModel","link","create","isOfConceptType","conceptTypeId","modelCategory","sectionId","section","fragment"],"sources":["../../../src/models/concepts/ConceptLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport ConceptTypeDetailModel from \"./ConceptTypeDetailModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type {\n IModelWithChildModels,\n ModelOptions,\n ModularUIModel,\n SectionFragment,\n} from \"../types\";\nimport type Href from \"../href/Href\";\n\n/**\n * Link to a concept\n */\nexport default class ConceptLinkModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _links: ?LinkCollection;\n _entryDate: ?ISO_DATE;\n _conceptType: ?ConceptTypeDetailModel;\n\n /**\n * Construct ConceptLinkModel\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 getInitialChildModelLinks(): Array<LinkModel> {\n if (this.conceptTypeLink) {\n this.conceptTypeLink.isCacheable = true;\n return [this.conceptTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n if (this.conceptTypeLink) {\n const href = this.conceptTypeLink.href;\n const conceptTypeModel = models.find((model) =>\n model.selfhref.equalsWithParameters(href),\n );\n\n if (conceptTypeModel?.type === \"ConceptTypeDetail\") {\n this.conceptType = conceptTypeModel;\n }\n }\n }\n\n /**\n * Retrieve concept type\n */\n get conceptType(): ?ConceptTypeDetailModel {\n return this._conceptType;\n }\n\n /**\n * Set concept type\n */\n set conceptType(conceptType: ?ModularUIModel) {\n this._conceptType =\n conceptType instanceof ConceptTypeDetailModel ? conceptType : null;\n }\n\n /**\n * Retrieve key\n */\n get key(): string {\n return this.data._id;\n }\n\n /**\n * Retrieve label\n */\n get label(): string {\n const label = this.getData(\"label\");\n\n if (label) {\n return label;\n }\n\n return this.getData(\"conceptLabel\", \"\");\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 const selflink = this.links.getLinkByKey(\"self\");\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 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 conceptTypeLink(): LinkModel | null {\n return this.links.getLinkByKey(\"concepttype\");\n }\n\n /**\n * Concept type href of concept\n */\n get concepttypeHref(): Href | null {\n return this.conceptTypeLink?.href ?? null;\n }\n\n /**\n */\n get taxonomyType(): string {\n return \"default\";\n }\n\n /**\n */\n asLinkModel(): LinkModel {\n const link = LinkModel.create(\n this.key,\n this.selfhref.href,\n this.label,\n this.modelOptions,\n );\n link.href = this.selfhref;\n\n return link;\n }\n\n /**\n * Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept\n */\n isOfConceptType(conceptTypeId: string): boolean {\n return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;\n }\n\n /**\n *\n */\n get modelCategory(): string {\n return this.getData(\"modelCategory\");\n }\n\n /**\n */\n get sectionId(): string {\n return this.data.section?._id;\n }\n\n /**\n *\n */\n get fragment(): SectionFragment {\n return this.data.section?.fragment;\n }\n}\n"],"mappings":";;AACA,OAAOA,SAAS,MAAM,mBAAmB;AACzC,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,OAAOC,cAAc,MAAM,yBAAyB;AACpD,OAAOC,sBAAsB,MAAM,0BAA0B;AAC7D,SAASC,uBAAuB,QAAQ,2BAA2B;AAUnE;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAC3BL,SAAS,CAEnB;EAKE;AACF;AACA;EACEM,WAAWA,CACTC,IAAY,EAGZ;IAAA,IAFAC,SAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,M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C;;EAEA;AACF;AACA;EACE,IAAIG,eAAeA,CAAA,EAAgB;IACjC,OAAO,IAAI,CAAC1B,eAAe,EAAEI,IAAI,IAAI,IAAI;EAC3C;;EAEA;AACF;EACE,IAAIuB,YAAYA,CAAA,EAAW;IACzB,OAAO,SAAS;EAClB;;EAEA;AACF;EACEC,WAAWA,CAAA,EAAc;IACvB,MAAMC,IAAI,GAAG5C,SAAS,CAAC6C,MAAM,CAC3B,IAAI,CAAChB,GAAG,EACR,IAAI,CAACL,QAAQ,CAACL,IAAI,EAClB,IAAI,CAACY,KAAK,EACV,IAAI,CAACpB,YACP,CAAC;IACDiC,IAAI,CAACzB,IAAI,GAAG,IAAI,CAACK,QAAQ;IAEzB,OAAOoB,IAAI;EACb;;EAEA;AACF;AACA;EACEE,eAAeA,CAACC,aAAqB,EAAW;IAC9C,OAAO,IAAI,CAACpB,WAAW,EAAEmB,eAAe,CAACC,aAAa,CAAC,IAAI,KAAK;EAClE;;EAEA;AACF;AACA;EACE,IAAIC,aAAaA,CAAA,EAAW;IAC1B,OAAO,IAAI,CAAChB,OAAO,CAAC,eAAe,CAAC;EACtC;;EAEA;AACF;EACE,IAAIiB,SAASA,CAAA,EAAW;IACtB,OAAO,IAAI,CAAC3C,IAAI,CAAC4C,OAAO,EAAEpB,GAAG;EAC/B;;EAEA;AACF;AACA;EACE,IAAIqB,QAAQA,CAAA,EAAoB;IAC9B,OAAO,IAAI,CAAC7C,IAAI,CAAC4C,OAAO,EAAEC,QAAQ;EACpC;AACF","ignoreList":[]}
|
|
@@ -25,7 +25,7 @@ class SourceReferenceModel {
|
|
|
25
25
|
/**
|
|
26
26
|
*/
|
|
27
27
|
get link() {
|
|
28
|
-
const section = this.
|
|
28
|
+
const section = this.sectionId || this._sourceReference._links.self.href.replace(`${this._sourceReference._links.content.href}/`, "");
|
|
29
29
|
return new ContentLinkModel({
|
|
30
30
|
...this._sourceReference,
|
|
31
31
|
section
|
|
@@ -69,6 +69,12 @@ class SourceReferenceModel {
|
|
|
69
69
|
return createHashFromHref(this.selfhref);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
*/
|
|
74
|
+
get sectionId() {
|
|
75
|
+
return this._sourceReference.sectionId;
|
|
76
|
+
}
|
|
77
|
+
|
|
72
78
|
/**
|
|
73
79
|
*
|
|
74
80
|
*/
|
|
@@ -32,7 +32,7 @@ class SourceReferenceModel {
|
|
|
32
32
|
*/
|
|
33
33
|
get link(): ContentLinkModel {
|
|
34
34
|
const section =
|
|
35
|
-
this.
|
|
35
|
+
this.sectionId ||
|
|
36
36
|
this._sourceReference._links.self.href.replace(
|
|
37
37
|
`${this._sourceReference._links.content.href}/`,
|
|
38
38
|
"",
|
|
@@ -85,6 +85,12 @@ class SourceReferenceModel {
|
|
|
85
85
|
return createHashFromHref(this.selfhref);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
*/
|
|
90
|
+
get sectionId(): string {
|
|
91
|
+
return this._sourceReference.sectionId;
|
|
92
|
+
}
|
|
93
|
+
|
|
88
94
|
/**
|
|
89
95
|
*
|
|
90
96
|
*/
|
|
@@ -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","
|
|
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,SAAo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AAO,IAAI,CAACjB,gBAAgB,CAACiB,kBAAkB;EACjD;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAW;IAC1B,OAAO/B,kBAAkB,CAAC,IAAI,CAAC0B,QAAQ,CAAC;EAC1C;;EAEA;AACF;EACE,IAAIN,SAASA,CAAA,EAAW;IACtB,OAAO,IAAI,CAACP,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":[]}
|
|
@@ -9,10 +9,10 @@ describe("Related concepts", () => {
|
|
|
9
9
|
|
|
10
10
|
expect(relatedConcepts.label).toBe("Related concepts of content");
|
|
11
11
|
expect(relatedConcepts.selfhref.toString()).toBe(
|
|
12
|
-
"/content/bundle-com.beinformed.source.Highlevelrequirements/ResearchGrant/High%20level%20requirements.formalsource/relatedConcepts?entryDate=2025-06-
|
|
12
|
+
"/content/bundle-com.beinformed.source.Highlevelrequirements/ResearchGrant/High%20level%20requirements.formalsource/relatedConcepts?entryDate=2025-06-04",
|
|
13
13
|
);
|
|
14
14
|
|
|
15
|
-
expect(relatedConcepts.entryDate).toBe("2025-06-
|
|
15
|
+
expect(relatedConcepts.entryDate).toBe("2025-06-04");
|
|
16
16
|
expect(relatedConcepts.modelCategoryFilter.label).toBe("Model category");
|
|
17
17
|
|
|
18
18
|
expect(relatedConcepts.items.size).toBe(116);
|
|
@@ -26,16 +26,14 @@ describe("Related concepts", () => {
|
|
|
26
26
|
);
|
|
27
27
|
expect(firstItem.modelCategory).toBe("Requirements");
|
|
28
28
|
expect(firstItem.selfhref.toString()).toBe(
|
|
29
|
-
"/concepts/bundle-com.beinformed.frames.ResearchGrantRequirements/frames.beimodel.json/SystemMustSendAutomatedNotificationsForStatusChanges?entryDate=2025-06-
|
|
29
|
+
"/concepts/bundle-com.beinformed.frames.ResearchGrantRequirements/frames.beimodel.json/SystemMustSendAutomatedNotificationsForStatusChanges?entryDate=2025-06-04",
|
|
30
30
|
);
|
|
31
31
|
expect(firstItem.conceptTypeLink.href.toString()).toBe(
|
|
32
32
|
"/concepttypes/bundle-com.beinformed.research.grant.metamodels/High%20level%20requirements.bixml/ArchitecturalSignificantRequirement",
|
|
33
33
|
);
|
|
34
34
|
|
|
35
|
-
expect(firstItem.
|
|
36
|
-
|
|
37
|
-
);
|
|
38
|
-
expect(firstItem.fragment.text).toBeUndefined();
|
|
35
|
+
expect(firstItem.sectionId).toBe("AutomatedNotifications_Requirement");
|
|
36
|
+
expect(firstItem.fragment).toBeUndefined();
|
|
39
37
|
|
|
40
38
|
const secondItem = relatedConcepts.items.get(1);
|
|
41
39
|
|
|
@@ -48,7 +46,7 @@ describe("Related concepts", () => {
|
|
|
48
46
|
|
|
49
47
|
expect(secondItem.modelCategory).toBe("Requirements");
|
|
50
48
|
|
|
51
|
-
expect(secondItem.
|
|
49
|
+
expect(secondItem.sectionId).toBe(
|
|
52
50
|
"MaximumFlexibilityWithinPolicyConstraints",
|
|
53
51
|
);
|
|
54
52
|
expect(secondItem.fragment.text).toBe(
|
|
@@ -14,8 +14,8 @@ const data = {
|
|
|
14
14
|
href: "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource",
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
|
+
sectionId: "Chapter4",
|
|
17
18
|
sectionFragment: {
|
|
18
|
-
sectionId: "Chapter4",
|
|
19
19
|
text: "Research Grant",
|
|
20
20
|
startOffset: 32,
|
|
21
21
|
endOffset: 18,
|
|
@@ -39,6 +39,8 @@ describe("sourceReferenceModel", () => {
|
|
|
39
39
|
expect(sourceReference.type).toBe("Reference");
|
|
40
40
|
expect(sourceReference.sourceAbbreviation).toBe("GFA-TC-01");
|
|
41
41
|
expect(sourceReference.referenceHash).toBe(10443215482258);
|
|
42
|
+
|
|
43
|
+
expect(sourceReference.sectionId).toBe("Chapter4");
|
|
42
44
|
expect(sourceReference.fragment.text).toBe("Research Grant");
|
|
43
45
|
expect(sourceReference.fragment.startOffset).toBe(32);
|
|
44
46
|
expect(sourceReference.fragment.endOffset).toBe(18);
|
|
@@ -60,7 +62,6 @@ describe("sourceReferenceModel", () => {
|
|
|
60
62
|
contextPath: "/BeInformed",
|
|
61
63
|
fragment: {
|
|
62
64
|
endOffset: 18,
|
|
63
|
-
sectionId: "Chapter4",
|
|
64
65
|
startOffset: 32,
|
|
65
66
|
text: "Research Grant",
|
|
66
67
|
},
|
|
@@ -95,7 +96,6 @@ describe("sourceReferenceModel", () => {
|
|
|
95
96
|
contextPath: "/BeInformed",
|
|
96
97
|
fragment: {
|
|
97
98
|
endOffset: 18,
|
|
98
|
-
sectionId: "Chapter4",
|
|
99
99
|
startOffset: 32,
|
|
100
100
|
text: "Research Grant",
|
|
101
101
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
2
|
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
3
|
+
import _endsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/ends-with";
|
|
3
4
|
import BaseModel from "../base/BaseModel";
|
|
4
5
|
import Href from "../href/Href";
|
|
5
6
|
import LinkModel from "../links/LinkModel";
|
|
@@ -140,10 +141,11 @@ export default class ContentLinkModel extends BaseModel {
|
|
|
140
141
|
get selflink() {
|
|
141
142
|
let selflink = this.links.getLinkByKey("self");
|
|
142
143
|
if (getSetting("COMPLETE_SOURCE", false)) {
|
|
144
|
+
var _context;
|
|
143
145
|
if (this.links.hasLinkByKey("content")) {
|
|
144
146
|
selflink = this.links.getLinkByKey("content");
|
|
145
147
|
}
|
|
146
|
-
if (selflink != null) {
|
|
148
|
+
if (selflink != null && !_endsWithInstanceProperty(_context = selflink.href.path).call(_context, this.data.section)) {
|
|
147
149
|
selflink.href.addParameter("complete", "true");
|
|
148
150
|
selflink.href.hash = this.data.section;
|
|
149
151
|
}
|
|
@@ -183,7 +183,7 @@ export default class ContentLinkModel
|
|
|
183
183
|
selflink = this.links.getLinkByKey("content");
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
if (selflink != null) {
|
|
186
|
+
if (selflink != null && !selflink.href.path.endsWith(this.data.section)) {
|
|
187
187
|
selflink.href.addParameter("complete", "true");
|
|
188
188
|
selflink.href.hash = this.data.section;
|
|
189
189
|
}
|
|
@@ -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","hasLinkByKey","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) {\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<ContentLin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AEA;AACF;EACE,IAAIsC,YAAYA,CAAA,EAAW;IACzB,OAAO,IAAI,CAACjC,QAAQ,CAAC6B,IAAI;EAC3B;;EAEA;AACF;EACE,IAAItC,eAAeA,CAAA,EAAqB;IACtC,OAAO,IAAI,CAACgC,KAAK,CAACI,YAAY,CAAC,aAAa,CAAC;EAC/C;;EAEA;AACF;AACA;EACE,IAAIO,eAAeA,CAAA,EAAgB;IACjC,IAAI,IAAI,CAAC3C,eAAe,EAAE;MACxB,OAAO,IAAI,CAACA,eAAe,CAACI,IAAI;IAClC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAIqC,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAAClD,IAAI,CAACqD,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","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,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;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA,uBAVQ,IAAI;IAAAA,eAAA;IAY1C,IAAI,CAACC,UAAU,GAAGN,SAAS;EAC7B;;EAEA;AACF;EACE;EACAO,yBAAyBA,CAAA,EAAqB;IAC5C,IAAI,IAAI,CAACC,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7 @@ import sectionContributions from "./formalsource-section-contributions.json";
|
|
|
9
9
|
|
|
10
10
|
import ContentTOCModel from "../ContentTOCModel";
|
|
11
11
|
import ContentModel from "../ContentModel";
|
|
12
|
+
import { setSetting } from "../../../constants";
|
|
12
13
|
|
|
13
14
|
describe("formalsource", () => {
|
|
14
15
|
it("TOC model", () => {
|
|
@@ -37,6 +38,8 @@ describe("formalsource", () => {
|
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
it("Complete model", () => {
|
|
41
|
+
setSetting("COMPLETE_SOURCE", true);
|
|
42
|
+
|
|
40
43
|
const response = ModularUIResponse.create({
|
|
41
44
|
key: "contentmodel",
|
|
42
45
|
data: complete,
|
|
@@ -62,6 +65,9 @@ describe("formalsource", () => {
|
|
|
62
65
|
expect(completeModel.isCompleteSource).toBe(true);
|
|
63
66
|
|
|
64
67
|
const firstSection = completeModel.sections[0];
|
|
68
|
+
expect(firstSection.selfhref.toString()).toBe(
|
|
69
|
+
"/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/Chapter1",
|
|
70
|
+
);
|
|
65
71
|
expect(firstSection.label).toBe("Introduction");
|
|
66
72
|
expect(firstSection.number).toBe("1.");
|
|
67
73
|
expect(firstSection.body).toBe(null);
|
|
@@ -75,6 +81,8 @@ describe("formalsource", () => {
|
|
|
75
81
|
expect(secondSection.sections[0].label).toBe("Payment of Grant");
|
|
76
82
|
expect(secondSection.sections[0].number).toBe("2.1");
|
|
77
83
|
expect(secondSection.sections[0].body).toHaveLength(222);
|
|
84
|
+
|
|
85
|
+
setSetting("COMPLETE_SOURCE", false);
|
|
78
86
|
});
|
|
79
87
|
|
|
80
88
|
it("Section model", () => {
|
|
@@ -92,4 +100,26 @@ describe("formalsource", () => {
|
|
|
92
100
|
|
|
93
101
|
expect(sectionModel.childSectionLinks).toHaveLength(2);
|
|
94
102
|
});
|
|
103
|
+
|
|
104
|
+
it("Can handle complete sources setting", () => {
|
|
105
|
+
setSetting("COMPLETE_SOURCE", true);
|
|
106
|
+
|
|
107
|
+
const response = ModularUIResponse.create({
|
|
108
|
+
key: "contentmodel",
|
|
109
|
+
data: section,
|
|
110
|
+
contributions: sectionContributions,
|
|
111
|
+
});
|
|
112
|
+
const sectionModel = new ContentModel(response);
|
|
113
|
+
|
|
114
|
+
expect(sectionModel.subSections).toHaveLength(0);
|
|
115
|
+
expect(sectionModel.childSectionLinks).toHaveLength(2);
|
|
116
|
+
|
|
117
|
+
const firstChildSection = sectionModel.childSectionLinks[0];
|
|
118
|
+
expect(firstChildSection.label).toBe("2.1 Payment of Grant");
|
|
119
|
+
expect(firstChildSection.selfhref.toString()).toBe(
|
|
120
|
+
"/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/Chapter2_1?entryDate=2025-05-28",
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
setSetting("COMPLETE_SOURCE", false);
|
|
124
|
+
});
|
|
95
125
|
});
|
package/esm/models/types.d.ts
CHANGED
package/esm/models/types.js.flow
CHANGED
package/esm/models/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/models/types.js"],"sourcesContent":["// @flow\nimport type ApplicationModel from \"./application/ApplicationModel\";\nimport type BooleanAttributeModel from \"./attributes/BooleanAttributeModel\";\nimport type CaptchaAttributeModel from \"./attributes/CaptchaAttributeModel\";\nimport type ChoiceAttributeModel from \"./attributes/ChoiceAttributeModel\";\nimport type CompositeAttributeModel from \"./attributes/CompositeAttributeModel\";\nimport type DatetimeAttributeModel from \"./attributes/DatetimeAttributeModel\";\nimport type HelptextAttributeModel from \"./attributes/HelptextAttributeModel\";\nimport type LabelAttributeModel from \"./attributes/LabelAttributeModel\";\nimport type MemoAttributeModel from \"./attributes/MemoAttributeModel\";\nimport type MoneyAttributeModel from \"./attributes/MoneyAttributeModel\";\nimport type NumberAttributeModel from \"./attributes/NumberAttributeModel\";\nimport type PasswordAttributeModel from \"./attributes/PasswordAttributeModel\";\nimport type StringAttributeModel from \"./attributes/StringAttributeModel\";\nimport type UploadAttributeModel from \"./attributes/UploadAttributeModel\";\nimport type XMLAttributeModel from \"./attributes/XMLAttributeModel\";\nimport type CaseViewModel from \"./caseview/CaseViewModel\";\nimport type BusinessScenarioModel from \"./concepts/BusinessScenarioModel\";\nimport type ConceptDetailModel from \"./concepts/ConceptDetailModel\";\nimport type ConceptIndexModel from \"./concepts/ConceptIndexModel\";\nimport type ConceptTypeDetailModel from \"./concepts/ConceptTypeDetailModel\";\nimport type ContentIndexModel from \"./content/ContentIndexModel\";\nimport type ContentModel from \"./content/ContentModel\";\nimport type SectionModel from \"./content/SectionModel\";\nimport type ContentTOCModel from \"./content/ContentTOCModel\";\nimport type ContentTypeModel from \"./content/ContentTypeModel\";\nimport type DetailModel from \"./detail/DetailModel\";\nimport type AssignmentFilterModel from \"./filters/AssignmentFilterModel\";\nimport type FilterModel from \"./filters/FilterModel\";\nimport type RangeFilterModel from \"./filters/RangeFilterModel\";\nimport type ConceptIndexFilterModel from \"./filters/ConceptIndexFilterModel\";\nimport type FormModel from \"./form/FormModel\";\nimport type ListDetailModel from \"./list/ListDetailModel\";\nimport type ListModel from \"./list/ListModel\";\nimport type ModelCatalogModel from \"./modelcatalog/ModelCatalogModel\";\nimport type GroupingPanelModel from \"./panels/GroupingPanelModel\";\nimport type CaseSearchModel from \"./search/CaseSearchModel\";\nimport type TabModel from \"./tab/TabModel\";\nimport type TaskGroupModel from \"./taskgroup/TaskGroupModel\";\nimport type UserModel from \"./user/UserModel\";\nimport type UserServicesModel from \"./user/UserServicesModel\";\nimport type LinkModel from \"./links/LinkModel\";\nimport type LookupOptionsModel from \"./lookup/LookupOptionsModel\";\nimport type BaseFilterModel from \"./filters/BaseFilterModel\";\nimport type AttributeCollection from \"./attributes/AttributeCollection\";\nimport type AttributeModel from \"./attributes/AttributeModel\";\nimport type LayoutHintCollection from \"./layouthint/LayoutHintCollection\";\nimport type ErrorResponse from \"./error/ErrorResponse\";\n\nexport type ModularUIModel =\n | ApplicationModel\n | CaseSearchModel\n | CaseViewModel\n | ListDetailModel\n | DetailModel\n | FormModel\n | GroupingPanelModel\n | ListModel\n | TabModel\n | TaskGroupModel\n | UserModel\n | UserServicesModel\n | ModelCatalogModel\n | ConceptIndexModel\n | ConceptDetailModel\n | BusinessScenarioModel\n | ConceptTypeDetailModel\n | ContentIndexModel\n | ContentTOCModel\n | ContentModel\n | ContentTypeModel\n | LookupOptionsModel;\n\nexport type AttributeType =\n | BooleanAttributeModel\n | CaptchaAttributeModel\n | ChoiceAttributeModel\n | DatetimeAttributeModel\n | HelptextAttributeModel\n | LabelAttributeModel\n | MemoAttributeModel\n | MoneyAttributeModel\n | NumberAttributeModel\n | PasswordAttributeModel\n | CompositeAttributeModel\n | StringAttributeModel\n | UploadAttributeModel\n | XMLAttributeModel;\n\nexport type RangeChildAttributeType =\n | NumberAttributeModel\n | DatetimeAttributeModel;\n\nexport type FilterType =\n | BaseFilterModel\n | FilterModel\n | AssignmentFilterModel\n | RangeFilterModel\n | ConceptIndexFilterModel;\n\nexport type FormErrorAnchor = {\n id: string,\n properties?: {\n [propertyName: string]: string | number,\n },\n anchor?: {\n objectid: string,\n elementid?: string,\n _links?: Object,\n index?: number,\n \"index-identifier\"?: string,\n },\n layouthint: LayoutHintCollection,\n message: string,\n param?: {\n name: string,\n },\n};\n\nexport type labelsJSON = {\n _id: string,\n label: string,\n value: string,\n};\n\nexport type propertyJSON = {\n _id: string,\n type: string,\n mandatory: string,\n label: string,\n value: string,\n};\n\nexport type textfragmentJSON = {\n label: string,\n text: string,\n type: string,\n};\n\nexport interface IConstraintModel {\n +id: string;\n +defaultMessage: string;\n +parameters: Object;\n +isMandatoryConstraint: boolean;\n validate(value: any): boolean;\n hasValidation(): boolean;\n}\n\nexport interface ILayoutHintRule {\n process(attribute: AttributeModel, attributes: AttributeCollection): void;\n}\n\nexport interface IModelWithChildModels {\n getInitialChildModelLinks(): Array<LinkModel>;\n setChildModels(\n models: Array<ModularUIModel>,\n errors: Array<ErrorResponse>,\n ): void;\n}\n\nexport type AuthenticationType = {\n name: string,\n authentication: string,\n redirectUri?: string,\n isPrimary: boolean,\n};\n\nexport type FileEntryType = {\n name: string,\n size?: number,\n progress: number,\n error?: string,\n token?: string,\n};\n\nexport type FilesType = {\n [filename: string]: FileEntryType,\n};\n\nexport type FiletypeConstraintsType = Array<{|\n extensions: Array<string>,\n mimeTypes: Array<string>,\n|}>;\n\nexport type FilesizeConstraintsType = {\n fileSize: ?number,\n maxTotalFileSize: ?number,\n isMaxTotal: boolean,\n};\n\nexport type PropertyData = { type: string, label: string, value: string };\nexport type TextFragmentData = {\n type: string,\n label: string,\n text: string | { id?: string, message: string, properties?: Object },\n};\nexport type SectionData = {\n id: string,\n type: string,\n label?: string,\n number?: string,\n body: string | { id?: string, message: string, properties?: Object },\n _links: { self: { href: string } },\n childSections: Array<SectionData>,\n subSections: Array<SectionData>,\n};\n\nexport type PropertyElement = {\n propertyElement: {\n label: string,\n layouthint: Array<string>,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElement = {\n textFragmentElement: {\n label: string,\n layouthint: Array<string>,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElement = {\n contentElement: {\n label: string,\n layouthint: Array<string>,\n sections: Array<SectionData>,\n },\n};\n\nexport type PropertyElementMapped = {\n propertyElement: {\n label: string,\n layouthint: LayoutHintCollection,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElementMapped = {\n textFragmentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElementMapped = {\n contentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n sections: Array<SectionModel>,\n },\n};\n\nexport type ContentAll = Array<\n PropertyElementMapped | TextFragmentElementMapped | ContentElementMapped,\n>;\n\nexport type ContentData = {\n header: {\n label?: string,\n description?: { id?: string, message: string, properties?: Object },\n },\n label?: string,\n elements: Array<PropertyElement | TextFragmentElement | ContentElement>,\n};\n\nexport type SectionFragment = {\n
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/models/types.js"],"sourcesContent":["// @flow\nimport type ApplicationModel from \"./application/ApplicationModel\";\nimport type BooleanAttributeModel from \"./attributes/BooleanAttributeModel\";\nimport type CaptchaAttributeModel from \"./attributes/CaptchaAttributeModel\";\nimport type ChoiceAttributeModel from \"./attributes/ChoiceAttributeModel\";\nimport type CompositeAttributeModel from \"./attributes/CompositeAttributeModel\";\nimport type DatetimeAttributeModel from \"./attributes/DatetimeAttributeModel\";\nimport type HelptextAttributeModel from \"./attributes/HelptextAttributeModel\";\nimport type LabelAttributeModel from \"./attributes/LabelAttributeModel\";\nimport type MemoAttributeModel from \"./attributes/MemoAttributeModel\";\nimport type MoneyAttributeModel from \"./attributes/MoneyAttributeModel\";\nimport type NumberAttributeModel from \"./attributes/NumberAttributeModel\";\nimport type PasswordAttributeModel from \"./attributes/PasswordAttributeModel\";\nimport type StringAttributeModel from \"./attributes/StringAttributeModel\";\nimport type UploadAttributeModel from \"./attributes/UploadAttributeModel\";\nimport type XMLAttributeModel from \"./attributes/XMLAttributeModel\";\nimport type CaseViewModel from \"./caseview/CaseViewModel\";\nimport type BusinessScenarioModel from \"./concepts/BusinessScenarioModel\";\nimport type ConceptDetailModel from \"./concepts/ConceptDetailModel\";\nimport type ConceptIndexModel from \"./concepts/ConceptIndexModel\";\nimport type ConceptTypeDetailModel from \"./concepts/ConceptTypeDetailModel\";\nimport type ContentIndexModel from \"./content/ContentIndexModel\";\nimport type ContentModel from \"./content/ContentModel\";\nimport type SectionModel from \"./content/SectionModel\";\nimport type ContentTOCModel from \"./content/ContentTOCModel\";\nimport type ContentTypeModel from \"./content/ContentTypeModel\";\nimport type DetailModel from \"./detail/DetailModel\";\nimport type AssignmentFilterModel from \"./filters/AssignmentFilterModel\";\nimport type FilterModel from \"./filters/FilterModel\";\nimport type RangeFilterModel from \"./filters/RangeFilterModel\";\nimport type ConceptIndexFilterModel from \"./filters/ConceptIndexFilterModel\";\nimport type FormModel from \"./form/FormModel\";\nimport type ListDetailModel from \"./list/ListDetailModel\";\nimport type ListModel from \"./list/ListModel\";\nimport type ModelCatalogModel from \"./modelcatalog/ModelCatalogModel\";\nimport type GroupingPanelModel from \"./panels/GroupingPanelModel\";\nimport type CaseSearchModel from \"./search/CaseSearchModel\";\nimport type TabModel from \"./tab/TabModel\";\nimport type TaskGroupModel from \"./taskgroup/TaskGroupModel\";\nimport type UserModel from \"./user/UserModel\";\nimport type UserServicesModel from \"./user/UserServicesModel\";\nimport type LinkModel from \"./links/LinkModel\";\nimport type LookupOptionsModel from \"./lookup/LookupOptionsModel\";\nimport type BaseFilterModel from \"./filters/BaseFilterModel\";\nimport type AttributeCollection from \"./attributes/AttributeCollection\";\nimport type AttributeModel from \"./attributes/AttributeModel\";\nimport type LayoutHintCollection from \"./layouthint/LayoutHintCollection\";\nimport type ErrorResponse from \"./error/ErrorResponse\";\n\nexport type ModularUIModel =\n | ApplicationModel\n | CaseSearchModel\n | CaseViewModel\n | ListDetailModel\n | DetailModel\n | FormModel\n | GroupingPanelModel\n | ListModel\n | TabModel\n | TaskGroupModel\n | UserModel\n | UserServicesModel\n | ModelCatalogModel\n | ConceptIndexModel\n | ConceptDetailModel\n | BusinessScenarioModel\n | ConceptTypeDetailModel\n | ContentIndexModel\n | ContentTOCModel\n | ContentModel\n | ContentTypeModel\n | LookupOptionsModel;\n\nexport type AttributeType =\n | BooleanAttributeModel\n | CaptchaAttributeModel\n | ChoiceAttributeModel\n | DatetimeAttributeModel\n | HelptextAttributeModel\n | LabelAttributeModel\n | MemoAttributeModel\n | MoneyAttributeModel\n | NumberAttributeModel\n | PasswordAttributeModel\n | CompositeAttributeModel\n | StringAttributeModel\n | UploadAttributeModel\n | XMLAttributeModel;\n\nexport type RangeChildAttributeType =\n | NumberAttributeModel\n | DatetimeAttributeModel;\n\nexport type FilterType =\n | BaseFilterModel\n | FilterModel\n | AssignmentFilterModel\n | RangeFilterModel\n | ConceptIndexFilterModel;\n\nexport type FormErrorAnchor = {\n id: string,\n properties?: {\n [propertyName: string]: string | number,\n },\n anchor?: {\n objectid: string,\n elementid?: string,\n _links?: Object,\n index?: number,\n \"index-identifier\"?: string,\n },\n layouthint: LayoutHintCollection,\n message: string,\n param?: {\n name: string,\n },\n};\n\nexport type labelsJSON = {\n _id: string,\n label: string,\n value: string,\n};\n\nexport type propertyJSON = {\n _id: string,\n type: string,\n mandatory: string,\n label: string,\n value: string,\n};\n\nexport type textfragmentJSON = {\n label: string,\n text: string,\n type: string,\n};\n\nexport interface IConstraintModel {\n +id: string;\n +defaultMessage: string;\n +parameters: Object;\n +isMandatoryConstraint: boolean;\n validate(value: any): boolean;\n hasValidation(): boolean;\n}\n\nexport interface ILayoutHintRule {\n process(attribute: AttributeModel, attributes: AttributeCollection): void;\n}\n\nexport interface IModelWithChildModels {\n getInitialChildModelLinks(): Array<LinkModel>;\n setChildModels(\n models: Array<ModularUIModel>,\n errors: Array<ErrorResponse>,\n ): void;\n}\n\nexport type AuthenticationType = {\n name: string,\n authentication: string,\n redirectUri?: string,\n isPrimary: boolean,\n};\n\nexport type FileEntryType = {\n name: string,\n size?: number,\n progress: number,\n error?: string,\n token?: string,\n};\n\nexport type FilesType = {\n [filename: string]: FileEntryType,\n};\n\nexport type FiletypeConstraintsType = Array<{|\n extensions: Array<string>,\n mimeTypes: Array<string>,\n|}>;\n\nexport type FilesizeConstraintsType = {\n fileSize: ?number,\n maxTotalFileSize: ?number,\n isMaxTotal: boolean,\n};\n\nexport type PropertyData = { type: string, label: string, value: string };\nexport type TextFragmentData = {\n type: string,\n label: string,\n text: string | { id?: string, message: string, properties?: Object },\n};\nexport type SectionData = {\n id: string,\n type: string,\n label?: string,\n number?: string,\n body: string | { id?: string, message: string, properties?: Object },\n _links: { self: { href: string } },\n childSections: Array<SectionData>,\n subSections: Array<SectionData>,\n};\n\nexport type PropertyElement = {\n propertyElement: {\n label: string,\n layouthint: Array<string>,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElement = {\n textFragmentElement: {\n label: string,\n layouthint: Array<string>,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElement = {\n contentElement: {\n label: string,\n layouthint: Array<string>,\n sections: Array<SectionData>,\n },\n};\n\nexport type PropertyElementMapped = {\n propertyElement: {\n label: string,\n layouthint: LayoutHintCollection,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElementMapped = {\n textFragmentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElementMapped = {\n contentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n sections: Array<SectionModel>,\n },\n};\n\nexport type ContentAll = Array<\n PropertyElementMapped | TextFragmentElementMapped | ContentElementMapped,\n>;\n\nexport type ContentData = {\n header: {\n label?: string,\n description?: { id?: string, message: string, properties?: Object },\n },\n label?: string,\n elements: Array<PropertyElement | TextFragmentElement | ContentElement>,\n};\n\nexport type SectionFragment = {\n text: string,\n startOffset: number,\n endOffset: number,\n};\n\nexport type ModelOptions = {\n origin?: ?string,\n contextPath?: ?string,\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -64,6 +64,9 @@ export default class ConceptLinkModel extends BaseModel {
|
|
|
64
64
|
*
|
|
65
65
|
*/
|
|
66
66
|
get modelCategory(): string;
|
|
67
|
+
/**
|
|
68
|
+
*/
|
|
69
|
+
get sectionId(): string;
|
|
67
70
|
/**
|
|
68
71
|
*
|
|
69
72
|
*/
|
|
@@ -75,11 +78,5 @@ import ConceptTypeDetailModel from "./ConceptTypeDetailModel";
|
|
|
75
78
|
import LinkModel from "../links/LinkModel";
|
|
76
79
|
import { ModularUIModel } from "../types";
|
|
77
80
|
import Href from "../href/Href";
|
|
78
|
-
|
|
79
|
-
sectionId: string;
|
|
80
|
-
text: string;
|
|
81
|
-
startOffset: number;
|
|
82
|
-
endOffset: number;
|
|
83
|
-
};
|
|
81
|
+
import { SectionFragment } from "../types";
|
|
84
82
|
import { ModelOptions } from "../types";
|
|
85
|
-
export {};
|
|
@@ -155,11 +155,17 @@ class ConceptLinkModel extends _BaseModel.default {
|
|
|
155
155
|
return this.getData("modelCategory");
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
/**
|
|
159
|
+
*/
|
|
160
|
+
get sectionId() {
|
|
161
|
+
return this.data.section?._id;
|
|
162
|
+
}
|
|
163
|
+
|
|
158
164
|
/**
|
|
159
165
|
*
|
|
160
166
|
*/
|
|
161
167
|
get fragment() {
|
|
162
|
-
return this.
|
|
168
|
+
return this.data.section?.fragment;
|
|
163
169
|
}
|
|
164
170
|
}
|
|
165
171
|
exports.default = ConceptLinkModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptLinkModel.js","names":["_BaseModel","_interopRequireDefault","require","_LinkModel","_LinkCollection","_ConceptTypeDetailModel","_Constants","ConceptLinkModel","BaseModel","constructor","data","entryDate","arguments","length","undefined","modelOptions","_defineProperty2","default","_entryDate","getInitialChildModelLinks","conceptTypeLink","isCacheable","setChildModels","models","href","conceptTypeModel","_find","call","model","selfhref","equalsWithParameters","type","conceptType","_conceptType","ConceptTypeDetailModel","key","_id","label","getData","links","_links","LinkCollection","Array","isArray","selflink","getLinkByKey","Error","addParameter","TIMEVERSION_FILTER_NAME","concepttypeHref","taxonomyType","asLinkModel","link","LinkModel","create","isOfConceptType","conceptTypeId","modelCategory","fragment","exports"],"sources":["../../../src/models/concepts/ConceptLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport ConceptTypeDetailModel from \"./ConceptTypeDetailModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type {\n IModelWithChildModels,\n ModelOptions,\n ModularUIModel,\n} from \"../types\";\nimport type Href from \"../href/Href\";\n\
|
|
1
|
+
{"version":3,"file":"ConceptLinkModel.js","names":["_BaseModel","_interopRequireDefault","require","_LinkModel","_LinkCollection","_ConceptTypeDetailModel","_Constants","ConceptLinkModel","BaseModel","constructor","data","entryDate","arguments","length","undefined","modelOptions","_defineProperty2","default","_entryDate","getInitialChildModelLinks","conceptTypeLink","isCacheable","setChildModels","models","href","conceptTypeModel","_find","call","model","selfhref","equalsWithParameters","type","conceptType","_conceptType","ConceptTypeDetailModel","key","_id","label","getData","links","_links","LinkCollection","Array","isArray","selflink","getLinkByKey","Error","addParameter","TIMEVERSION_FILTER_NAME","concepttypeHref","taxonomyType","asLinkModel","link","LinkModel","create","isOfConceptType","conceptTypeId","modelCategory","sectionId","section","fragment","exports"],"sources":["../../../src/models/concepts/ConceptLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport ConceptTypeDetailModel from \"./ConceptTypeDetailModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type {\n IModelWithChildModels,\n ModelOptions,\n ModularUIModel,\n SectionFragment,\n} from \"../types\";\nimport type Href from \"../href/Href\";\n\n/**\n * Link to a concept\n */\nexport default class ConceptLinkModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _links: ?LinkCollection;\n _entryDate: ?ISO_DATE;\n _conceptType: ?ConceptTypeDetailModel;\n\n /**\n * Construct ConceptLinkModel\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 getInitialChildModelLinks(): Array<LinkModel> {\n if (this.conceptTypeLink) {\n this.conceptTypeLink.isCacheable = true;\n return [this.conceptTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n if (this.conceptTypeLink) {\n const href = this.conceptTypeLink.href;\n const conceptTypeModel = models.find((model) =>\n model.selfhref.equalsWithParameters(href),\n );\n\n if (conceptTypeModel?.type === \"ConceptTypeDetail\") {\n this.conceptType = conceptTypeModel;\n }\n }\n }\n\n /**\n * Retrieve concept type\n */\n get conceptType(): ?ConceptTypeDetailModel {\n return this._conceptType;\n }\n\n /**\n * Set concept type\n */\n set conceptType(conceptType: ?ModularUIModel) {\n this._conceptType =\n conceptType instanceof ConceptTypeDetailModel ? conceptType : null;\n }\n\n /**\n * Retrieve key\n */\n get key(): string {\n return this.data._id;\n }\n\n /**\n * Retrieve label\n */\n get label(): string {\n const label = this.getData(\"label\");\n\n if (label) {\n return label;\n }\n\n return this.getData(\"conceptLabel\", \"\");\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 const selflink = this.links.getLinkByKey(\"self\");\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 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 conceptTypeLink(): LinkModel | null {\n return this.links.getLinkByKey(\"concepttype\");\n }\n\n /**\n * Concept type href of concept\n */\n get concepttypeHref(): Href | null {\n return this.conceptTypeLink?.href ?? null;\n }\n\n /**\n */\n get taxonomyType(): string {\n return \"default\";\n }\n\n /**\n */\n asLinkModel(): LinkModel {\n const link = LinkModel.create(\n this.key,\n this.selfhref.href,\n this.label,\n this.modelOptions,\n );\n link.href = this.selfhref;\n\n return link;\n }\n\n /**\n * Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept\n */\n isOfConceptType(conceptTypeId: string): boolean {\n return this.conceptType?.isOfConceptType(conceptTypeId) ?? false;\n }\n\n /**\n *\n */\n get modelCategory(): string {\n return this.getData(\"modelCategory\");\n }\n\n /**\n */\n get sectionId(): string {\n return this.data.section?._id;\n }\n\n /**\n *\n */\n get fragment(): SectionFragment {\n return this.data.section?.fragment;\n }\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,uBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAUA;AACA;AACA;AACe,MAAMK,gBAAgB,SAC3BC,kBAAS,CAEnB;EAKE;AACF;AACA;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;IAE9B,IAAI,CAACC,UAAU,GAAGP,SAAS;EAC7B;;EAEA;AACF;EACEQ,yBAAyBA,CAAA,EAAqB;IAC5C,IAAI,IAAI,CAACC,eAAe,EAAE;MACxB,IAAI,CAACA,eAAe,CAACC,WAAW,GAAG,IAAI;MACvC,OAAO,CAAC,IAAI,CAACD,eAAe,CAAC;IAC/B;IAEA,OAAO,EAAE;EACX;;EAEA;AACF;EACEE,cAAcA,CAACC,MAA6B,EAAE;IAC5C,IAAI,IAAI,CAACH,eA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