@beinformed/ui 1.9.0-beta.6 → 1.9.1
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 +50 -0
- package/esm/constants/Settings.js +10 -8
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useNotification.js.map +1 -1
- package/esm/hooks/useRouter.js.map +1 -1
- package/esm/models/attributes/AttributeContent.js +126 -58
- package/esm/models/attributes/AttributeContent.js.map +1 -1
- package/esm/models/attributes/AttributeDataHelper.js +1 -1
- package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
- package/esm/models/attributes/AttributeModel.js +3 -3
- package/esm/models/attributes/AttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionModel.js +4 -4
- package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/esm/models/attributes/HelptextAttributeModel.js +17 -1
- package/esm/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/esm/models/caseview/CaseViewModel.js +26 -12
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/content/SectionModel.js +2 -1
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/content/SubSectionModel.js +3 -1
- package/esm/models/content/SubSectionModel.js.map +1 -1
- package/esm/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/esm/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
- package/esm/models/form/FormObjectModel.js +8 -2
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/esm/models/layouthint/LayoutHintCollection.js +3 -2
- package/esm/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/esm/models/list/ListDetailModel.js +25 -0
- package/esm/models/list/ListDetailModel.js.map +1 -1
- package/esm/models/list/ListModel.js +22 -16
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/panels/GroupingPanelModel.js +19 -17
- package/esm/models/panels/GroupingPanelModel.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +2 -1
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/utils/helpers/text.js +19 -0
- package/esm/utils/helpers/text.js.map +1 -0
- package/esm/utils/index.js +2 -1
- package/esm/utils/index.js.map +1 -1
- package/lib/constants/Settings.js +12 -1
- package/lib/constants/Settings.js.flow +9 -5
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/useForm.js.flow +10 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useNotification.js.flow +5 -2
- package/lib/hooks/useNotification.js.map +1 -1
- package/lib/hooks/useRouter.js.flow +12 -5
- package/lib/hooks/useRouter.js.map +1 -1
- package/lib/models/attributes/AttributeContent.js +136 -59
- package/lib/models/attributes/AttributeContent.js.flow +91 -39
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/attributes/AttributeDataHelper.js +1 -1
- package/lib/models/attributes/AttributeDataHelper.js.flow +2 -1
- package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
- package/lib/models/attributes/AttributeModel.js +1 -1
- package/lib/models/attributes/AttributeModel.js.flow +2 -3
- package/lib/models/attributes/AttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js +3 -3
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +4 -7
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/HelptextAttributeModel.js +17 -1
- package/lib/models/attributes/HelptextAttributeModel.js.flow +11 -1
- package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +10 -2
- package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +9 -3
- package/lib/models/attributes/__tests__/HelptextAttributeModel.spec.js.flow +39 -1
- package/lib/models/caseview/CaseViewModel.js +27 -13
- package/lib/models/caseview/CaseViewModel.js.flow +17 -7
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/caseview/__tests__/CaseViewModel.spec.js.flow +68 -184
- package/lib/models/concepts/__mock__/business_scenario.js.flow +14 -1
- package/lib/models/concepts/__mock__/conceptdetail.js.flow +15 -6
- package/lib/models/concepts/__tests__/BusinessScenarioModel.spec.js.flow +5 -6
- package/lib/models/concepts/__tests__/ConceptDetailModel.spec.js.flow +58 -3
- package/lib/models/content/SectionModel.js +3 -1
- package/lib/models/content/SectionModel.js.flow +2 -1
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/content/SubSectionModel.js +4 -1
- package/lib/models/content/SubSectionModel.js.flow +3 -1
- package/lib/models/content/SubSectionModel.js.map +1 -1
- package/lib/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/lib/models/contentconfiguration/ContentConfigurationResults.js.flow +2 -2
- package/lib/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
- package/lib/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js.flow +6 -6
- package/lib/models/form/FormObjectModel.js +8 -2
- package/lib/models/form/FormObjectModel.js.flow +5 -1
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/form/__tests__/FormObjectModel.spec.js.flow +2 -2
- package/lib/models/layouthint/LayoutHintCollection.js +4 -2
- package/lib/models/layouthint/LayoutHintCollection.js.flow +8 -7
- package/lib/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/lib/models/list/ListDetailModel.js +25 -0
- package/lib/models/list/ListDetailModel.js.flow +19 -0
- package/lib/models/list/ListDetailModel.js.map +1 -1
- package/lib/models/list/ListModel.js +23 -16
- package/lib/models/list/ListModel.js.flow +9 -5
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/list/__tests__/ListDetailModel.spec.js.flow +64 -0
- package/lib/models/list/__tests__/ListModel.spec.js.flow +64 -2
- package/lib/models/panels/GroupingPanelModel.js +21 -18
- package/lib/models/panels/GroupingPanelModel.js.flow +10 -9
- package/lib/models/panels/GroupingPanelModel.js.map +1 -1
- package/lib/models/panels/__tests__/GroupingPanelModel.spec.js.flow +90 -0
- package/lib/models/types.js.flow +38 -11
- package/lib/modularui/ModularUIRequest.js +2 -1
- package/lib/modularui/ModularUIRequest.js.flow +1 -0
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/utils/helpers/text.js +28 -0
- package/lib/utils/helpers/text.js.flow +23 -0
- package/lib/utils/helpers/text.js.map +1 -0
- package/lib/utils/index.js +14 -0
- package/lib/utils/index.js.flow +1 -0
- package/lib/utils/index.js.map +1 -1
- package/package.json +13 -13
- package/src/constants/Settings.js +9 -5
- package/src/hooks/useForm.js +10 -5
- package/src/hooks/useNotification.js +5 -2
- package/src/hooks/useRouter.js +12 -5
- package/src/models/attributes/AttributeContent.js +91 -39
- package/src/models/attributes/AttributeDataHelper.js +2 -1
- package/src/models/attributes/AttributeModel.js +2 -3
- package/src/models/attributes/ChoiceAttributeOptionModel.js +4 -7
- package/src/models/attributes/HelptextAttributeModel.js +11 -1
- package/src/models/attributes/__tests__/AttributeContent.spec.js +10 -2
- package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +9 -3
- package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +39 -1
- package/src/models/caseview/CaseViewModel.js +17 -7
- package/src/models/caseview/__tests__/CaseViewModel.spec.js +68 -184
- package/src/models/caseview/__tests__/caseview.json +38 -0
- package/src/models/caseview/__tests__/caseviewContributions.json +147 -0
- package/src/models/concepts/__mock__/business_scenario.js +14 -1
- package/src/models/concepts/__mock__/business_scenario_step.json +64 -0
- package/src/models/concepts/__mock__/conceptdetail.js +15 -6
- package/src/models/concepts/__mock__/conceptdetail_data.json +117 -17
- package/src/models/concepts/__mock__/concepttype_Calculation.json +75 -0
- package/src/models/concepts/__tests__/BusinessScenarioModel.spec.js +5 -6
- package/src/models/concepts/__tests__/ConceptDetailModel.spec.js +58 -3
- package/src/models/content/SectionModel.js +2 -1
- package/src/models/content/SubSectionModel.js +3 -1
- package/src/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/src/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js +6 -6
- package/src/models/form/FormObjectModel.js +5 -1
- package/src/models/form/__tests__/FormObjectModel.spec.js +2 -2
- package/src/models/form/__tests__/FormWithContentData.json +1 -0
- package/src/models/layouthint/LayoutHintCollection.js +8 -7
- package/src/models/list/ListDetailModel.js +19 -0
- package/src/models/list/ListModel.js +9 -5
- package/src/models/list/__tests__/ListDetailModel.spec.js +64 -0
- package/src/models/list/__tests__/ListModel.spec.js +64 -2
- package/src/models/list/__tests__/caselist-34.contributions.json +1 -1
- package/src/models/list/__tests__/listContributions.json +1 -1
- package/src/models/panels/GroupingPanelModel.js +10 -9
- package/src/models/panels/__tests__/GroupingPanelModel.spec.js +90 -0
- package/src/models/panels/__tests__/groupingPanel.json +30 -0
- package/src/models/panels/__tests__/groupingPanelContributions.json +46 -0
- package/src/models/types.js +38 -11
- package/src/modularui/ModularUIRequest.js +1 -0
- package/src/utils/helpers/text.js +23 -0
- package/src/utils/index.js +1 -0
|
@@ -76,11 +76,19 @@ export default class CaseViewModel extends DetailModel {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
+
* Retrieve the case label, this can be configured with a case property with the layout hint 'title'
|
|
79
80
|
*/
|
|
80
81
|
get label(): string {
|
|
81
82
|
return this.casename ? this.casename.value : "";
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Retrieve the label that was configured on the caseview
|
|
87
|
+
*/
|
|
88
|
+
get viewLabel(): string {
|
|
89
|
+
return this.getContribution("label", "");
|
|
90
|
+
}
|
|
91
|
+
|
|
84
92
|
/**
|
|
85
93
|
* Check if an introtext exists for this caseview
|
|
86
94
|
*/
|
|
@@ -92,14 +100,16 @@ export default class CaseViewModel extends DetailModel {
|
|
|
92
100
|
* Getting the introduction text configured on the case view
|
|
93
101
|
*/
|
|
94
102
|
get introtext(): string {
|
|
95
|
-
if (this.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
);
|
|
103
|
+
if (this.data._text) {
|
|
104
|
+
return this.data._text.message ?? this.data._text;
|
|
105
|
+
}
|
|
99
106
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
if (this.contributions.text) {
|
|
108
|
+
return this.contributions.text.message ?? this.contributions.text;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
112
|
+
return this.contributions.texts[0].text;
|
|
103
113
|
}
|
|
104
114
|
|
|
105
115
|
return "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/caseview/CaseViewModel.js"],"names":["CaseViewModel","caseviewData","createTaskGroupCollection","links","getLinksByGroup","all","models","taskGroupModels","i","length","TaskGroupModel","push","taskGroupCollection","add","attributeCollection","getAttributeByLayoutHint","TITLE","casename","value","introtext","
|
|
1
|
+
{"version":3,"sources":["../../../src/models/caseview/CaseViewModel.js"],"names":["CaseViewModel","caseviewData","createTaskGroupCollection","links","getLinksByGroup","all","models","taskGroupModels","i","length","TaskGroupModel","push","taskGroupCollection","add","attributeCollection","getAttributeByLayoutHint","TITLE","casename","value","getContribution","introtext","data","_text","message","contributions","text","Array","isArray","texts","selfLink","getLinkByKey","Error","Href","href","allTaskgroupData","getData","allTaskgroupContributions","taskgroup","some","taskgroupContribution","name","taskgroupContributions","create","_taskGroupCollection","taskgroups","TaskGroupCollection","hasItems","resourcetype","DetailModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAOA;AACA;AACA;IACqBA,a;;;;;AAGnB;AACF;AACE,yBAAYC,YAAZ,EAA6C;AAAA;;AAAA;AAC3C,8BAAMA,YAAN;AAD2C;;AAG3C,UAAKC,yBAAL;;AAH2C;AAI5C;AAED;AACF;;;;;SACE,eAAmB;AACjB,aAAO,UAAP;AACD;AAED;AACF;;;;;AAQE;AACF;AACE,yCAA8C;AAC5C,aAAO,KAAKC,KAA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;AACE,mBAA+C;AAC7C,aAAO,KAAKE,oBAAZ;AACD;AAED;AACF;AACA;;SAbE,aAAwBC,UAAxB,EAA2D;AACzD,WAAKD,oBAAL,GAA4B,IAAIE,4BAAJ,CAAwBD,UAAxB,CAA5B;AACD;;;WAYD,yBAAyB;AACvB,aAAO,KAAKhC,mBAAL,IAA4B,KAAKA,mBAAL,CAAyBkC,QAA5D;AACD;;;WA7ID,2BAAyBzB,IAAzB,EAA2D;AACzD,aACEA,IAAI,CAACG,aAAL,CAAmBuB,YAAnB,IACA1B,IAAI,CAACG,aAAL,CAAmBuB,YAAnB,KAAoC,UAFtC;AAID;;;EAxBwCC,qB","sourcesContent":["// @flow\nimport DetailModel from \"../detail/DetailModel\";\nimport Href from \"../href/Href\";\nimport TaskGroupCollection from \"../taskgroup/TaskGroupCollection\";\nimport TaskGroupModel from \"../taskgroup/TaskGroupModel\";\n\nimport { TITLE } from \"../../constants/LayoutHints\";\n\nimport type { ModularUIModel, AttributeType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Model containing the details of one case.\n */\nexport default class CaseViewModel extends DetailModel {\n _taskGroupCollection: TaskGroupCollection;\n\n /**\n */\n constructor(caseviewData: ModularUIResponse) {\n super(caseviewData);\n\n this.createTaskGroupCollection();\n }\n\n /**\n */\n get type(): string {\n return \"CaseView\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"CaseView\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this.links.getLinksByGroup(\"taskgroup\").all;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.links.getLinksByGroup(\"panel\");\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n super.setChildModels(models);\n\n const taskGroupModels = [];\n for (let i = 0; i < models.length; i++) {\n if (models[i] instanceof TaskGroupModel) {\n taskGroupModels.push(models[i]);\n }\n }\n\n this.taskGroupCollection.add(taskGroupModels);\n }\n\n /**\n * Getting the case name\n */\n get casename(): ?AttributeType {\n return this.attributeCollection.getAttributeByLayoutHint(TITLE);\n }\n\n /**\n * Retrieve the case label, this can be configured with a case property with the layout hint 'title'\n */\n get label(): string {\n return this.casename ? this.casename.value : \"\";\n }\n\n /**\n * Retrieve the label that was configured on the caseview\n */\n get viewLabel(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Check if an introtext exists for this caseview\n */\n hasIntroText(): boolean {\n return this.introtext !== \"\";\n }\n\n /**\n * Getting the introduction text configured on the case view\n */\n get introtext(): string {\n if (this.data._text) {\n return this.data._text.message ?? this.data._text;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n * Getting the self href\n */\n get selfhref(): Href {\n const selfLink = this.links.getLinkByKey(\"self\");\n\n if (selfLink === null) {\n throw new Error(\"No self href available\");\n }\n\n return new Href(selfLink.href);\n }\n\n /**\n */\n createTaskGroupCollection() {\n const allTaskgroupData = this.getData(\"taskgroups\", []);\n const allTaskgroupContributions = this.getContribution(\"taskgroups\", []);\n\n this.taskGroupCollection = allTaskgroupData\n .filter((taskgroup) =>\n allTaskgroupContributions.some(\n (taskgroupContribution) =>\n taskgroupContribution.name === taskgroup.name\n )\n )\n .map((taskgroup) => {\n const taskgroupContributions = allTaskgroupContributions.find(\n (taskgroupContribution) =>\n taskgroupContribution.name === taskgroup.name\n );\n\n return TaskGroupModel.create(\n taskgroup.name,\n taskgroup,\n taskgroupContributions\n );\n });\n }\n\n /**\n * Setting the taskgroup panel collection\n */\n set taskGroupCollection(taskgroups: Array<TaskGroupModel>) {\n this._taskGroupCollection = new TaskGroupCollection(taskgroups);\n }\n\n /**\n * Getting the taskgrouppanels on the tab\n */\n get taskGroupCollection(): TaskGroupCollection {\n return this._taskGroupCollection;\n }\n\n /**\n * Has taskgroups\n */\n hasTaskGroups(): boolean {\n return this.taskGroupCollection && this.taskGroupCollection.hasItems;\n }\n}\n"],"file":"CaseViewModel.js"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import CaseViewModel from "../CaseViewModel";
|
|
2
2
|
import DetailModel from "../../detail/DetailModel";
|
|
3
3
|
|
|
4
|
+
import caseviewJson from "./caseview.json";
|
|
5
|
+
import caseviewContributionsJson from "./caseviewContributions.json";
|
|
6
|
+
|
|
4
7
|
describe("caseViewModel", () => {
|
|
5
8
|
it("should be able to create an empty casedetail", () => {
|
|
6
9
|
const caseview = new CaseViewModel({});
|
|
@@ -10,200 +13,81 @@ describe("caseViewModel", () => {
|
|
|
10
13
|
|
|
11
14
|
it("should be able to create a casedetail from a typical modular UI json structure", () => {
|
|
12
15
|
const caseDetail = new CaseViewModel({
|
|
16
|
+
key: "Book",
|
|
17
|
+
data: caseviewJson,
|
|
18
|
+
contributions: caseviewContributionsJson,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
expect(caseDetail).toBeInstanceOf(CaseViewModel);
|
|
22
|
+
expect(caseDetail).toBeInstanceOf(DetailModel);
|
|
23
|
+
|
|
24
|
+
expect(caseDetail.key).toBe("Book");
|
|
25
|
+
expect(caseDetail.id).toBe(24);
|
|
26
|
+
|
|
27
|
+
expect(caseDetail.casename.value).toBe("The safety of objects");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should be able to handle different kind of introtext", () => {
|
|
31
|
+
const caseviewOldStructure = new CaseViewModel({
|
|
32
|
+
key: "Book",
|
|
33
|
+
data: caseviewJson,
|
|
34
|
+
contributions: caseviewContributionsJson,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
expect(caseviewOldStructure.introtext).toBe("<p>This is introtext</p>");
|
|
38
|
+
|
|
39
|
+
const caseviewFromDataPlain = new CaseViewModel({
|
|
13
40
|
key: "Book",
|
|
14
41
|
data: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
href: "/books/book/24/editions",
|
|
30
|
-
},
|
|
31
|
-
Activities: {
|
|
32
|
-
href: "/books/book/24/activities",
|
|
33
|
-
},
|
|
34
|
-
taskgroup: [
|
|
35
|
-
{
|
|
36
|
-
href: "/books/book/24/Tasks",
|
|
37
|
-
name: "Tasks",
|
|
38
|
-
},
|
|
39
|
-
],
|
|
42
|
+
_text: "<p>This is introtext</p>",
|
|
43
|
+
...caseviewJson,
|
|
44
|
+
},
|
|
45
|
+
contributions: caseviewContributionsJson,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(caseviewFromDataPlain.introtext).toBe("<p>This is introtext</p>");
|
|
49
|
+
|
|
50
|
+
const caseviewFromDataApplicationMessage = new CaseViewModel({
|
|
51
|
+
key: "Book",
|
|
52
|
+
data: {
|
|
53
|
+
...caseviewJson,
|
|
54
|
+
_text: {
|
|
55
|
+
message: "<p>This is introtext</p>",
|
|
40
56
|
},
|
|
41
|
-
_id: 24,
|
|
42
|
-
CaseName: "The safety of objects",
|
|
43
|
-
CaseType: "Book",
|
|
44
|
-
Owner: "Arnold",
|
|
45
|
-
Format: "Paperback",
|
|
46
|
-
ISBN10: "1847087302",
|
|
47
|
-
ISBN13: "9781847087300",
|
|
48
|
-
Language: "EN",
|
|
49
|
-
NumberOfPages: 176,
|
|
50
|
-
State: "Registered",
|
|
51
57
|
},
|
|
58
|
+
contributions: caseviewContributionsJson,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(caseviewFromDataApplicationMessage.introtext).toBe(
|
|
62
|
+
"<p>This is introtext</p>"
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const caseviewFromNewContributionsRawTextMessage = new CaseViewModel({
|
|
66
|
+
key: "Book",
|
|
67
|
+
data: caseviewJson,
|
|
52
68
|
contributions: {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
type: "master",
|
|
58
|
-
text: "<p>This view contains all the data about this book. It contains a list of the creators and editions. A person can be an author(1) or an illustrator(2)<br /><br />This is a list of books that is ordered by the role (author (1), co-author, illustrator(2)) of the person that contributed to the book.<br /><br />1) An author is broadly defined as "the person who originated or gave existence to anything" and whose authorship determines responsibility for what was created. Narrowly defined, an author is the originator of any written work and can also be described as a writer.<br /><br />2) An illustrator is an artist who specializes in enhancing writing or elucidating concepts by providing a visual representation that corresponds to the content of the associated text or idea. The illustration may be intended to clarify complicated concepts or objects that are difficult to describe textually, which is the reason illustrations are often found in children's books.<br /></p>",
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
_links: {
|
|
62
|
-
panel: [
|
|
63
|
-
{
|
|
64
|
-
name: "Creator",
|
|
65
|
-
label: "Creator",
|
|
66
|
-
resourcetype: "CaseRelationListPanel",
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: "Editions",
|
|
70
|
-
label: "Editions",
|
|
71
|
-
resourcetype: "RecordListPanel",
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: "Activities",
|
|
75
|
-
label: "Activities",
|
|
76
|
-
resourcetype: "GroupingPanel",
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
taskgroup: [
|
|
80
|
-
{
|
|
81
|
-
name: "Tasks",
|
|
82
|
-
label: "Tasks",
|
|
83
|
-
resourcetype: "TaskGroup",
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
},
|
|
87
|
-
metadata: {
|
|
88
|
-
_id: {
|
|
89
|
-
label: "Id",
|
|
90
|
-
type: "integer",
|
|
91
|
-
},
|
|
69
|
+
...caseviewContributionsJson,
|
|
70
|
+
text: {
|
|
71
|
+
message: "<p>This is introtext</p>",
|
|
92
72
|
},
|
|
93
|
-
attributes: [
|
|
94
|
-
{
|
|
95
|
-
CaseName: {
|
|
96
|
-
label: "Case name",
|
|
97
|
-
type: "string",
|
|
98
|
-
layouthint: ["title"],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
CaseType: {
|
|
103
|
-
label: "Case type",
|
|
104
|
-
type: "string",
|
|
105
|
-
layouthint: ["type"],
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
Owner: {
|
|
110
|
-
label: "Case owner",
|
|
111
|
-
type: "string",
|
|
112
|
-
layouthint: ["owner"],
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
State: {
|
|
117
|
-
label: "State",
|
|
118
|
-
type: "string",
|
|
119
|
-
layouthint: ["state"],
|
|
120
|
-
options: [
|
|
121
|
-
{
|
|
122
|
-
code: "Registered",
|
|
123
|
-
label: "Registered",
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
Format: {
|
|
130
|
-
label: "Format",
|
|
131
|
-
type: "string",
|
|
132
|
-
multiplechoice: false,
|
|
133
|
-
layouthint: ["combobox"],
|
|
134
|
-
options: [
|
|
135
|
-
{
|
|
136
|
-
code: "Hardcover",
|
|
137
|
-
label: "Hardcover",
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
code: "Paperback",
|
|
141
|
-
label: "Paperback",
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
code: "Ebook",
|
|
145
|
-
label: "Ebook",
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
code: "Audio",
|
|
149
|
-
label: "Audio book",
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
ISBN10: {
|
|
156
|
-
label: "ISBN10",
|
|
157
|
-
type: "string",
|
|
158
|
-
displaysize: 50,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
ISBN13: {
|
|
163
|
-
label: "ISBN13",
|
|
164
|
-
type: "string",
|
|
165
|
-
displaysize: 50,
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
Language: {
|
|
170
|
-
label: "Language",
|
|
171
|
-
type: "string",
|
|
172
|
-
multiplechoice: false,
|
|
173
|
-
layouthint: ["radiobutton"],
|
|
174
|
-
options: [
|
|
175
|
-
{
|
|
176
|
-
code: "EN",
|
|
177
|
-
label: "English",
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
code: "DU",
|
|
181
|
-
label: "Dutch",
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
NumberOfPages: {
|
|
188
|
-
label: "Number of pages",
|
|
189
|
-
type: "number",
|
|
190
|
-
format: "0",
|
|
191
|
-
groupingSeparator: ".",
|
|
192
|
-
decimalSeparator: ",",
|
|
193
|
-
minimum: 1,
|
|
194
|
-
maximum: 1000,
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
],
|
|
198
73
|
},
|
|
199
74
|
});
|
|
200
75
|
|
|
201
|
-
expect(
|
|
202
|
-
|
|
76
|
+
expect(caseviewFromNewContributionsRawTextMessage.introtext).toBe(
|
|
77
|
+
"<p>This is introtext</p>"
|
|
78
|
+
);
|
|
203
79
|
|
|
204
|
-
|
|
205
|
-
|
|
80
|
+
const caseviewFromNewContributionsSimpleMessage = new CaseViewModel({
|
|
81
|
+
key: "Book",
|
|
82
|
+
data: caseviewJson,
|
|
83
|
+
contributions: {
|
|
84
|
+
...caseviewContributionsJson,
|
|
85
|
+
text: "<p>This is introtext</p>",
|
|
86
|
+
},
|
|
87
|
+
});
|
|
206
88
|
|
|
207
|
-
expect(
|
|
89
|
+
expect(caseviewFromNewContributionsSimpleMessage.introtext).toBe(
|
|
90
|
+
"<p>This is introtext</p>"
|
|
91
|
+
);
|
|
208
92
|
});
|
|
209
93
|
});
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import BusinessScenarioModel from "../BusinessScenarioModel";
|
|
2
2
|
import ModularUIResponse from "../../../modularui/ModularUIResponse";
|
|
3
|
+
import ConceptDetailModel from "../ConceptDetailModel";
|
|
3
4
|
|
|
4
5
|
import data from "./business_scenario_data.json";
|
|
5
6
|
import contributions from "./conceptdetail_contributions.json";
|
|
6
7
|
|
|
8
|
+
import stepData from "./business_scenario_step.json";
|
|
9
|
+
import conceptType from "./concepttype";
|
|
10
|
+
|
|
7
11
|
const response = ModularUIResponse.create({
|
|
8
12
|
key: "business_scenario",
|
|
9
13
|
data,
|
|
10
14
|
contributions,
|
|
11
15
|
});
|
|
16
|
+
const scenario = new BusinessScenarioModel(response);
|
|
17
|
+
|
|
18
|
+
const stepResponse = ModularUIResponse.create({
|
|
19
|
+
key: "business_scenario_step",
|
|
20
|
+
data: stepData,
|
|
21
|
+
contributions,
|
|
22
|
+
});
|
|
23
|
+
const step = new ConceptDetailModel(stepResponse);
|
|
24
|
+
step.conceptType = conceptType;
|
|
12
25
|
|
|
13
|
-
export
|
|
26
|
+
export { scenario, step };
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import ConceptDetailModel from "../ConceptDetailModel";
|
|
2
|
+
import ConceptTypeDetailModel from "../ConceptTypeDetailModel";
|
|
2
3
|
import ModularUIResponse from "../../../modularui/ModularUIResponse";
|
|
3
4
|
|
|
4
5
|
import data from "./conceptdetail_data.json";
|
|
5
6
|
import contributions from "./conceptdetail_contributions.json";
|
|
7
|
+
import conceptTypeData from "./concepttype_Calculation.json";
|
|
8
|
+
import conceptTypeContributions from "./concepttype_contributions.json";
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const response = ModularUIResponse.create({
|
|
10
|
-
key: "conceptdetail",
|
|
10
|
+
const conceptResponse = ModularUIResponse.create({
|
|
11
|
+
key: "concept",
|
|
11
12
|
data,
|
|
12
13
|
contributions,
|
|
13
14
|
});
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
+
const conceptTypeResponse = ModularUIResponse.create({
|
|
17
|
+
key: "concepttype",
|
|
18
|
+
data: conceptTypeData,
|
|
19
|
+
contributions: conceptTypeContributions,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const conceptType = new ConceptTypeDetailModel(conceptTypeResponse);
|
|
23
|
+
|
|
24
|
+
const conceptDetail = new ConceptDetailModel(conceptResponse);
|
|
16
25
|
conceptDetail.conceptType = conceptType;
|
|
17
26
|
|
|
18
|
-
export
|
|
27
|
+
export { conceptDetail };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import BusinessScenarioModel from "../BusinessScenarioModel";
|
|
2
|
-
import
|
|
3
|
-
import conceptDetail from "../__mock__/conceptdetail";
|
|
2
|
+
import { scenario, step } from "../__mock__/business_scenario";
|
|
4
3
|
import conceptType from "../__mock__/concepttype";
|
|
5
4
|
|
|
6
5
|
describe("businessScenarioModel", () => {
|
|
@@ -12,16 +11,16 @@ describe("businessScenarioModel", () => {
|
|
|
12
11
|
});
|
|
13
12
|
|
|
14
13
|
it("can retrieve child model links", () => {
|
|
15
|
-
const initialChildModelLinks =
|
|
14
|
+
const initialChildModelLinks = scenario.getInitialChildModelLinks();
|
|
16
15
|
|
|
17
16
|
expect(initialChildModelLinks).toHaveLength(13);
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
it("can set scenarioSteps", () => {
|
|
21
|
-
|
|
20
|
+
scenario.setChildModels([conceptType, step]);
|
|
22
21
|
|
|
23
|
-
const scenarioSteps =
|
|
24
|
-
const actors =
|
|
22
|
+
const scenarioSteps = scenario.scenarioSteps;
|
|
23
|
+
const actors = scenario.actors;
|
|
25
24
|
|
|
26
25
|
expect(scenarioSteps).toHaveLength(1);
|
|
27
26
|
expect(actors).toHaveLength(1);
|
|
@@ -1,10 +1,65 @@
|
|
|
1
1
|
import ConceptDetailModel from "../ConceptDetailModel";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
it("should be able to create an empty ConceptDetailModel object", () => {
|
|
5
|
-
const conceptDetail = new ConceptDetailModel();
|
|
3
|
+
import { conceptDetail } from "../__mock__/conceptdetail";
|
|
6
4
|
|
|
5
|
+
describe("conceptDetailModel", () => {
|
|
6
|
+
it("should be able to create a ConceptDetailModel object", () => {
|
|
7
7
|
expect(conceptDetail).toBeInstanceOf(ConceptDetailModel);
|
|
8
8
|
expect(conceptDetail.type).toBe("ConceptDetail");
|
|
9
|
+
|
|
10
|
+
expect(conceptDetail.key).toBe("DurationDrivingBan");
|
|
11
|
+
expect(conceptDetail.conceptType.label).toBe("Calculation");
|
|
12
|
+
|
|
13
|
+
expect(conceptDetail.label).toBe("Duration driving ban");
|
|
14
|
+
expect(conceptDetail.taxonomyType).toBe("default");
|
|
15
|
+
|
|
16
|
+
expect(conceptDetail.formula).toBe(
|
|
17
|
+
"IF (NoviceDriver) (NUMBER)DurationDrivingBanNoviceDriver ELSE IF\n(ExperiencedDriver) (NUMBER)DurationDrivingBanExperiencedDriver ENDIF ENDIF"
|
|
18
|
+
);
|
|
19
|
+
expect(conceptDetail.labels).toStrictEqual([
|
|
20
|
+
{
|
|
21
|
+
_id: "QuestionLabel",
|
|
22
|
+
label: "Question label",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
_id: "ResultLabel",
|
|
26
|
+
label: "Result label",
|
|
27
|
+
type: "ResultLabel",
|
|
28
|
+
value: "Duration of driving ban (in months)",
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
expect(conceptDetail.conceptProperties).toStrictEqual([
|
|
32
|
+
{
|
|
33
|
+
_id: "PartnerService",
|
|
34
|
+
label: "Partner Service",
|
|
35
|
+
mandatory: "false",
|
|
36
|
+
type: "string",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
_id: "Abbreviation",
|
|
40
|
+
label: "Abbreviation",
|
|
41
|
+
mandatory: "false",
|
|
42
|
+
type: "Abbreviation",
|
|
43
|
+
value: "DDB",
|
|
44
|
+
},
|
|
45
|
+
]);
|
|
46
|
+
expect(conceptDetail.textfragments).toStrictEqual([
|
|
47
|
+
{
|
|
48
|
+
_id: "Description",
|
|
49
|
+
label: "Description",
|
|
50
|
+
id: "DurationDrivingBan.tv852.Description",
|
|
51
|
+
text: "Text fragment for duration driving ban",
|
|
52
|
+
type: "Description",
|
|
53
|
+
},
|
|
54
|
+
{ _id: "Definition", label: "Definition" },
|
|
55
|
+
{ _id: "IconSmall", label: "Icon-small" },
|
|
56
|
+
{ _id: "IconMedium", label: "Icon-medium" },
|
|
57
|
+
{ _id: "IconLarge", label: "Icon-large" },
|
|
58
|
+
{ _id: "NonFunctionalRequirement", label: "Non functional requirement" },
|
|
59
|
+
{ _id: "FunctionalRequirement", label: "Functional requirement" },
|
|
60
|
+
{ _id: "Rationale", label: "Rationale" },
|
|
61
|
+
{ _id: "tfNote", label: "NL TF NOTE" },
|
|
62
|
+
]);
|
|
63
|
+
expect(conceptDetail.entryDate).toBe("2021-09-23");
|
|
9
64
|
});
|
|
10
65
|
});
|
|
@@ -47,6 +47,8 @@ var _createHash = require("../../utils/helpers/createHash");
|
|
|
47
47
|
|
|
48
48
|
var _LinkModel = _interopRequireDefault(require("../links/LinkModel"));
|
|
49
49
|
|
|
50
|
+
var _utils = require("../../utils");
|
|
51
|
+
|
|
50
52
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
51
53
|
|
|
52
54
|
function _unsupportedIterableToArray(o, minLen) { var _context5; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context5 = Object.prototype.toString.call(o)).call(_context5, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -171,7 +173,7 @@ var SectionModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
171
173
|
}, {
|
|
172
174
|
key: "body",
|
|
173
175
|
get: function get() {
|
|
174
|
-
return this.data.body;
|
|
176
|
+
return (0, _utils.retrieveText)(this.data.body);
|
|
175
177
|
}
|
|
176
178
|
/**
|
|
177
179
|
* Retrieve child section links
|
|
@@ -7,6 +7,7 @@ import { createHashFromHref } from "../../utils/helpers/createHash";
|
|
|
7
7
|
import LinkModel from "../links/LinkModel";
|
|
8
8
|
|
|
9
9
|
import type Href from "../href/Href";
|
|
10
|
+
import { retrieveText } from "../../utils";
|
|
10
11
|
|
|
11
12
|
class SectionModel extends BaseModel {
|
|
12
13
|
_entryDate: ISO_DATE | null;
|
|
@@ -88,7 +89,7 @@ class SectionModel extends BaseModel {
|
|
|
88
89
|
* Get content body
|
|
89
90
|
*/
|
|
90
91
|
get body(): ?string {
|
|
91
|
-
return this.data.body;
|
|
92
|
+
return retrieveText(this.data.body);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/content/SectionModel.js"],"names":["SectionModel","data","entryDate","_entryDate","referred","_selflink","LinkModel","_links","self","selflink","href","type","sourceLabel","id","_id","getData","number","body","childSections","childSection","ContentLinkModel","section","label","_childSections","sections","subSections","subSection","SubSectionModel","selfhref","push","referredChilds","getReferredSections","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/models/content/SectionModel.js"],"names":["SectionModel","data","entryDate","_entryDate","referred","_selflink","LinkModel","_links","self","selflink","href","type","sourceLabel","id","_id","getData","number","body","childSections","childSection","ContentLinkModel","section","label","_childSections","sections","subSections","subSection","SubSectionModel","selfhref","push","referredChilds","getReferredSections","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAGA;;;;;;;;;;;;IAEMA,Y;;;;;AAKJ,wBAAYC,IAAZ,EAA0BC,SAA1B,EAAsD;AAAA;;AAAA;AACpD,8BAAMD,IAAN,EAAY,EAAZ;AADoD;AAAA;AAAA;AAGpD,UAAKE,UAAL,GAAkBD,SAAlB;AAHoD;AAIrD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,KAAKD,IAAL,CAAUG,QAAjB;AACD;AAED;AACF;;;;SACE,eAA0B;AACxB,UAAI,CAAC,KAAKC,SAAV,EAAqB;AAAA;;AACnB,aAAKA,SAAL,GAAiB,IAAIC,kBAAJ,sBAAc,KAAKL,IAAL,CAAUM,MAAxB,sDAAc,kBAAkBC,IAAhC,CAAjB;AACD;;AACD,aAAO,KAAKH,SAAZ;AACD;AAED;AACF;;;;SACE,eAAqB;AACnB,aAAO,KAAKI,QAAL,CAAcC,IAArB;AACD;AAED;AACF;;;;SACE,eAAiC;AAC/B,aAAO,KAAKP,UAAZ;AACD;AAED;AACF;;;;SACE,eAAmB;AACjB,aAAO,KAAKF,IAAL,CAAUU,IAAjB;AACD;AAED;AACF;;;;SACE,eAA0B;AACxB,aAAO,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Q,mCAASM,cAAT,EAAR;AACD;AAV0D;AAAA;AAAA;AAAA;AAAA;;AAAA,kDAYhC,KAAKZ,aAZ2B;AAAA;;AAAA;AAY3D,+DAA+C;AAAA,cAApCC,YAAoC;;AAC7C,cAAIA,YAAY,CAACf,QAAjB,EAA2B;AACzBoB,YAAAA,QAAQ,CAACK,IAAT,CAAcV,YAAd;AACD;;AAED,cAAMW,eAAc,GAAGX,YAAY,CAACY,mBAAb,EAAvB;;AACAP,UAAAA,QAAQ,CAACK,IAAT,OAAAL,QAAQ,mCAASM,eAAT,EAAR;AACD;AAnB0D;AAAA;AAAA;AAAA;AAAA;;AAqB3D,aAAON,QAAP;AACD;;;EAnLwBQ,mB;;eAsLZhC,Y","sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport SubSectionModel from \"./SubSectionModel\";\n\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\nimport LinkModel from \"../links/LinkModel\";\n\nimport type Href from \"../href/Href\";\nimport { retrieveText } from \"../../utils\";\n\nclass SectionModel extends BaseModel {\n _entryDate: ISO_DATE | null;\n _selflink: ?LinkModel;\n _childSections: Array<SectionModel>;\n\n constructor(data: Object, entryDate: ISO_DATE | null) {\n super(data, {});\n\n this._entryDate = entryDate;\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get selflink(): LinkModel {\n if (!this._selflink) {\n this._selflink = new LinkModel(this.data._links?.self);\n }\n return this._selflink;\n }\n\n /**\n */\n get selfhref(): Href {\n return this.selflink.href;\n }\n\n /**\n */\n get entryDate(): ISO_DATE | null {\n return this._entryDate;\n }\n\n /**\n */\n get type(): string {\n return this.data.type;\n }\n\n /**\n */\n get sourceLabel(): string {\n return this.data.sourceLabel;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n */\n get key(): string {\n return this.id;\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Get content body\n */\n get body(): ?string {\n return retrieveText(this.data.body);\n }\n\n /**\n * Retrieve child section links\n */\n get childSectionLinks(): Array<ContentLinkModel> {\n return this.data.childSections\n ? this.data.childSections.map(\n (childSection) =>\n new ContentLinkModel(\n {\n section: childSection.id || childSection._id,\n _id: childSection.id || childSection._id,\n label: childSection.label,\n sourceLabel: childSection.sourceLabel,\n _links: childSection._links,\n },\n this.entryDate\n )\n )\n : [];\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(\n {\n section: this.id,\n _id: this.id,\n label: this.data.label,\n sourceLabel: this.data.sourceLabel,\n _links: this.data._links,\n },\n this.entryDate\n );\n }\n\n /**\n * Get tree of child sections\n */\n get childSections(): Array<SectionModel> {\n if (!this._childSections && this.data.childSections) {\n this._childSections = this.data.childSections\n .filter((childSection) => \"body\" in childSection)\n .map((childSection) => new SectionModel(childSection, this.entryDate));\n }\n return this._childSections || [];\n }\n\n /**\n * set resolved child sections\n */\n set childSections(sections: Array<SectionModel>) {\n this._childSections = sections || [];\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection)\n )\n : [];\n }\n\n /**\n */\n get referenceHash(): number {\n return createHashFromHref(this.selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel | SectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n for (const childSection of this.childSections) {\n if (childSection.referred) {\n sections.push(childSection);\n }\n\n const referredChilds = childSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n\nexport default SectionModel;\n"],"file":"SectionModel.js"}
|
|
@@ -45,6 +45,8 @@ var _Href = _interopRequireDefault(require("../href/Href"));
|
|
|
45
45
|
|
|
46
46
|
var _LinkModel = _interopRequireDefault(require("../links/LinkModel"));
|
|
47
47
|
|
|
48
|
+
var _utils = require("../../utils");
|
|
49
|
+
|
|
48
50
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
49
51
|
|
|
50
52
|
function _unsupportedIterableToArray(o, minLen) { var _context2; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -106,7 +108,8 @@ var SubSectionModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
106
108
|
}, {
|
|
107
109
|
key: "body",
|
|
108
110
|
get: function get() {
|
|
109
|
-
|
|
111
|
+
var body = this.getData("body", "");
|
|
112
|
+
return (0, _utils.retrieveText)(body);
|
|
110
113
|
}
|
|
111
114
|
/**
|
|
112
115
|
* Retrieve number of section
|
|
@@ -5,6 +5,7 @@ import BaseModel from "../base/BaseModel";
|
|
|
5
5
|
import LinkCollection from "../links/LinkCollection";
|
|
6
6
|
import Href from "../href/Href";
|
|
7
7
|
import LinkModel from "../links/LinkModel";
|
|
8
|
+
import { retrieveText } from "../../utils";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Link to a concept
|
|
@@ -41,7 +42,8 @@ export default class SubSectionModel extends BaseModel {
|
|
|
41
42
|
* Retrieve html body
|
|
42
43
|
*/
|
|
43
44
|
get body(): string {
|
|
44
|
-
|
|
45
|
+
const body = this.getData("body", "");
|
|
46
|
+
return retrieveText(body);
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
/**
|