@beinformed/ui 1.61.0 → 1.62.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 +16 -0
- package/esm/models/attributes/__tests__/AttributeContent.spec.js.flow +1 -1
- package/esm/models/concepts/ConceptIndexModel.js +1 -1
- package/esm/models/concepts/ConceptIndexModel.js.flow +3 -1
- package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.d.ts +15 -0
- package/esm/models/concepts/ConceptLinkModel.js +14 -0
- package/esm/models/concepts/ConceptLinkModel.js.flow +21 -0
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.d.ts +9 -0
- package/esm/models/concepts/SourceReferenceModel.js +14 -0
- package/esm/models/concepts/SourceReferenceModel.js.flow +15 -1
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/concepts/__mock__/related_concepts.js.flow +12 -0
- package/esm/models/concepts/__tests__/RelatedConcepts.spec.js.flow +60 -0
- package/esm/models/concepts/__tests__/SourceReferenceModel.spec.js.flow +58 -0
- package/esm/models/content/ContentLinkModel.d.ts +8 -0
- package/esm/models/content/ContentLinkModel.js +20 -0
- package/esm/models/content/ContentLinkModel.js.flow +22 -0
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/ContentTOCModel.d.ts +3 -0
- package/esm/models/content/ContentTOCModel.js +6 -0
- package/esm/models/content/ContentTOCModel.js.flow +6 -0
- package/esm/models/content/ContentTOCModel.js.map +1 -1
- package/esm/models/content/__tests__/ContentIndexModel.spec.js.flow +3 -0
- package/esm/models/content/__tests__/ContentModel.spec.js.flow +5 -5
- package/esm/models/content/__tests__/Formalsource.spec.js.flow +4 -0
- package/esm/models/form/FormObjectModel.js +5 -3
- package/esm/models/form/FormObjectModel.js.flow +12 -11
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/esm/models/types.d.ts +6 -0
- package/esm/models/types.js.flow +7 -0
- package/esm/models/types.js.map +1 -1
- package/esm/utils/helpers/__tests__/createHash.spec.js.flow +5 -5
- package/esm/utils/helpers/createHash.d.ts +2 -1
- package/esm/utils/helpers/createHash.js +10 -9
- package/esm/utils/helpers/createHash.js.flow +10 -10
- package/esm/utils/helpers/createHash.js.map +1 -1
- package/lib/models/concepts/ConceptIndexModel.js +1 -1
- package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.d.ts +15 -0
- package/lib/models/concepts/ConceptLinkModel.js +14 -0
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.d.ts +9 -0
- package/lib/models/concepts/SourceReferenceModel.js +14 -0
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.d.ts +8 -0
- package/lib/models/content/ContentLinkModel.js +20 -0
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/ContentTOCModel.d.ts +3 -0
- package/lib/models/content/ContentTOCModel.js +6 -0
- package/lib/models/content/ContentTOCModel.js.map +1 -1
- package/lib/models/form/FormObjectModel.js +5 -3
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/types.d.ts +6 -0
- package/lib/models/types.js.map +1 -1
- package/lib/utils/helpers/createHash.d.ts +2 -1
- package/lib/utils/helpers/createHash.js +11 -9
- package/lib/utils/helpers/createHash.js.map +1 -1
- package/package.json +3 -1
- package/src/models/attributes/__tests__/AttributeContent.spec.js +1 -1
- package/src/models/concepts/ConceptIndexModel.js +3 -1
- package/src/models/concepts/ConceptLinkModel.js +21 -0
- package/src/models/concepts/SourceReferenceModel.js +15 -1
- package/src/models/concepts/__mock__/related_concepts.js +12 -0
- package/src/models/concepts/__mock__/related_concepts_contributions.json +41 -0
- package/src/models/concepts/__mock__/related_concepts_data.json +2292 -0
- package/src/models/concepts/__tests__/RelatedConcepts.spec.js +60 -0
- package/src/models/concepts/__tests__/SourceReferenceModel.spec.js +58 -0
- package/src/models/content/ContentLinkModel.js +22 -0
- package/src/models/content/ContentTOCModel.js +6 -0
- package/src/models/content/__tests__/ContentIndexModel.spec.js +3 -0
- package/src/models/content/__tests__/ContentModel.spec.js +5 -5
- package/src/models/content/__tests__/Formalsource.spec.js +4 -0
- package/src/models/content/__tests__/content-index.json +1 -0
- package/src/models/content/__tests__/formalsource-complete.json +1 -0
- package/src/models/form/FormObjectModel.js +12 -11
- package/src/models/types.js +7 -0
- package/src/utils/helpers/__tests__/createHash.spec.js +5 -5
- package/src/utils/helpers/createHash.js +10 -10
|
@@ -92,6 +92,12 @@ export default class ContentTOCModel extends ResourceModel {
|
|
|
92
92
|
return this.getData("label", "");
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
*/
|
|
97
|
+
get abbreviation(): string | null {
|
|
98
|
+
return this.getData("abbreviation");
|
|
99
|
+
}
|
|
100
|
+
|
|
95
101
|
/**
|
|
96
102
|
* Getting the self link of this list
|
|
97
103
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentTOCModel.js","names":["has","ResourceModel","FilterCollection","ContentLinkModel","ContentTypeModel","Href","SectionModel","TIMEVERSION_FILTER_NAME","getItems","items","entryDate","modelOptions","_mapInstanceProperty","call","item","link","section","_id","sections","ContentTOCModel","constructor","arguments","_defineProperty","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","contentTypeLink","links","getLinkByKey","setChildModels","models","contentType","_findInstanceProperty","model","label","getData","selfhref","href","selflink","filterCollection","forEach","filter","params","param","value","setParameter","name","removeParameter","selfContentLink","_context","categories","_context2","category","_contentType","_filterCollection","_context3","_filterInstanceProperty","_context4","key","_Object$keys","timeversionFilter","getFilterByAttributeKey","attribute","isCompleteSource","completeFilter"],"sources":["../../../src/models/content/ContentTOCModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport Href from \"../href/Href\";\n\nimport SectionModel from \"./SectionModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * Get content items recursively\n */\nconst getItems = (\n items: Array<Object>,\n entryDate: ISO_DATE | null,\n modelOptions?: ModelOptions,\n): Array<ContentLinkModel> =>\n items.map((item) => {\n const link = new ContentLinkModel(\n {\n ...item,\n section: item._id,\n },\n entryDate,\n modelOptions,\n );\n\n if (item.items) {\n link.items = getItems(item.items, entryDate, modelOptions);\n }\n if (item.sections) {\n link.items = getItems(item.sections, entryDate, modelOptions);\n }\n\n return link;\n });\n\n/**\n * Content detail model\n */\nexport default class ContentTOCModel extends ResourceModel {\n _contentType: ContentTypeModel | null = null;\n _filterCollection: FilterCollection;\n\n /**\n */\n get type(): string {\n return \"ContentTOC\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ContentTOCModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return data.contributions?.resourcetype === \"ContentTOC\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const contentTypeLink = this.links.getLinkByKey(\"contenttype\");\n\n if (contentTypeLink) {\n return [contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.contentType = models.find((model) => model.type === \"ContentType\");\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const href = new Href(this.selflink.href);\n\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n\n return href;\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(this.data, this.entryDate, this.modelOptions);\n }\n\n /**\n * Get sub items of toc\n */\n get items(): Array<ContentLinkModel> {\n if (this.data.items) {\n return getItems(this.data.items, this.entryDate, this.modelOptions);\n }\n\n if (this.data.sections) {\n return getItems(this.data.sections, this.entryDate, this.modelOptions);\n }\n\n return [];\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n if (this.data.sections) {\n return this.data.sections.map(\n (section) =>\n new SectionModel(section, this.entryDate, this.modelOptions),\n );\n }\n return [];\n }\n\n /**\n * get categories of content\n */\n get categories(): Array<ContentLinkModel> {\n if (this.data.categories) {\n return this.data.categories.map(\n (category) => new ContentLinkModel(category, null, this.modelOptions),\n );\n }\n\n return [];\n }\n\n /**\n * Retrieve content type model\n */\n get contentType(): ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n * Retrieve available filters on concept toc\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter.filter((filter) => {\n const [key] = Object.keys(filter);\n return has(this.data?.filter, key);\n }),\n },\n this.modelOptions,\n );\n }\n\n return this._filterCollection;\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): ISO_DATE | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n\n return timeversionFilter?.attribute?.value ?? null;\n }\n\n /**\n */\n get isCompleteSource(): boolean {\n const completeFilter =\n this.filterCollection.getFilterByAttributeKey(\"complete\");\n return completeFilter?.attribute?.value === \"true\";\n }\n}\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,aAAa,MAAM,uBAAuB;AACj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AAG+B,WAAW,GAAG,IAAI;EAChE;;EAEA;AACF;AACA;EACE,IAAIQ,gBAAgBA,CAAA,EAAqB;IACvC,IAAI,CAAC,IAAI,CAACe,iBAAiB,EAAE;MAAA,IAAAC,SAAA;MAC3B,IAAI,CAACD,iBAAiB,GAAG,IAAIxD,gBAAgB,CAAA0D,uBAAA,CAC3C,IAAI,CAAClC,IAAI,GACT;QACEmB,MAAM,EAAEe,uBAAA,CAAAD,SAAA,GAAAC,uBAAA,KAAI,CAACjC,aAAa,GAAAd,IAAA,CAAA8C,SAAA,EAAgBd,MAAM,IAAK;UAAA,IAAAgB,SAAA;UACnD,MAAM,CAACC,GAAG,CAAC,GAAGC,YAAA,CAAYlB,MAAM,CAAC;UACjC,OAAO7C,GAAG,EAAA6D,SAAA,GAAC,IAAI,CAACnC,IAAI,qBAAAkC,uBAAA,CAAAC,SAAA,GAAUC,GAAG,CAAC;QACpC,CAAC;MACH,CAAC,EACD,IAAI,CAACnD,YACP,CAAC;IACH;IAEA,OAAO,IAAI,CAAC+C,iBAAiB;EAC/B;;EAEA;AACF;AACA;EACE,IAAIhD,SAASA,CAAA,EAAoB;IAC/B,MAAMsD,iBAAiB,GAAG,IAAI,CAACrB,gBAAgB,CAACsB,uBAAuB,CACrE1D,uBACF,CAAC;IAED,OAAOyD,iBAAiB,EAAEE,SAAS,EAAElB,KAAK,IAAI,IAAI;EACpD;;EAEA;AACF;EACE,IAAImB,gBAAgBA,CAAA,EAAY;IAC9B,MAAMC,cAAc,GAClB,IAAI,CAACzB,gBAAgB,CAACsB,uBAAuB,CAAC,UAAU,CAAC;IAC3D,OAAOG,cAAc,EAAEF,SAAS,EAAElB,KAAK,KAAK,MAAM;EACpD;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ContentTOCModel.js","names":["has","ResourceModel","FilterCollection","ContentLinkModel","ContentTypeModel","Href","SectionModel","TIMEVERSION_FILTER_NAME","getItems","items","entryDate","modelOptions","_mapInstanceProperty","call","item","link","section","_id","sections","ContentTOCModel","constructor","arguments","_defineProperty","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","contentTypeLink","links","getLinkByKey","setChildModels","models","contentType","_findInstanceProperty","model","label","getData","abbreviation","selfhref","href","selflink","filterCollection","forEach","filter","params","param","value","setParameter","name","removeParameter","selfContentLink","_context","categories","_context2","category","_contentType","_filterCollection","_context3","_filterInstanceProperty","_context4","key","_Object$keys","timeversionFilter","getFilterByAttributeKey","attribute","isCompleteSource","completeFilter"],"sources":["../../../src/models/content/ContentTOCModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport ContentTypeModel from \"./ContentTypeModel\";\nimport Href from \"../href/Href\";\n\nimport SectionModel from \"./SectionModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type { ModelOptions, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * Get content items recursively\n */\nconst getItems = (\n items: Array<Object>,\n entryDate: ISO_DATE | null,\n modelOptions?: ModelOptions,\n): Array<ContentLinkModel> =>\n items.map((item) => {\n const link = new ContentLinkModel(\n {\n ...item,\n section: item._id,\n },\n entryDate,\n modelOptions,\n );\n\n if (item.items) {\n link.items = getItems(item.items, entryDate, modelOptions);\n }\n if (item.sections) {\n link.items = getItems(item.sections, entryDate, modelOptions);\n }\n\n return link;\n });\n\n/**\n * Content detail model\n */\nexport default class ContentTOCModel extends ResourceModel {\n _contentType: ContentTypeModel | null = null;\n _filterCollection: FilterCollection;\n\n /**\n */\n get type(): string {\n return \"ContentTOC\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ContentTOCModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return data.contributions?.resourcetype === \"ContentTOC\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const contentTypeLink = this.links.getLinkByKey(\"contenttype\");\n\n if (contentTypeLink) {\n return [contentTypeLink];\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.contentType = models.find((model) => model.type === \"ContentType\");\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n */\n get abbreviation(): string | null {\n return this.getData(\"abbreviation\");\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const href = new Href(this.selflink.href);\n\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n\n return href;\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(this.data, this.entryDate, this.modelOptions);\n }\n\n /**\n * Get sub items of toc\n */\n get items(): Array<ContentLinkModel> {\n if (this.data.items) {\n return getItems(this.data.items, this.entryDate, this.modelOptions);\n }\n\n if (this.data.sections) {\n return getItems(this.data.sections, this.entryDate, this.modelOptions);\n }\n\n return [];\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n if (this.data.sections) {\n return this.data.sections.map(\n (section) =>\n new SectionModel(section, this.entryDate, this.modelOptions),\n );\n }\n return [];\n }\n\n /**\n * get categories of content\n */\n get categories(): Array<ContentLinkModel> {\n if (this.data.categories) {\n return this.data.categories.map(\n (category) => new ContentLinkModel(category, null, this.modelOptions),\n );\n }\n\n return [];\n }\n\n /**\n * Retrieve content type model\n */\n get contentType(): ContentTypeModel | null {\n return this._contentType;\n }\n\n /**\n */\n set contentType(contentType: ?ModularUIModel) {\n this._contentType =\n contentType instanceof ContentTypeModel ? contentType : null;\n }\n\n /**\n * Retrieve available filters on concept toc\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter.filter((filter) => {\n const [key] = Object.keys(filter);\n return has(this.data?.filter, key);\n }),\n },\n this.modelOptions,\n );\n }\n\n return this._filterCollection;\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): ISO_DATE | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n\n return timeversionFilter?.attribute?.value ?? null;\n }\n\n /**\n */\n get isCompleteSource(): boolean {\n const completeFilter =\n this.filterCollection.getFilterByAttributeKey(\"complete\");\n return completeFilter?.attribute?.value === \"true\";\n }\n}\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,aAAa,MAAM,uBAAuB;AACjD,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,gBAAgB,MAAM,oBAAoB;AACjD,OAAOC,IAAI,MAAM,cAAc;AAE/B,OAAOC,YAAY,MAAM,gBAAgB;AAEzC,SAASC,uBAAuB,QAAQ,2BAA2B;AAKnE;AACA;AACA;AACA,MAAMC,QAAQ,GAAGA,CACfC,KAAoB,EACpBC,SAA0B,EAC1BC,YAA2B,KAE3BC,oBAAA,CAAAH,KAAK,EAAAI,IAAA,CAALJ,KAAK,EAAMK,IAAI,IAAK;EAClB,MAAMC,IAAI,GAAG,IAAIZ,gBAAgB,CAC/B;IACE,GAAGW,IAAI;IACPE,OAAO,EAAEF,IAAI,CAACG;EAChB,CAAC,EACDP,SAAS,EACTC,YACF,CAAC;EAED,IAAIG,IAAI,CAACL,KAAK,EAAE;IACdM,IAAI,CAACN,KAAK,GAAGD,QAAQ,CAACM,IAAI,CAACL,KAAK,EAAEC,SAAS,EAAEC,YAAY,CAAC;EAC5D;EACA,IAAIG,IAAI,CAACI,QAAQ,EAAE;IACjBH,IAAI,CAACN,KAAK,GAAGD,QAAQ,CAACM,IAAI,CAACI,QAAQ,EAAER,SAAS,EAAEC,YAAY,CA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,IAAIjD,SAASA,CAAA,EAAoB;IAC/B,MAAMuD,iBAAiB,GAAG,IAAI,CAACrB,gBAAgB,CAACsB,uBAAuB,CACrE3D,uBACF,CAAC;IAED,OAAO0D,iBAAiB,EAAEE,SAAS,EAAElB,KAAK,IAAI,IAAI;EACpD;;EAEA;AACF;EACE,IAAImB,gBAAgBA,CAAA,EAAY;IAC9B,MAAMC,cAAc,GAClB,IAAI,CAACzB,gBAAgB,CAACsB,uBAAuB,CAAC,UAAU,CAAC;IAC3D,OAAOG,cAAc,EAAEF,SAAS,EAAElB,KAAK,KAAK,MAAM;EACpD;AACF","ignoreList":[]}
|
|
@@ -30,6 +30,9 @@ describe("content index model", () => {
|
|
|
30
30
|
const firstLink = contentIndexModel.items.first;
|
|
31
31
|
expect(firstLink).toBeInstanceOf(ContentLinkModel);
|
|
32
32
|
|
|
33
|
+
expect(firstLink.label).toBe("Another formal content");
|
|
34
|
+
expect(firstLink.abbreviation).toBe("AFC-01");
|
|
35
|
+
|
|
33
36
|
expect(firstLink.encodedHref.toString()).toBe(
|
|
34
37
|
"/content/Content%2FSources%2FFormal%2FAnother%2520formal%2520content.formalsource",
|
|
35
38
|
);
|
|
@@ -67,7 +67,7 @@ describe("contentmodel", () => {
|
|
|
67
67
|
expect(contentModel.relatedConceptsHref.href.toString()).toBe(
|
|
68
68
|
"/content/Incident/Business design/Content/Blaastest.bixml/67beed02/relatedConcepts?entryDate=2021-08-31",
|
|
69
69
|
);
|
|
70
|
-
expect(contentModel.referenceHash).toBe(
|
|
70
|
+
expect(contentModel.referenceHash).toBe(9969574676612);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it("can handle content service with childsections", () => {
|
|
@@ -106,7 +106,7 @@ describe("contentmodel", () => {
|
|
|
106
106
|
expect(contentModel.relatedConceptsHref.href.toString()).toBe(
|
|
107
107
|
"/content/Incident/Business design/Content/Blaastest.textilesource/uitslag/relatedConcepts?entryDate=2021-08-31",
|
|
108
108
|
);
|
|
109
|
-
expect(contentModel.referenceHash).toBe(
|
|
109
|
+
expect(contentModel.referenceHash).toBe(8236987459042);
|
|
110
110
|
|
|
111
111
|
const firstChildSectionLink = contentModel.childSectionLinks[0];
|
|
112
112
|
expect(firstChildSectionLink instanceof ContentLinkModel).toBe(true);
|
|
@@ -174,7 +174,7 @@ describe("contentmodel", () => {
|
|
|
174
174
|
expect(contentModel.subSections).toHaveLength(4);
|
|
175
175
|
expect(contentModel.relatedConceptsHrefs).toHaveLength(4);
|
|
176
176
|
expect(contentModel.relatedConceptsHref).toBeNull();
|
|
177
|
-
expect(contentModel.referenceHash).toBe(
|
|
177
|
+
expect(contentModel.referenceHash).toBe(3949483866644);
|
|
178
178
|
|
|
179
179
|
const firstSubSection = contentModel.subSections[0];
|
|
180
180
|
expect(firstSubSection instanceof SubSectionModel).toBe(true);
|
|
@@ -199,8 +199,8 @@ describe("contentmodel", () => {
|
|
|
199
199
|
"/content/Incident/Business design/Content/Blaastest subsections.formalsource/Pass/relatedConcepts?entryDate=2021-08-31",
|
|
200
200
|
);
|
|
201
201
|
expect(firstSubSection.relatedConceptsHref.getReferenceHash()).toBe(
|
|
202
|
-
|
|
202
|
+
7092890320518,
|
|
203
203
|
);
|
|
204
|
-
expect(firstSubSection.referenceHash).toBe(
|
|
204
|
+
expect(firstSubSection.referenceHash).toBe(7092890320518);
|
|
205
205
|
});
|
|
206
206
|
});
|
|
@@ -55,6 +55,10 @@ describe("formalsource", () => {
|
|
|
55
55
|
expect(completeModel.sections[0].sections).toHaveLength(0);
|
|
56
56
|
expect(completeModel.sections[1].sections).toHaveLength(2);
|
|
57
57
|
|
|
58
|
+
expect(completeModel.label).toBe(
|
|
59
|
+
"Grant Funding Agreement - Terms and Conditions",
|
|
60
|
+
);
|
|
61
|
+
expect(completeModel.abbreviation).toBe("GFA-TC-01");
|
|
58
62
|
expect(completeModel.isCompleteSource).toBe(true);
|
|
59
63
|
|
|
60
64
|
const firstSection = completeModel.sections[0];
|
|
@@ -428,9 +428,11 @@ export default class FormObjectModel extends BaseModel {
|
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
431
|
+
if (Array.isArray(errors)) {
|
|
432
|
+
_filterInstanceProperty(errors).call(errors, error => error.id === "Constraint.Mandatory" && error.anchor?.objectid === this.key && has(error.anchor, "elementid")).forEach(error => {
|
|
433
|
+
attributeErrors.push(error);
|
|
434
|
+
});
|
|
435
|
+
}
|
|
434
436
|
this.attributeCollection.updateValidations(attributeErrors);
|
|
435
437
|
}
|
|
436
438
|
|
|
@@ -541,17 +541,18 @@ export default class FormObjectModel extends BaseModel {
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
-
errors
|
|
545
|
-
|
|
546
|
-
(
|
|
547
|
-
error
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
544
|
+
if (Array.isArray(errors)) {
|
|
545
|
+
errors
|
|
546
|
+
.filter(
|
|
547
|
+
(error) =>
|
|
548
|
+
error.id === "Constraint.Mandatory" &&
|
|
549
|
+
error.anchor?.objectid === this.key &&
|
|
550
|
+
has(error.anchor, "elementid"),
|
|
551
|
+
)
|
|
552
|
+
.forEach((error) => {
|
|
553
|
+
attributeErrors.push(error);
|
|
554
|
+
});
|
|
555
|
+
}
|
|
555
556
|
this.attributeCollection.updateValidations(attributeErrors);
|
|
556
557
|
}
|
|
557
558
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormObjectModel.js","names":["has","BaseModel","AttributeCollection","CompositeAttributeModel","ContentConfiguration","ErrorCollection","IllegalArgumentException","LayoutHintCollection","FormObjectModel","constructor","object","objectContributions","modelOptions","_defineProperty","getElements","length","_attributeCollection","getApplicableAttributeContributions","isReadonly","_contentConfiguration","content","_errorCollection","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","createEmpty","formObjectModel","contributions","equals","_context","withRepeatIndex","arguments","undefined","key","objectContainsOneOfTheAttributes","_filterInstanceProperty","all","call","attribute","isResult","some","hasAttributeByKey","hasSameRepeatIndex","repeatIndex","getAttributeByAttribute","getAttributeByKey","elements","push","results","_context2","dataResults","_mapInstanceProperty","result","elementid","_context3","dataElementIds","element","getAttributesInData","attributes","isDynamic","attributeKey","_Object$keys","mandatory","attributesContributions","attributeContributions","dataElementId","split","getInitialChildModelLinks","setChildModels","models","errors","objectid","hasEndResultConfiguration","getContribution","hasDynamicValidations","isRepeatable","_repeatIndex","index","maxRepeats","hasFixedNrOfRepeats","isRepeatWithUnknownTotal","isLastRepeat","last","repeatIndexLabel","label","introText","text","message","assistent","buttonLabels","mergeObject","oldObject","forEach","mergeWithAttribute","mergeAttribute","updateAttribute","value","attributeToUpdate","Error","name","update","isChangedSince","timestamp","_context4","_findInstanceProperty","resetErrors","errorCollection","addServerError","error","anchor","id","properties","layouthint","hasServerErrors","hasItems","hasErrors","isValid","visible","every","dynamicValidationsLoaded","_dynamicValidationsLoaded","handleErrorValidations","attributeErrors","updateValidations","handleMissingValidations","missing","anchors","Array","isArray","formdata","getFormData","validationData"],"sources":["../../../src/models/form/FormObjectModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport ErrorCollection from \"../error/ErrorCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type {\n AttributeType,\n ModularUIModel,\n FormErrorAnchor,\n ModelOptions,\n} from \"../types\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\n\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\nimport type { MessageParameters } from \"../../i18n\";\n\ntype ErrorObject = {\n anchor: {\n objectid: string,\n elementid?: string,\n },\n id: string,\n message: string,\n properties: MessageParameters,\n layouthint: Array<string>,\n};\n\n/**\n * Form Object\n */\nexport default class FormObjectModel extends BaseModel {\n _attributeCollection: AttributeCollection;\n _contentConfiguration: ContentConfiguration;\n _errorCollection: ErrorCollection;\n _repeatIndex: number;\n _dynamicValidationsLoaded: boolean;\n\n /**\n * Construct FormObjectModel\n */\n constructor(\n object: Object,\n objectContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(object, objectContributions, modelOptions);\n\n if (object && this.getElements().length > 0) {\n this._attributeCollection = new AttributeCollection(\n this.getElements(),\n this.getApplicableAttributeContributions(),\n { ...modelOptions, isReadonly: false },\n );\n } else {\n this._attributeCollection = new AttributeCollection();\n }\n\n this._contentConfiguration = new ContentConfiguration(\n objectContributions ? objectContributions.content : {},\n );\n\n this._errorCollection = new ErrorCollection(\"formobject\");\n\n if (has(this.data, \"referenceDate\")) {\n this.attributeCollection.setReferenceDate(this.getData(\"referenceDate\"));\n }\n\n this.attributeCollection.indicateContentConfiguration(\n this.contentConfiguration,\n );\n }\n\n /**\n */\n static createEmpty(formObjectModel: FormObjectModel): FormObjectModel {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\n \"createEmpty method needs a FormObjectModel as input argument to create a new version of the object\",\n );\n }\n return new FormObjectModel(\n formObjectModel.data,\n formObjectModel.contributions,\n formObjectModel.modelOptions,\n );\n }\n\n /**\n */\n equals(object: ?FormObjectModel, withRepeatIndex: boolean = true): boolean {\n if (!object || this.key !== object.key) {\n return false;\n }\n\n const objectContainsOneOfTheAttributes = this.attributeCollection.all\n .filter((attribute) => !attribute.isResult)\n .some(\n (attribute) =>\n object && object.attributeCollection.hasAttributeByKey(attribute.key),\n );\n\n const hasSameRepeatIndex = withRepeatIndex\n ? this.repeatIndex === object.repeatIndex\n : true;\n\n return hasSameRepeatIndex && objectContainsOneOfTheAttributes;\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.attributeCollection.getAttributeByAttribute(attribute);\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.attributeCollection.hasAttributeByKey(key);\n }\n\n /**\n * Get elements from both the missing attributes and the result attributes\n */\n getElements(): Array<Object> {\n const elements = [];\n\n if (this.data.elements) {\n elements.push(...this.data.elements);\n }\n\n if (this.data.results) {\n const dataResults = this.data.results.map((result) => ({\n ...result,\n isResult: true,\n }));\n\n elements.push(...dataResults);\n }\n\n if (this.data.elementid) {\n elements.push({\n ...this.data,\n });\n }\n\n return elements;\n }\n\n /**\n * Map available contributions on the available data. Only use contributions that are needed for the data\n */\n getApplicableAttributeContributions(): Array<Object> {\n if (this.data && this.contributions) {\n const dataElementIds = this.getElements().map(\n (element) => element.elementid,\n );\n\n const contributions = this.getAttributesInData(\n dataElementIds,\n this.contributions.attributes,\n );\n\n // set all attribute mandatory for dynamic object\n if (this.isDynamic) {\n return contributions.map((attribute) => {\n const [attributeKey] = Object.keys(attribute);\n return {\n [attributeKey]: {\n ...attribute[attributeKey],\n mandatory: true,\n },\n };\n });\n }\n\n return contributions;\n }\n\n return [];\n }\n\n /**\n * Recursevily check if an attribute id occurs in the tree of attribute contributions.\n * The complete leaf of the tree is returned when an attribute id matches\n */\n getAttributesInData(\n dataElementIds: Array<string>,\n attributesContributions: Object,\n ): Array<Object> {\n return attributesContributions.filter((attributeContributions) => {\n const [attributeKey] = Object.keys(attributeContributions);\n\n return dataElementIds.some(\n (dataElementId) => dataElementId.split(\".\")[0] === attributeKey,\n );\n });\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this._attributeCollection.getInitialChildModelLinks();\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this._attributeCollection.setChildModels(models, errors);\n }\n\n /**\n * get key\n */\n get key(): string {\n return this.data.objectid;\n }\n\n /**\n * Get content configuration for form objects\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n get hasEndResultConfiguration(): boolean {\n return this.contributions.content?.results != null;\n }\n\n /**\n * Indicates if object is dynamic.\n *\n * A subtle difference exists between objects for wizard style instrument dialogs and other objects.\n * In the 'missing object' response, wizard style objects will include only the first attribute(s) to be answered,\n * while other objects will include the complete set of attributes of that object.\n *\n * This difference is condensed in the term of 'dynamic objects': these objects start (in the 'missing object' response)\n * with a very select set of attributes to be answered, and each successive 'missing elements' response will include next attributes to be answered.\n * When an object is dynamic, the form contributions will mention a \"dynamicObject\": true property.\n */\n get isDynamic(): boolean {\n return this.getContribution(\"dynamicObject\", false);\n }\n\n /**\n */\n get hasDynamicValidations(): boolean {\n return this.getContribution(\"dynamicValidations\", false);\n }\n\n /**\n * Indicates if object is repeatable\n */\n get isRepeatable(): boolean {\n return this.getContribution(\"repeatable\", false);\n }\n\n /**\n */\n get repeatIndex(): number {\n return this._repeatIndex ?? this.data.index ?? 1;\n }\n\n /**\n */\n set repeatIndex(repeatIndex: number) {\n this._repeatIndex = repeatIndex;\n }\n\n /**\n */\n get maxRepeats(): number {\n if (this.isRepeatable) {\n return this.getData(\"numberofrepeats\", -1);\n }\n\n return 1;\n }\n\n /**\n */\n get hasFixedNrOfRepeats(): boolean {\n return this.maxRepeats > -1;\n }\n\n /**\n */\n get isRepeatWithUnknownTotal(): boolean {\n return this.isRepeatable && this.maxRepeats === -1;\n }\n\n /**\n */\n get isLastRepeat(): boolean {\n if (this.isRepeatable) {\n return this.data.last || false;\n }\n\n return true;\n }\n\n /**\n */\n get repeatIndexLabel(): string | null {\n return this.data[\"index-identifier\"] || null;\n }\n\n /**\n * Get label of form object\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n * Get introText of form object\n */\n get introText(): string {\n if (this.data.content?.text) {\n return this.data.content.text.message;\n }\n\n if (this.contributions.text?.message) {\n return this.contributions.text.message;\n }\n\n return this.contributions.introText;\n }\n\n /**\n * Get assistent of form object\n */\n get assistent(): string {\n return this.contributions.assistent;\n }\n\n /**\n * Get button labels\n */\n get buttonLabels(): Object {\n return this.getContribution(\"buttonLabels\", {});\n }\n\n /**\n * get attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(attributeCollection: AttributeCollection) {\n this._attributeCollection = attributeCollection;\n }\n\n /**\n */\n mergeObject(oldObject: FormObjectModel) {\n this.attributeCollection.forEach((attribute) => {\n const mergeWithAttribute = oldObject.getAttributeByAttribute(attribute);\n if (mergeWithAttribute) {\n attribute.mergeAttribute(mergeWithAttribute);\n }\n });\n\n this.repeatIndex = oldObject.repeatIndex;\n }\n\n /**\n * Update attribute\n */\n updateAttribute(attribute: AttributeType, value: any): AttributeType {\n const attributeToUpdate =\n this.attributeCollection.getAttributeByAttribute(attribute);\n\n if (attributeToUpdate === null) {\n throw new Error(`Attribute with name: ${attribute.name} not found.`);\n }\n\n if (attributeToUpdate instanceof CompositeAttributeModel) {\n attributeToUpdate.update(value, attribute);\n } else {\n attributeToUpdate.update(value);\n }\n\n return attributeToUpdate;\n }\n\n /**\n * Inidicates if Form is changed since a given timestamp (Date.now)\n */\n isChangedSince(timestamp: number): boolean {\n return (\n this.attributeCollection.find((attribute) =>\n attribute.isChangedSince(timestamp),\n ) !== null\n );\n }\n\n /**\n * Reset all errors on Form Object\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"formobject\");\n this.attributeCollection.forEach((attribute) => attribute.resetErrors());\n }\n\n /**\n * Get error messages\n */\n get errorCollection(): ErrorCollection {\n return this._errorCollection;\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n if (error.anchor?.elementid != null) {\n this.attributeCollection.addServerError(error);\n } else {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n error.layouthint,\n );\n }\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.attributeCollection.hasServerErrors()\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems || this.attributeCollection.hasErrors()\n );\n }\n\n /**\n */\n get isValid(): boolean {\n return (\n this.attributeCollection.visible.every(\n (attribute) => attribute.isValid,\n ) && !this.errorCollection.hasItems\n );\n }\n\n /**\n */\n get dynamicValidationsLoaded(): boolean {\n return this._dynamicValidationsLoaded;\n }\n\n /**\n */\n set dynamicValidationsLoaded(dynamicValidationsLoaded: boolean) {\n this._dynamicValidationsLoaded = dynamicValidationsLoaded;\n }\n\n /**\n * Convert error json from a form service to validation messages on the form object and attributes\n */\n handleErrorValidations(errors: Array<ErrorObject>) {\n const attributeErrors = [];\n\n errors\n .filter((error) => error.anchor?.objectid === this.key)\n .forEach((error) => {\n if (has(error.anchor, \"elementid\")) {\n attributeErrors.push(error);\n } else {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n new LayoutHintCollection(error.layouthint),\n );\n }\n });\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n * Convert missing json from a form service to mandatory validation constraints and messages\n */\n handleMissingValidations(\n missing: {\n anchors: Array<\n | {\n elements: Array<{ elementid: string }>,\n objectid?: string,\n }\n | { anchor: { elementid: string, objectid?: string } },\n >,\n },\n errors: Array<ErrorObject>,\n ) {\n const attributeErrors = [];\n\n for (const anchor of missing.anchors) {\n if (!anchor.objectid || anchor.objectid === this.key) {\n if (Array.isArray(anchor.elements)) {\n for (const element of anchor.elements) {\n attributeErrors.push({\n anchor: { elementid: element.elementid },\n id: \"Constraint.Mandatory\",\n });\n }\n } else {\n attributeErrors.push({\n anchor,\n id: \"Constraint.Mandatory\",\n });\n }\n }\n }\n\n errors\n .filter(\n (error) =>\n error.id === \"Constraint.Mandatory\" &&\n error.anchor?.objectid === this.key &&\n has(error.anchor, \"elementid\"),\n )\n .forEach((error) => {\n attributeErrors.push(error);\n });\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n */\n updateValidations(data: any): FormObjectModel {\n this.resetErrors();\n\n if (Array.isArray(data.errors)) {\n this.handleErrorValidations(data.errors);\n }\n\n // missing attribute errors\n if (Array.isArray(data.missing?.anchors)) {\n this.handleMissingValidations(data.missing, data.errors);\n }\n\n this.dynamicValidationsLoaded = true;\n\n return this;\n }\n\n /**\n * Generate formdata object for current formobject based on formdata of attributes\n */\n get formdata(): { [string]: any } | null {\n return this.attributeCollection.formdata;\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n return this.attributeCollection.getFormData(validationData);\n }\n}\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,mBAAmB,MAAM,mCAAmC;AACnE,OAAOC,uBAAuB,MAAM,uCAAuC;AAC3E,OAAOC,oBAAoB,MAAM,8CAA8C;AAC/E,OAAOC,eAAe,MAAM,0BAA0B;AACtD,SAASC,wBAAwB,QAAQ,kBAAkB;AAS3D,OAAOC,oBAAoB,MAAM,oCAAoC;AAiBrE;AACA;AACA;AACA,eAAe,MAAMC,eAAe,SAASP,SAAS,CAAC;EAOrD;AACF;AACA;EACEQ,WAAWA,CACTC,MAAc,EACdC,mBAA2B,EAC3BC,YAA2B,EAC3B;IACA,KAAK,CAACF,MAAM,EAAEC,mBAAmB,EAAEC,YAAY,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAEjD,IAAIH,MAAM,IAAI,IAAI,CAACI,WAAW,CAAC,CAAC,CAACC,MAAM,GAAG,CAAC,EAAE;MAC3C,IAAI,CAACC,oBAAoB,GAAG,IAAId,mBAAmB,CACjD,IAAI,CAACY,WAAW,CAAC,CAAC,EAClB,IAAI,CAACG,mCAAmC,CAAC,CAAC,EAC1C;QAAE,GAAGL,YAAY;QAAEM,UAAU,EAAE;MAAM,CACvC,CAAC;IACH,CAAC,MAAM;MACL,IAAI,CAACF,oBAAoB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;EAEA;AACF;EACEC,WAAWA,CAAA,EAA4D;IAAA,IAA3DC,cAAuB,GAAApG,SAAA,CAAAnB,MAAA,QAAAmB,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,KAAK;IACzC,OAAO,IAAI,CAACX,mBAAmB,CAAC8G,WAAW,CAACC,cAAc,CAAC;EAC7D;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"FormObjectModel.js","names":["has","BaseModel","AttributeCollection","CompositeAttributeModel","ContentConfiguration","ErrorCollection","IllegalArgumentException","LayoutHintCollection","FormObjectModel","constructor","object","objectContributions","modelOptions","_defineProperty","getElements","length","_attributeCollection","getApplicableAttributeContributions","isReadonly","_contentConfiguration","content","_errorCollection","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","createEmpty","formObjectModel","contributions","equals","_context","withRepeatIndex","arguments","undefined","key","objectContainsOneOfTheAttributes","_filterInstanceProperty","all","call","attribute","isResult","some","hasAttributeByKey","hasSameRepeatIndex","repeatIndex","getAttributeByAttribute","getAttributeByKey","elements","push","results","_context2","dataResults","_mapInstanceProperty","result","elementid","_context3","dataElementIds","element","getAttributesInData","attributes","isDynamic","attributeKey","_Object$keys","mandatory","attributesContributions","attributeContributions","dataElementId","split","getInitialChildModelLinks","setChildModels","models","errors","objectid","hasEndResultConfiguration","getContribution","hasDynamicValidations","isRepeatable","_repeatIndex","index","maxRepeats","hasFixedNrOfRepeats","isRepeatWithUnknownTotal","isLastRepeat","last","repeatIndexLabel","label","introText","text","message","assistent","buttonLabels","mergeObject","oldObject","forEach","mergeWithAttribute","mergeAttribute","updateAttribute","value","attributeToUpdate","Error","name","update","isChangedSince","timestamp","_context4","_findInstanceProperty","resetErrors","errorCollection","addServerError","error","anchor","id","properties","layouthint","hasServerErrors","hasItems","hasErrors","isValid","visible","every","dynamicValidationsLoaded","_dynamicValidationsLoaded","handleErrorValidations","attributeErrors","updateValidations","handleMissingValidations","missing","anchors","Array","isArray","formdata","getFormData","validationData"],"sources":["../../../src/models/form/FormObjectModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport ErrorCollection from \"../error/ErrorCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type {\n AttributeType,\n ModularUIModel,\n FormErrorAnchor,\n ModelOptions,\n} from \"../types\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\n\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\nimport type { MessageParameters } from \"../../i18n\";\n\ntype ErrorObject = {\n anchor: {\n objectid: string,\n elementid?: string,\n },\n id: string,\n message: string,\n properties: MessageParameters,\n layouthint: Array<string>,\n};\n\n/**\n * Form Object\n */\nexport default class FormObjectModel extends BaseModel {\n _attributeCollection: AttributeCollection;\n _contentConfiguration: ContentConfiguration;\n _errorCollection: ErrorCollection;\n _repeatIndex: number;\n _dynamicValidationsLoaded: boolean;\n\n /**\n * Construct FormObjectModel\n */\n constructor(\n object: Object,\n objectContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(object, objectContributions, modelOptions);\n\n if (object && this.getElements().length > 0) {\n this._attributeCollection = new AttributeCollection(\n this.getElements(),\n this.getApplicableAttributeContributions(),\n { ...modelOptions, isReadonly: false },\n );\n } else {\n this._attributeCollection = new AttributeCollection();\n }\n\n this._contentConfiguration = new ContentConfiguration(\n objectContributions ? objectContributions.content : {},\n );\n\n this._errorCollection = new ErrorCollection(\"formobject\");\n\n if (has(this.data, \"referenceDate\")) {\n this.attributeCollection.setReferenceDate(this.getData(\"referenceDate\"));\n }\n\n this.attributeCollection.indicateContentConfiguration(\n this.contentConfiguration,\n );\n }\n\n /**\n */\n static createEmpty(formObjectModel: FormObjectModel): FormObjectModel {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\n \"createEmpty method needs a FormObjectModel as input argument to create a new version of the object\",\n );\n }\n return new FormObjectModel(\n formObjectModel.data,\n formObjectModel.contributions,\n formObjectModel.modelOptions,\n );\n }\n\n /**\n */\n equals(object: ?FormObjectModel, withRepeatIndex: boolean = true): boolean {\n if (!object || this.key !== object.key) {\n return false;\n }\n\n const objectContainsOneOfTheAttributes = this.attributeCollection.all\n .filter((attribute) => !attribute.isResult)\n .some(\n (attribute) =>\n object && object.attributeCollection.hasAttributeByKey(attribute.key),\n );\n\n const hasSameRepeatIndex = withRepeatIndex\n ? this.repeatIndex === object.repeatIndex\n : true;\n\n return hasSameRepeatIndex && objectContainsOneOfTheAttributes;\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.attributeCollection.getAttributeByAttribute(attribute);\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.attributeCollection.hasAttributeByKey(key);\n }\n\n /**\n * Get elements from both the missing attributes and the result attributes\n */\n getElements(): Array<Object> {\n const elements = [];\n\n if (this.data.elements) {\n elements.push(...this.data.elements);\n }\n\n if (this.data.results) {\n const dataResults = this.data.results.map((result) => ({\n ...result,\n isResult: true,\n }));\n\n elements.push(...dataResults);\n }\n\n if (this.data.elementid) {\n elements.push({\n ...this.data,\n });\n }\n\n return elements;\n }\n\n /**\n * Map available contributions on the available data. Only use contributions that are needed for the data\n */\n getApplicableAttributeContributions(): Array<Object> {\n if (this.data && this.contributions) {\n const dataElementIds = this.getElements().map(\n (element) => element.elementid,\n );\n\n const contributions = this.getAttributesInData(\n dataElementIds,\n this.contributions.attributes,\n );\n\n // set all attribute mandatory for dynamic object\n if (this.isDynamic) {\n return contributions.map((attribute) => {\n const [attributeKey] = Object.keys(attribute);\n return {\n [attributeKey]: {\n ...attribute[attributeKey],\n mandatory: true,\n },\n };\n });\n }\n\n return contributions;\n }\n\n return [];\n }\n\n /**\n * Recursevily check if an attribute id occurs in the tree of attribute contributions.\n * The complete leaf of the tree is returned when an attribute id matches\n */\n getAttributesInData(\n dataElementIds: Array<string>,\n attributesContributions: Object,\n ): Array<Object> {\n return attributesContributions.filter((attributeContributions) => {\n const [attributeKey] = Object.keys(attributeContributions);\n\n return dataElementIds.some(\n (dataElementId) => dataElementId.split(\".\")[0] === attributeKey,\n );\n });\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this._attributeCollection.getInitialChildModelLinks();\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this._attributeCollection.setChildModels(models, errors);\n }\n\n /**\n * get key\n */\n get key(): string {\n return this.data.objectid;\n }\n\n /**\n * Get content configuration for form objects\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n get hasEndResultConfiguration(): boolean {\n return this.contributions.content?.results != null;\n }\n\n /**\n * Indicates if object is dynamic.\n *\n * A subtle difference exists between objects for wizard style instrument dialogs and other objects.\n * In the 'missing object' response, wizard style objects will include only the first attribute(s) to be answered,\n * while other objects will include the complete set of attributes of that object.\n *\n * This difference is condensed in the term of 'dynamic objects': these objects start (in the 'missing object' response)\n * with a very select set of attributes to be answered, and each successive 'missing elements' response will include next attributes to be answered.\n * When an object is dynamic, the form contributions will mention a \"dynamicObject\": true property.\n */\n get isDynamic(): boolean {\n return this.getContribution(\"dynamicObject\", false);\n }\n\n /**\n */\n get hasDynamicValidations(): boolean {\n return this.getContribution(\"dynamicValidations\", false);\n }\n\n /**\n * Indicates if object is repeatable\n */\n get isRepeatable(): boolean {\n return this.getContribution(\"repeatable\", false);\n }\n\n /**\n */\n get repeatIndex(): number {\n return this._repeatIndex ?? this.data.index ?? 1;\n }\n\n /**\n */\n set repeatIndex(repeatIndex: number) {\n this._repeatIndex = repeatIndex;\n }\n\n /**\n */\n get maxRepeats(): number {\n if (this.isRepeatable) {\n return this.getData(\"numberofrepeats\", -1);\n }\n\n return 1;\n }\n\n /**\n */\n get hasFixedNrOfRepeats(): boolean {\n return this.maxRepeats > -1;\n }\n\n /**\n */\n get isRepeatWithUnknownTotal(): boolean {\n return this.isRepeatable && this.maxRepeats === -1;\n }\n\n /**\n */\n get isLastRepeat(): boolean {\n if (this.isRepeatable) {\n return this.data.last || false;\n }\n\n return true;\n }\n\n /**\n */\n get repeatIndexLabel(): string | null {\n return this.data[\"index-identifier\"] || null;\n }\n\n /**\n * Get label of form object\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n * Get introText of form object\n */\n get introText(): string {\n if (this.data.content?.text) {\n return this.data.content.text.message;\n }\n\n if (this.contributions.text?.message) {\n return this.contributions.text.message;\n }\n\n return this.contributions.introText;\n }\n\n /**\n * Get assistent of form object\n */\n get assistent(): string {\n return this.contributions.assistent;\n }\n\n /**\n * Get button labels\n */\n get buttonLabels(): Object {\n return this.getContribution(\"buttonLabels\", {});\n }\n\n /**\n * get attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(attributeCollection: AttributeCollection) {\n this._attributeCollection = attributeCollection;\n }\n\n /**\n */\n mergeObject(oldObject: FormObjectModel) {\n this.attributeCollection.forEach((attribute) => {\n const mergeWithAttribute = oldObject.getAttributeByAttribute(attribute);\n if (mergeWithAttribute) {\n attribute.mergeAttribute(mergeWithAttribute);\n }\n });\n\n this.repeatIndex = oldObject.repeatIndex;\n }\n\n /**\n * Update attribute\n */\n updateAttribute(attribute: AttributeType, value: any): AttributeType {\n const attributeToUpdate =\n this.attributeCollection.getAttributeByAttribute(attribute);\n\n if (attributeToUpdate === null) {\n throw new Error(`Attribute with name: ${attribute.name} not found.`);\n }\n\n if (attributeToUpdate instanceof CompositeAttributeModel) {\n attributeToUpdate.update(value, attribute);\n } else {\n attributeToUpdate.update(value);\n }\n\n return attributeToUpdate;\n }\n\n /**\n * Inidicates if Form is changed since a given timestamp (Date.now)\n */\n isChangedSince(timestamp: number): boolean {\n return (\n this.attributeCollection.find((attribute) =>\n attribute.isChangedSince(timestamp),\n ) !== null\n );\n }\n\n /**\n * Reset all errors on Form Object\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"formobject\");\n this.attributeCollection.forEach((attribute) => attribute.resetErrors());\n }\n\n /**\n * Get error messages\n */\n get errorCollection(): ErrorCollection {\n return this._errorCollection;\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n if (error.anchor?.elementid != null) {\n this.attributeCollection.addServerError(error);\n } else {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n error.layouthint,\n );\n }\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.attributeCollection.hasServerErrors()\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems || this.attributeCollection.hasErrors()\n );\n }\n\n /**\n */\n get isValid(): boolean {\n return (\n this.attributeCollection.visible.every(\n (attribute) => attribute.isValid,\n ) && !this.errorCollection.hasItems\n );\n }\n\n /**\n */\n get dynamicValidationsLoaded(): boolean {\n return this._dynamicValidationsLoaded;\n }\n\n /**\n */\n set dynamicValidationsLoaded(dynamicValidationsLoaded: boolean) {\n this._dynamicValidationsLoaded = dynamicValidationsLoaded;\n }\n\n /**\n * Convert error json from a form service to validation messages on the form object and attributes\n */\n handleErrorValidations(errors: Array<ErrorObject>) {\n const attributeErrors = [];\n\n errors\n .filter((error) => error.anchor?.objectid === this.key)\n .forEach((error) => {\n if (has(error.anchor, \"elementid\")) {\n attributeErrors.push(error);\n } else {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n new LayoutHintCollection(error.layouthint),\n );\n }\n });\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n * Convert missing json from a form service to mandatory validation constraints and messages\n */\n handleMissingValidations(\n missing: {\n anchors: Array<\n | {\n elements: Array<{ elementid: string }>,\n objectid?: string,\n }\n | { anchor: { elementid: string, objectid?: string } },\n >,\n },\n errors: Array<ErrorObject>,\n ) {\n const attributeErrors = [];\n\n for (const anchor of missing.anchors) {\n if (!anchor.objectid || anchor.objectid === this.key) {\n if (Array.isArray(anchor.elements)) {\n for (const element of anchor.elements) {\n attributeErrors.push({\n anchor: { elementid: element.elementid },\n id: \"Constraint.Mandatory\",\n });\n }\n } else {\n attributeErrors.push({\n anchor,\n id: \"Constraint.Mandatory\",\n });\n }\n }\n }\n\n if (Array.isArray(errors)) {\n errors\n .filter(\n (error) =>\n error.id === \"Constraint.Mandatory\" &&\n error.anchor?.objectid === this.key &&\n has(error.anchor, \"elementid\"),\n )\n .forEach((error) => {\n attributeErrors.push(error);\n });\n }\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n */\n updateValidations(data: any): FormObjectModel {\n this.resetErrors();\n\n if (Array.isArray(data.errors)) {\n this.handleErrorValidations(data.errors);\n }\n\n // missing attribute errors\n if (Array.isArray(data.missing?.anchors)) {\n this.handleMissingValidations(data.missing, data.errors);\n }\n\n this.dynamicValidationsLoaded = true;\n\n return this;\n }\n\n /**\n * Generate formdata object for current formobject based on formdata of attributes\n */\n get formdata(): { [string]: any } | null {\n return this.attributeCollection.formdata;\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n return this.attributeCollection.getFormData(validationData);\n }\n}\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,mBAAmB,MAAM,mCAAmC;AACnE,OAAOC,uBAAuB,MAAM,uCAAuC;AAC3E,OAAOC,oBAAoB,MAAM,8CAA8C;AAC/E,OAAOC,eAAe,MAAM,0BAA0B;AACtD,SAASC,wBAAwB,QAAQ,kBAAkB;AAS3D,OAAOC,oBAAoB,MAAM,oCAAoC;AAiBrE;AACA;AACA;AACA,eAAe,MAAMC,eAAe,SAASP,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C7D;;EAEA;AACF;EACEC,iBAAiBA,CAACxG,IAAS,EAAmB;IAC5C,IAAI,CAACsF,WAAW,CAAC,CAAC;IAElB,IAAIsB,KAAK,CAACC,OAAO,CAAC7G,IAAI,CAACmD,MAAM,CAAC,EAAE;MAC9B,IAAI,CAACmD,sBAAsB,CAACtG,IAAI,CAACmD,MAAM,CAAC;IAC1C;;IAEA;IACA,IAAIyD,KAAK,CAACC,OAAO,CAAC7G,IAAI,CAAC0G,OAAO,EAAEC,OAAO,CAAC,EAAE;MACxC,IAAI,CAACF,wBAAwB,CAACzG,IAAI,CAAC0G,OAAO,EAAE1G,IAAI,CAACmD,MAAM,CAAC;IAC1D;IAEA,IAAI,CAACiD,wBAAwB,GAAG,IAAI;IAEpC,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACE,IAAIU,QAAQA,CAAA,EAA6B;IACvC,OAAO,IAAI,CAAC7G,mBAAmB,CAAC6G,QAAQ;EAC1C;;EAEA;AACF;EACEC,WAAWA,CAAA,EAA4D;IAAA,IAA3DC,cAAuB,GAAApG,SAAA,CAAAnB,MAAA,QAAAmB,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,KAAK;IACzC,OAAO,IAAI,CAACX,mBAAmB,CAAC8G,WAAW,CAACC,cAAc,CAAC;EAC7D;AACF","ignoreList":[]}
|
package/esm/models/types.d.ts
CHANGED
|
@@ -155,6 +155,12 @@ type ContentData = {
|
|
|
155
155
|
label?: string | undefined;
|
|
156
156
|
elements: (PropertyElement | TextFragmentElement | ContentElement)[];
|
|
157
157
|
};
|
|
158
|
+
type SectionFragment = {
|
|
159
|
+
sectionId?: string | undefined;
|
|
160
|
+
text: string;
|
|
161
|
+
startOffset: number;
|
|
162
|
+
endOffset: number;
|
|
163
|
+
};
|
|
158
164
|
type ModelOptions = {
|
|
159
165
|
origin?: string | null | undefined;
|
|
160
166
|
contextPath?: string | null | undefined;
|
package/esm/models/types.js.flow
CHANGED
|
@@ -262,6 +262,13 @@ export type ContentData = {
|
|
|
262
262
|
elements: Array<PropertyElement | TextFragmentElement | ContentElement>,
|
|
263
263
|
};
|
|
264
264
|
|
|
265
|
+
export type SectionFragment = {
|
|
266
|
+
sectionId?: string,
|
|
267
|
+
text: string,
|
|
268
|
+
startOffset: number,
|
|
269
|
+
endOffset: number,
|
|
270
|
+
};
|
|
271
|
+
|
|
265
272
|
export type ModelOptions = {
|
|
266
273
|
origin?: ?string,
|
|
267
274
|
contextPath?: ?string,
|
package/esm/models/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/models/types.js"],"sourcesContent":["// @flow\nimport type ApplicationModel from \"./application/ApplicationModel\";\nimport type BooleanAttributeModel from \"./attributes/BooleanAttributeModel\";\nimport type CaptchaAttributeModel from \"./attributes/CaptchaAttributeModel\";\nimport type ChoiceAttributeModel from \"./attributes/ChoiceAttributeModel\";\nimport type CompositeAttributeModel from \"./attributes/CompositeAttributeModel\";\nimport type DatetimeAttributeModel from \"./attributes/DatetimeAttributeModel\";\nimport type HelptextAttributeModel from \"./attributes/HelptextAttributeModel\";\nimport type LabelAttributeModel from \"./attributes/LabelAttributeModel\";\nimport type MemoAttributeModel from \"./attributes/MemoAttributeModel\";\nimport type MoneyAttributeModel from \"./attributes/MoneyAttributeModel\";\nimport type NumberAttributeModel from \"./attributes/NumberAttributeModel\";\nimport type PasswordAttributeModel from \"./attributes/PasswordAttributeModel\";\nimport type StringAttributeModel from \"./attributes/StringAttributeModel\";\nimport type UploadAttributeModel from \"./attributes/UploadAttributeModel\";\nimport type XMLAttributeModel from \"./attributes/XMLAttributeModel\";\nimport type CaseViewModel from \"./caseview/CaseViewModel\";\nimport type BusinessScenarioModel from \"./concepts/BusinessScenarioModel\";\nimport type ConceptDetailModel from \"./concepts/ConceptDetailModel\";\nimport type ConceptIndexModel from \"./concepts/ConceptIndexModel\";\nimport type ConceptTypeDetailModel from \"./concepts/ConceptTypeDetailModel\";\nimport type ContentIndexModel from \"./content/ContentIndexModel\";\nimport type ContentModel from \"./content/ContentModel\";\nimport type SectionModel from \"./content/SectionModel\";\nimport type ContentTOCModel from \"./content/ContentTOCModel\";\nimport type ContentTypeModel from \"./content/ContentTypeModel\";\nimport type DetailModel from \"./detail/DetailModel\";\nimport type AssignmentFilterModel from \"./filters/AssignmentFilterModel\";\nimport type FilterModel from \"./filters/FilterModel\";\nimport type RangeFilterModel from \"./filters/RangeFilterModel\";\nimport type ConceptIndexFilterModel from \"./filters/ConceptIndexFilterModel\";\nimport type FormModel from \"./form/FormModel\";\nimport type ListDetailModel from \"./list/ListDetailModel\";\nimport type ListModel from \"./list/ListModel\";\nimport type ModelCatalogModel from \"./modelcatalog/ModelCatalogModel\";\nimport type GroupingPanelModel from \"./panels/GroupingPanelModel\";\nimport type CaseSearchModel from \"./search/CaseSearchModel\";\nimport type TabModel from \"./tab/TabModel\";\nimport type TaskGroupModel from \"./taskgroup/TaskGroupModel\";\nimport type UserModel from \"./user/UserModel\";\nimport type UserServicesModel from \"./user/UserServicesModel\";\nimport type LinkModel from \"./links/LinkModel\";\nimport type LookupOptionsModel from \"./lookup/LookupOptionsModel\";\nimport type BaseFilterModel from \"./filters/BaseFilterModel\";\nimport type AttributeCollection from \"./attributes/AttributeCollection\";\nimport type AttributeModel from \"./attributes/AttributeModel\";\nimport type LayoutHintCollection from \"./layouthint/LayoutHintCollection\";\nimport type ErrorResponse from \"./error/ErrorResponse\";\n\nexport type ModularUIModel =\n | ApplicationModel\n | CaseSearchModel\n | CaseViewModel\n | ListDetailModel\n | DetailModel\n | FormModel\n | GroupingPanelModel\n | ListModel\n | TabModel\n | TaskGroupModel\n | UserModel\n | UserServicesModel\n | ModelCatalogModel\n | ConceptIndexModel\n | ConceptDetailModel\n | BusinessScenarioModel\n | ConceptTypeDetailModel\n | ContentIndexModel\n | ContentTOCModel\n | ContentModel\n | ContentTypeModel\n | LookupOptionsModel;\n\nexport type AttributeType =\n | BooleanAttributeModel\n | CaptchaAttributeModel\n | ChoiceAttributeModel\n | DatetimeAttributeModel\n | HelptextAttributeModel\n | LabelAttributeModel\n | MemoAttributeModel\n | MoneyAttributeModel\n | NumberAttributeModel\n | PasswordAttributeModel\n | CompositeAttributeModel\n | StringAttributeModel\n | UploadAttributeModel\n | XMLAttributeModel;\n\nexport type RangeChildAttributeType =\n | NumberAttributeModel\n | DatetimeAttributeModel;\n\nexport type FilterType =\n | BaseFilterModel\n | FilterModel\n | AssignmentFilterModel\n | RangeFilterModel\n | ConceptIndexFilterModel;\n\nexport type FormErrorAnchor = {\n id: string,\n properties?: {\n [propertyName: string]: string | number,\n },\n anchor?: {\n objectid: string,\n elementid?: string,\n _links?: Object,\n index?: number,\n \"index-identifier\"?: string,\n },\n layouthint: LayoutHintCollection,\n message: string,\n param?: {\n name: string,\n },\n};\n\nexport type labelsJSON = {\n _id: string,\n label: string,\n value: string,\n};\n\nexport type propertyJSON = {\n _id: string,\n type: string,\n mandatory: string,\n label: string,\n value: string,\n};\n\nexport type textfragmentJSON = {\n label: string,\n text: string,\n type: string,\n};\n\nexport interface IConstraintModel {\n +id: string;\n +defaultMessage: string;\n +parameters: Object;\n +isMandatoryConstraint: boolean;\n validate(value: any): boolean;\n hasValidation(): boolean;\n}\n\nexport interface ILayoutHintRule {\n process(attribute: AttributeModel, attributes: AttributeCollection): void;\n}\n\nexport interface IModelWithChildModels {\n getInitialChildModelLinks(): Array<LinkModel>;\n setChildModels(\n models: Array<ModularUIModel>,\n errors: Array<ErrorResponse>,\n ): void;\n}\n\nexport type AuthenticationType = {\n name: string,\n authentication: string,\n redirectUri?: string,\n isPrimary: boolean,\n};\n\nexport type FileEntryType = {\n name: string,\n size?: number,\n progress: number,\n error?: string,\n token?: string,\n};\n\nexport type FilesType = {\n [filename: string]: FileEntryType,\n};\n\nexport type FiletypeConstraintsType = Array<{|\n extensions: Array<string>,\n mimeTypes: Array<string>,\n|}>;\n\nexport type FilesizeConstraintsType = {\n fileSize: ?number,\n maxTotalFileSize: ?number,\n isMaxTotal: boolean,\n};\n\nexport type PropertyData = { type: string, label: string, value: string };\nexport type TextFragmentData = {\n type: string,\n label: string,\n text: string | { id?: string, message: string, properties?: Object },\n};\nexport type SectionData = {\n id: string,\n type: string,\n label?: string,\n number?: string,\n body: string | { id?: string, message: string, properties?: Object },\n _links: { self: { href: string } },\n childSections: Array<SectionData>,\n subSections: Array<SectionData>,\n};\n\nexport type PropertyElement = {\n propertyElement: {\n label: string,\n layouthint: Array<string>,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElement = {\n textFragmentElement: {\n label: string,\n layouthint: Array<string>,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElement = {\n contentElement: {\n label: string,\n layouthint: Array<string>,\n sections: Array<SectionData>,\n },\n};\n\nexport type PropertyElementMapped = {\n propertyElement: {\n label: string,\n layouthint: LayoutHintCollection,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElementMapped = {\n textFragmentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElementMapped = {\n contentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n sections: Array<SectionModel>,\n },\n};\n\nexport type ContentAll = Array<\n PropertyElementMapped | TextFragmentElementMapped | ContentElementMapped,\n>;\n\nexport type ContentData = {\n header: {\n label?: string,\n description?: { id?: string, message: string, properties?: Object },\n },\n label?: string,\n elements: Array<PropertyElement | TextFragmentElement | ContentElement>,\n};\n\nexport type ModelOptions = {\n origin?: ?string,\n contextPath?: ?string,\n};\n"],"mappings":"","ignoreList":[]}
|
|
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 sectionId?: string,\n text: string,\n startOffset: number,\n endOffset: number,\n};\n\nexport type ModelOptions = {\n origin?: ?string,\n contextPath?: ?string,\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -2,10 +2,10 @@ import { createHash } from "../createHash";
|
|
|
2
2
|
|
|
3
3
|
describe("createHash", () => {
|
|
4
4
|
it("creates hash from string", () => {
|
|
5
|
-
expect(createHash("")).toBe(
|
|
6
|
-
expect(createHash("abcdefgh")).toBe(
|
|
7
|
-
expect(createHash(123455)).toBe(
|
|
8
|
-
expect(createHash(null)).toBe(
|
|
9
|
-
expect(createHash()).toBe(
|
|
5
|
+
expect(createHash("")).toBe(729279156);
|
|
6
|
+
expect(createHash("abcdefgh")).toBe(17595859189820);
|
|
7
|
+
expect(createHash(123455)).toBe(15900277965517);
|
|
8
|
+
expect(createHash(null)).toBe(711079339769);
|
|
9
|
+
expect(createHash()).toBe(4721361581144);
|
|
10
10
|
});
|
|
11
11
|
});
|
|
@@ -4,5 +4,6 @@
|
|
|
4
4
|
export function createHash(str: string): number;
|
|
5
5
|
/**
|
|
6
6
|
*/
|
|
7
|
-
export function createHashFromHref(href: Href): number;
|
|
7
|
+
export function createHashFromHref(href: Href, fragment?: SectionFragment): number;
|
|
8
8
|
import Href from "../../models/href/Href";
|
|
9
|
+
import { SectionFragment } from "../../models";
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
+
import hash from "hash-it";
|
|
1
2
|
/**
|
|
2
3
|
* https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
|
|
3
4
|
*/
|
|
4
5
|
const createHash = str => {
|
|
5
|
-
|
|
6
|
-
let hash = 0;
|
|
7
|
-
for (let i = 0; i < str.length; i++) {
|
|
8
|
-
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
9
|
-
hash = hash & hash;
|
|
10
|
-
}
|
|
11
|
-
return hash;
|
|
6
|
+
return hash(str);
|
|
12
7
|
};
|
|
13
8
|
|
|
14
9
|
/**
|
|
15
10
|
*/
|
|
16
|
-
const createHashFromHref = href => {
|
|
11
|
+
const createHashFromHref = (href, fragment) => {
|
|
17
12
|
const hrefString = href.hash ? [href.toString(), href.hash].join("#") : href.toString();
|
|
18
|
-
|
|
13
|
+
if (fragment) {
|
|
14
|
+
return hash({
|
|
15
|
+
hrefString,
|
|
16
|
+
fragment
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return hash(hrefString);
|
|
19
20
|
};
|
|
20
21
|
export { createHash, createHashFromHref };
|
|
21
22
|
//# sourceMappingURL=createHash.js.map
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
// @flow
|
|
2
|
+
import hash from "hash-it";
|
|
3
|
+
|
|
2
4
|
import type Href from "../../models/href/Href";
|
|
5
|
+
import type { SectionFragment } from "../../models";
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
|
|
6
9
|
*/
|
|
7
10
|
const createHash = (str: string): number => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let hash = 0;
|
|
11
|
-
for (let i = 0; i < str.length; i++) {
|
|
12
|
-
hash = (hash << 5) - hash + str.charCodeAt(i);
|
|
13
|
-
hash = hash & hash;
|
|
14
|
-
}
|
|
15
|
-
return hash;
|
|
11
|
+
return hash(str);
|
|
16
12
|
};
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
15
|
*/
|
|
20
|
-
const createHashFromHref = (href: Href): number => {
|
|
16
|
+
const createHashFromHref = (href: Href, fragment?: SectionFragment): number => {
|
|
21
17
|
const hrefString = href.hash
|
|
22
18
|
? [href.toString(), href.hash].join("#")
|
|
23
19
|
: href.toString();
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
if (fragment) {
|
|
22
|
+
return hash({ hrefString, fragment });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return hash(hrefString);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export { createHash, createHashFromHref };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHash.js","names":["
|
|
1
|
+
{"version":3,"file":"createHash.js","names":["hash","createHash","str","createHashFromHref","href","fragment","hrefString","toString","join"],"sources":["../../../src/utils/helpers/createHash.js"],"sourcesContent":["// @flow\nimport hash from \"hash-it\";\n\nimport type Href from \"../../models/href/Href\";\nimport type { SectionFragment } from \"../../models\";\n\n/**\n * https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/\n */\nconst createHash = (str: string): number => {\n return hash(str);\n};\n\n/**\n */\nconst createHashFromHref = (href: Href, fragment?: SectionFragment): number => {\n const hrefString = href.hash\n ? [href.toString(), href.hash].join(\"#\")\n : href.toString();\n\n if (fragment) {\n return hash({ hrefString, fragment });\n }\n\n return hash(hrefString);\n};\n\nexport { createHash, createHashFromHref };\n"],"mappings":"AACA,OAAOA,IAAI,MAAM,SAAS;AAK1B;AACA;AACA;AACA,MAAMC,UAAU,GAAIC,GAAW,IAAa;EAC1C,OAAOF,IAAI,CAACE,GAAG,CAAC;AAClB,CAAC;;AAED;AACA;AACA,MAAMC,kBAAkB,GAAGA,CAACC,IAAU,EAAEC,QAA0B,KAAa;EAC7E,MAAMC,UAAU,GAAGF,IAAI,CAACJ,IAAI,GACxB,CAACI,IAAI,CAACG,QAAQ,CAAC,CAAC,EAAEH,IAAI,CAACJ,IAAI,CAAC,CAACQ,IAAI,CAAC,GAAG,CAAC,GACtCJ,IAAI,CAACG,QAAQ,CAAC,CAAC;EAEnB,IAAIF,QAAQ,EAAE;IACZ,OAAOL,IAAI,CAAC;MAAEM,UAAU;MAAED;IAAS,CAAC,CAAC;EACvC;EAEA,OAAOL,IAAI,CAACM,UAAU,CAAC;AACzB,CAAC;AAED,SAASL,UAAU,EAAEE,kBAAkB","ignoreList":[]}
|
|
@@ -51,7 +51,7 @@ class ConceptIndexModel extends _ResourceModel.default {
|
|
|
51
51
|
*/
|
|
52
52
|
static isApplicableModel(data) {
|
|
53
53
|
const resourceType = data.contributions?.resourcetype;
|
|
54
|
-
return resourceType === "ConceptSearch" || resourceType === "relatedConcepts";
|
|
54
|
+
return resourceType === "ConceptSearch" || resourceType === "relatedConcepts" || resourceType === "RelatedConcepts";
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptIndexModel.js","names":["_ResourceModel","_interopRequireDefault","require","_ResourceCollection","_FilterCollection","_ConceptLinkModel","_Constants","ConceptIndexModel","ResourceModel","constructor","modularuiResponse","_context","_defineProperty2","default","_filterCollection","FilterCollection","_filter","data","filter","contributions","dynamicschema","modelOptions","_concepts","ResourceCollection","collection","_embedded","_map","results","call","concept","ConceptLinkModel","entryDate","type","resourcetype","modelName","isApplicableModel","resourceType","getInitialChildModelLinks","items","setChildModels","models","errors","selfhref","href","selflink","filterCollection","hasItems","forEach","params","param","value","setParameter","name","removeParameter","label","getContribution","indexfilter","getFilterByAttributeKey","timeversionFilter","TIMEVERSION_FILTER_NAME","attribute","searchtermfilter","modelCategoryFilter","itemCollection","exports"],"sources":["../../../src/models/concepts/ConceptIndexModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ConceptLinkModel from \"./ConceptLinkModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type { FilterType, ModularUIModel } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type Href from \"../href/Href\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Get Index of concepts, to filter model catalog\n */\nexport default class ConceptIndexModel extends ResourceModel {\n _filterCollection: FilterCollection;\n _concepts: ResourceCollection<ConceptLinkModel>;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter,\n dynamicschema: this.data.dynamicschema,\n },\n this.modelOptions,\n );\n\n this._concepts = new ResourceCollection();\n this._concepts.collection = this.data._embedded\n ? this.data._embedded.results.map(\n (concept) =>\n new ConceptLinkModel(\n concept.concept,\n this.entryDate,\n this.modelOptions,\n ),\n )\n : [];\n }\n\n /**\n */\n get type(): string {\n if (this.resourcetype === \"RelatedConcepts\") {\n return \"RelatedConcepts\";\n }\n\n return \"ConceptIndex\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ConceptIndexModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourceType = data.contributions?.resourcetype;\n return (\n resourceType === \"ConceptSearch\"
|
|
1
|
+
{"version":3,"file":"ConceptIndexModel.js","names":["_ResourceModel","_interopRequireDefault","require","_ResourceCollection","_FilterCollection","_ConceptLinkModel","_Constants","ConceptIndexModel","ResourceModel","constructor","modularuiResponse","_context","_defineProperty2","default","_filterCollection","FilterCollection","_filter","data","filter","contributions","dynamicschema","modelOptions","_concepts","ResourceCollection","collection","_embedded","_map","results","call","concept","ConceptLinkModel","entryDate","type","resourcetype","modelName","isApplicableModel","resourceType","getInitialChildModelLinks","items","setChildModels","models","errors","selfhref","href","selflink","filterCollection","hasItems","forEach","params","param","value","setParameter","name","removeParameter","label","getContribution","indexfilter","getFilterByAttributeKey","timeversionFilter","TIMEVERSION_FILTER_NAME","attribute","searchtermfilter","modelCategoryFilter","itemCollection","exports"],"sources":["../../../src/models/concepts/ConceptIndexModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport ConceptLinkModel from \"./ConceptLinkModel\";\n\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type { FilterType, ModularUIModel } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type Href from \"../href/Href\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Get Index of concepts, to filter model catalog\n */\nexport default class ConceptIndexModel extends ResourceModel {\n _filterCollection: FilterCollection;\n _concepts: ResourceCollection<ConceptLinkModel>;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this._filterCollection = new FilterCollection(\n this.data.filter,\n {\n filter: this.contributions.filter,\n dynamicschema: this.data.dynamicschema,\n },\n this.modelOptions,\n );\n\n this._concepts = new ResourceCollection();\n this._concepts.collection = this.data._embedded\n ? this.data._embedded.results.map(\n (concept) =>\n new ConceptLinkModel(\n concept.concept,\n this.entryDate,\n this.modelOptions,\n ),\n )\n : [];\n }\n\n /**\n */\n get type(): string {\n if (this.resourcetype === \"RelatedConcepts\") {\n return \"RelatedConcepts\";\n }\n\n return \"ConceptIndex\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ConceptIndexModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourceType = data.contributions?.resourcetype;\n return (\n resourceType === \"ConceptSearch\" ||\n resourceType === \"relatedConcepts\" ||\n resourceType === \"RelatedConcepts\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this.items.getInitialChildModelLinks();\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this.items.setChildModels(models, errors);\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): Href {\n const { href } = this.selflink;\n\n if (this.filterCollection.hasItems) {\n this.filterCollection.forEach((filter) => {\n filter.params.forEach((param) => {\n if (param.value) {\n href.setParameter(param.name, param.value);\n } else {\n href.removeParameter(param.name);\n }\n });\n });\n }\n\n return href;\n }\n\n /**\n */\n get label(): string {\n return this.getContribution(\"label\");\n }\n\n /**\n * Retrieve filters of conceptindex model\n */\n get filterCollection(): FilterCollection {\n return this._filterCollection;\n }\n\n /**\n * Get index filter\n */\n get indexfilter(): FilterType | null {\n return this.filterCollection.getFilterByAttributeKey(\"index\");\n }\n\n /**\n * Retrieve modelcatalog.js of content toc\n */\n get entryDate(): string | null {\n const timeversionFilter = this.filterCollection.getFilterByAttributeKey(\n TIMEVERSION_FILTER_NAME,\n );\n if (timeversionFilter && timeversionFilter.attribute) {\n return timeversionFilter.attribute.value;\n }\n\n return null;\n }\n\n /**\n * get searchterm filter\n */\n get searchtermfilter(): FilterType | null {\n return this.filterCollection.getFilterByAttributeKey(\"label\");\n }\n\n /**\n * Get model category filter\n */\n get modelCategoryFilter(): FilterType | null {\n return this.filterCollection.getFilterByAttributeKey(\"modelCategory\");\n }\n\n /**\n * Get concept links found by index filter\n */\n get items(): ResourceCollection<ConceptLinkModel> {\n return this._concepts;\n }\n\n /**\n * Replace the items collection\n */\n set items(itemCollection: ResourceCollection<ConceptLinkModel>) {\n this._concepts = itemCollection;\n }\n}\n"],"mappings":";;;;;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,iBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,iBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AAQA;AACA;AACA;AACe,MAAMK,iBAAiB,SAASC,sBAAa,CAAC;EAI3D;AACF;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IAAIA,iBAAiB,CAACE,SAAS,EAAE;MACpD,OAAOF,iBAAiB,CAACE,SAAS,CAACV,KAAK;IAC1C;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACE,IAAIW,gBAAgBA,CAAA,EAAsB;IACxC,OAAO,IAAI,CAAChB,gBAAgB,CAACY,uBAAuB,CAAC,OAAO,CAAC;EAC/D;;EAEA;AACF;AACA;EACE,IAAIK,mBAAmBA,CAAA,EAAsB;IAC3C,OAAO,IAAI,CAACjB,gBAAgB,CAACY,uBAAuB,CAAC,eAAe,CAAC;EACvE;;EAEA;AACF;AACA;EACE,IAAInB,KAAKA,CAAA,EAAyC;IAChD,OAAO,IAAI,CAAChB,SAAS;EACvB;;EAEA;AACF;AACA;EACE,IAAIgB,KAAKA,CAACyB,cAAoD,EAAE;IAC9D,IAAI,CAACzC,SAAS,GAAGyC,cAAc;EACjC;AACF;AAACC,OAAA,CAAAnD,OAAA,GAAAN,iBAAA","ignoreList":[]}
|
|
@@ -60,6 +60,14 @@ export default class ConceptLinkModel extends BaseModel {
|
|
|
60
60
|
* Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept
|
|
61
61
|
*/
|
|
62
62
|
isOfConceptType(conceptTypeId: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
get modelCategory(): string;
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
get fragment(): SectionFragment;
|
|
63
71
|
}
|
|
64
72
|
import BaseModel from "../base/BaseModel";
|
|
65
73
|
import LinkCollection from "../links/LinkCollection";
|
|
@@ -67,4 +75,11 @@ import ConceptTypeDetailModel from "./ConceptTypeDetailModel";
|
|
|
67
75
|
import LinkModel from "../links/LinkModel";
|
|
68
76
|
import { ModularUIModel } from "../types";
|
|
69
77
|
import Href from "../href/Href";
|
|
78
|
+
type SectionFragment = {
|
|
79
|
+
sectionId: string;
|
|
80
|
+
text: string;
|
|
81
|
+
startOffset: number;
|
|
82
|
+
endOffset: number;
|
|
83
|
+
};
|
|
70
84
|
import { ModelOptions } from "../types";
|
|
85
|
+
export {};
|