@beinformed/ui 1.57.0-contextpath.1 → 1.57.0
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 +53 -0
- package/esm/constants/Settings.js +10 -2
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useModularUI.js +19 -18
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +52 -41
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +1 -8
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/ConceptIndexModel.js +1 -1
- package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.js +8 -9
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/ConceptTypeDetailModel.js +3 -20
- package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceCollection.js +3 -1
- package/esm/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.js +9 -3
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/content/ContentLinkModel.js +10 -4
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/SectionModel.js +10 -6
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/error/ErrorResponse.js +20 -5
- package/esm/models/error/ErrorResponse.js.map +1 -1
- package/esm/modularui/CaptchaRequest.js +12 -3
- package/esm/modularui/CaptchaRequest.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +1 -1
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/modularui/UploadRequest.js +7 -3
- package/esm/modularui/UploadRequest.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +11 -9
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js +4 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +2 -1
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/esm/redux/_modularui/ModularUISelectors.js +7 -6
- package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/connectors/PanelRenderer.js +0 -2
- package/esm/redux/connectors/PanelRenderer.js.map +1 -1
- package/esm/utils/helpers/repositoryResource.js +6 -5
- package/esm/utils/helpers/repositoryResource.js.map +1 -1
- package/lib/constants/Settings.js +10 -2
- package/lib/constants/Settings.js.flow +8 -2
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +11 -4
- package/lib/hooks/__tests__/useAuthentication.spec.js.flow +2 -8
- package/lib/hooks/__tests__/useForm.spec.js.flow +14 -12
- package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +10 -4
- package/lib/hooks/__tests__/useModels.spec.js.flow +3 -12
- package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +9 -8
- package/lib/hooks/useModularUI.js +18 -17
- package/lib/hooks/useModularUI.js.flow +25 -15
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +52 -41
- package/lib/hooks/useModularUIBasic.js.flow +66 -50
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +1 -8
- package/lib/models/concepts/ConceptDetailModel.js.flow +2 -7
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptIndexModel.js +1 -1
- package/lib/models/concepts/ConceptIndexModel.js.flow +7 -1
- package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js +8 -9
- package/lib/models/concepts/ConceptLinkModel.js.flow +14 -9
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/ConceptTypeDetailModel.js +3 -20
- package/lib/models/concepts/ConceptTypeDetailModel.js.flow +3 -25
- package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceCollection.js +3 -1
- package/lib/models/concepts/SourceReferenceCollection.js.flow +8 -1
- package/lib/models/concepts/SourceReferenceCollection.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js +9 -3
- package/lib/models/concepts/SourceReferenceModel.js.flow +19 -3
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/concepts/__mock__/conceptindex.js.flow +15 -0
- package/lib/models/concepts/__tests__/ConceptIndexModel.spec.js.flow +30 -2
- package/lib/models/concepts/__tests__/ConceptTypeDetailModel.spec.js.flow +1 -18
- package/lib/models/content/ContentLinkModel.js +9 -4
- package/lib/models/content/ContentLinkModel.js.flow +19 -4
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/SectionModel.js +10 -6
- package/lib/models/content/SectionModel.js.flow +31 -5
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/error/ErrorResponse.js +20 -5
- package/lib/models/error/ErrorResponse.js.flow +34 -5
- package/lib/models/error/ErrorResponse.js.map +1 -1
- package/lib/modularui/CaptchaRequest.js +11 -2
- package/lib/modularui/CaptchaRequest.js.flow +17 -3
- package/lib/modularui/CaptchaRequest.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +1 -1
- package/lib/modularui/ModularUIRequest.js.flow +3 -1
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/modularui/UploadRequest.js +6 -2
- package/lib/modularui/UploadRequest.js.flow +12 -2
- package/lib/modularui/UploadRequest.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +11 -9
- package/lib/redux/_modularui/ModularUIActions.js.flow +20 -10
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js +3 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.flow +6 -3
- package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +2 -1
- package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/ModularUISelectors.js +5 -6
- package/lib/redux/_modularui/ModularUISelectors.js.flow +22 -10
- package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/lib/redux/_modularui/__tests__/actions.spec.js.flow +1 -4
- package/lib/redux/_modularui/types.js.flow +1 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/actions/__tests__/Application.spec.js.flow +1 -8
- package/lib/redux/actions/__tests__/Authorization.spec.js.flow +0 -4
- package/lib/redux/connectors/PanelRenderer.js +0 -2
- package/lib/redux/connectors/PanelRenderer.js.flow +0 -1
- package/lib/redux/connectors/PanelRenderer.js.map +1 -1
- package/lib/utils/helpers/repositoryResource.js +6 -5
- package/lib/utils/helpers/repositoryResource.js.flow +8 -6
- package/lib/utils/helpers/repositoryResource.js.map +1 -1
- package/package.json +18 -18
- package/src/constants/Settings.js +8 -2
- package/src/hooks/__tests__/UseModularUIModel.spec.js +11 -4
- package/src/hooks/__tests__/useAuthentication.spec.js +2 -8
- package/src/hooks/__tests__/useForm.spec.js +14 -12
- package/src/hooks/__tests__/useModelCatalog.spec.js +10 -4
- package/src/hooks/__tests__/useModels.spec.js +3 -12
- package/src/hooks/__tests__/useModularUIBasic.spec.js +9 -8
- package/src/hooks/useModularUI.js +25 -15
- package/src/hooks/useModularUIBasic.js +66 -50
- package/src/models/concepts/ConceptDetailModel.js +2 -7
- package/src/models/concepts/ConceptIndexModel.js +7 -1
- package/src/models/concepts/ConceptLinkModel.js +14 -9
- package/src/models/concepts/ConceptTypeDetailModel.js +3 -25
- package/src/models/concepts/SourceReferenceCollection.js +8 -1
- package/src/models/concepts/SourceReferenceModel.js +19 -3
- package/src/models/concepts/__mock__/conceptindex.js +15 -0
- package/src/models/concepts/__mock__/conceptindex_contributions.json +86 -0
- package/src/models/concepts/__mock__/conceptindex_data.json +323 -0
- package/src/models/concepts/__mock__/concepttype_hierarchy.json +1 -11
- package/src/models/concepts/__tests__/ConceptIndexModel.spec.js +30 -2
- package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +1 -18
- package/src/models/content/ContentLinkModel.js +19 -4
- package/src/models/content/SectionModel.js +31 -5
- package/src/models/error/ErrorResponse.js +34 -5
- package/src/modularui/CaptchaRequest.js +17 -3
- package/src/modularui/ModularUIRequest.js +3 -1
- package/src/modularui/UploadRequest.js +12 -2
- package/src/redux/_modularui/ModularUIActions.js +20 -10
- package/src/redux/_modularui/ModularUIMiddleware.js +6 -3
- package/src/redux/_modularui/ModularUIReducer.js +1 -0
- package/src/redux/_modularui/ModularUISelectors.js +22 -10
- package/src/redux/_modularui/__tests__/actions.spec.js +1 -4
- package/src/redux/_modularui/types.js +1 -0
- package/src/redux/actions/__tests__/Application.spec.js +1 -8
- package/src/redux/actions/__tests__/Authorization.spec.js +0 -4
- package/src/redux/connectors/PanelRenderer.js +0 -1
- package/src/utils/helpers/repositoryResource.js +8 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceReferenceModel.js","names":["_createHash","require","_ContentLinkModel","_interopRequireDefault","_Href","SourceReferenceModel","constructor","sourceReference","entryDate","arguments","length","undefined","_defineProperty2","default","_sourceReference","_entryDate","link","section","_links","self","href","replace","content","ContentLinkModel","selfhref","Href","type","label","sourceLabel","referenceHash","createHashFromHref","_default","exports"],"sources":["../../../src/models/concepts/SourceReferenceModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport ContentLinkModel from \"../content/ContentLinkModel\";\nimport Href from \"../href/Href\";\n\n/**\n */\nclass SourceReferenceModel {\n _sourceReference: Object;\n _entryDate: ?ISO_DATE;\n\n /**\n */\n constructor(sourceReference: Object
|
|
1
|
+
{"version":3,"file":"SourceReferenceModel.js","names":["_createHash","require","_ContentLinkModel","_interopRequireDefault","_Href","_constants","SourceReferenceModel","constructor","sourceReference","entryDate","arguments","length","undefined","origin","contextPath","_defineProperty2","default","getBasePath","_sourceReference","_entryDate","_origin","_contextPath","link","section","_links","self","href","replace","content","ContentLinkModel","selfhref","Href","type","label","sourceLabel","referenceHash","createHashFromHref","_default","exports"],"sources":["../../../src/models/concepts/SourceReferenceModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport ContentLinkModel from \"../content/ContentLinkModel\";\nimport Href from \"../href/Href\";\nimport { getBasePath } from \"../../constants\";\n\n/**\n */\nclass SourceReferenceModel {\n _sourceReference: Object;\n _entryDate: ?ISO_DATE;\n _origin: string = \"\";\n _contextPath: string = getBasePath();\n\n /**\n */\n constructor(\n sourceReference: Object,\n entryDate: ?ISO_DATE = null,\n origin?: string,\n contextPath?: string,\n ) {\n this._sourceReference = sourceReference;\n this._entryDate = entryDate;\n this._origin = origin || \"\";\n this._contextPath = contextPath || getBasePath();\n }\n\n /**\n */\n get link(): ContentLinkModel {\n const section = 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._origin,\n this._contextPath,\n );\n }\n\n /**\n */\n get selfhref(): Href {\n return new Href(\n this._sourceReference._links.self.href,\n \"SourceReference\",\n this._origin,\n this._contextPath,\n );\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 get referenceHash(): number {\n return createHashFromHref(this.selfhref);\n }\n}\n\nexport default SourceReferenceModel;\n"],"mappings":";;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;A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IACnB,OAAO,IAAIC,aAAI,CACb,IAAI,CAACb,gBAAgB,CAACM,MAAM,CAACC,IAAI,CAACC,IAAI,EACtC,iBAAiB,EACjB,IAAI,CAACN,OAAO,EACZ,IAAI,CAACC,YACP,CAAC;EACH;;EAEA;AACF;EACE,IAAIW,IAAIA,CAAA,EAAW;IACjB,OAAO,IAAI,CAACd,gBAAgB,CAACc,IAAI;EACnC;;EAEA;AACF;EACE,IAAIC,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACf,gBAAgB,CAACe,KAAK;EACpC;;EAEA;AACF;EACE,IAAIC,WAAWA,CAAA,EAAW;IACxB,OAAO,IAAI,CAAChB,gBAAgB,CAACgB,WAAW;EAC1C;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAW;IAC1B,OAAO,IAAAC,8BAAkB,EAAC,IAAI,CAACN,QAAQ,CAAC;EAC1C;AACF;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAAtB,OAAA,GAEcV,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import ConceptIndexModel from "../ConceptIndexModel";
|
|
2
|
+
import ModularUIResponse from "../../../modularui/ModularUIResponse";
|
|
3
|
+
|
|
4
|
+
import data from "./conceptindex_data.json";
|
|
5
|
+
import contributions from "./conceptindex_contributions.json";
|
|
6
|
+
|
|
7
|
+
const conceptIndexResponse = ModularUIResponse.create({
|
|
8
|
+
key: "ConceptSearch",
|
|
9
|
+
data,
|
|
10
|
+
contributions,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const conceptIndex = new ConceptIndexModel(conceptIndexResponse);
|
|
14
|
+
|
|
15
|
+
export { conceptIndex };
|
|
@@ -1,10 +1,38 @@
|
|
|
1
1
|
import ConceptIndexModel from "../ConceptIndexModel";
|
|
2
2
|
|
|
3
|
+
import { conceptIndex } from "../__mock__/conceptindex";
|
|
4
|
+
|
|
3
5
|
describe("conceptIndexModel", () => {
|
|
4
6
|
it("should be able to create an empty ConceptIndexModel object", () => {
|
|
5
|
-
const
|
|
7
|
+
const emptyConceptIndex = new ConceptIndexModel();
|
|
8
|
+
|
|
9
|
+
expect(emptyConceptIndex).toBeInstanceOf(ConceptIndexModel);
|
|
10
|
+
expect(emptyConceptIndex.type).toBe("ConceptIndex");
|
|
11
|
+
});
|
|
6
12
|
|
|
13
|
+
it("should be able to create a ConceptIndexModel from concept search resposne", () => {
|
|
7
14
|
expect(conceptIndex).toBeInstanceOf(ConceptIndexModel);
|
|
8
|
-
|
|
15
|
+
|
|
16
|
+
expect(conceptIndex.label).toBe("Concept search");
|
|
17
|
+
expect(conceptIndex.selfhref.toString()).toBe(
|
|
18
|
+
"/concepts?entryDate=2024-10-21",
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
expect(conceptIndex.indexfilter.label).toBe("Index");
|
|
22
|
+
expect(conceptIndex.searchtermfilter.label).toBe("Label");
|
|
23
|
+
expect(conceptIndex.modelCategoryFilter.label).toBe("Model category");
|
|
24
|
+
|
|
25
|
+
expect(conceptIndex.items.size).toBe(7);
|
|
26
|
+
|
|
27
|
+
const firstItem = conceptIndex.items.first;
|
|
28
|
+
expect(firstItem.label).toBe(
|
|
29
|
+
"Capture compliance artifacts in customer case",
|
|
30
|
+
);
|
|
31
|
+
expect(firstItem.selfhref.toString()).toBe(
|
|
32
|
+
"/concepts/bundle-com.beinformed.models.FSDemoBusinessDesign/High%20level%20requirements/Architectural%20significant%20requirements.beimodel.json/CaptureComplianceArtifactsInCustomerCase?entryDate=2024-10-21",
|
|
33
|
+
);
|
|
34
|
+
expect(firstItem.conceptTypeLink.href.toString()).toBe(
|
|
35
|
+
"/concepttypes/bundle-com.beinformed.fs.demo.metamodels/High%20level%20requirements.bixml/ArchitecturalSignificantRequirement",
|
|
36
|
+
);
|
|
9
37
|
});
|
|
10
38
|
});
|
|
@@ -19,30 +19,13 @@ describe("conceptTypeDetailModel", () => {
|
|
|
19
19
|
expect(conceptTypeDetail.backgroundColor).toBe("#FFFF3C");
|
|
20
20
|
expect(conceptTypeDetail.borderColor).toBe("#000000");
|
|
21
21
|
|
|
22
|
-
expect(conceptTypeDetail.conceptTypeHierarchy.length).toBe(2);
|
|
23
22
|
expect(
|
|
24
23
|
conceptTypeDetail.isOfConceptType(
|
|
25
|
-
"
|
|
24
|
+
"/concepttypes/bundle-com.beinformed.fs.demo.metamodels/Advice%20and%20request%20business%20scenarios.bixml/ScenarioStep_Advice",
|
|
26
25
|
),
|
|
27
26
|
).toBe(true);
|
|
28
|
-
expect(
|
|
29
|
-
conceptTypeDetail.isOfConceptType("BusinessScenarios#ScenarioStep"),
|
|
30
|
-
).toBe(true);
|
|
31
27
|
expect(conceptTypeDetail.isOfConceptType("BEI_CaseManagement#Case")).toBe(
|
|
32
28
|
false,
|
|
33
29
|
);
|
|
34
|
-
|
|
35
|
-
expect(
|
|
36
|
-
conceptTypeDetail.isOfConceptType(
|
|
37
|
-
"/concepttypes/bundle-com.beinformed.fs.demo.metamodels/Business%20scenarios.bixml/ScenarioStep",
|
|
38
|
-
),
|
|
39
|
-
).toBe(true);
|
|
40
|
-
|
|
41
|
-
expect(
|
|
42
|
-
conceptTypeDetail.hasMetamodelIdInHierarchy("BusinessScenarios"),
|
|
43
|
-
).toBe(true);
|
|
44
|
-
expect(
|
|
45
|
-
conceptTypeDetail.hasMetamodelIdInHierarchy("BEI_CaseManagement"),
|
|
46
|
-
).toBe(false);
|
|
47
30
|
});
|
|
48
31
|
});
|
|
@@ -13,6 +13,7 @@ var _LinkModel = _interopRequireDefault(require("../links/LinkModel"));
|
|
|
13
13
|
var _ContentTypeModel = _interopRequireDefault(require("./ContentTypeModel"));
|
|
14
14
|
var _Constants = require("../../constants/Constants");
|
|
15
15
|
var _LinkCollection = _interopRequireDefault(require("../links/LinkCollection"));
|
|
16
|
+
var _constants = require("../../constants");
|
|
16
17
|
/**
|
|
17
18
|
* Link to a concept
|
|
18
19
|
*/
|
|
@@ -21,12 +22,18 @@ class ContentLinkModel extends _BaseModel.default {
|
|
|
21
22
|
*/
|
|
22
23
|
constructor(data) {
|
|
23
24
|
let entryDate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
25
|
+
let origin = arguments.length > 2 ? arguments[2] : undefined;
|
|
26
|
+
let contextPath = arguments.length > 3 ? arguments[3] : undefined;
|
|
24
27
|
super(data, {});
|
|
25
28
|
(0, _defineProperty2.default)(this, "_links", void 0);
|
|
26
29
|
(0, _defineProperty2.default)(this, "_entryDate", void 0);
|
|
27
30
|
(0, _defineProperty2.default)(this, "_contentType", null);
|
|
28
31
|
(0, _defineProperty2.default)(this, "_items", void 0);
|
|
32
|
+
(0, _defineProperty2.default)(this, "_origin", "");
|
|
33
|
+
(0, _defineProperty2.default)(this, "_contextPath", (0, _constants.getBasePath)());
|
|
29
34
|
this._entryDate = entryDate;
|
|
35
|
+
this._origin = origin || "";
|
|
36
|
+
this._contextPath = contextPath || (0, _constants.getBasePath)();
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
/**
|
|
@@ -97,9 +104,8 @@ class ContentLinkModel extends _BaseModel.default {
|
|
|
97
104
|
/**
|
|
98
105
|
*/
|
|
99
106
|
createEncodedHref() {
|
|
100
|
-
// TODO SBO: origin and context
|
|
101
107
|
const startURI = "/content/";
|
|
102
|
-
const selfHref = new _Href.default(this.data._links.self.href);
|
|
108
|
+
const selfHref = new _Href.default(this.data._links.self.href, this._origin, this._contextPath);
|
|
103
109
|
const href = selfHref.path;
|
|
104
110
|
const section = this.data.section;
|
|
105
111
|
const sourceId = section ? href.substring(startURI.length, href.lastIndexOf("/")) : href.substring(startURI.length);
|
|
@@ -128,8 +134,7 @@ class ContentLinkModel extends _BaseModel.default {
|
|
|
128
134
|
*/
|
|
129
135
|
get links() {
|
|
130
136
|
if (!this._links) {
|
|
131
|
-
|
|
132
|
-
this._links = new _LinkCollection.default(Array.isArray(this.data._links) ? this.data._links[0] : this.data._links);
|
|
137
|
+
this._links = new _LinkCollection.default(Array.isArray(this.data._links) ? this.data._links[0] : this.data._links, null, this._origin, this._contextPath);
|
|
133
138
|
}
|
|
134
139
|
return this._links;
|
|
135
140
|
}
|
|
@@ -8,6 +8,7 @@ import { TIMEVERSION_FILTER_NAME } from "../../constants/Constants";
|
|
|
8
8
|
import LinkCollection from "../links/LinkCollection";
|
|
9
9
|
|
|
10
10
|
import type { ModularUIModel, IModelWithChildModels } from "../types";
|
|
11
|
+
import { getBasePath } from "../../constants";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Link to a concept
|
|
@@ -20,13 +21,22 @@ export default class ContentLinkModel
|
|
|
20
21
|
_entryDate: ?ISO_DATE;
|
|
21
22
|
_contentType: ContentTypeModel | null = null;
|
|
22
23
|
_items: Array<ContentLinkModel>;
|
|
24
|
+
_origin: string = "";
|
|
25
|
+
_contextPath: string = getBasePath();
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
*/
|
|
26
|
-
constructor(
|
|
29
|
+
constructor(
|
|
30
|
+
data: Object,
|
|
31
|
+
entryDate: ?ISO_DATE = null,
|
|
32
|
+
origin?: string,
|
|
33
|
+
contextPath?: string,
|
|
34
|
+
) {
|
|
27
35
|
super(data, {});
|
|
28
36
|
|
|
29
37
|
this._entryDate = entryDate;
|
|
38
|
+
this._origin = origin || "";
|
|
39
|
+
this._contextPath = contextPath || getBasePath();
|
|
30
40
|
}
|
|
31
41
|
|
|
32
42
|
/**
|
|
@@ -102,9 +112,12 @@ export default class ContentLinkModel
|
|
|
102
112
|
/**
|
|
103
113
|
*/
|
|
104
114
|
createEncodedHref(): Href {
|
|
105
|
-
// TODO SBO: origin and context
|
|
106
115
|
const startURI = "/content/";
|
|
107
|
-
const selfHref = new Href(
|
|
116
|
+
const selfHref = new Href(
|
|
117
|
+
this.data._links.self.href,
|
|
118
|
+
this._origin,
|
|
119
|
+
this._contextPath,
|
|
120
|
+
);
|
|
108
121
|
const href = selfHref.path;
|
|
109
122
|
|
|
110
123
|
const section = this.data.section;
|
|
@@ -140,11 +153,13 @@ export default class ContentLinkModel
|
|
|
140
153
|
*/
|
|
141
154
|
get links(): LinkCollection {
|
|
142
155
|
if (!this._links) {
|
|
143
|
-
// TODO SBO: origin and context
|
|
144
156
|
this._links = new LinkCollection(
|
|
145
157
|
Array.isArray(this.data._links)
|
|
146
158
|
? this.data._links[0]
|
|
147
159
|
: this.data._links,
|
|
160
|
+
null,
|
|
161
|
+
this._origin,
|
|
162
|
+
this._contextPath,
|
|
148
163
|
);
|
|
149
164
|
}
|
|
150
165
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentLinkModel.js","names":["_BaseModel","_interopRequireDefault","require","_Href","_LinkModel","_ContentTypeModel","_Constants","_LinkCollection","ContentLinkModel","BaseModel","constructor","data","entryDate","arguments","length","undefined","_defineProperty2","default","_entryDate","getInitialChildModelLinks","contentTypeLink","isCacheable","setChildModels","models","href","contentTypeModel","_find","call","model","selfhref","equalsWithParameters","type","contentType","_contentType","ContentTypeModel","key","getData","label","sourceLabel","createEncodedHref","startURI","selfHref","Href","_links","self","path","section","sourceId","substring","lastIndexOf","encodeURIComponent","encodedHref","addParameter","TIMEVERSION_FILTER_NAME","links","LinkCollection","Array","isArray","selflink","getLinkByKey","Error","subSectionID","hash","contentTypeHref","items","_items","exports"],"sources":["../../../src/models/content/ContentLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport LinkCollection from \"../links/LinkCollection\";\n\nimport type { ModularUIModel, IModelWithChildModels } 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(data: Object, entryDate: ?ISO_DATE = null) {\n super(data, {});\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 createEncodedHref(): Href {\n // TODO SBO: origin and context\n const startURI = \"/content/\";\n const selfHref = new Href(this.data._links.self.href);\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 // TODO SBO: origin and context\n this._links = new LinkCollection(\n Array.isArray(this.data._links)\n ? this.data._links[0]\n : this.data._links,\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 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 * Children of link model in TOC\n */\n set items(items: Array<ContentLinkModel>) {\n this._items = items;\n }\n\n /**\n */\n get items(): Array<ContentLinkModel> {\n return this._items;\n }\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,iBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,IAAAK,eAAA,GAAAN,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACe,MAAMM,gBAAgB,SAC3BC,kBAAS,CAEnB;EAME;AACF;EACEC,WAAWA,CAACC,IAAY,EAA+B;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C,IAAI;EAC3B;;EAEA;AACF;EACE,IAAI1C,eAAeA,CAAA,EAAqB;IACtC,OAAO,IAAI,CAACkC,KAAK,CAACK,YAAY,CAAC,aAAa,CAAC;EAC/C;;EAEA;AACF;AACA;EACE,IAAII,eAAeA,CAAA,EAAgB;IACjC,IAAI,IAAI,CAAC3C,eAAe,EAAE;MACxB,OAAO,IAAI,CAACA,eAAe,CAACI,IAAI;IAClC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACE,IAAIwC,KAAKA,CAACA,KAA8B,EAAE;IACxC,IAAI,CAACC,MAAM,GAAGD,KAAK;EACrB;;EAEA;AACF;EACE,IAAIA,KAAKA,CAAA,EAA4B;IACnC,OAAO,IAAI,CAACC,MAAM;EACpB;AACF;AAACC,OAAA,CAAAjD,OAAA,GAAAT,gBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ContentLinkModel.js","names":["_BaseModel","_interopRequireDefault","require","_Href","_LinkModel","_ContentTypeModel","_Constants","_LinkCollection","_constants","ContentLinkModel","BaseModel","constructor","data","entryDate","arguments","length","undefined","origin","contextPath","_defineProperty2","default","getBasePath","_entryDate","_origin","_contextPath","getInitialChildModelLinks","contentTypeLink","isCacheable","setChildModels","models","href","contentTypeModel","_find","call","model","selfhref","equalsWithParameters","type","contentType","_contentType","ContentTypeModel","key","getData","label","sourceLabel","createEncodedHref","startURI","selfHref","Href","_links","self","path","section","sourceId","substring","lastIndexOf","encodeURIComponent","encodedHref","addParameter","TIMEVERSION_FILTER_NAME","links","LinkCollection","Array","isArray","selflink","getLinkByKey","Error","subSectionID","hash","contentTypeHref","items","_items","exports"],"sources":["../../../src/models/content/ContentLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport LinkCollection from \"../links/LinkCollection\";\n\nimport type { ModularUIModel, IModelWithChildModels } from \"../types\";\nimport { getBasePath } from \"../../constants\";\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 _origin: string = \"\";\n _contextPath: string = getBasePath();\n\n /**\n */\n constructor(\n data: Object,\n entryDate: ?ISO_DATE = null,\n origin?: string,\n contextPath?: string,\n ) {\n super(data, {});\n\n this._entryDate = entryDate;\n this._origin = origin || \"\";\n this._contextPath = contextPath || getBasePath();\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 createEncodedHref(): Href {\n const startURI = \"/content/\";\n const selfHref = new Href(\n this.data._links.self.href,\n this._origin,\n this._contextPath,\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._origin,\n this._contextPath,\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 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 * 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,I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AI,CAACC,MAAM,GAAGD,KAAK;EACrB;;EAEA;AACF;EACE,IAAIA,KAAKA,CAAA,EAA4B;IACnC,OAAO,IAAI,CAACC,MAAM;EACpB;AACF;AAACC,OAAA,CAAApD,OAAA,GAAAX,gBAAA","ignoreList":[]}
|
|
@@ -14,15 +14,20 @@ var _SubSectionModel = _interopRequireDefault(require("./SubSectionModel"));
|
|
|
14
14
|
var _createHash = require("../../utils/helpers/createHash");
|
|
15
15
|
var _LinkModel = _interopRequireDefault(require("../links/LinkModel"));
|
|
16
16
|
var _utils = require("../../utils");
|
|
17
|
+
var _constants = require("../../constants");
|
|
17
18
|
/**
|
|
18
19
|
*/
|
|
19
20
|
class SectionModel extends _BaseModel.default {
|
|
20
|
-
constructor(data, entryDate) {
|
|
21
|
+
constructor(data, entryDate, origin, contextPath) {
|
|
21
22
|
super(data, {});
|
|
22
23
|
(0, _defineProperty2.default)(this, "_entryDate", void 0);
|
|
23
24
|
(0, _defineProperty2.default)(this, "_selflink", void 0);
|
|
24
25
|
(0, _defineProperty2.default)(this, "_childSections", void 0);
|
|
26
|
+
(0, _defineProperty2.default)(this, "_origin", "");
|
|
27
|
+
(0, _defineProperty2.default)(this, "_contextPath", (0, _constants.getBasePath)());
|
|
25
28
|
this._entryDate = entryDate;
|
|
29
|
+
this._origin = origin || "";
|
|
30
|
+
this._contextPath = contextPath || (0, _constants.getBasePath)();
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
/**
|
|
@@ -35,8 +40,7 @@ class SectionModel extends _BaseModel.default {
|
|
|
35
40
|
*/
|
|
36
41
|
get selflink() {
|
|
37
42
|
if (!this._selflink) {
|
|
38
|
-
|
|
39
|
-
this._selflink = new _LinkModel.default(this.data._links?.self);
|
|
43
|
+
this._selflink = new _LinkModel.default(this.data._links?.self, null, this._origin, this._contextPath);
|
|
40
44
|
}
|
|
41
45
|
return this._selflink;
|
|
42
46
|
}
|
|
@@ -109,7 +113,7 @@ class SectionModel extends _BaseModel.default {
|
|
|
109
113
|
label: childSection.label,
|
|
110
114
|
sourceLabel: childSection.sourceLabel,
|
|
111
115
|
_links: childSection._links
|
|
112
|
-
}, this.entryDate)) : [];
|
|
116
|
+
}, this.entryDate, this._origin, this._contextPath)) : [];
|
|
113
117
|
}
|
|
114
118
|
|
|
115
119
|
/**
|
|
@@ -121,7 +125,7 @@ class SectionModel extends _BaseModel.default {
|
|
|
121
125
|
label: this.data.label,
|
|
122
126
|
sourceLabel: this.data.sourceLabel,
|
|
123
127
|
_links: this.data._links
|
|
124
|
-
}, this.entryDate);
|
|
128
|
+
}, this.entryDate, this._origin, this._contextPath);
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
/**
|
|
@@ -130,7 +134,7 @@ class SectionModel extends _BaseModel.default {
|
|
|
130
134
|
get childSections() {
|
|
131
135
|
if (!this._childSections && this.data.childSections) {
|
|
132
136
|
var _context2, _context3;
|
|
133
|
-
this._childSections = (0, _map.default)(_context2 = (0, _filter.default)(_context3 = this.data.childSections).call(_context3, childSection => "body" in childSection)).call(_context2, childSection => new SectionModel(childSection, this.entryDate));
|
|
137
|
+
this._childSections = (0, _map.default)(_context2 = (0, _filter.default)(_context3 = this.data.childSections).call(_context3, childSection => "body" in childSection)).call(_context2, childSection => new SectionModel(childSection, this.entryDate, this._origin, this._contextPath));
|
|
134
138
|
}
|
|
135
139
|
return this._childSections || [];
|
|
136
140
|
}
|
|
@@ -8,6 +8,7 @@ import LinkModel from "../links/LinkModel";
|
|
|
8
8
|
|
|
9
9
|
import type Href from "../href/Href";
|
|
10
10
|
import { retrieveText } from "../../utils";
|
|
11
|
+
import { getBasePath } from "../../constants";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
*/
|
|
@@ -15,11 +16,20 @@ class SectionModel extends BaseModel {
|
|
|
15
16
|
_entryDate: ISO_DATE | null;
|
|
16
17
|
_selflink: ?LinkModel;
|
|
17
18
|
_childSections: Array<SectionModel>;
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
_origin: string = "";
|
|
20
|
+
_contextPath: string = getBasePath();
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
data: Object,
|
|
24
|
+
entryDate: ISO_DATE | null,
|
|
25
|
+
origin?: string,
|
|
26
|
+
contextPath?: string,
|
|
27
|
+
) {
|
|
20
28
|
super(data, {});
|
|
21
29
|
|
|
22
30
|
this._entryDate = entryDate;
|
|
31
|
+
this._origin = origin || "";
|
|
32
|
+
this._contextPath = contextPath || getBasePath();
|
|
23
33
|
}
|
|
24
34
|
|
|
25
35
|
/**
|
|
@@ -32,8 +42,12 @@ class SectionModel extends BaseModel {
|
|
|
32
42
|
*/
|
|
33
43
|
get selflink(): LinkModel {
|
|
34
44
|
if (!this._selflink) {
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
this._selflink = new LinkModel(
|
|
46
|
+
this.data._links?.self,
|
|
47
|
+
null,
|
|
48
|
+
this._origin,
|
|
49
|
+
this._contextPath,
|
|
50
|
+
);
|
|
37
51
|
}
|
|
38
52
|
return this._selflink;
|
|
39
53
|
}
|
|
@@ -111,6 +125,8 @@ class SectionModel extends BaseModel {
|
|
|
111
125
|
_links: childSection._links,
|
|
112
126
|
},
|
|
113
127
|
this.entryDate,
|
|
128
|
+
this._origin,
|
|
129
|
+
this._contextPath,
|
|
114
130
|
),
|
|
115
131
|
)
|
|
116
132
|
: [];
|
|
@@ -128,6 +144,8 @@ class SectionModel extends BaseModel {
|
|
|
128
144
|
_links: this.data._links,
|
|
129
145
|
},
|
|
130
146
|
this.entryDate,
|
|
147
|
+
this._origin,
|
|
148
|
+
this._contextPath,
|
|
131
149
|
);
|
|
132
150
|
}
|
|
133
151
|
|
|
@@ -138,7 +156,15 @@ class SectionModel extends BaseModel {
|
|
|
138
156
|
if (!this._childSections && this.data.childSections) {
|
|
139
157
|
this._childSections = this.data.childSections
|
|
140
158
|
.filter((childSection) => "body" in childSection)
|
|
141
|
-
.map(
|
|
159
|
+
.map(
|
|
160
|
+
(childSection) =>
|
|
161
|
+
new SectionModel(
|
|
162
|
+
childSection,
|
|
163
|
+
this.entryDate,
|
|
164
|
+
this._origin,
|
|
165
|
+
this._contextPath,
|
|
166
|
+
),
|
|
167
|
+
);
|
|
142
168
|
}
|
|
143
169
|
return this._childSections || [];
|
|
144
170
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionModel.js","names":["_BaseModel","_interopRequireDefault","require","_ContentLinkModel","_SubSectionModel","_createHash","_LinkModel","_utils","SectionModel","BaseModel","constructor","data","entryDate","_defineProperty2","default","_entryDate","referred","selflink","_selflink","LinkModel","_links","self","selfhref","href","type","sourceLabel","id","_id","key","label","getData","number","body","retrieveText","childSectionLinks","_context","childSections","_map","call","childSection","ContentLinkModel","section","selfContentLink","_childSections","_context2","_context3","_filter","sections","subSections","_context4","subSection","SubSectionModel","referenceHash","createHashFromHref","getReferredSections","push","referredChilds","_default","exports"],"sources":["../../../src/models/content/SectionModel.js"],"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\n/**\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 // TODO SBO: origin and context\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"],"mappings":";;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAL,sBAAA,CAAAC,OAAA;AAGA,IAAAK,MAAA,GAAAL,OAAA;AAEA;AACA;AACA,MAAMM,YAAY,SAASC,kBAAS,CAAC;EAKnCC,WAAWA,CAACC,IAAY,EAAEC,SAA0B,EAAE;IACpD,KAAK,CAACD,IAAI,EAAE,CAAC,CAAC,CAAC;IAAC,IAAAE,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEhB,IAAI,CAACC,UAAU,GAAGH,SAAS;EAC7B;;EAEA;AACF;EACE,IAAII,QAAQA,CAAA,EAAY;IACtB,OAAO,IAAI,CAACL,IAAI,CAACK,QAAQ;EAC3B;;EAEA;AACF;EACE,IAAIC,QAAQA,CAAA,EAAc;IACxB,IAAI,CAAC,IAAI,CAACC,SAAS,EAAE;MACnB;MACA,IAAI,CAACA,SAAS,GAAG,IAAIC,kBAAS,CAAC,IAAI,CAACR,IAAI,CAACS,MAAM,EAAEC,IAAI,CAAC;IACxD;IACA,OAAO,IAAI,CAACH,SAAS;EACvB;;EAEA;AACF;EACE,IAAII,QAAQA,CAAA,EAAS;IACnB,OAAO,IAAI,CAACL,QAAQ,CAACM,IAAI;EAC3B;;EAEA;AACF;EACE,IAAIX,SAASA,CAAA,EAAoB;IAC/B,OAAO,IAAI,CAACG,UAAU;EACxB;;EAEA;AACF;EACE,IAAIS,IAAIA,CAAA,EAAW;IACjB,O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,EAAAV,IAAA,CAAAW,SAAA,EAClBC,UAAU,IAAK,IAAIC,wBAAe,CAACD,UAAU,CAChD,CAAC,GACD,EAAE;EACR;;EAEA;AACF;EACE,IAAIE,aAAaA,CAAA,EAAW;IAC1B,OAAO,IAAAC,8BAAkB,EAAC,IAAI,CAAC/B,QAAQ,CAAC;EAC1C;;EAEA;AACF;EACEgC,mBAAmBA,CAAA,EAA0C;IAC3D,MAAMP,QAAQ,GAAG,EAAE;IAEnB,KAAK,MAAMG,UAAU,IAAI,IAAI,CAACF,WAAW,EAAE;MACzC,IAAIE,UAAU,CAAClC,QAAQ,EAAE;QACvB+B,QAAQ,CAACQ,IAAI,CAACL,UAAU,CAAC;MAC3B;MAEA,MAAMM,cAAc,GAAGN,UAAU,CAACI,mBAAmB,CAAC,CAAC;MACvDP,QAAQ,CAACQ,IAAI,CAAC,GAAGC,cAAc,CAAC;IAClC;IAEA,KAAK,MAAMjB,YAAY,IAAI,IAAI,CAACH,aAAa,EAAE;MAC7C,IAAIG,YAAY,CAACvB,QAAQ,EAAE;QACzB+B,QAAQ,CAACQ,IAAI,CAAChB,YAAY,CAAC;MAC7B;MAEA,MAAMiB,cAAc,GAAGjB,YAAY,CAACe,mBAAmB,CAAC,CAAC;MACzDP,QAAQ,CAACQ,IAAI,CAAC,GAAGC,cAAc,CAAC;IAClC;IAEA,OAAOT,QAAQ;EACjB;AACF;AAAC,IAAAU,QAAA,GAAAC,OAAA,CAAA5C,OAAA,GAEcN,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"SectionModel.js","names":["_BaseModel","_interopRequireDefault","require","_ContentLinkModel","_SubSectionModel","_createHash","_LinkModel","_utils","_constants","SectionModel","BaseModel","constructor","data","entryDate","origin","contextPath","_defineProperty2","default","getBasePath","_entryDate","_origin","_contextPath","referred","selflink","_selflink","LinkModel","_links","self","selfhref","href","type","sourceLabel","id","_id","key","label","getData","number","body","retrieveText","childSectionLinks","_context","childSections","_map","call","childSection","ContentLinkModel","section","selfContentLink","_childSections","_context2","_context3","_filter","sections","subSections","_context4","subSection","SubSectionModel","referenceHash","createHashFromHref","getReferredSections","push","referredChilds","_default","exports"],"sources":["../../../src/models/content/SectionModel.js"],"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\";\nimport { getBasePath } from \"../../constants\";\n\n/**\n */\nclass SectionModel extends BaseModel {\n _entryDate: ISO_DATE | null;\n _selflink: ?LinkModel;\n _childSections: Array<SectionModel>;\n _origin: string = \"\";\n _contextPath: string = getBasePath();\n\n constructor(\n data: Object,\n entryDate: ISO_DATE | null,\n origin?: string,\n contextPath?: string,\n ) {\n super(data, {});\n\n this._entryDate = entryDate;\n this._origin = origin || \"\";\n this._contextPath = contextPath || getBasePath();\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(\n this.data._links?.self,\n null,\n this._origin,\n this._contextPath,\n );\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 this._origin,\n this._contextPath,\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 this._origin,\n this._contextPath,\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(\n (childSection) =>\n new SectionModel(\n childSection,\n this.entryDate,\n this._origin,\n this._contextPath,\n ),\n );\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"],"mappings":";;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IA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
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
9
9
|
var _Href = _interopRequireDefault(require("../href/Href"));
|
|
10
10
|
var _LayoutHintCollection = _interopRequireDefault(require("../layouthint/LayoutHintCollection"));
|
|
11
|
+
var _constants = require("../../constants");
|
|
11
12
|
/**
|
|
12
13
|
*/
|
|
13
14
|
/**
|
|
@@ -21,11 +22,15 @@ class ErrorResponse {
|
|
|
21
22
|
/**
|
|
22
23
|
* Construct ErrorResponse
|
|
23
24
|
*/
|
|
24
|
-
constructor(data, connectKey) {
|
|
25
|
+
constructor(data, connectKey, origin, contextPath) {
|
|
25
26
|
(0, _defineProperty2.default)(this, "_error", void 0);
|
|
26
27
|
(0, _defineProperty2.default)(this, "_connectKey", void 0);
|
|
28
|
+
(0, _defineProperty2.default)(this, "_origin", "");
|
|
29
|
+
(0, _defineProperty2.default)(this, "_contextPath", (0, _constants.getBasePath)());
|
|
27
30
|
this._error = data;
|
|
28
31
|
this._connectKey = connectKey;
|
|
32
|
+
this._origin = origin || "";
|
|
33
|
+
this._contextPath = contextPath || (0, _constants.getBasePath)();
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
/**
|
|
@@ -40,6 +45,18 @@ class ErrorResponse {
|
|
|
40
45
|
return this._connectKey;
|
|
41
46
|
}
|
|
42
47
|
|
|
48
|
+
/**
|
|
49
|
+
*/
|
|
50
|
+
get origin() {
|
|
51
|
+
return this._origin;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
*/
|
|
56
|
+
get contextPath() {
|
|
57
|
+
return this._contextPath;
|
|
58
|
+
}
|
|
59
|
+
|
|
43
60
|
/**
|
|
44
61
|
* Return error information
|
|
45
62
|
*/
|
|
@@ -145,9 +162,8 @@ class ErrorResponse {
|
|
|
145
162
|
* Return response error redirect href
|
|
146
163
|
*/
|
|
147
164
|
get redirectHref() {
|
|
148
|
-
// TODO SBO: origin and context
|
|
149
165
|
if (this.response.redirect?.href) {
|
|
150
|
-
return new _Href.default(this.response.redirect?.href);
|
|
166
|
+
return new _Href.default(this.response.redirect?.href, "", this.origin, this.contextPath);
|
|
151
167
|
}
|
|
152
168
|
return new _Href.default();
|
|
153
169
|
}
|
|
@@ -262,8 +278,7 @@ class ErrorResponse {
|
|
|
262
278
|
* Get response url
|
|
263
279
|
*/
|
|
264
280
|
get changePasswordHref() {
|
|
265
|
-
|
|
266
|
-
return this.properties.redirect ? new _Href.default(this.properties.redirect) : null;
|
|
281
|
+
return this.properties.redirect ? new _Href.default(this.properties.redirect, "", this.origin, this.contextPath) : null;
|
|
267
282
|
}
|
|
268
283
|
|
|
269
284
|
/**
|
|
@@ -3,6 +3,7 @@ import Href from "../href/Href";
|
|
|
3
3
|
|
|
4
4
|
import type { MessageParameters } from "../../i18n/types";
|
|
5
5
|
import LayoutHintCollection from "../layouthint/LayoutHintCollection";
|
|
6
|
+
import { getBasePath } from "../../constants";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
*/
|
|
@@ -33,12 +34,23 @@ export default class ErrorResponse {
|
|
|
33
34
|
_error: Object;
|
|
34
35
|
_connectKey: ?string;
|
|
35
36
|
|
|
37
|
+
_origin: string = "";
|
|
38
|
+
_contextPath: string = getBasePath();
|
|
39
|
+
|
|
36
40
|
/**
|
|
37
41
|
* Construct ErrorResponse
|
|
38
42
|
*/
|
|
39
|
-
constructor(
|
|
43
|
+
constructor(
|
|
44
|
+
data: Object,
|
|
45
|
+
connectKey?: string,
|
|
46
|
+
origin?: string,
|
|
47
|
+
contextPath?: string,
|
|
48
|
+
) {
|
|
40
49
|
this._error = data;
|
|
41
50
|
this._connectKey = connectKey;
|
|
51
|
+
|
|
52
|
+
this._origin = origin || "";
|
|
53
|
+
this._contextPath = contextPath || getBasePath();
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
/**
|
|
@@ -53,6 +65,18 @@ export default class ErrorResponse {
|
|
|
53
65
|
return this._connectKey;
|
|
54
66
|
}
|
|
55
67
|
|
|
68
|
+
/**
|
|
69
|
+
*/
|
|
70
|
+
get origin(): string {
|
|
71
|
+
return this._origin;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
*/
|
|
76
|
+
get contextPath(): string {
|
|
77
|
+
return this._contextPath;
|
|
78
|
+
}
|
|
79
|
+
|
|
56
80
|
/**
|
|
57
81
|
* Return error information
|
|
58
82
|
*/
|
|
@@ -161,9 +185,13 @@ export default class ErrorResponse {
|
|
|
161
185
|
* Return response error redirect href
|
|
162
186
|
*/
|
|
163
187
|
get redirectHref(): Href {
|
|
164
|
-
// TODO SBO: origin and context
|
|
165
188
|
if (this.response.redirect?.href) {
|
|
166
|
-
return new Href(
|
|
189
|
+
return new Href(
|
|
190
|
+
this.response.redirect?.href,
|
|
191
|
+
"",
|
|
192
|
+
this.origin,
|
|
193
|
+
this.contextPath,
|
|
194
|
+
);
|
|
167
195
|
}
|
|
168
196
|
return new Href();
|
|
169
197
|
}
|
|
@@ -291,8 +319,9 @@ export default class ErrorResponse {
|
|
|
291
319
|
* Get response url
|
|
292
320
|
*/
|
|
293
321
|
get changePasswordHref(): ?Href {
|
|
294
|
-
|
|
295
|
-
|
|
322
|
+
return this.properties.redirect
|
|
323
|
+
? new Href(this.properties.redirect, "", this.origin, this.contextPath)
|
|
324
|
+
: null;
|
|
296
325
|
}
|
|
297
326
|
|
|
298
327
|
/**
|