@beinformed/ui 1.62.0 → 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.
Files changed (43) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/esm/constants/Settings.js +2 -1
  3. package/esm/constants/Settings.js.flow +2 -0
  4. package/esm/constants/Settings.js.map +1 -1
  5. package/esm/models/concepts/ConceptLinkModel.d.ts +4 -7
  6. package/esm/models/concepts/ConceptLinkModel.js +7 -1
  7. package/esm/models/concepts/ConceptLinkModel.js.flow +8 -8
  8. package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
  9. package/esm/models/concepts/SourceReferenceModel.d.ts +3 -0
  10. package/esm/models/concepts/SourceReferenceModel.js +8 -2
  11. package/esm/models/concepts/SourceReferenceModel.js.flow +13 -9
  12. package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
  13. package/esm/models/concepts/__tests__/RelatedConcepts.spec.js.flow +6 -8
  14. package/esm/models/concepts/__tests__/SourceReferenceModel.spec.js.flow +72 -31
  15. package/esm/models/content/ContentLinkModel.js +13 -1
  16. package/esm/models/content/ContentLinkModel.js.flow +13 -1
  17. package/esm/models/content/ContentLinkModel.js.map +1 -1
  18. package/esm/models/content/__tests__/Formalsource.spec.js.flow +30 -0
  19. package/esm/models/types.d.ts +0 -1
  20. package/esm/models/types.js.flow +0 -1
  21. package/esm/models/types.js.map +1 -1
  22. package/lib/constants/Settings.js +2 -1
  23. package/lib/constants/Settings.js.map +1 -1
  24. package/lib/models/concepts/ConceptLinkModel.d.ts +4 -7
  25. package/lib/models/concepts/ConceptLinkModel.js +7 -1
  26. package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
  27. package/lib/models/concepts/SourceReferenceModel.d.ts +3 -0
  28. package/lib/models/concepts/SourceReferenceModel.js +8 -2
  29. package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
  30. package/lib/models/content/ContentLinkModel.js +13 -1
  31. package/lib/models/content/ContentLinkModel.js.map +1 -1
  32. package/lib/models/types.d.ts +0 -1
  33. package/lib/models/types.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/constants/Settings.js +2 -0
  36. package/src/models/concepts/ConceptLinkModel.js +8 -8
  37. package/src/models/concepts/SourceReferenceModel.js +13 -9
  38. package/src/models/concepts/__mock__/related_concepts_data.json +871 -755
  39. package/src/models/concepts/__tests__/RelatedConcepts.spec.js +6 -8
  40. package/src/models/concepts/__tests__/SourceReferenceModel.spec.js +72 -31
  41. package/src/models/content/ContentLinkModel.js +13 -1
  42. package/src/models/content/__tests__/Formalsource.spec.js +30 -0
  43. package/src/models/types.js +0 -1
@@ -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-03",
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-03");
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-03",
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.fragment.sectionId).toBe(
36
- "AutomatedNotifications_Requirement",
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.fragment.sectionId).toBe(
49
+ expect(secondItem.sectionId).toBe(
52
50
  "MaximumFlexibilityWithinPolicyConstraints",
53
51
  );
54
52
  expect(secondItem.fragment.text).toBe(
@@ -1,22 +1,24 @@
1
1
  import SourceReferenceModel from "../SourceReferenceModel";
2
+ import { setSetting } from "../../../constants/Settings";
2
3
 
3
4
  const data = {
4
- label: "Requirement: Implement scoring systems based on predefined cr...",
5
+ label: "4. Purpose of Grant",
5
6
  type: "Reference",
6
- sourceLabel: "High level requirements",
7
- sourceAbbreviation: "HLR-01",
7
+ sourceLabel: "Grant Funding Agreement - Terms and Conditions",
8
+ sourceAbbreviation: "GFA-TC-01",
8
9
  _links: {
9
10
  self: {
10
- href: "/content/bundle-com.beinformed.source.Highlevelrequirements/ResearchGrant/High%20level%20requirements.formalsource/ScoringAndEvaluationCriteria#ScoringAndEvaluationCriteria_Requirement",
11
+ href: "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/Chapter4",
11
12
  },
12
13
  content: {
13
- href: "/content/bundle-com.beinformed.source.Highlevelrequirements/ResearchGrant/High%20level%20requirements.formalsource",
14
+ href: "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource",
14
15
  },
15
16
  },
17
+ sectionId: "Chapter4",
16
18
  sectionFragment: {
17
- text: "Implement scoring systems based on predefined criteria.",
18
- startOffset: 12,
19
- endOffset: 68,
19
+ text: "Research Grant",
20
+ startOffset: 32,
21
+ endOffset: 18,
20
22
  },
21
23
  };
22
24
 
@@ -30,38 +32,77 @@ describe("sourceReferenceModel", () => {
30
32
  it("can handle source reference data", () => {
31
33
  const sourceReference = new SourceReferenceModel(data);
32
34
 
33
- expect(sourceReference.label).toBe(
34
- "Requirement: Implement scoring systems based on predefined cr...",
35
+ expect(sourceReference.label).toBe("4. Purpose of Grant");
36
+ expect(sourceReference.sourceLabel).toBe(
37
+ "Grant Funding Agreement - Terms and Conditions",
35
38
  );
36
- expect(sourceReference.sourceLabel).toBe("High level requirements");
37
39
  expect(sourceReference.type).toBe("Reference");
38
- expect(sourceReference.sourceAbbreviation).toBe("HLR-01");
39
- expect(sourceReference.referenceHash).toBe(6767520005362);
40
- expect(sourceReference.fragment.text).toBe(
41
- "Implement scoring systems based on predefined criteria.",
42
- );
43
- expect(sourceReference.fragment.startOffset).toBe(12);
44
- expect(sourceReference.fragment.endOffset).toBe(68);
40
+ expect(sourceReference.sourceAbbreviation).toBe("GFA-TC-01");
41
+ expect(sourceReference.referenceHash).toBe(10443215482258);
42
+
43
+ expect(sourceReference.sectionId).toBe("Chapter4");
44
+ expect(sourceReference.fragment.text).toBe("Research Grant");
45
+ expect(sourceReference.fragment.startOffset).toBe(32);
46
+ expect(sourceReference.fragment.endOffset).toBe(18);
45
47
 
46
- expect(sourceReference.link.label).toBe(
47
- "Requirement: Implement scoring systems based on predefined cr...",
48
+ expect(sourceReference.link.label).toBe("4. Purpose of Grant");
49
+ expect(sourceReference.link.sourceLabel).toBe(
50
+ "Grant Funding Agreement - Terms and Conditions",
48
51
  );
49
- expect(sourceReference.link.sourceLabel).toBe("High level requirements");
50
- expect(sourceReference.link.abbreviation).toBe("HLR-01");
52
+ expect(sourceReference.link.abbreviation).toBe("GFA-TC-01");
51
53
  expect(sourceReference.link.selfhref.path).toBe(
52
- "/content/bundle-com.beinformed.source.Highlevelrequirements/ResearchGrant/High%20level%20requirements.formalsource/ScoringAndEvaluationCriteria",
54
+ "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/Chapter4",
53
55
  );
56
+ expect(sourceReference.link.selfhref.toLocation()).toEqual({
57
+ hash: "",
58
+ pathname:
59
+ "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource/Chapter4",
60
+ search: "",
61
+ state: {
62
+ contextPath: "/BeInformed",
63
+ fragment: {
64
+ endOffset: 18,
65
+ startOffset: 32,
66
+ text: "Research Grant",
67
+ },
68
+ origin: "",
69
+ },
70
+ });
54
71
 
55
- expect(sourceReference.link.fragment.text).toBe(
56
- "Implement scoring systems based on predefined criteria.",
57
- );
58
- expect(sourceReference.link.fragment.startOffset).toBe(12);
59
- expect(sourceReference.link.fragment.endOffset).toBe(68);
72
+ expect(sourceReference.link.fragment.text).toBe("Research Grant");
73
+ expect(sourceReference.link.fragment.startOffset).toBe(32);
74
+ expect(sourceReference.link.fragment.endOffset).toBe(18);
60
75
 
61
76
  expect(sourceReference.link.selfhref.state.fragment.text).toBe(
62
- "Implement scoring systems based on predefined criteria.",
77
+ "Research Grant",
78
+ );
79
+ expect(sourceReference.link.selfhref.state.fragment.startOffset).toBe(32);
80
+ expect(sourceReference.link.selfhref.state.fragment.endOffset).toBe(18);
81
+ });
82
+
83
+ it("can handle source reference data complete source", () => {
84
+ setSetting("COMPLETE_SOURCE", true);
85
+ const sourceReference = new SourceReferenceModel(data);
86
+
87
+ expect(sourceReference.link.selfhref.path).toBe(
88
+ "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource",
63
89
  );
64
- expect(sourceReference.link.selfhref.state.fragment.startOffset).toBe(12);
65
- expect(sourceReference.link.selfhref.state.fragment.endOffset).toBe(68);
90
+ expect(sourceReference.link.selfhref.toLocation()).toEqual({
91
+ hash: "#Chapter4",
92
+ pathname:
93
+ "/content/bundle-com.beinformed.source.GrantFundingAgreementTermsandConditions/Grant%20Funding%20Agreement.formalsource",
94
+ search: "?complete=true",
95
+ state: {
96
+ contextPath: "/BeInformed",
97
+ fragment: {
98
+ endOffset: 18,
99
+ startOffset: 32,
100
+ text: "Research Grant",
101
+ },
102
+ origin: "",
103
+ },
104
+ });
105
+
106
+ setSetting("COMPLETE_SOURCE", false);
66
107
  });
67
108
  });
@@ -4,6 +4,7 @@ import Href from "../href/Href";
4
4
  import LinkModel from "../links/LinkModel";
5
5
  import ContentTypeModel from "./ContentTypeModel";
6
6
  import { TIMEVERSION_FILTER_NAME } from "../../constants/Constants";
7
+ import { getSetting } from "../../constants/Settings";
7
8
 
8
9
  import LinkCollection from "../links/LinkCollection";
9
10
 
@@ -175,7 +176,18 @@ export default class ContentLinkModel
175
176
  * Get self link of model
176
177
  */
177
178
  get selflink(): LinkModel {
178
- const selflink = this.links.getLinkByKey("self");
179
+ let selflink = this.links.getLinkByKey("self");
180
+
181
+ if (getSetting("COMPLETE_SOURCE", false)) {
182
+ if (this.links.hasLinkByKey("content")) {
183
+ selflink = this.links.getLinkByKey("content");
184
+ }
185
+
186
+ if (selflink != null && !selflink.href.path.endsWith(this.data.section)) {
187
+ selflink.href.addParameter("complete", "true");
188
+ selflink.href.hash = this.data.section;
189
+ }
190
+ }
179
191
 
180
192
  if (selflink === null) {
181
193
  throw new Error(
@@ -9,6 +9,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
  });
@@ -263,7 +263,6 @@ export type ContentData = {
263
263
  };
264
264
 
265
265
  export type SectionFragment = {
266
- sectionId?: string,
267
266
  text: string,
268
267
  startOffset: number,
269
268
  endOffset: number,