@beinformed/ui 1.62.1 → 1.62.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/esm/models/concepts/ConceptLinkModel.d.ts +4 -7
- package/esm/models/concepts/ConceptLinkModel.js +7 -1
- package/esm/models/concepts/ConceptLinkModel.js.flow +8 -8
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.d.ts +3 -0
- package/esm/models/concepts/SourceReferenceModel.js +7 -1
- package/esm/models/concepts/SourceReferenceModel.js.flow +7 -1
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/concepts/__tests__/RelatedConcepts.spec.js.flow +6 -8
- package/esm/models/concepts/__tests__/SourceReferenceModel.spec.js.flow +3 -3
- package/esm/models/content/ContentLinkModel.js +3 -1
- package/esm/models/content/ContentLinkModel.js.flow +1 -1
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/__tests__/Formalsource.spec.js.flow +30 -0
- package/esm/models/types.d.ts +0 -1
- package/esm/models/types.js.flow +0 -1
- package/esm/models/types.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.d.ts +4 -7
- package/lib/models/concepts/ConceptLinkModel.js +7 -1
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.d.ts +3 -0
- package/lib/models/concepts/SourceReferenceModel.js +7 -1
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.js +3 -1
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/types.d.ts +0 -1
- package/lib/models/types.js.map +1 -1
- package/package.json +1 -1
- package/src/models/concepts/ConceptLinkModel.js +8 -8
- package/src/models/concepts/SourceReferenceModel.js +7 -1
- package/src/models/concepts/__mock__/related_concepts_data.json +871 -755
- package/src/models/concepts/__tests__/RelatedConcepts.spec.js +6 -8
- package/src/models/concepts/__tests__/SourceReferenceModel.spec.js +3 -3
- package/src/models/content/ContentLinkModel.js +1 -1
- package/src/models/content/__tests__/Formalsource.spec.js +30 -0
- package/src/models/types.js +0 -1
|
@@ -32,7 +32,7 @@ class SourceReferenceModel {
|
|
|
32
32
|
/**
|
|
33
33
|
*/
|
|
34
34
|
get link() {
|
|
35
|
-
const section = this.
|
|
35
|
+
const section = this.sectionId || this._sourceReference._links.self.href.replace(`${this._sourceReference._links.content.href}/`, "");
|
|
36
36
|
return new _ContentLinkModel.default({
|
|
37
37
|
...this._sourceReference,
|
|
38
38
|
section
|
|
@@ -76,6 +76,12 @@ class SourceReferenceModel {
|
|
|
76
76
|
return (0, _createHash.createHashFromHref)(this.selfhref);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
*/
|
|
81
|
+
get sectionId() {
|
|
82
|
+
return this._sourceReference.sectionId;
|
|
83
|
+
}
|
|
84
|
+
|
|
79
85
|
/**
|
|
80
86
|
*
|
|
81
87
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceReferenceModel.js","names":["_createHash","require","_ContentLinkModel","_interopRequireDefault","_Href","_constants","SourceReferenceModel","constructor","sourceReference","entryDate","arguments","length","undefined","modelOptions","_defineProperty2","default","_sourceReference","_entryDate","_modelOptions","origin","contextPath","getBasePathModularUI","link","section","
|
|
1
|
+
{"version":3,"file":"SourceReferenceModel.js","names":["_createHash","require","_ContentLinkModel","_interopRequireDefault","_Href","_constants","SourceReferenceModel","constructor","sourceReference","entryDate","arguments","length","undefined","modelOptions","_defineProperty2","default","_sourceReference","_entryDate","_modelOptions","origin","contextPath","getBasePathModularUI","link","section","sectionId","_links","self","href","replace","content","ContentLinkModel","selfhref","type","label","sourceLabel","sourceAbbreviation","referenceHash","createHashFromHref","fragment","sectionFragment","_default","exports"],"sources":["../../../src/models/concepts/SourceReferenceModel.js"],"sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport ContentLinkModel from \"../content/ContentLinkModel\";\nimport Href from \"../href/Href\";\nimport { getBasePathModularUI } from \"../../constants\";\nimport type { ModelOptions, SectionFragment } from \"../types\";\n\n/**\n */\nclass SourceReferenceModel {\n _sourceReference: Object;\n _entryDate: ?ISO_DATE;\n _modelOptions: ModelOptions;\n\n /**\n */\n constructor(\n sourceReference: Object,\n entryDate: ?ISO_DATE = null,\n modelOptions?: ModelOptions,\n ) {\n this._sourceReference = sourceReference;\n this._entryDate = entryDate;\n this._modelOptions = modelOptions || {\n origin: \"\",\n contextPath: getBasePathModularUI(),\n };\n }\n\n /**\n */\n get link(): ContentLinkModel {\n const section =\n this.sectionId ||\n this._sourceReference._links.self.href.replace(\n `${this._sourceReference._links.content.href}/`,\n \"\",\n );\n\n return new ContentLinkModel(\n {\n ...this._sourceReference,\n section,\n },\n this._entryDate,\n this._modelOptions,\n );\n }\n\n /**\n */\n get selfhref(): Href {\n return this.link.selfhref;\n }\n\n /**\n */\n get type(): string {\n return this._sourceReference.type;\n }\n\n /**\n */\n get label(): string {\n return this._sourceReference.label;\n }\n\n /**\n */\n get sourceLabel(): string {\n return this._sourceReference.sourceLabel;\n }\n\n /**\n *\n */\n get sourceAbbreviation(): string {\n return this._sourceReference.sourceAbbreviation;\n }\n\n /**\n */\n get referenceHash(): number {\n return createHashFromHref(this.selfhref);\n }\n\n /**\n */\n get sectionId(): string {\n return this._sourceReference.sectionId;\n }\n\n /**\n *\n */\n get fragment(): SectionFragment | void {\n return this._sourceReference.sectionFragment;\n }\n}\n\nexport default SourceReferenceModel;\n"],"mappings":";;;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAGA;AACA;AACA,MAAMK,oBAAoB,CAAC;EAKzB;AACF;EACEC,WAAWA,CACTC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AAI,CAAClB,gBAAgB,CAACkB,WAAW;EAC1C;;EAEA;AACF;AACA;EACE,IAAIC,kBAAkBA,CAAA,EAAW;IAC/B,OAAO,IAAI,CAACnB,gBAAgB,CAACmB,kBAAkB;EACjD;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAW;IAC1B,OAAO,IAAAC,8BAAkB,EAAC,IAAI,CAACN,QAAQ,CAAC;EAC1C;;EAEA;AACF;EACE,IAAIP,SAASA,CAAA,EAAW;IACtB,OAAO,IAAI,CAACR,gBAAgB,CAACQ,SAAS;EACxC;;EAEA;AACF;AACA;EACE,IAAIc,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAACtB,gBAAgB,CAACuB,eAAe;EAC9C;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1B,OAAA,GAEcT,oBAAoB","ignoreList":[]}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
9
|
+
var _endsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/ends-with"));
|
|
9
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
10
11
|
var _BaseModel = _interopRequireDefault(require("../base/BaseModel"));
|
|
11
12
|
var _Href = _interopRequireDefault(require("../href/Href"));
|
|
@@ -147,10 +148,11 @@ class ContentLinkModel extends _BaseModel.default {
|
|
|
147
148
|
get selflink() {
|
|
148
149
|
let selflink = this.links.getLinkByKey("self");
|
|
149
150
|
if ((0, _Settings.getSetting)("COMPLETE_SOURCE", false)) {
|
|
151
|
+
var _context;
|
|
150
152
|
if (this.links.hasLinkByKey("content")) {
|
|
151
153
|
selflink = this.links.getLinkByKey("content");
|
|
152
154
|
}
|
|
153
|
-
if (selflink != null) {
|
|
155
|
+
if (selflink != null && !(0, _endsWith.default)(_context = selflink.href.path).call(_context, this.data.section)) {
|
|
154
156
|
selflink.href.addParameter("complete", "true");
|
|
155
157
|
selflink.href.hash = this.data.section;
|
|
156
158
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentLinkModel.js","names":["_BaseModel","_interopRequireDefault","require","_Href","_LinkModel","_ContentTypeModel","_Constants","_Settings","_LinkCollection","ContentLinkModel","BaseModel","constructor","data","entryDate","arguments","length","undefined","modelOptions","_defineProperty2","default","_entryDate","getInitialChildModelLinks","contentTypeLink","isCacheable","setChildModels","models","href","contentTypeModel","_find","call","model","selfhref","equalsWithParameters","type","contentType","_contentType","ContentTypeModel","key","getData","label","sourceLabel","abbreviation","createEncodedHref","startURI","selfHref","Href","_links","self","path","section","sourceId","substring","lastIndexOf","encodeURIComponent","encodedHref","addParameter","TIMEVERSION_FILTER_NAME","links","LinkCollection","Array","isArray","selflink","getLinkByKey","getSetting","hasLinkByKey","hash","Error","state","fragment","subSectionID","contentTypeHref","sectionFragment","items","_items","exports"],"sources":["../../../src/models/content/ContentLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\n\nimport LinkCollection from \"../links/LinkCollection\";\n\nimport type {\n ModularUIModel,\n IModelWithChildModels,\n ModelOptions,\n SectionFragment,\n} from \"../types\";\n\n/**\n * Link to a concept\n */\nexport default class ContentLinkModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _links: ?LinkCollection;\n _entryDate: ?ISO_DATE;\n _contentType: ContentTypeModel | null = null;\n _items: Array<ContentLinkModel>;\n\n /**\n */\n constructor(\n data: Object,\n entryDate: ?ISO_DATE = null,\n modelOptions?: ModelOptions,\n ) {\n super(data, {}, modelOptions);\n\n this._entryDate = entryDate;\n }\n\n /**\n */\n // $FlowFixMe[method-unbinding]\n getInitialChildModelLinks(): Array<LinkModel> {\n if (this.contentTypeLink) {\n this.contentTypeLink.isCacheable = true;\n return [this.contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n // $FlowFixMe[method-unbinding]\n setChildModels(models: Array<ModularUIModel>) {\n if (this.contentTypeLink) {\n const href = this.contentTypeLink.href;\n const contentTypeModel = models.find((model) =>\n model.selfhref.equalsWithParameters(href),\n );\n\n if (contentTypeModel?.type === \"ContentType\") {\n this.contentType = contentTypeModel;\n }\n }\n }\n\n /**\n * Retrieve content type\n */\n get contentType(): ?ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n * Set concept type\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n */\n set entryDate(entryDate: ISO_DATE) {\n this._entryDate = entryDate;\n }\n\n /**\n * Retrieve key\n */\n get key(): string {\n return this.getData(\"_id\", \"\");\n }\n\n /**\n * Retrieve label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Retrieve the label of the source a link to a section belongs to\n */\n get sourceLabel(): string | null {\n return this.getData(\"sourceLabel\");\n }\n\n /**\n *\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\") || this.getData(\"sourceAbbreviation\");\n }\n\n /**\n */\n createEncodedHref(): Href {\n const startURI = \"/content/\";\n const selfHref = new Href(\n this.data._links.self.href,\n \"\",\n this.modelOptions,\n );\n const href = selfHref.path;\n\n const section = this.data.section;\n const sourceId = section\n ? href.substring(startURI.length, href.lastIndexOf(\"/\"))\n : href.substring(startURI.length);\n\n if (section) {\n selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${encodeURIComponent(section)}`;\n } else {\n selfHref.path = `${startURI}${encodeURIComponent(sourceId)}`;\n }\n\n return selfHref;\n }\n\n /**\n * Encode the content-identifier of the path to the content resource.\n * This makes it a single uri part, which can be used on routes to make nested routes\n */\n get encodedHref(): Href {\n const href = this.createEncodedHref();\n\n if (this._entryDate !== null) {\n return href.addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);\n }\n\n return href;\n }\n\n /**\n * Getting the links of the resource\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n Array.isArray(this.data._links)\n ? this.data._links[0]\n : this.data._links,\n null,\n this.modelOptions,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel {\n let selflink = this.links.getLinkByKey(\"self\");\n\n if (getSetting(\"COMPLETE_SOURCE\", false)) {\n if (this.links.hasLinkByKey(\"content\")) {\n selflink = this.links.getLinkByKey(\"content\");\n }\n\n if (selflink != null) {\n selflink.href.addParameter(\"complete\", \"true\");\n selflink.href.hash = this.data.section;\n }\n }\n\n if (selflink === null) {\n throw new Error(\n `Could not find self link for ${\n this.key === null ? \"unknown\" : this.key\n }`,\n );\n }\n\n if (!selflink.href.state) {\n selflink.href.state = {\n fragment: this.fragment,\n };\n } else {\n selflink.href.state.fragment = this.fragment;\n }\n\n return selflink;\n }\n\n /**\n * Self href of concept\n */\n get selfhref(): Href {\n if (this._entryDate !== null) {\n return this.selflink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this._entryDate,\n );\n }\n\n return this.selflink.href;\n }\n\n /**\n */\n get subSectionID(): string {\n return this.selfhref.hash;\n }\n\n /**\n */\n get contentTypeLink(): LinkModel | null {\n return this.links.getLinkByKey(\"contenttype\");\n }\n\n /**\n * Concept type href of concept\n */\n get contentTypeHref(): Href | null {\n if (this.contentTypeLink) {\n return this.contentTypeLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get fragment(): SectionFragment | void {\n return this.data.sectionFragment;\n }\n\n /**\n * Children of link model in TOC\n */\n set items(items: Array<ContentLinkModel>) {\n this._items = items;\n }\n\n /**\n */\n get items(): Array<ContentLinkModel> {\n return this._items;\n }\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,UAAA,GAAAC,s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,CAACnC,IAAI;EAC3B;;EAEA;AACF;EACE,IAAI2C,YAAYA,CAAA,EAAW;IACzB,OAAO,IAAI,CAACtC,QAAQ,CAACkC,IAAI;EAC3B;;EAEA;AACF;EACE,IAAI3C,eAAeA,CAAA,EAAqB;IACtC,OAAO,IAAI,CAACmC,KAAK,CAACK,YAAY,CAAC,aAAa,CAAC;EAC/C;;EAEA;AACF;AACA;EACE,IAAIQ,eAAeA,CAAA,EAAgB;IACjC,IAAI,IAAI,CAAChD,eAAe,EAAE;MACxB,OAAO,IAAI,CAACA,eAAe,CAACI,IAAI;IAClC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAI0C,QAAQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAACxD,IAAI,CAAC2D,eAAe;EAClC;;EAEA;AACF;AACA;EACE,IAAIC,KAAKA,CAACA,KAA8B,EAAE;IACxC,IAAI,CAACC,MAAM,GAAGD,KAAK;EACrB;;EAEA;AACF;EACE,IAAIA,KAAKA,CAAA,EAA4B;IACnC,OAAO,IAAI,CAACC,MAAM;EACpB;AACF;AAACC,OAAA,CAAAvD,OAAA,GAAAV,gBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ContentLinkModel.js","names":["_BaseModel","_interopRequireDefault","require","_Href","_LinkModel","_ContentTypeModel","_Constants","_Settings","_LinkCollection","ContentLinkModel","BaseModel","constructor","data","entryDate","arguments","length","undefined","modelOptions","_defineProperty2","default","_entryDate","getInitialChildModelLinks","contentTypeLink","isCacheable","setChildModels","models","href","contentTypeModel","_find","call","model","selfhref","equalsWithParameters","type","contentType","_contentType","ContentTypeModel","key","getData","label","sourceLabel","abbreviation","createEncodedHref","startURI","selfHref","Href","_links","self","path","section","sourceId","substring","lastIndexOf","encodeURIComponent","encodedHref","addParameter","TIMEVERSION_FILTER_NAME","links","LinkCollection","Array","isArray","selflink","getLinkByKey","getSetting","_context","hasLinkByKey","_endsWith","hash","Error","state","fragment","subSectionID","contentTypeHref","sectionFragment","items","_items","exports"],"sources":["../../../src/models/content/ContentLinkModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\n\nimport LinkCollection from \"../links/LinkCollection\";\n\nimport type {\n ModularUIModel,\n IModelWithChildModels,\n ModelOptions,\n SectionFragment,\n} from \"../types\";\n\n/**\n * Link to a concept\n */\nexport default class ContentLinkModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _links: ?LinkCollection;\n _entryDate: ?ISO_DATE;\n _contentType: ContentTypeModel | null = null;\n _items: Array<ContentLinkModel>;\n\n /**\n */\n constructor(\n data: Object,\n entryDate: ?ISO_DATE = null,\n modelOptions?: ModelOptions,\n ) {\n super(data, {}, modelOptions);\n\n this._entryDate = entryDate;\n }\n\n /**\n */\n // $FlowFixMe[method-unbinding]\n getInitialChildModelLinks(): Array<LinkModel> {\n if (this.contentTypeLink) {\n this.contentTypeLink.isCacheable = true;\n return [this.contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n // $FlowFixMe[method-unbinding]\n setChildModels(models: Array<ModularUIModel>) {\n if (this.contentTypeLink) {\n const href = this.contentTypeLink.href;\n const contentTypeModel = models.find((model) =>\n model.selfhref.equalsWithParameters(href),\n );\n\n if (contentTypeModel?.type === \"ContentType\") {\n this.contentType = contentTypeModel;\n }\n }\n }\n\n /**\n * Retrieve content type\n */\n get contentType(): ?ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n * Set concept type\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n */\n set entryDate(entryDate: ISO_DATE) {\n this._entryDate = entryDate;\n }\n\n /**\n * Retrieve key\n */\n get key(): string {\n return this.getData(\"_id\", \"\");\n }\n\n /**\n * Retrieve label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Retrieve the label of the source a link to a section belongs to\n */\n get sourceLabel(): string | null {\n return this.getData(\"sourceLabel\");\n }\n\n /**\n *\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\") || this.getData(\"sourceAbbreviation\");\n }\n\n /**\n */\n createEncodedHref(): Href {\n const startURI = \"/content/\";\n const selfHref = new Href(\n this.data._links.self.href,\n \"\",\n this.modelOptions,\n );\n const href = selfHref.path;\n\n const section = this.data.section;\n const sourceId = section\n ? href.substring(startURI.length, href.lastIndexOf(\"/\"))\n : href.substring(startURI.length);\n\n if (section) {\n selfHref.path = `${startURI}${encodeURIComponent(sourceId)}/${encodeURIComponent(section)}`;\n } else {\n selfHref.path = `${startURI}${encodeURIComponent(sourceId)}`;\n }\n\n return selfHref;\n }\n\n /**\n * Encode the content-identifier of the path to the content resource.\n * This makes it a single uri part, which can be used on routes to make nested routes\n */\n get encodedHref(): Href {\n const href = this.createEncodedHref();\n\n if (this._entryDate !== null) {\n return href.addParameter(TIMEVERSION_FILTER_NAME, this._entryDate);\n }\n\n return href;\n }\n\n /**\n * Getting the links of the resource\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n Array.isArray(this.data._links)\n ? this.data._links[0]\n : this.data._links,\n null,\n this.modelOptions,\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel {\n let selflink = this.links.getLinkByKey(\"self\");\n\n if (getSetting(\"COMPLETE_SOURCE\", false)) {\n if (this.links.hasLinkByKey(\"content\")) {\n selflink = this.links.getLinkByKey(\"content\");\n }\n\n if (selflink != null && !selflink.href.path.endsWith(this.data.section)) {\n selflink.href.addParameter(\"complete\", \"true\");\n selflink.href.hash = this.data.section;\n }\n }\n\n if (selflink === null) {\n throw new Error(\n `Could not find self link for ${\n this.key === null ? \"unknown\" : this.key\n }`,\n );\n }\n\n if (!selflink.href.state) {\n selflink.href.state = {\n fragment: this.fragment,\n };\n } else {\n selflink.href.state.fragment = this.fragment;\n }\n\n return selflink;\n }\n\n /**\n * Self href of concept\n */\n get selfhref(): Href {\n if (this._entryDate !== null) {\n return this.selflink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this._entryDate,\n );\n }\n\n return this.selflink.href;\n }\n\n /**\n */\n get subSectionID(): string {\n return this.selfhref.hash;\n }\n\n /**\n */\n get contentTypeLink(): LinkModel | null {\n return this.links.getLinkByKey(\"contenttype\");\n }\n\n /**\n * Concept type href of concept\n */\n get contentTypeHref(): Href | null {\n if (this.contentTypeLink) {\n return this.contentTypeLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get fragment(): SectionFragment | void {\n return this.data.sectionFragment;\n }\n\n /**\n * Children of link model in TOC\n */\n set items(items: Array<ContentLinkModel>) {\n this._items = items;\n }\n\n /**\n */\n get items(): Array<ContentLinkModel> {\n return this._items;\n }\n}\n"],"mappings":";;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,iBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,IAAAM,eAAA,GAAAP,sBAAA,CAAAC,OAAA;AASA;AACA;AACA;AACe,MAAMO,gBAAgB,SAC3BC,kBAAS,CAEnB;EAME;AACF;EACEC,WAAWA,CACTC,IAAY,EAGZ;IAAA,IAFAC,SAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;IAAA,IAC3BG,YAA2B,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAE3B,KAAK,CAACJ,IAAI,EAAE,CAAC,CAAC,EAAEK,YAAY,CAAC;IAAC,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AQA,CAAA,EAA2B;IACrC,OAAO,IAAI,CAAC1D,IAAI,CAAC6D,eAAe;EAClC;;EAEA;AACF;AACA;EACE,IAAIC,KAAKA,CAACA,KAA8B,EAAE;IACxC,IAAI,CAACC,MAAM,GAAGD,KAAK;EACrB;;EAEA;AACF;EACE,IAAIA,KAAKA,CAAA,EAA4B;IACnC,OAAO,IAAI,CAACC,MAAM;EACpB;AACF;AAACC,OAAA,CAAAzD,OAAA,GAAAV,gBAAA","ignoreList":[]}
|
package/lib/models/types.d.ts
CHANGED
package/lib/models/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/models/types.js"],"sourcesContent":["// @flow\nimport type ApplicationModel from \"./application/ApplicationModel\";\nimport type BooleanAttributeModel from \"./attributes/BooleanAttributeModel\";\nimport type CaptchaAttributeModel from \"./attributes/CaptchaAttributeModel\";\nimport type ChoiceAttributeModel from \"./attributes/ChoiceAttributeModel\";\nimport type CompositeAttributeModel from \"./attributes/CompositeAttributeModel\";\nimport type DatetimeAttributeModel from \"./attributes/DatetimeAttributeModel\";\nimport type HelptextAttributeModel from \"./attributes/HelptextAttributeModel\";\nimport type LabelAttributeModel from \"./attributes/LabelAttributeModel\";\nimport type MemoAttributeModel from \"./attributes/MemoAttributeModel\";\nimport type MoneyAttributeModel from \"./attributes/MoneyAttributeModel\";\nimport type NumberAttributeModel from \"./attributes/NumberAttributeModel\";\nimport type PasswordAttributeModel from \"./attributes/PasswordAttributeModel\";\nimport type StringAttributeModel from \"./attributes/StringAttributeModel\";\nimport type UploadAttributeModel from \"./attributes/UploadAttributeModel\";\nimport type XMLAttributeModel from \"./attributes/XMLAttributeModel\";\nimport type CaseViewModel from \"./caseview/CaseViewModel\";\nimport type BusinessScenarioModel from \"./concepts/BusinessScenarioModel\";\nimport type ConceptDetailModel from \"./concepts/ConceptDetailModel\";\nimport type ConceptIndexModel from \"./concepts/ConceptIndexModel\";\nimport type ConceptTypeDetailModel from \"./concepts/ConceptTypeDetailModel\";\nimport type ContentIndexModel from \"./content/ContentIndexModel\";\nimport type ContentModel from \"./content/ContentModel\";\nimport type SectionModel from \"./content/SectionModel\";\nimport type ContentTOCModel from \"./content/ContentTOCModel\";\nimport type ContentTypeModel from \"./content/ContentTypeModel\";\nimport type DetailModel from \"./detail/DetailModel\";\nimport type AssignmentFilterModel from \"./filters/AssignmentFilterModel\";\nimport type FilterModel from \"./filters/FilterModel\";\nimport type RangeFilterModel from \"./filters/RangeFilterModel\";\nimport type ConceptIndexFilterModel from \"./filters/ConceptIndexFilterModel\";\nimport type FormModel from \"./form/FormModel\";\nimport type ListDetailModel from \"./list/ListDetailModel\";\nimport type ListModel from \"./list/ListModel\";\nimport type ModelCatalogModel from \"./modelcatalog/ModelCatalogModel\";\nimport type GroupingPanelModel from \"./panels/GroupingPanelModel\";\nimport type CaseSearchModel from \"./search/CaseSearchModel\";\nimport type TabModel from \"./tab/TabModel\";\nimport type TaskGroupModel from \"./taskgroup/TaskGroupModel\";\nimport type UserModel from \"./user/UserModel\";\nimport type UserServicesModel from \"./user/UserServicesModel\";\nimport type LinkModel from \"./links/LinkModel\";\nimport type LookupOptionsModel from \"./lookup/LookupOptionsModel\";\nimport type BaseFilterModel from \"./filters/BaseFilterModel\";\nimport type AttributeCollection from \"./attributes/AttributeCollection\";\nimport type AttributeModel from \"./attributes/AttributeModel\";\nimport type LayoutHintCollection from \"./layouthint/LayoutHintCollection\";\nimport type ErrorResponse from \"./error/ErrorResponse\";\n\nexport type ModularUIModel =\n | ApplicationModel\n | CaseSearchModel\n | CaseViewModel\n | ListDetailModel\n | DetailModel\n | FormModel\n | GroupingPanelModel\n | ListModel\n | TabModel\n | TaskGroupModel\n | UserModel\n | UserServicesModel\n | ModelCatalogModel\n | ConceptIndexModel\n | ConceptDetailModel\n | BusinessScenarioModel\n | ConceptTypeDetailModel\n | ContentIndexModel\n | ContentTOCModel\n | ContentModel\n | ContentTypeModel\n | LookupOptionsModel;\n\nexport type AttributeType =\n | BooleanAttributeModel\n | CaptchaAttributeModel\n | ChoiceAttributeModel\n | DatetimeAttributeModel\n | HelptextAttributeModel\n | LabelAttributeModel\n | MemoAttributeModel\n | MoneyAttributeModel\n | NumberAttributeModel\n | PasswordAttributeModel\n | CompositeAttributeModel\n | StringAttributeModel\n | UploadAttributeModel\n | XMLAttributeModel;\n\nexport type RangeChildAttributeType =\n | NumberAttributeModel\n | DatetimeAttributeModel;\n\nexport type FilterType =\n | BaseFilterModel\n | FilterModel\n | AssignmentFilterModel\n | RangeFilterModel\n | ConceptIndexFilterModel;\n\nexport type FormErrorAnchor = {\n id: string,\n properties?: {\n [propertyName: string]: string | number,\n },\n anchor?: {\n objectid: string,\n elementid?: string,\n _links?: Object,\n index?: number,\n \"index-identifier\"?: string,\n },\n layouthint: LayoutHintCollection,\n message: string,\n param?: {\n name: string,\n },\n};\n\nexport type labelsJSON = {\n _id: string,\n label: string,\n value: string,\n};\n\nexport type propertyJSON = {\n _id: string,\n type: string,\n mandatory: string,\n label: string,\n value: string,\n};\n\nexport type textfragmentJSON = {\n label: string,\n text: string,\n type: string,\n};\n\nexport interface IConstraintModel {\n +id: string;\n +defaultMessage: string;\n +parameters: Object;\n +isMandatoryConstraint: boolean;\n validate(value: any): boolean;\n hasValidation(): boolean;\n}\n\nexport interface ILayoutHintRule {\n process(attribute: AttributeModel, attributes: AttributeCollection): void;\n}\n\nexport interface IModelWithChildModels {\n getInitialChildModelLinks(): Array<LinkModel>;\n setChildModels(\n models: Array<ModularUIModel>,\n errors: Array<ErrorResponse>,\n ): void;\n}\n\nexport type AuthenticationType = {\n name: string,\n authentication: string,\n redirectUri?: string,\n isPrimary: boolean,\n};\n\nexport type FileEntryType = {\n name: string,\n size?: number,\n progress: number,\n error?: string,\n token?: string,\n};\n\nexport type FilesType = {\n [filename: string]: FileEntryType,\n};\n\nexport type FiletypeConstraintsType = Array<{|\n extensions: Array<string>,\n mimeTypes: Array<string>,\n|}>;\n\nexport type FilesizeConstraintsType = {\n fileSize: ?number,\n maxTotalFileSize: ?number,\n isMaxTotal: boolean,\n};\n\nexport type PropertyData = { type: string, label: string, value: string };\nexport type TextFragmentData = {\n type: string,\n label: string,\n text: string | { id?: string, message: string, properties?: Object },\n};\nexport type SectionData = {\n id: string,\n type: string,\n label?: string,\n number?: string,\n body: string | { id?: string, message: string, properties?: Object },\n _links: { self: { href: string } },\n childSections: Array<SectionData>,\n subSections: Array<SectionData>,\n};\n\nexport type PropertyElement = {\n propertyElement: {\n label: string,\n layouthint: Array<string>,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElement = {\n textFragmentElement: {\n label: string,\n layouthint: Array<string>,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElement = {\n contentElement: {\n label: string,\n layouthint: Array<string>,\n sections: Array<SectionData>,\n },\n};\n\nexport type PropertyElementMapped = {\n propertyElement: {\n label: string,\n layouthint: LayoutHintCollection,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElementMapped = {\n textFragmentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElementMapped = {\n contentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n sections: Array<SectionModel>,\n },\n};\n\nexport type ContentAll = Array<\n PropertyElementMapped | TextFragmentElementMapped | ContentElementMapped,\n>;\n\nexport type ContentData = {\n header: {\n label?: string,\n description?: { id?: string, message: string, properties?: Object },\n },\n label?: string,\n elements: Array<PropertyElement | TextFragmentElement | ContentElement>,\n};\n\nexport type SectionFragment = {\n
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/models/types.js"],"sourcesContent":["// @flow\nimport type ApplicationModel from \"./application/ApplicationModel\";\nimport type BooleanAttributeModel from \"./attributes/BooleanAttributeModel\";\nimport type CaptchaAttributeModel from \"./attributes/CaptchaAttributeModel\";\nimport type ChoiceAttributeModel from \"./attributes/ChoiceAttributeModel\";\nimport type CompositeAttributeModel from \"./attributes/CompositeAttributeModel\";\nimport type DatetimeAttributeModel from \"./attributes/DatetimeAttributeModel\";\nimport type HelptextAttributeModel from \"./attributes/HelptextAttributeModel\";\nimport type LabelAttributeModel from \"./attributes/LabelAttributeModel\";\nimport type MemoAttributeModel from \"./attributes/MemoAttributeModel\";\nimport type MoneyAttributeModel from \"./attributes/MoneyAttributeModel\";\nimport type NumberAttributeModel from \"./attributes/NumberAttributeModel\";\nimport type PasswordAttributeModel from \"./attributes/PasswordAttributeModel\";\nimport type StringAttributeModel from \"./attributes/StringAttributeModel\";\nimport type UploadAttributeModel from \"./attributes/UploadAttributeModel\";\nimport type XMLAttributeModel from \"./attributes/XMLAttributeModel\";\nimport type CaseViewModel from \"./caseview/CaseViewModel\";\nimport type BusinessScenarioModel from \"./concepts/BusinessScenarioModel\";\nimport type ConceptDetailModel from \"./concepts/ConceptDetailModel\";\nimport type ConceptIndexModel from \"./concepts/ConceptIndexModel\";\nimport type ConceptTypeDetailModel from \"./concepts/ConceptTypeDetailModel\";\nimport type ContentIndexModel from \"./content/ContentIndexModel\";\nimport type ContentModel from \"./content/ContentModel\";\nimport type SectionModel from \"./content/SectionModel\";\nimport type ContentTOCModel from \"./content/ContentTOCModel\";\nimport type ContentTypeModel from \"./content/ContentTypeModel\";\nimport type DetailModel from \"./detail/DetailModel\";\nimport type AssignmentFilterModel from \"./filters/AssignmentFilterModel\";\nimport type FilterModel from \"./filters/FilterModel\";\nimport type RangeFilterModel from \"./filters/RangeFilterModel\";\nimport type ConceptIndexFilterModel from \"./filters/ConceptIndexFilterModel\";\nimport type FormModel from \"./form/FormModel\";\nimport type ListDetailModel from \"./list/ListDetailModel\";\nimport type ListModel from \"./list/ListModel\";\nimport type ModelCatalogModel from \"./modelcatalog/ModelCatalogModel\";\nimport type GroupingPanelModel from \"./panels/GroupingPanelModel\";\nimport type CaseSearchModel from \"./search/CaseSearchModel\";\nimport type TabModel from \"./tab/TabModel\";\nimport type TaskGroupModel from \"./taskgroup/TaskGroupModel\";\nimport type UserModel from \"./user/UserModel\";\nimport type UserServicesModel from \"./user/UserServicesModel\";\nimport type LinkModel from \"./links/LinkModel\";\nimport type LookupOptionsModel from \"./lookup/LookupOptionsModel\";\nimport type BaseFilterModel from \"./filters/BaseFilterModel\";\nimport type AttributeCollection from \"./attributes/AttributeCollection\";\nimport type AttributeModel from \"./attributes/AttributeModel\";\nimport type LayoutHintCollection from \"./layouthint/LayoutHintCollection\";\nimport type ErrorResponse from \"./error/ErrorResponse\";\n\nexport type ModularUIModel =\n | ApplicationModel\n | CaseSearchModel\n | CaseViewModel\n | ListDetailModel\n | DetailModel\n | FormModel\n | GroupingPanelModel\n | ListModel\n | TabModel\n | TaskGroupModel\n | UserModel\n | UserServicesModel\n | ModelCatalogModel\n | ConceptIndexModel\n | ConceptDetailModel\n | BusinessScenarioModel\n | ConceptTypeDetailModel\n | ContentIndexModel\n | ContentTOCModel\n | ContentModel\n | ContentTypeModel\n | LookupOptionsModel;\n\nexport type AttributeType =\n | BooleanAttributeModel\n | CaptchaAttributeModel\n | ChoiceAttributeModel\n | DatetimeAttributeModel\n | HelptextAttributeModel\n | LabelAttributeModel\n | MemoAttributeModel\n | MoneyAttributeModel\n | NumberAttributeModel\n | PasswordAttributeModel\n | CompositeAttributeModel\n | StringAttributeModel\n | UploadAttributeModel\n | XMLAttributeModel;\n\nexport type RangeChildAttributeType =\n | NumberAttributeModel\n | DatetimeAttributeModel;\n\nexport type FilterType =\n | BaseFilterModel\n | FilterModel\n | AssignmentFilterModel\n | RangeFilterModel\n | ConceptIndexFilterModel;\n\nexport type FormErrorAnchor = {\n id: string,\n properties?: {\n [propertyName: string]: string | number,\n },\n anchor?: {\n objectid: string,\n elementid?: string,\n _links?: Object,\n index?: number,\n \"index-identifier\"?: string,\n },\n layouthint: LayoutHintCollection,\n message: string,\n param?: {\n name: string,\n },\n};\n\nexport type labelsJSON = {\n _id: string,\n label: string,\n value: string,\n};\n\nexport type propertyJSON = {\n _id: string,\n type: string,\n mandatory: string,\n label: string,\n value: string,\n};\n\nexport type textfragmentJSON = {\n label: string,\n text: string,\n type: string,\n};\n\nexport interface IConstraintModel {\n +id: string;\n +defaultMessage: string;\n +parameters: Object;\n +isMandatoryConstraint: boolean;\n validate(value: any): boolean;\n hasValidation(): boolean;\n}\n\nexport interface ILayoutHintRule {\n process(attribute: AttributeModel, attributes: AttributeCollection): void;\n}\n\nexport interface IModelWithChildModels {\n getInitialChildModelLinks(): Array<LinkModel>;\n setChildModels(\n models: Array<ModularUIModel>,\n errors: Array<ErrorResponse>,\n ): void;\n}\n\nexport type AuthenticationType = {\n name: string,\n authentication: string,\n redirectUri?: string,\n isPrimary: boolean,\n};\n\nexport type FileEntryType = {\n name: string,\n size?: number,\n progress: number,\n error?: string,\n token?: string,\n};\n\nexport type FilesType = {\n [filename: string]: FileEntryType,\n};\n\nexport type FiletypeConstraintsType = Array<{|\n extensions: Array<string>,\n mimeTypes: Array<string>,\n|}>;\n\nexport type FilesizeConstraintsType = {\n fileSize: ?number,\n maxTotalFileSize: ?number,\n isMaxTotal: boolean,\n};\n\nexport type PropertyData = { type: string, label: string, value: string };\nexport type TextFragmentData = {\n type: string,\n label: string,\n text: string | { id?: string, message: string, properties?: Object },\n};\nexport type SectionData = {\n id: string,\n type: string,\n label?: string,\n number?: string,\n body: string | { id?: string, message: string, properties?: Object },\n _links: { self: { href: string } },\n childSections: Array<SectionData>,\n subSections: Array<SectionData>,\n};\n\nexport type PropertyElement = {\n propertyElement: {\n label: string,\n layouthint: Array<string>,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElement = {\n textFragmentElement: {\n label: string,\n layouthint: Array<string>,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElement = {\n contentElement: {\n label: string,\n layouthint: Array<string>,\n sections: Array<SectionData>,\n },\n};\n\nexport type PropertyElementMapped = {\n propertyElement: {\n label: string,\n layouthint: LayoutHintCollection,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElementMapped = {\n textFragmentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElementMapped = {\n contentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n sections: Array<SectionModel>,\n },\n};\n\nexport type ContentAll = Array<\n PropertyElementMapped | TextFragmentElementMapped | ContentElementMapped,\n>;\n\nexport type ContentData = {\n header: {\n label?: string,\n description?: { id?: string, message: string, properties?: Object },\n },\n label?: string,\n elements: Array<PropertyElement | TextFragmentElement | ContentElement>,\n};\n\nexport type SectionFragment = {\n text: string,\n startOffset: number,\n endOffset: number,\n};\n\nexport type ModelOptions = {\n origin?: ?string,\n contextPath?: ?string,\n};\n"],"mappings":"","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -9,16 +9,10 @@ import type {
|
|
|
9
9
|
IModelWithChildModels,
|
|
10
10
|
ModelOptions,
|
|
11
11
|
ModularUIModel,
|
|
12
|
+
SectionFragment,
|
|
12
13
|
} from "../types";
|
|
13
14
|
import type Href from "../href/Href";
|
|
14
15
|
|
|
15
|
-
type SectionFragment = {
|
|
16
|
-
sectionId: string,
|
|
17
|
-
text: string,
|
|
18
|
-
startOffset: number,
|
|
19
|
-
endOffset: number,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
16
|
/**
|
|
23
17
|
* Link to a concept
|
|
24
18
|
*/
|
|
@@ -199,10 +193,16 @@ export default class ConceptLinkModel
|
|
|
199
193
|
return this.getData("modelCategory");
|
|
200
194
|
}
|
|
201
195
|
|
|
196
|
+
/**
|
|
197
|
+
*/
|
|
198
|
+
get sectionId(): string {
|
|
199
|
+
return this.data.section?._id;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
202
|
/**
|
|
203
203
|
*
|
|
204
204
|
*/
|
|
205
205
|
get fragment(): SectionFragment {
|
|
206
|
-
return this.
|
|
206
|
+
return this.data.section?.fragment;
|
|
207
207
|
}
|
|
208
208
|
}
|
|
@@ -32,7 +32,7 @@ class SourceReferenceModel {
|
|
|
32
32
|
*/
|
|
33
33
|
get link(): ContentLinkModel {
|
|
34
34
|
const section =
|
|
35
|
-
this.
|
|
35
|
+
this.sectionId ||
|
|
36
36
|
this._sourceReference._links.self.href.replace(
|
|
37
37
|
`${this._sourceReference._links.content.href}/`,
|
|
38
38
|
"",
|
|
@@ -85,6 +85,12 @@ class SourceReferenceModel {
|
|
|
85
85
|
return createHashFromHref(this.selfhref);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
*/
|
|
90
|
+
get sectionId(): string {
|
|
91
|
+
return this._sourceReference.sectionId;
|
|
92
|
+
}
|
|
93
|
+
|
|
88
94
|
/**
|
|
89
95
|
*
|
|
90
96
|
*/
|