@beinformed/ui 1.9.0-beta.4 → 1.9.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/esm/constants/Settings.js +10 -8
  3. package/esm/constants/Settings.js.map +1 -1
  4. package/esm/models/attributes/AttributeContent.js +99 -60
  5. package/esm/models/attributes/AttributeContent.js.map +1 -1
  6. package/esm/models/attributes/AttributeDataHelper.js +41 -14
  7. package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
  8. package/esm/models/attributes/AttributeModel.js +3 -3
  9. package/esm/models/attributes/AttributeModel.js.map +1 -1
  10. package/esm/models/attributes/ChoiceAttributeOptionModel.js +4 -4
  11. package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  12. package/esm/models/attributes/HelptextAttributeModel.js +15 -1
  13. package/esm/models/attributes/HelptextAttributeModel.js.map +1 -1
  14. package/esm/models/content/SectionModel.js +2 -1
  15. package/esm/models/content/SectionModel.js.map +1 -1
  16. package/esm/models/content/SubSectionModel.js +3 -1
  17. package/esm/models/content/SubSectionModel.js.map +1 -1
  18. package/esm/models/list/ListDetailModel.js +7 -3
  19. package/esm/models/list/ListDetailModel.js.map +1 -1
  20. package/esm/utils/helpers/text.js +19 -0
  21. package/esm/utils/helpers/text.js.map +1 -0
  22. package/esm/utils/index.js +2 -1
  23. package/esm/utils/index.js.map +1 -1
  24. package/lib/constants/Settings.js +12 -1
  25. package/lib/constants/Settings.js.flow +9 -5
  26. package/lib/constants/Settings.js.map +1 -1
  27. package/lib/models/attributes/AttributeContent.js +107 -61
  28. package/lib/models/attributes/AttributeContent.js.flow +67 -42
  29. package/lib/models/attributes/AttributeContent.js.map +1 -1
  30. package/lib/models/attributes/AttributeDataHelper.js +43 -13
  31. package/lib/models/attributes/AttributeDataHelper.js.flow +30 -5
  32. package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
  33. package/lib/models/attributes/AttributeModel.js +1 -1
  34. package/lib/models/attributes/AttributeModel.js.flow +2 -3
  35. package/lib/models/attributes/AttributeModel.js.map +1 -1
  36. package/lib/models/attributes/ChoiceAttributeOptionModel.js +3 -3
  37. package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +4 -7
  38. package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  39. package/lib/models/attributes/HelptextAttributeModel.js +15 -1
  40. package/lib/models/attributes/HelptextAttributeModel.js.flow +11 -1
  41. package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
  42. package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +11 -5
  43. package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +156 -0
  44. package/lib/models/attributes/__tests__/HelptextAttributeModel.spec.js.flow +39 -1
  45. package/lib/models/content/SectionModel.js +3 -1
  46. package/lib/models/content/SectionModel.js.flow +2 -1
  47. package/lib/models/content/SectionModel.js.map +1 -1
  48. package/lib/models/content/SubSectionModel.js +4 -1
  49. package/lib/models/content/SubSectionModel.js.flow +3 -1
  50. package/lib/models/content/SubSectionModel.js.map +1 -1
  51. package/lib/models/list/ListDetailModel.js +7 -3
  52. package/lib/models/list/ListDetailModel.js.flow +2 -0
  53. package/lib/models/list/ListDetailModel.js.map +1 -1
  54. package/lib/models/types.js.flow +15 -6
  55. package/lib/utils/helpers/text.js +28 -0
  56. package/lib/utils/helpers/text.js.flow +23 -0
  57. package/lib/utils/helpers/text.js.map +1 -0
  58. package/lib/utils/index.js +14 -0
  59. package/lib/utils/index.js.flow +1 -0
  60. package/lib/utils/index.js.map +1 -1
  61. package/package.json +11 -11
  62. package/src/constants/Settings.js +9 -5
  63. package/src/models/attributes/AttributeContent.js +67 -42
  64. package/src/models/attributes/AttributeDataHelper.js +30 -5
  65. package/src/models/attributes/AttributeModel.js +2 -3
  66. package/src/models/attributes/ChoiceAttributeOptionModel.js +4 -7
  67. package/src/models/attributes/HelptextAttributeModel.js +11 -1
  68. package/src/models/attributes/__tests__/AttributeContent.spec.js +11 -5
  69. package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +156 -0
  70. package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +39 -1
  71. package/src/models/content/SectionModel.js +2 -1
  72. package/src/models/content/SubSectionModel.js +3 -1
  73. package/src/models/form/__tests__/FormWithContentData.json +6 -6
  74. package/src/models/list/ListDetailModel.js +2 -0
  75. package/src/models/types.js +15 -6
  76. package/src/utils/helpers/text.js +23 -0
  77. package/src/utils/index.js +1 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/attributes/ChoiceAttributeOptionModel.js"],"names":["ChoiceAttributeOptionModel","selectedValues","option","referenceDate","DateUtil","now","code","contributions","key","_isSelected","_referenceDate","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","LinkCollection","_content","AttributeContent","content","initialLinks","hasContentFromData","conceptLink","push","children","getInitialChildModelLinks","models","conceptHref","href","concept","model","selfhref","equalsWithParameters","setChildModels","_code","toString","attributeCollection","getContribution","data","AttributeCollection","label","hasItems","title","getAttributeByLayoutHint","TITLE","readonlyvalue","first","contentConfiguration","configuredLabelProperties","labelConfig","types","length","configuredLabels","getLabelElementByIds","configuredLabel","value","configuredLabelProperty","some","_id","selected","ChoiceAttributeOptionCollection","create","options","links","date","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","_concept","ConceptDetailModel","level","withOption","mergeOptions","ALL_CONTENT_IN_DATA_SETTING","listitem","id","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAIA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;;;;;AAEA;AACA;IACMA,0B;;;;;AAWJ;AACF;AACE,wCAIE;AAAA;;AAAA;;AAAA,QAHAC,cAGA,uEAHgC,EAGhC;AAAA,QAFAC,MAEA,uEAFiB,EAEjB;AAAA,QADAC,aACA,uEAD0BC,uBAASC,GAAT,EAC1B;A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CAAYzC,QAAZ,EAAd;AACAlC,MAAAA,MAAM,CAACmC,mBAAP,GAA6BuC,QAAQ,CAACvC,mBAAtC;AACAnC,MAAAA,MAAM,CAAC8D,KAAP,GAAeY,QAAQ,CAACZ,KAAxB;AAEA,aAAO9D,MAAP;AACD;;;EAhDsC4E,mB;;eA0V1B9E,0B","sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\nimport { has } from \"../../utils/helpers/objects\";\nimport {\n ALL_CONTENT_IN_DATA_SETTING,\n TIMEVERSION_FILTER_NAME,\n} from \"../../constants/Constants\";\nimport { TITLE } from \"../../constants/LayoutHints\";\n\nimport LinkCollection from \"../links/LinkCollection\";\nimport AttributeCollection from \"./AttributeCollection\";\nimport ConceptDetailModel from \"../concepts/ConceptDetailModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\nimport { getSetting } from \"../../constants\";\nimport AttributeContent from \"./AttributeContent\";\n\n/**\n */\nclass ChoiceAttributeOptionModel extends BaseModel {\n _code: string;\n _isSelected: boolean;\n _referenceDate: ISO_DATE;\n _level: number;\n _children: ChoiceAttributeOptionCollection;\n _concept: ?ConceptDetailModel;\n _links: LinkCollection;\n _attributeCollection: AttributeCollection;\n _content: AttributeContent;\n\n /**\n */\n constructor(\n selectedValues: Array<string> = [],\n option: Object = {},\n referenceDate: ISO_DATE = DateUtil.now()\n ) {\n super({}, option);\n\n this.code = this.contributions.code ?? this.contributions.key ?? \"\";\n\n this._isSelected = selectedValues.includes(this.code);\n\n this._referenceDate = referenceDate;\n\n this._level = 0;\n\n this._attributeCollection = this.createAttributeCollection();\n this._children = this.addChildren(selectedValues, option, referenceDate);\n\n this._links = new LinkCollection(this.contributions._links);\n\n this._content = new AttributeContent(option.content);\n }\n\n /**\n */\n static createFromListItemModel(\n listitem: ListItemModel\n ): ChoiceAttributeOptionModel {\n const option = new ChoiceAttributeOptionModel();\n\n option.code = listitem.id.toString();\n option.attributeCollection = listitem.attributeCollection;\n option.links = listitem.links;\n\n return option;\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const initialLinks = [];\n\n if (!this.hasContentFromData && this.conceptLink !== null) {\n initialLinks.push(this.conceptLink);\n }\n\n if (this.children) {\n initialLinks.push(...this.children.getInitialChildModelLinks());\n }\n\n return initialLinks;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n if (this.conceptLink !== null) {\n const conceptHref = this.conceptLink.href;\n\n this.concept = models.find((model) =>\n model.selfhref.equalsWithParameters(conceptHref)\n );\n }\n\n if (this.children) {\n this.children.setChildModels(models);\n }\n }\n\n /**\n * Get code of option\n */\n get code(): string {\n return this._code;\n }\n\n /**\n */\n set code(code: string) {\n this._code = code;\n }\n\n /**\n */\n equals(model: ChoiceAttributeOptionModel): boolean {\n return this.code.toString() === model.code.toString();\n }\n\n /**\n * Retrieve attributes for Composite codemaps (e.g. table and case list codemaps)\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 createAttributeCollection(): AttributeCollection {\n const contributions = this.getContribution(\"elementsContributions\", []);\n\n if (has(this.contributions, \"elements\")) {\n const data = this.getContribution(\"elements\", {});\n return new AttributeCollection(data, contributions, true);\n }\n\n return new AttributeCollection();\n }\n\n /**\n * Get label of option for simple codemaps (e.g. static codemap)\n */\n get label(): string {\n if (this.contributions.label) {\n return this.contributions.label;\n }\n\n if (this.attributeCollection.hasItems) {\n const title = this.attributeCollection.getAttributeByLayoutHint(TITLE);\n\n if (title) {\n return title.readonlyvalue;\n }\n\n if (this.attributeCollection.first) {\n return this.attributeCollection.first.readonlyvalue;\n }\n }\n\n return \"\";\n }\n\n /**\n * Retrieve the first permitted label to render when a concept and contentConfiguration is available\n * Be aware that permission could be in place for labels from a concept.\n */\n getContentConfiguredLabel(contentConfiguration: Object): string {\n const configuredLabelProperties =\n contentConfiguration?.labelConfig?.[0]?.types ?? [];\n\n if (\n !this.hasContentFromData &&\n this.concept &&\n configuredLabelProperties.length > 0\n ) {\n const configuredLabels = this.concept\n .getLabelElementByIds(configuredLabelProperties)\n .filter(\n (configuredLabel) =>\n configuredLabel.value && configuredLabel.value !== \"\"\n );\n\n if (configuredLabels.length > 0) {\n return configuredLabelProperties\n .filter((configuredLabelProperty) =>\n configuredLabels.some(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty\n )\n )\n .map((configuredLabelProperty) =>\n configuredLabels.find(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty\n )\n )[0].value;\n }\n }\n\n return this.label;\n }\n\n /**\n * Indicates if option is selected\n */\n get selected(): boolean {\n return this._isSelected;\n }\n\n /**\n * Set selected property of option\n */\n set selected(selected: boolean) {\n this._isSelected = selected;\n }\n\n /**\n * Retrieve count of filter for option\n */\n get count(): number | null {\n return this.getContribution(\"count\");\n }\n\n /**\n */\n addChildren(\n selectedValues: Array<string> = [],\n option: Object = {},\n referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n // When contributions contain elements this is a list not nested options\n if (has(option, \"elements\")) {\n return new ChoiceAttributeOptionCollection();\n }\n\n return ChoiceAttributeOptionCollection.create(\n {\n value: selectedValues,\n },\n { options: option?.children ?? [] },\n referenceDate\n );\n }\n\n /**\n * get children of option\n */\n get children(): ChoiceAttributeOptionCollection {\n return this._children;\n }\n\n /**\n * Retrieve links of attribute\n */\n get links(): LinkCollection {\n return this._links;\n }\n\n /**\n */\n set links(links: LinkCollection) {\n this._links = links;\n }\n\n /**\n * referenceDate received from attribute\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this._referenceDate = date;\n }\n\n /**\n * Retrieve concept link of attribute when available\n */\n get conceptLink(): LinkModel | null {\n const conceptLink = this.links.getLinkByKey(\"concept\");\n if (conceptLink !== null) {\n conceptLink.href = conceptLink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this.referenceDate\n );\n\n conceptLink.isCacheable = true;\n }\n\n return conceptLink;\n }\n\n /**\n * Get concept information\n */\n get concept(): ConceptDetailModel | null {\n return this._concept || null;\n }\n\n /**\n * Set the concept\n */\n set concept(concept: ?ModularUIModel) {\n this._concept = concept instanceof ConceptDetailModel ? concept : null;\n }\n\n /**\n * Get level of option, used in tree view choice attributes (taxonomy)\n */\n get level(): number {\n return this._level;\n }\n\n /**\n * Set level of option\n */\n set level(level: number) {\n this._level = level;\n }\n\n /**\n */\n get isBooleanType(): boolean {\n return this.getContribution(\"isBooleanType\", false);\n }\n\n /**\n */\n get hasAlternativeLabel(): boolean {\n return this.getContribution(\"hasAlternativeLabel\", false);\n }\n\n /**\n */\n mergeOption(withOption: ChoiceAttributeOptionModel) {\n this.concept = withOption.concept;\n\n if (this.children != null && withOption.children != null) {\n this.children.mergeOptions(withOption.children);\n }\n }\n\n /**\n * Indicates if content comes from the data service\n */\n get hasContentFromData(): boolean {\n return getSetting(ALL_CONTENT_IN_DATA_SETTING, true);\n }\n\n /**\n */\n get content(): AttributeContent {\n return this._content;\n }\n}\n\nexport default ChoiceAttributeOptionModel;\n"],"file":"ChoiceAttributeOptionModel.js"}
1
+ {"version":3,"sources":["../../../src/models/attributes/ChoiceAttributeOptionModel.js"],"names":["ChoiceAttributeOptionModel","selectedValues","option","referenceDate","DateUtil","now","code","contributions","key","_isSelected","_referenceDate","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","LinkCollection","_content","AttributeContent","content","initialLinks","hasContentFromData","conceptLink","push","children","getInitialChildModelLinks","models","conceptHref","href","concept","model","selfhref","equalsWithParameters","setChildModels","_code","toString","attributeCollection","getContribution","data","AttributeCollection","label","hasItems","title","getAttributeByLayoutHint","TITLE","readonlyvalue","first","contentConfiguration","configuredLabelProperties","labelConfig","types","length","configuredLabels","getLabelElementByIds","configuredLabel","value","configuredLabelProperty","some","_id","selected","ChoiceAttributeOptionCollection","create","options","links","date","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","_concept","ConceptDetailModel","level","withOption","mergeOptions","listitem","id","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAMA;AACA;IACMA,0B;;;;;AAWJ;AACF;AACE,wCAIE;AAAA;;AAAA;;AAAA,QAHAC,cAGA,uEAHgC,EAGhC;AAAA,QAFAC,MAEA,uEAFiB,EAEjB;AAAA,QADAC,aACA,uEAD0BC,uBAASC,GAAT,EAC1B;AAAA;AACA,8BAAM,EAAN,EAAUH,MAAV;AADA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,UAAKI,IAAL,oCAAY,MAAKC,aAAL,CAAmBD,IAA/B,yEAAuC,MAAKC,aAAL,CAAmBC,GAA1D,uCAAiE,EAAjE;AAEA,UAAKC,WAAL,GAAmB,uBAAAR,cAAc,MAAd,CAAAA,cAAc,EAAU,MAAKK,IAAf,CAAjC;AAEA,UAAKI,cAAL,GAAsBP,aAAtB;AAEA,UAAKQ,MAAL,GAAc,CAAd;AAEA,UAAKC,oBAAL,GAA4B,MAAKC,yBAAL,EAA5B;AACA,UAAKC,SAAL,GAAiB,MAAKC,WAAL,CAAiBd,cAAjB,EAAiCC,MAAjC,EAAyCC,aAAzC,CAAjB;AAEA,UAAKa,MAAL,GAAc,IAAIC,uBAAJ,CAAmB,MAAKV,aAAL,CAAmBS,MAAtC,CAAd;AAEA,UAAKE,QAAL,GAAgB,IAAIC,yBAAJ,CAAqBjB,MAAM,CAACkB,OAA5B,CAAhB;AAhBA;AAiBD;AAED;AACF;;;;;;AAaE;AACF;AACE,yCAA8C;AAC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qBAAYmC,UAAZ,EAAoD;AAClD,WAAK3C,OAAL,GAAe2C,UAAU,CAAC3C,OAA1B;;AAEA,UAAI,KAAKL,QAAL,IAAiB,IAAjB,IAAyBgD,UAAU,CAAChD,QAAX,IAAuB,IAApD,EAA0D;AACxD,aAAKA,QAAL,CAAciD,YAAd,CAA2BD,UAAU,CAAChD,QAAtC;AACD;AACF;AAED;AACF;AACA;;;;SACE,eAAkC;AAChC,aAAO,oCAAP;AACD;AAED;AACF;;;;SACE,eAAgC;AAC9B,aAAO,KAAKP,QAAZ;AACD;;;WAjTD,iCACEyD,QADF,EAE8B;AAC5B,UAAMzE,MAAM,GAAG,IAAIF,0BAAJ,EAAf;AAEAE,MAAAA,MAAM,CAACI,IAAP,GAAcqE,QAAQ,CAACC,EAAT,CAAYxC,QAAZ,EAAd;AACAlC,MAAAA,MAAM,CAACmC,mBAAP,GAA6BsC,QAAQ,CAACtC,mBAAtC;AACAnC,MAAAA,MAAM,CAAC8D,KAAP,GAAeW,QAAQ,CAACX,KAAxB;AAEA,aAAO9D,MAAP;AACD;;;EAhDsC2E,mB;;eA0V1B7E,0B","sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\nimport { has } from \"../../utils/helpers/objects\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport { TITLE } from \"../../constants/LayoutHints\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\n\nimport LinkCollection from \"../links/LinkCollection\";\nimport AttributeCollection from \"./AttributeCollection\";\nimport ConceptDetailModel from \"../concepts/ConceptDetailModel\";\nimport AttributeContent from \"./AttributeContent\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n */\nclass ChoiceAttributeOptionModel extends BaseModel {\n _code: string;\n _isSelected: boolean;\n _referenceDate: ISO_DATE;\n _level: number;\n _children: ChoiceAttributeOptionCollection;\n _concept: ?ConceptDetailModel;\n _links: LinkCollection;\n _attributeCollection: AttributeCollection;\n _content: AttributeContent;\n\n /**\n */\n constructor(\n selectedValues: Array<string> = [],\n option: Object = {},\n referenceDate: ISO_DATE = DateUtil.now()\n ) {\n super({}, option);\n\n this.code = this.contributions.code ?? this.contributions.key ?? \"\";\n\n this._isSelected = selectedValues.includes(this.code);\n\n this._referenceDate = referenceDate;\n\n this._level = 0;\n\n this._attributeCollection = this.createAttributeCollection();\n this._children = this.addChildren(selectedValues, option, referenceDate);\n\n this._links = new LinkCollection(this.contributions._links);\n\n this._content = new AttributeContent(option.content);\n }\n\n /**\n */\n static createFromListItemModel(\n listitem: ListItemModel\n ): ChoiceAttributeOptionModel {\n const option = new ChoiceAttributeOptionModel();\n\n option.code = listitem.id.toString();\n option.attributeCollection = listitem.attributeCollection;\n option.links = listitem.links;\n\n return option;\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const initialLinks = [];\n\n if (!this.hasContentFromData && this.conceptLink !== null) {\n initialLinks.push(this.conceptLink);\n }\n\n if (this.children) {\n initialLinks.push(...this.children.getInitialChildModelLinks());\n }\n\n return initialLinks;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n if (this.conceptLink !== null) {\n const conceptHref = this.conceptLink.href;\n\n this.concept = models.find((model) =>\n model.selfhref.equalsWithParameters(conceptHref)\n );\n }\n\n if (this.children) {\n this.children.setChildModels(models);\n }\n }\n\n /**\n * Get code of option\n */\n get code(): string {\n return this._code;\n }\n\n /**\n */\n set code(code: string) {\n this._code = code;\n }\n\n /**\n */\n equals(model: ChoiceAttributeOptionModel): boolean {\n return this.code.toString() === model.code.toString();\n }\n\n /**\n * Retrieve attributes for Composite codemaps (e.g. table and case list codemaps)\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 createAttributeCollection(): AttributeCollection {\n const contributions = this.getContribution(\"elementsContributions\", []);\n\n if (has(this.contributions, \"elements\")) {\n const data = this.getContribution(\"elements\", {});\n return new AttributeCollection(data, contributions, true);\n }\n\n return new AttributeCollection();\n }\n\n /**\n * Get label of option for simple codemaps (e.g. static codemap)\n */\n get label(): string {\n if (this.contributions.label) {\n return this.contributions.label;\n }\n\n if (this.attributeCollection.hasItems) {\n const title = this.attributeCollection.getAttributeByLayoutHint(TITLE);\n\n if (title) {\n return title.readonlyvalue;\n }\n\n if (this.attributeCollection.first) {\n return this.attributeCollection.first.readonlyvalue;\n }\n }\n\n return \"\";\n }\n\n /**\n * Retrieve the first permitted label to render when a concept and contentConfiguration is available\n * Be aware that permission could be in place for labels from a concept.\n */\n getContentConfiguredLabel(contentConfiguration: Object): string {\n const configuredLabelProperties =\n contentConfiguration?.labelConfig?.[0]?.types ?? [];\n\n if (\n !this.hasContentFromData &&\n this.concept &&\n configuredLabelProperties.length > 0\n ) {\n const configuredLabels = this.concept\n .getLabelElementByIds(configuredLabelProperties)\n .filter(\n (configuredLabel) =>\n configuredLabel.value && configuredLabel.value !== \"\"\n );\n\n if (configuredLabels.length > 0) {\n return configuredLabelProperties\n .filter((configuredLabelProperty) =>\n configuredLabels.some(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty\n )\n )\n .map((configuredLabelProperty) =>\n configuredLabels.find(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty\n )\n )[0].value;\n }\n }\n\n return this.label;\n }\n\n /**\n * Indicates if option is selected\n */\n get selected(): boolean {\n return this._isSelected;\n }\n\n /**\n * Set selected property of option\n */\n set selected(selected: boolean) {\n this._isSelected = selected;\n }\n\n /**\n * Retrieve count of filter for option\n */\n get count(): number | null {\n return this.getContribution(\"count\");\n }\n\n /**\n */\n addChildren(\n selectedValues: Array<string> = [],\n option: Object = {},\n referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n // When contributions contain elements this is a list not nested options\n if (has(option, \"elements\")) {\n return new ChoiceAttributeOptionCollection();\n }\n\n return ChoiceAttributeOptionCollection.create(\n {\n value: selectedValues,\n },\n { options: option?.children ?? [] },\n referenceDate\n );\n }\n\n /**\n * get children of option\n */\n get children(): ChoiceAttributeOptionCollection {\n return this._children;\n }\n\n /**\n * Retrieve links of attribute\n */\n get links(): LinkCollection {\n return this._links;\n }\n\n /**\n */\n set links(links: LinkCollection) {\n this._links = links;\n }\n\n /**\n * referenceDate received from attribute\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this._referenceDate = date;\n }\n\n /**\n * Retrieve concept link of attribute when available\n */\n get conceptLink(): LinkModel | null {\n const conceptLink = this.links.getLinkByKey(\"concept\");\n if (conceptLink !== null) {\n conceptLink.href = conceptLink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this.referenceDate\n );\n\n conceptLink.isCacheable = true;\n }\n\n return conceptLink;\n }\n\n /**\n * Get concept information\n */\n get concept(): ConceptDetailModel | null {\n return this._concept || null;\n }\n\n /**\n * Set the concept\n */\n set concept(concept: ?ModularUIModel) {\n this._concept = concept instanceof ConceptDetailModel ? concept : null;\n }\n\n /**\n * Get level of option, used in tree view choice attributes (taxonomy)\n */\n get level(): number {\n return this._level;\n }\n\n /**\n * Set level of option\n */\n set level(level: number) {\n this._level = level;\n }\n\n /**\n */\n get isBooleanType(): boolean {\n return this.getContribution(\"isBooleanType\", false);\n }\n\n /**\n */\n get hasAlternativeLabel(): boolean {\n return this.getContribution(\"hasAlternativeLabel\", false);\n }\n\n /**\n */\n mergeOption(withOption: ChoiceAttributeOptionModel) {\n this.concept = withOption.concept;\n\n if (this.children != null && withOption.children != null) {\n this.children.mergeOptions(withOption.children);\n }\n }\n\n /**\n * Indicates if content comes from the data service\n */\n get hasContentFromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get content(): AttributeContent {\n return this._content;\n }\n}\n\nexport default ChoiceAttributeOptionModel;\n"],"file":"ChoiceAttributeOptionModel.js"}
@@ -55,7 +55,21 @@ var HelptextAttributeModel = /*#__PURE__*/function (_LabelAttributeModel) {
55
55
  }, {
56
56
  key: "text",
57
57
  get: function get() {
58
- return this.getContribution("text");
58
+ var dataText = this.getData("value");
59
+
60
+ if (dataText) {
61
+ return dataText.message;
62
+ }
63
+
64
+ var contributionText = this.getContribution("text");
65
+
66
+ if (contributionText) {
67
+ var _contributionText$mes;
68
+
69
+ return (_contributionText$mes = contributionText.message) !== null && _contributionText$mes !== void 0 ? _contributionText$mes : contributionText;
70
+ }
71
+
72
+ return null;
59
73
  }
60
74
  }], [{
61
75
  key: "isApplicableModel",
@@ -26,6 +26,16 @@ export default class HelptextAttributeModel extends LabelAttributeModel {
26
26
  * Get helptext text
27
27
  */
28
28
  get text(): string | null {
29
- return this.getContribution("text");
29
+ const dataText = this.getData("value");
30
+ if (dataText) {
31
+ return dataText.message;
32
+ }
33
+
34
+ const contributionText = this.getContribution("text");
35
+ if (contributionText) {
36
+ return contributionText.message ?? contributionText;
37
+ }
38
+
39
+ return null;
30
40
  }
31
41
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/attributes/HelptextAttributeModel.js"],"names":["HelptextAttributeModel","getContribution","contributions","type","readonly","LabelAttributeModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;;;;;AAEA;AACA;AACA;IACqBA,sB;;;;;;;;;;;;;AAUnB;AACF;AACE,mBAAmB;AACjB,aAAO,UAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA0B;AACxB,aAAO,KAAKC,eAAL,CAAqB,MAArB,CAAP;AACD;;;;AApBD;AACF;AACE,+BAAyBC,aAAzB,EAAyD;AACvD,aACEA,aAAa,CAACC,IAAd,KAAuB,UAAvB,IACCD,aAAa,CAACE,QAAd,IAA0B,kBAAIF,aAAJ,EAAmB,MAAnB,CAF7B;AAID;;;EARiDG,6B","sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport LabelAttributeModel from \"./LabelAttributeModel\";\n\n/**\n * Helptext attribute\n */\nexport default class HelptextAttributeModel extends LabelAttributeModel {\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return (\n contributions.type === \"helptext\" ||\n (contributions.readonly && has(contributions, \"text\"))\n );\n }\n\n /**\n */\n get type(): string {\n return \"helptext\";\n }\n\n /**\n * Get helptext text\n */\n get text(): string | null {\n return this.getContribution(\"text\");\n }\n}\n"],"file":"HelptextAttributeModel.js"}
1
+ {"version":3,"sources":["../../../src/models/attributes/HelptextAttributeModel.js"],"names":["HelptextAttributeModel","dataText","getData","message","contributionText","getContribution","contributions","type","readonly","LabelAttributeModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;;;;;AAEA;AACA;AACA;IACqBA,sB;;;;;;;;;;;;;AAUnB;AACF;AACE,mBAAmB;AACjB,aAAO,UAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA0B;AACxB,UAAMC,QAAQ,GAAG,KAAKC,OAAL,CAAa,OAAb,CAAjB;;AACA,UAAID,QAAJ,EAAc;AACZ,eAAOA,QAAQ,CAACE,OAAhB;AACD;;AAED,UAAMC,gBAAgB,GAAG,KAAKC,eAAL,CAAqB,MAArB,CAAzB;;AACA,UAAID,gBAAJ,EAAsB;AAAA;;AACpB,wCAAOA,gBAAgB,CAACD,OAAxB,yEAAmCC,gBAAnC;AACD;;AAED,aAAO,IAAP;AACD;;;;AA9BD;AACF;AACE,+BAAyBE,aAAzB,EAAyD;AACvD,aACEA,aAAa,CAACC,IAAd,KAAuB,UAAvB,IACCD,aAAa,CAACE,QAAd,IAA0B,kBAAIF,aAAJ,EAAmB,MAAnB,CAF7B;AAID;;;EARiDG,6B","sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport LabelAttributeModel from \"./LabelAttributeModel\";\n\n/**\n * Helptext attribute\n */\nexport default class HelptextAttributeModel extends LabelAttributeModel {\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return (\n contributions.type === \"helptext\" ||\n (contributions.readonly && has(contributions, \"text\"))\n );\n }\n\n /**\n */\n get type(): string {\n return \"helptext\";\n }\n\n /**\n * Get helptext text\n */\n get text(): string | null {\n const dataText = this.getData(\"value\");\n if (dataText) {\n return dataText.message;\n }\n\n const contributionText = this.getContribution(\"text\");\n if (contributionText) {\n return contributionText.message ?? contributionText;\n }\n\n return null;\n }\n}\n"],"file":"HelptextAttributeModel.js"}
@@ -2,10 +2,15 @@ import AttributeContent from "../AttributeContent";
2
2
  import SectionModel from "../../content/SectionModel";
3
3
 
4
4
  const json = {
5
- label: "Blaastest geslaagd",
5
+ header: {
6
+ label: "Blaastest geslaagd",
7
+ description: {
8
+ message: "Dit is de beschrijving",
9
+ },
10
+ },
6
11
  elements: [
7
12
  {
8
- propertiesElement: {
13
+ propertyElement: {
9
14
  label: "Properties",
10
15
  id: "properties",
11
16
  properties: [
@@ -18,7 +23,7 @@ const json = {
18
23
  },
19
24
  },
20
25
  {
21
- propertiesElement: {
26
+ propertyElement: {
22
27
  label: "Second Properties",
23
28
  id: "secondProperties",
24
29
  properties: [
@@ -38,7 +43,7 @@ const json = {
38
43
  {
39
44
  type: "Description",
40
45
  label: "Description",
41
- text: "Dit is een text fragment",
46
+ text: { message: "Dit is een text fragment" },
42
47
  },
43
48
  ],
44
49
  },
@@ -147,6 +152,7 @@ describe("AttributeContent", () => {
147
152
  it("Handles basic content elements", () => {
148
153
  const content = new AttributeContent(json);
149
154
  expect(content.label).toBe("Blaastest geslaagd");
155
+ expect(content.description).toBe("Dit is de beschrijving");
150
156
  expect(content.properties).toHaveLength(2);
151
157
  expect(content.textfragments).toHaveLength(1);
152
158
  expect(content.sections).toHaveLength(1);
@@ -218,6 +224,6 @@ describe("AttributeContent", () => {
218
224
  it("can retrieve all content", () => {
219
225
  const content = new AttributeContent(json);
220
226
 
221
- expect(content.all).toHaveLength(4);
227
+ expect(content.elements).toHaveLength(4);
222
228
  });
223
229
  });
@@ -384,4 +384,160 @@ describe("attributeDataHelper", () => {
384
384
  content: null,
385
385
  });
386
386
  });
387
+
388
+ it("can handle classification result list detail", () => {
389
+ const data = {
390
+ key: "results",
391
+ dynamicschema: {
392
+ "results.Sanctions": [
393
+ {
394
+ code: "DrivingBan",
395
+ label: "Driving ban",
396
+ _links: {
397
+ concept: {
398
+ href: "/concepts/_Context/Police incident decisions/Models/Sanctions/Sanctions.bixml/DrivingBan",
399
+ },
400
+ },
401
+ content: {
402
+ elements: [
403
+ {
404
+ propertyElement: {
405
+ id: "3d38501d",
406
+ label: "Property: Abbreviation",
407
+ properties: {
408
+ type: "Abbreviation",
409
+ label: "Abbreviation",
410
+ value: "DB",
411
+ },
412
+ },
413
+ },
414
+ ],
415
+ },
416
+ },
417
+ {
418
+ code: "PoliceReport",
419
+ label: "Police report",
420
+ _links: {
421
+ concept: {
422
+ href: "/concepts/_Context/Police incident decisions/Models/Sanctions/Sanctions.bixml/PoliceReport",
423
+ },
424
+ },
425
+ content: {
426
+ elements: [
427
+ {
428
+ propertyElement: {
429
+ id: "3d38501d",
430
+ label: "Property: Abbreviation",
431
+ properties: {
432
+ type: "Abbreviation",
433
+ label: "Abbreviation",
434
+ value: "PR",
435
+ },
436
+ },
437
+ },
438
+ ],
439
+ },
440
+ },
441
+ {
442
+ code: "RevocateLicense",
443
+ label: "Revocate license",
444
+ _links: {
445
+ concept: {
446
+ href: "/concepts/_Context/Police incident decisions/Models/Sanctions/Sanctions.bixml/RevocateLicense",
447
+ },
448
+ },
449
+ content: {
450
+ elements: [
451
+ {
452
+ propertyElement: {
453
+ id: "6c4e8b69",
454
+ label: "Property: Abbreviation",
455
+ properties: {
456
+ type: "Abbreviation",
457
+ label: "Abbreviation",
458
+ value: "RL",
459
+ },
460
+ },
461
+ },
462
+ ],
463
+ },
464
+ },
465
+ ],
466
+ },
467
+ results: { Sanctions: ["DrivingBan", "PoliceReport"] },
468
+ };
469
+ const key = "results";
470
+ const childrenKeys = [{ key: "Sanctions", children: [] }];
471
+
472
+ const dataHelper = new AttributeDataHelper(data, key, childrenKeys);
473
+ const dataHelperData = dataHelper.getData();
474
+
475
+ expect(dataHelperData.content).toBeNull();
476
+ expect(dataHelperData.dynamicschemaId).toBe("results");
477
+ expect(dataHelperData.key).toBe("results");
478
+ expect(dataHelperData.value).toStrictEqual({
479
+ Sanctions: ["DrivingBan", "PoliceReport"],
480
+ });
481
+ expect(dataHelperData.children).toHaveLength(1);
482
+
483
+ const firstChild = dataHelperData.children[0];
484
+ expect(firstChild.dynamicschemaId).toBe("results.Sanctions");
485
+ expect(firstChild.key).toBe("Sanctions");
486
+ expect(firstChild.value).toStrictEqual(["DrivingBan", "PoliceReport"]);
487
+ expect(firstChild.content).toBeNull();
488
+
489
+ expect(firstChild.dynamicschema).toHaveLength(3);
490
+ const firstDynamicSchema = firstChild.dynamicschema[0];
491
+
492
+ expect(firstDynamicSchema.code).toBe("DrivingBan");
493
+ expect(firstDynamicSchema.label).toBe("Driving ban");
494
+ expect(firstDynamicSchema.content.elements).toHaveLength(1);
495
+ });
496
+
497
+ it("can handle decision result list detail", () => {
498
+ const data = {
499
+ key: "results",
500
+ content: {
501
+ InvestigationNecessary: {
502
+ elements: [
503
+ {
504
+ textFragmentElement: {
505
+ label: "Text fragment: Description",
506
+ textfragments: [
507
+ {
508
+ type: "Description",
509
+ label: "Description",
510
+ text: "Text fragment for investigation necessary",
511
+ },
512
+ ],
513
+ "layout-hint": ["full"],
514
+ },
515
+ },
516
+ ],
517
+ },
518
+ },
519
+ results: { InvestigationNecessary: true },
520
+ };
521
+ const key = "results";
522
+ const childrenKeys = [{ key: "InvestigationNecessary", children: [] }];
523
+
524
+ const dataHelper = new AttributeDataHelper(data, key, childrenKeys);
525
+ const dataHelperData = dataHelper.getData();
526
+
527
+ expect(dataHelperData.content).toBeNull();
528
+ expect(dataHelperData.dynamicschemaId).toBe("results");
529
+ expect(dataHelperData.key).toBe("results");
530
+ expect(dataHelperData.value).toStrictEqual({
531
+ InvestigationNecessary: true,
532
+ });
533
+ expect(dataHelperData.children).toHaveLength(1);
534
+
535
+ const firstChild = dataHelperData.children[0];
536
+ expect(firstChild.dynamicschemaId).toBe("results.InvestigationNecessary");
537
+ expect(firstChild.key).toBe("InvestigationNecessary");
538
+ expect(firstChild.value).toBe(true);
539
+ expect(firstChild.content.elements).toHaveLength(1);
540
+
541
+ expect(firstChild.dynamicschema).toBeUndefined();
542
+ });
387
543
  });
@@ -1,7 +1,7 @@
1
1
  import HelptextAttributeModel from "../HelptextAttributeModel";
2
2
 
3
3
  describe("helptextAttributeModel", () => {
4
- it("should be able to create an empty HelptextAttribute object", () => {
4
+ it("should be able to create a HelptextAttribute object", () => {
5
5
  const attribute = new HelptextAttributeModel();
6
6
 
7
7
  expect(attribute).toBeInstanceOf(HelptextAttributeModel);
@@ -15,4 +15,42 @@ describe("helptextAttributeModel", () => {
15
15
 
16
16
  expect(attributeWithText.text).toBe("Example helptext text");
17
17
  });
18
+
19
+ it("should be able to handle content in data", () => {
20
+ const attributeWithText = new HelptextAttributeModel(
21
+ {
22
+ key: "CarDetails",
23
+ value: {
24
+ id: "CarDetails.text",
25
+ properties: {
26
+ PersonPrivateCar: "Ferrari GTO",
27
+ PersonLessFavoriteCars: "Mercedes",
28
+ PersonFavoriteCars: "BMW 5 Series, Fiat Panda",
29
+ },
30
+ message:
31
+ "<p>Currently the person drives in a Ferrari GTO, although his favorite cars are BMW 5 Series, Fiat Panda. Less favorite cars of the person are Mercedes.</p>",
32
+ },
33
+ static: true,
34
+ dynamicschemaId: "CarDetails",
35
+ isResult: false,
36
+ children: [],
37
+ content: null,
38
+ },
39
+ {
40
+ type: "string",
41
+ label: "Car details",
42
+ mandatory: false,
43
+ readonly: true,
44
+ text: {
45
+ id: "CarDetails.text",
46
+ rawText:
47
+ "<p>Currently the person drives in a ${PersonPrivateCar}, although his favorite cars are ${PersonFavoriteCars}. Less favorite cars of the person are ${PersonLessFavoriteCars}.</p>",
48
+ },
49
+ }
50
+ );
51
+
52
+ expect(attributeWithText.text).toBe(
53
+ "<p>Currently the person drives in a Ferrari GTO, although his favorite cars are BMW 5 Series, Fiat Panda. Less favorite cars of the person are Mercedes.</p>"
54
+ );
55
+ });
18
56
  });
@@ -47,6 +47,8 @@ var _createHash = require("../../utils/helpers/createHash");
47
47
 
48
48
  var _LinkModel = _interopRequireDefault(require("../links/LinkModel"));
49
49
 
50
+ var _utils = require("../../utils");
51
+
50
52
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
51
53
 
52
54
  function _unsupportedIterableToArray(o, minLen) { var _context5; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context5 = Object.prototype.toString.call(o)).call(_context5, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -171,7 +173,7 @@ var SectionModel = /*#__PURE__*/function (_BaseModel) {
171
173
  }, {
172
174
  key: "body",
173
175
  get: function get() {
174
- return this.data.body;
176
+ return (0, _utils.retrieveText)(this.data.body);
175
177
  }
176
178
  /**
177
179
  * Retrieve child section links
@@ -7,6 +7,7 @@ import { createHashFromHref } from "../../utils/helpers/createHash";
7
7
  import LinkModel from "../links/LinkModel";
8
8
 
9
9
  import type Href from "../href/Href";
10
+ import { retrieveText } from "../../utils";
10
11
 
11
12
  class SectionModel extends BaseModel {
12
13
  _entryDate: ISO_DATE | null;
@@ -88,7 +89,7 @@ class SectionModel extends BaseModel {
88
89
  * Get content body
89
90
  */
90
91
  get body(): ?string {
91
- return this.data.body;
92
+ return retrieveText(this.data.body);
92
93
  }
93
94
 
94
95
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/content/SectionModel.js"],"names":["SectionModel","data","entryDate","_entryDate","referred","_selflink","LinkModel","_links","self","selflink","href","type","sourceLabel","id","_id","getData","number","body","childSections","childSection","ContentLinkModel","section","label","_childSections","sections","subSections","subSection","SubSectionModel","selfhref","push","referredChilds","getReferredSections","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;IAIMA,Y;;;;;AAKJ,wBAAYC,IAAZ,EAA0BC,SAA1B,EAAsD;AAAA;;AAAA;AACpD,8BAAMD,IAAN,EAAY,EAAZ;AADoD;AAAA;AAAA;AAGpD,UAAKE,UAAL,GAAkBD,SAAlB;AAHoD;AAIrD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,KAAKD,IAAL,CAAUG,QAAjB;AACD;AAED;AACF;;;;SACE,eAA0B;AACxB,UAAI,CAAC,KAAKC,SAAV,EAAqB;AAAA;;AACnB,aAAKA,SAAL,GAAiB,IAAIC,kBAAJ,sBAAc,KAAKL,IAAL,CAAUM,MAAxB,sDAAc,kBAAkBC,IAAhC,CAAjB;AACD;;AACD,aAAO,KAAKH,SAAZ;AACD;AAED;AACF;;;;SACE,eAAqB;AACnB,aAAO,KAAKI,QAAL,CAAcC,IAArB;A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AyB;AACvBoB,YAAAA,QAAQ,CAACK,IAAT,CAAcH,UAAd;AACD;;AAED,cAAMI,cAAc,GAAGJ,UAAU,CAACK,mBAAX,EAAvB;AACAP,UAAAA,QAAQ,CAACK,IAAT,OAAAL,QAAQ,mCAASM,cAAT,EAAR;AACD;AAV0D;AAAA;AAAA;AAAA;AAAA;;AAAA,kDAYhC,KAAKZ,aAZ2B;AAAA;;AAAA;AAY3D,+DAA+C;AAAA,cAApCC,YAAoC;;AAC7C,cAAIA,YAAY,CAACf,QAAjB,EAA2B;AACzBoB,YAAAA,QAAQ,CAACK,IAAT,CAAcV,YAAd;AACD;;AAED,cAAMW,eAAc,GAAGX,YAAY,CAACY,mBAAb,EAAvB;;AACAP,UAAAA,QAAQ,CAACK,IAAT,OAAAL,QAAQ,mCAASM,eAAT,EAAR;AACD;AAnB0D;AAAA;AAAA;AAAA;AAAA;;AAqB3D,aAAON,QAAP;AACD;;;EAnLwBQ,mB;;eAsLZhC,Y","sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport SubSectionModel from \"./SubSectionModel\";\n\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\nimport LinkModel from \"../links/LinkModel\";\n\nimport type Href from \"../href/Href\";\n\nclass SectionModel extends BaseModel {\n _entryDate: ISO_DATE | null;\n _selflink: ?LinkModel;\n _childSections: Array<SectionModel>;\n\n constructor(data: Object, entryDate: ISO_DATE | null) {\n super(data, {});\n\n this._entryDate = entryDate;\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get selflink(): LinkModel {\n if (!this._selflink) {\n this._selflink = new LinkModel(this.data._links?.self);\n }\n return this._selflink;\n }\n\n /**\n */\n get selfhref(): Href {\n return this.selflink.href;\n }\n\n /**\n */\n get entryDate(): ISO_DATE | null {\n return this._entryDate;\n }\n\n /**\n */\n get type(): string {\n return this.data.type;\n }\n\n /**\n */\n get sourceLabel(): string {\n return this.data.sourceLabel;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n */\n get key(): string {\n return this.id;\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Get content body\n */\n get body(): ?string {\n return this.data.body;\n }\n\n /**\n * Retrieve child section links\n */\n get childSectionLinks(): Array<ContentLinkModel> {\n return this.data.childSections\n ? this.data.childSections.map(\n (childSection) =>\n new ContentLinkModel(\n {\n section: childSection.id || childSection._id,\n _id: childSection.id || childSection._id,\n label: childSection.label,\n sourceLabel: childSection.sourceLabel,\n _links: childSection._links,\n },\n this.entryDate\n )\n )\n : [];\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(\n {\n section: this.id,\n _id: this.id,\n label: this.data.label,\n sourceLabel: this.data.sourceLabel,\n _links: this.data._links,\n },\n this.entryDate\n );\n }\n\n /**\n * Get tree of child sections\n */\n get childSections(): Array<SectionModel> {\n if (!this._childSections && this.data.childSections) {\n this._childSections = this.data.childSections\n .filter((childSection) => \"body\" in childSection)\n .map((childSection) => new SectionModel(childSection, this.entryDate));\n }\n return this._childSections || [];\n }\n\n /**\n * set resolved child sections\n */\n set childSections(sections: Array<SectionModel>) {\n this._childSections = sections || [];\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection)\n )\n : [];\n }\n\n /**\n */\n get referenceHash(): number {\n return createHashFromHref(this.selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel | SectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n for (const childSection of this.childSections) {\n if (childSection.referred) {\n sections.push(childSection);\n }\n\n const referredChilds = childSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n\nexport default SectionModel;\n"],"file":"SectionModel.js"}
1
+ {"version":3,"sources":["../../../src/models/content/SectionModel.js"],"names":["SectionModel","data","entryDate","_entryDate","referred","_selflink","LinkModel","_links","self","selflink","href","type","sourceLabel","id","_id","getData","number","body","childSections","childSection","ContentLinkModel","section","label","_childSections","sections","subSections","subSection","SubSectionModel","selfhref","push","referredChilds","getReferredSections","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAGA;;;;;;;;;;;;IAEMA,Y;;;;;AAKJ,wBAAYC,IAAZ,EAA0BC,SAA1B,EAAsD;AAAA;;AAAA;AACpD,8BAAMD,IAAN,EAAY,EAAZ;AADoD;AAAA;AAAA;AAGpD,UAAKE,UAAL,GAAkBD,SAAlB;AAHoD;AAIrD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,KAAKD,IAAL,CAAUG,QAAjB;AACD;AAED;AACF;;;;SACE,eAA0B;AACxB,UAAI,CAAC,KAAKC,SAAV,EAAqB;AAAA;;AACnB,aAAKA,SAAL,GAAiB,IAAIC,kBAAJ,sBAAc,KAAKL,IAAL,CAAUM,MAAxB,sDAAc,kBAAkBC,IAAhC,CAAjB;AACD;;AACD,aAAO,KAAKH,SAAZ;AACD;AAED;AACF;;;;SACE,eAAqB;AACnB,aAAO,KAAKI,QAAL,CAAcC,IAArB;AACD;AAED;AACF;;;;SACE,eAAiC;AAC/B,aAAO,KAAKP,UAAZ;AACD;AAED;AACF;;;;SACE,eAAmB;AACjB,aAAO,KAAKF,IAAL,CAAUU,IAAjB;AACD;AAED;AACF;;;;SACE,eAA0B;AACxB,aAAO,KAAKV,IAAL,CAAUW,WAAjB;AACD;AAED;AACF;;;;SACE,eAAiB;AACf,aAAO,KAAKX,IAAL,CAAUY,EAAV,IAAgB,KAAKZ,IAAL,CAAUa,GAAj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ApCC,YAAoC;;AAC7C,cAAIA,YAAY,CAACf,QAAjB,EAA2B;AACzBoB,YAAAA,QAAQ,CAACK,IAAT,CAAcV,YAAd;AACD;;AAED,cAAMW,eAAc,GAAGX,YAAY,CAACY,mBAAb,EAAvB;;AACAP,UAAAA,QAAQ,CAACK,IAAT,OAAAL,QAAQ,mCAASM,eAAT,EAAR;AACD;AAnB0D;AAAA;AAAA;AAAA;AAAA;;AAqB3D,aAAON,QAAP;AACD;;;EAnLwBQ,mB;;eAsLZhC,Y","sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport ContentLinkModel from \"./ContentLinkModel\";\nimport SubSectionModel from \"./SubSectionModel\";\n\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\nimport LinkModel from \"../links/LinkModel\";\n\nimport type Href from \"../href/Href\";\nimport { retrieveText } from \"../../utils\";\n\nclass SectionModel extends BaseModel {\n _entryDate: ISO_DATE | null;\n _selflink: ?LinkModel;\n _childSections: Array<SectionModel>;\n\n constructor(data: Object, entryDate: ISO_DATE | null) {\n super(data, {});\n\n this._entryDate = entryDate;\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get selflink(): LinkModel {\n if (!this._selflink) {\n this._selflink = new LinkModel(this.data._links?.self);\n }\n return this._selflink;\n }\n\n /**\n */\n get selfhref(): Href {\n return this.selflink.href;\n }\n\n /**\n */\n get entryDate(): ISO_DATE | null {\n return this._entryDate;\n }\n\n /**\n */\n get type(): string {\n return this.data.type;\n }\n\n /**\n */\n get sourceLabel(): string {\n return this.data.sourceLabel;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n */\n get key(): string {\n return this.id;\n }\n\n /**\n * Get content label\n */\n get label(): string {\n return this.getData(\"label\", \"\");\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Get content body\n */\n get body(): ?string {\n return retrieveText(this.data.body);\n }\n\n /**\n * Retrieve child section links\n */\n get childSectionLinks(): Array<ContentLinkModel> {\n return this.data.childSections\n ? this.data.childSections.map(\n (childSection) =>\n new ContentLinkModel(\n {\n section: childSection.id || childSection._id,\n _id: childSection.id || childSection._id,\n label: childSection.label,\n sourceLabel: childSection.sourceLabel,\n _links: childSection._links,\n },\n this.entryDate\n )\n )\n : [];\n }\n\n /**\n */\n get selfContentLink(): ContentLinkModel {\n return new ContentLinkModel(\n {\n section: this.id,\n _id: this.id,\n label: this.data.label,\n sourceLabel: this.data.sourceLabel,\n _links: this.data._links,\n },\n this.entryDate\n );\n }\n\n /**\n * Get tree of child sections\n */\n get childSections(): Array<SectionModel> {\n if (!this._childSections && this.data.childSections) {\n this._childSections = this.data.childSections\n .filter((childSection) => \"body\" in childSection)\n .map((childSection) => new SectionModel(childSection, this.entryDate));\n }\n return this._childSections || [];\n }\n\n /**\n * set resolved child sections\n */\n set childSections(sections: Array<SectionModel>) {\n this._childSections = sections || [];\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection)\n )\n : [];\n }\n\n /**\n */\n get referenceHash(): number {\n return createHashFromHref(this.selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel | SectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n for (const childSection of this.childSections) {\n if (childSection.referred) {\n sections.push(childSection);\n }\n\n const referredChilds = childSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n\nexport default SectionModel;\n"],"file":"SectionModel.js"}
@@ -45,6 +45,8 @@ var _Href = _interopRequireDefault(require("../href/Href"));
45
45
 
46
46
  var _LinkModel = _interopRequireDefault(require("../links/LinkModel"));
47
47
 
48
+ var _utils = require("../../utils");
49
+
48
50
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
49
51
 
50
52
  function _unsupportedIterableToArray(o, minLen) { var _context2; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context2 = Object.prototype.toString.call(o)).call(_context2, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -106,7 +108,8 @@ var SubSectionModel = /*#__PURE__*/function (_BaseModel) {
106
108
  }, {
107
109
  key: "body",
108
110
  get: function get() {
109
- return this.getData("body", "");
111
+ var body = this.getData("body", "");
112
+ return (0, _utils.retrieveText)(body);
110
113
  }
111
114
  /**
112
115
  * Retrieve number of section
@@ -5,6 +5,7 @@ import BaseModel from "../base/BaseModel";
5
5
  import LinkCollection from "../links/LinkCollection";
6
6
  import Href from "../href/Href";
7
7
  import LinkModel from "../links/LinkModel";
8
+ import { retrieveText } from "../../utils";
8
9
 
9
10
  /**
10
11
  * Link to a concept
@@ -41,7 +42,8 @@ export default class SubSectionModel extends BaseModel {
41
42
  * Retrieve html body
42
43
  */
43
44
  get body(): string {
44
- return this.getData("body", "");
45
+ const body = this.getData("body", "");
46
+ return retrieveText(body);
45
47
  }
46
48
 
47
49
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/models/content/SubSectionModel.js"],"names":["SubSectionModel","data","referred","id","_id","getData","number","label","subSections","subSection","_links","LinkCollection","contributions","links","getLinkByKey","selflink","href","hrefs","relatedConceptsHref","push","forEach","relatedConceptsHrefs","relatedConceptsLink","selfhref","Href","sections","referredChilds","getReferredSections","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA;AACA;AACA;IACqBA,e;;;;;AAGnB;AACF;AACE,2BAAYC,IAAZ,EAA0B;AAAA;;AAAA;AACxB,8BAAMA,IAAN,EAAY,EAAZ;AADwB;AAAA;AAEzB;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,KAAKA,IAAL,CAAUC,QAAjB;AACD;AAED;AACF;;;;SACE,eAAiB;AACf,aAAO,KAAKD,IAAL,CAAUE,EAAV,IAAgB,KAAKF,IAAL,CAAUG,GAAjC;AACD;AAED;AACF;AACA;;;;SACE,eAAmB;AACjB,aAAO,KAAKD,EAAZ;AACD;AAED;AACF;AACA;;;;SACE,eAAmB;AACjB,aAAO,KAAKE,OAAL,CAAa,MAAb,EAAqB,EAArB,CAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA4B;AAAA;;AAC1B,kCAAO,KAAKJ,IAAL,CAAUK,MAAjB,iEAA2B,IAA3B;AACD;AAED;AACF;AACA;;;;SACE,eAAqB;AACnB,aAAO,KAAKL,IAAL,CAAUM,KAAjB;AACD;AAED;AACF;AACA;;;;SACE,eAA0C;AAAA;;AACxC,aAAO,KAAKN,IAAL,CAAUO,WAAV,GACH,kCAAKP,IAAL,CAAUO,WAAV,iBACE,UAACC,UAAD;AAAA,eAAgB,IAAIT,eAAJ,CAAoBS,UAApB,CAAhB;AAAA,OADF,CADG,GAIH,EAJJ;AAK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;AACzC,cAAIA,UAAU,CAACP,QAAf,EAAyB;AACvBuB,YAAAA,QAAQ,CAACN,IAAT,CAAcV,UAAd;AACD;;AAED,cAAMiB,cAAc,GAAGjB,UAAU,CAACkB,mBAAX,EAAvB;AACAF,UAAAA,QAAQ,CAACN,IAAT,OAAAM,QAAQ,mCAASC,cAAT,EAAR;AACD;AAV2C;AAAA;AAAA;AAAA;AAAA;;AAY5C,aAAOD,QAAP;AACD;;;EA3I0CG,mB","sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n return this.getData(\"body\", \"\");\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection)\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n return relatedConceptsLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"file":"SubSectionModel.js"}
1
+ {"version":3,"sources":["../../../src/models/content/SubSectionModel.js"],"names":["SubSectionModel","data","referred","id","_id","body","getData","number","label","subSections","subSection","_links","LinkCollection","contributions","links","getLinkByKey","selflink","href","hrefs","relatedConceptsHref","push","forEach","relatedConceptsHrefs","relatedConceptsLink","selfhref","Href","sections","referredChilds","getReferredSections","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA;AACA;AACA;IACqBA,e;;;;;AAGnB;AACF;AACE,2BAAYC,IAAZ,EAA0B;AAAA;;AAAA;AACxB,8BAAMA,IAAN,EAAY,EAAZ;AADwB;AAAA;AAEzB;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,KAAKA,IAAL,CAAUC,QAAjB;AACD;AAED;AACF;;;;SACE,eAAiB;AACf,aAAO,KAAKD,IAAL,CAAUE,EAAV,IAAgB,KAAKF,IAAL,CAAUG,GAAjC;AACD;AAED;AACF;AACA;;;;SACE,eAAmB;AACjB,aAAO,KAAKD,EAAZ;AAC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ApB,EAAL;AACD,OAFD;AAIA,aAAOJ,KAAP;AACD;AAED;AACF;AACA;;;;SACE,eAAuC;AACrC,UAAMK,mBAAmB,GAAG,KAAKT,KAAL,CAAWC,YAAX,CAAwB,iBAAxB,CAA5B;;AAEA,UAAIQ,mBAAJ,EAAyB;AACvB,eAAOA,mBAAmB,CAACN,IAA3B;AACD;;AAED,aAAO,IAAP;AACD;AAED;AACF;;;;SACE,eAA4B;AAC1B,UAAMO,QAAQ,GAAG,KAAKA,QAAL,IAAiB,IAAIC,aAAJ,EAAlC;AAEA,aAAO,oCAAmBD,QAAnB,CAAP;AACD;AAED;AACF;;;;WACE,+BAA8C;AAC5C,UAAME,QAAQ,GAAG,EAAjB;;AAD4C,iDAGnB,KAAKjB,WAHc;AAAA;;AAAA;AAG5C,4DAA2C;AAAA,cAAhCC,UAAgC;;AACzC,cAAIA,UAAU,CAACR,QAAf,EAAyB;AACvBwB,YAAAA,QAAQ,CAACN,IAAT,CAAcV,UAAd;AACD;;AAED,cAAMiB,cAAc,GAAGjB,UAAU,CAACkB,mBAAX,EAAvB;AACAF,UAAAA,QAAQ,CAACN,IAAT,OAAAM,QAAQ,mCAASC,cAAT,EAAR;AACD;AAV2C;AAAA;AAAA;AAAA;AAAA;;AAY5C,aAAOD,QAAP;AACD;;;EA5I0CG,mB","sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n const body = this.getData(\"body\", \"\");\n return retrieveText(body);\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection)\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n return relatedConceptsLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"file":"SubSectionModel.js"}
@@ -211,9 +211,12 @@ var ListDetailModel = /*#__PURE__*/function (_DetailModel) {
211
211
  key: "setResults",
212
212
  value: function setResults() {
213
213
  if ((0, _objects.has)(this.data, "resultSection.results") && (0, _objects.has)(this.contributions, "resultSection.results")) {
214
+ var _this$data$content;
215
+
214
216
  var results = (0, _createAttribute.default)("results", _objectSpread({
215
217
  key: "results",
216
- dynamicschema: this.data.dynamicschema
218
+ dynamicschema: this.data.dynamicschema,
219
+ content: (_this$data$content = this.data.content) === null || _this$data$content === void 0 ? void 0 : _this$data$content.results
217
220
  }, this.data.resultSection), this.contributions.resultSection.results);
218
221
 
219
222
  if (results instanceof _CompositeAttributeModel.default) {
@@ -230,7 +233,7 @@ var ListDetailModel = /*#__PURE__*/function (_DetailModel) {
230
233
  key: "setGivenAnswers",
231
234
  value: function setGivenAnswers() {
232
235
  if ((0, _objects.has)(this.data, "resultSection.givenAnswers") && (0, _objects.has)(this.contributions, "resultSection.givenAnswers")) {
233
- var _context2;
236
+ var _context2, _this$data$content2;
234
237
 
235
238
  var givenAnswersData = this.data.resultSection.givenAnswers;
236
239
  var givenAnswersContributions = this.contributions.resultSection.givenAnswers;
@@ -244,7 +247,8 @@ var ListDetailModel = /*#__PURE__*/function (_DetailModel) {
244
247
 
245
248
  var givenAnswers = (0, _createAttribute.default)("givenAnswers", _objectSpread({
246
249
  key: "givenAnswers",
247
- dynamicschema: this.data.dynamicschema
250
+ dynamicschema: this.data.dynamicschema,
251
+ content: (_this$data$content2 = this.data.content) === null || _this$data$content2 === void 0 ? void 0 : _this$data$content2.givenAnswers
248
252
  }, this.data.resultSection), filteredContributions);
249
253
 
250
254
  if (givenAnswers instanceof _CompositeAttributeModel.default) {
@@ -157,6 +157,7 @@ export default class ListDetailModel extends DetailModel {
157
157
  {
158
158
  key: "results",
159
159
  dynamicschema: this.data.dynamicschema,
160
+ content: this.data.content?.results,
160
161
  ...this.data.resultSection,
161
162
  },
162
163
  this.contributions.resultSection.results
@@ -194,6 +195,7 @@ export default class ListDetailModel extends DetailModel {
194
195
  {
195
196
  key: "givenAnswers",
196
197
  dynamicschema: this.data.dynamicschema,
198
+ content: this.data.content?.givenAnswers,
197
199
  ...this.data.resultSection,
198
200
  },
199
201
  filteredContributions