@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/list/ListDetailModel.js"],"names":["ListDetailModel","modularUIResponse","_actionCollection","ActionCollection","_contentConfiguration","ContentConfiguration","contributions","content","setResultSection","setEventData","listitemPanels","listitem","links","getLinksByGroup","all","hasResults","results","push","getInitialChildModelLinks","givenAnswers","models","_attributeCollection","setChildModels","_listitem","actionCollection","configuration","data","setResults","setGivenAnswers","key","dynamicschema","resultSection","CompositeAttributeModel","isResult","indicateContentConfiguration","contentConfiguration","_results","givenAnswersData","givenAnswersContributions","filteredContributions","children","child","childKey","_givenAnswers","eventdata","eventData","eventContributions","_eventdata","AttributeSetModel","hasEventData","forEach","eventDataContribution","Array","isArray","eventDataData","i","addAttributes","resourcetype","DetailModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAQA;AACA;AACA;IACqBA,e;;;;;AAOnB;AACF;AACA;AACE,2BAAYC,iBAAZ,EAAkD;AAAA;;AAAA;AAChD,8BAAMA,iBAAN;AADgD;AAAA;AAAA;AAAA;AAAA;AAGhD,UAAKC,iBAAL,GAAyB,IAAIC,yBAAJ,EAAzB;AAEA,UAAKC,qBAAL,GAA6B,IAAIC,6BAAJ,CAC3B,MAAKC,aAAL,GAAqB,MAAKA,aAAL,CAAmBC,OAAxC,GAAkD,EADvB,CAA7B;;AAIA,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,iCAJnB;AAMD;;;EA5E0CC,qB","sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport DetailModel from \"../detail/DetailModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport AttributeSetModel from \"../attributes/AttributeSetModel\";\n\nimport createAttribute from \"../attributes/_createAttribute\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Detail of a list item\n */\nexport default class ListDetailModel extends DetailModel {\n _contentConfiguration: ContentConfiguration;\n _listitem: ListItemModel;\n _givenAnswers: ?CompositeAttributeModel;\n _results: ?CompositeAttributeModel;\n _eventdata: Array<AttributeSetModel>;\n\n /**\n * Construct\n */\n constructor(modularUIResponse: ModularUIResponse) {\n super(modularUIResponse);\n\n this._actionCollection = new ActionCollection();\n\n this._contentConfiguration = new ContentConfiguration(\n this.contributions ? this.contributions.content : {}\n );\n\n this.setResultSection();\n this.setEventData();\n }\n\n /**\n * Add links to expand on initialization of this model\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const listitemPanels = this.listitem\n ? this.listitem.links.getLinksByGroup(\"panel\").all\n : [];\n\n const links = [...super.getInitialChildModelLinks(), ...listitemPanels];\n\n if (this.hasResults) {\n if (this.results) {\n links.push(...this.results.getInitialChildModelLinks());\n }\n if (this.givenAnswers) {\n links.push(...this.givenAnswers.getInitialChildModelLinks());\n }\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this._attributeCollection.setChildModels(models);\n\n if (this.results) {\n this.results.setChildModels(models);\n }\n\n if (this.givenAnswers) {\n this.givenAnswers.setChildModels(models);\n }\n }\n\n /**\n */\n get type(): string {\n return \"ListDetail\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourcetype = data.contributions?.resourcetype ?? \"unknown\";\n\n return (\n resourcetype.endsWith(\"ListPanelDetail\") ||\n resourcetype.endsWith(\"ListDetail\") ||\n resourcetype === \"DatastoreRelatedDatastorePanelDetail\" ||\n resourcetype === \"CaseRelatedDataStorePanelDetail\"\n );\n }\n\n /**\n * Set listitem of this listdetail and transfer listitem actions to listdetail actions\n */\n set listitem(listitem: ListItemModel) {\n this._listitem = listitem;\n\n // transfer listitem actions to _actions\n this._actionCollection = listitem.actionCollection;\n }\n\n /**\n * Get listitem\n */\n get listitem(): ListItemModel {\n return this._listitem;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.listitem.links.getLinksByGroup(\"panel\");\n }\n\n /**\n * Getting the contentConfiguration\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n set contentConfiguration(configuration: ContentConfiguration) {\n this._contentConfiguration = configuration;\n }\n\n /**\n */\n setResultSection() {\n if (\n has(this.contributions, \"resultSection\") &&\n has(this.data, \"resultSection\")\n ) {\n this.setResults();\n this.setGivenAnswers();\n }\n }\n\n /**\n */\n setResults() {\n if (\n has(this.data, \"resultSection.results\") &&\n has(this.contributions, \"resultSection.results\")\n ) {\n const results = createAttribute(\n \"results\",\n {\n key: \"results\",\n dynamicschema: this.data.dynamicschema,\n ...this.data.resultSection,\n },\n this.contributions.resultSection.results\n );\n\n if (results instanceof CompositeAttributeModel) {\n results.isResult = true;\n results.indicateContentConfiguration(this.contentConfiguration);\n this._results = results;\n }\n }\n }\n\n /**\n */\n setGivenAnswers() {\n if (\n has(this.data, \"resultSection.givenAnswers\") &&\n has(this.contributions, \"resultSection.givenAnswers\")\n ) {\n const givenAnswersData = this.data.resultSection.givenAnswers;\n const givenAnswersContributions =\n this.contributions.resultSection.givenAnswers;\n\n const filteredContributions = {\n ...givenAnswersContributions,\n children: givenAnswersContributions.children.filter((child) => {\n const childKey = Object.keys(child)[0];\n return childKey in givenAnswersData;\n }),\n };\n\n const givenAnswers = createAttribute(\n \"givenAnswers\",\n {\n key: \"givenAnswers\",\n dynamicschema: this.data.dynamicschema,\n ...this.data.resultSection,\n },\n filteredContributions\n );\n\n if (givenAnswers instanceof CompositeAttributeModel) {\n givenAnswers.isResult = true;\n this._givenAnswers = givenAnswers;\n }\n }\n }\n\n /**\n */\n get givenAnswers(): ?CompositeAttributeModel {\n return this._givenAnswers;\n }\n\n /**\n */\n get hasResults(): boolean {\n return has(this.contributions, \"resultSection\");\n }\n\n /**\n */\n get results(): ?CompositeAttributeModel {\n return this._results;\n }\n\n /**\n */\n get hasEventData(): boolean {\n return (\n has(this.contributions, \"eventdata\") &&\n has(this.data, \"eventdata\") &&\n this.data.eventdata != null &&\n this.contributions.eventdata != null\n );\n }\n\n /**\n */\n addAttributes(key: string, eventData: Object, eventContributions: Object) {\n this._eventdata.push(\n new AttributeSetModel(key, eventData, eventContributions)\n );\n }\n\n /**\n */\n setEventData() {\n if (this.hasEventData) {\n this._eventdata = [];\n\n this.contributions.eventdata.forEach((eventDataContribution) => {\n const [key] = Object.keys(eventDataContribution);\n if (key in this.data.eventdata) {\n if (Array.isArray(this.data.eventdata[key])) {\n this.data.eventdata[key].forEach((eventDataData, i) => {\n this.addAttributes(\n `${key}-${i + 1}`,\n {\n ...eventDataData,\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key]\n );\n });\n } else {\n this.addAttributes(\n key,\n {\n ...this.data.eventdata[key],\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key]\n );\n }\n }\n });\n }\n }\n\n /**\n */\n get eventdata(): Array<AttributeSetModel> {\n return this._eventdata;\n }\n}\n"],"file":"ListDetailModel.js"}
1
+ {"version":3,"sources":["../../../src/models/list/ListDetailModel.js"],"names":["ListDetailModel","modularUIResponse","_actionCollection","ActionCollection","_contentConfiguration","ContentConfiguration","contributions","content","setResultSection","setEventData","listitemPanels","listitem","links","getLinksByGroup","all","hasResults","results","push","getInitialChildModelLinks","givenAnswers","models","_attributeCollection","setChildModels","_listitem","actionCollection","configuration","data","setResults","setGivenAnswers","key","dynamicschema","resultSection","CompositeAttributeModel","isResult","indicateContentConfiguration","contentConfiguration","_results","givenAnswersData","givenAnswersContributions","filteredContributions","children","child","childKey","_givenAnswers","eventdata","eventData","eventContributions","_eventdata","AttributeSetModel","hasEventData","forEach","eventDataContribution","Array","isArray","eventDataData","i","addAttributes","resourcetype","DetailModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAQA;AACA;AACA;IACqBA,e;;;;;AAOnB;AACF;AACA;AACE,2BAAYC,iBAAZ,EAAkD;AAAA;;AAAA;AAChD,8BAAMA,iBAAN;AADgD;AAAA;AAAA;AAAA;AAAA;AAGhD,UAAKC,iBAAL,GAAyB,IAAIC,yBAAJ,EAAzB;AAEA,UAAKC,qBAAL,GAA6B,IAAIC,6BAAJ,CAC3B,MAAKC,aAAL,GAAqB,MAAKA,aAAL,CAAmBC,OAAxC,GAAkD,EADvB,CAA7B;;AAIA,UAAKC,gBAAL;;AACA,UAAKC,YAAL;;AAVgD;AAWjD;AAED;AACF;AACA;;;;;WACE,qCAA8C;AAAA;;AAC5C,UAAMC,cAAc,GAAG,KAAKC,QAAL,GACnB,KAAKA,QAAL,CAAcC,KAAd,CAAoBC,eAApB,CAAoC,OAApC,EAA6CC,GAD1B,GAEnB,EAFJ;AAIA,UAAMF,KAAK,qPAA6CF,cAA7C,EAAX;;AAEA,UAAI,KAAKK,UAAT,EAAqB;AACnB,YAAI,KAAKC,OAAT,EAAkB;AAChBJ,UAAAA,KAAK,CAACK,IAAN,OAAAL,KAAK,mCAAS,KAAKI,OAAL,CAAaE,yBAAb,EAAT,EAAL;AACD;;AACD,YAAI,KAAKC,YAAT,EAAuB;AACrBP,UAAAA,KAAK,CA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ACH,IAAL,CAAUkB,SAAV,CAAoBf,GAApB,EAAyBqB,OAAzB,CAAiC,UAACI,aAAD,EAAgBC,CAAhB,EAAsB;AAAA;;AACrD,gBAAA,MAAI,CAACC,aAAL,4CACK3B,GADL,wBACY0B,CAAC,GAAG,CADhB,mCAGOD,aAHP;AAIIxB,kBAAAA,aAAa,EAAE,MAAI,CAACJ,IAAL,CAAUI;AAJ7B,oBAMEqB,qBAAqB,CAACtB,GAAD,CANvB;AAQD,eATD;AAUD,aAXD,MAWO;AACL,cAAA,MAAI,CAAC2B,aAAL,CACE3B,GADF,kCAGO,MAAI,CAACH,IAAL,CAAUkB,SAAV,CAAoBf,GAApB,CAHP;AAIIC,gBAAAA,aAAa,EAAE,MAAI,CAACJ,IAAL,CAAUI;AAJ7B,kBAMEqB,qBAAqB,CAACtB,GAAD,CANvB;AAQD;AACF;AACF,SAzBD;AA0BD;AACF;AAED;AACF;;;;SACE,eAA0C;AACxC,aAAO,KAAKkB,UAAZ;AACD;;;WAvMD,2BAAyBrB,IAAzB,EAA2D;AAAA;;AACzD,UAAM+B,YAAY,mDAAG/B,IAAI,CAACpB,aAAR,wDAAG,oBAAoBmD,YAAvB,yEAAuC,SAAzD;AAEA,aACE,uBAAAA,YAAY,MAAZ,CAAAA,YAAY,EAAU,iBAAV,CAAZ,IACA,uBAAAA,YAAY,MAAZ,CAAAA,YAAY,EAAU,YAAV,CADZ,IAEAA,YAAY,KAAK,sCAFjB,IAGAA,YAAY,KAAK,iCAJnB;AAMD;;;EA5E0CC,qB","sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport DetailModel from \"../detail/DetailModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport AttributeSetModel from \"../attributes/AttributeSetModel\";\n\nimport createAttribute from \"../attributes/_createAttribute\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Detail of a list item\n */\nexport default class ListDetailModel extends DetailModel {\n _contentConfiguration: ContentConfiguration;\n _listitem: ListItemModel;\n _givenAnswers: ?CompositeAttributeModel;\n _results: ?CompositeAttributeModel;\n _eventdata: Array<AttributeSetModel>;\n\n /**\n * Construct\n */\n constructor(modularUIResponse: ModularUIResponse) {\n super(modularUIResponse);\n\n this._actionCollection = new ActionCollection();\n\n this._contentConfiguration = new ContentConfiguration(\n this.contributions ? this.contributions.content : {}\n );\n\n this.setResultSection();\n this.setEventData();\n }\n\n /**\n * Add links to expand on initialization of this model\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const listitemPanels = this.listitem\n ? this.listitem.links.getLinksByGroup(\"panel\").all\n : [];\n\n const links = [...super.getInitialChildModelLinks(), ...listitemPanels];\n\n if (this.hasResults) {\n if (this.results) {\n links.push(...this.results.getInitialChildModelLinks());\n }\n if (this.givenAnswers) {\n links.push(...this.givenAnswers.getInitialChildModelLinks());\n }\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this._attributeCollection.setChildModels(models);\n\n if (this.results) {\n this.results.setChildModels(models);\n }\n\n if (this.givenAnswers) {\n this.givenAnswers.setChildModels(models);\n }\n }\n\n /**\n */\n get type(): string {\n return \"ListDetail\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourcetype = data.contributions?.resourcetype ?? \"unknown\";\n\n return (\n resourcetype.endsWith(\"ListPanelDetail\") ||\n resourcetype.endsWith(\"ListDetail\") ||\n resourcetype === \"DatastoreRelatedDatastorePanelDetail\" ||\n resourcetype === \"CaseRelatedDataStorePanelDetail\"\n );\n }\n\n /**\n * Set listitem of this listdetail and transfer listitem actions to listdetail actions\n */\n set listitem(listitem: ListItemModel) {\n this._listitem = listitem;\n\n // transfer listitem actions to _actions\n this._actionCollection = listitem.actionCollection;\n }\n\n /**\n * Get listitem\n */\n get listitem(): ListItemModel {\n return this._listitem;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.listitem.links.getLinksByGroup(\"panel\");\n }\n\n /**\n * Getting the contentConfiguration\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n set contentConfiguration(configuration: ContentConfiguration) {\n this._contentConfiguration = configuration;\n }\n\n /**\n */\n setResultSection() {\n if (\n has(this.contributions, \"resultSection\") &&\n has(this.data, \"resultSection\")\n ) {\n this.setResults();\n this.setGivenAnswers();\n }\n }\n\n /**\n */\n setResults() {\n if (\n has(this.data, \"resultSection.results\") &&\n has(this.contributions, \"resultSection.results\")\n ) {\n const results = createAttribute(\n \"results\",\n {\n key: \"results\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.results,\n ...this.data.resultSection,\n },\n this.contributions.resultSection.results\n );\n\n if (results instanceof CompositeAttributeModel) {\n results.isResult = true;\n results.indicateContentConfiguration(this.contentConfiguration);\n this._results = results;\n }\n }\n }\n\n /**\n */\n setGivenAnswers() {\n if (\n has(this.data, \"resultSection.givenAnswers\") &&\n has(this.contributions, \"resultSection.givenAnswers\")\n ) {\n const givenAnswersData = this.data.resultSection.givenAnswers;\n const givenAnswersContributions =\n this.contributions.resultSection.givenAnswers;\n\n const filteredContributions = {\n ...givenAnswersContributions,\n children: givenAnswersContributions.children.filter((child) => {\n const childKey = Object.keys(child)[0];\n return childKey in givenAnswersData;\n }),\n };\n\n const givenAnswers = createAttribute(\n \"givenAnswers\",\n {\n key: \"givenAnswers\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.givenAnswers,\n ...this.data.resultSection,\n },\n filteredContributions\n );\n\n if (givenAnswers instanceof CompositeAttributeModel) {\n givenAnswers.isResult = true;\n this._givenAnswers = givenAnswers;\n }\n }\n }\n\n /**\n */\n get givenAnswers(): ?CompositeAttributeModel {\n return this._givenAnswers;\n }\n\n /**\n */\n get hasResults(): boolean {\n return has(this.contributions, \"resultSection\");\n }\n\n /**\n */\n get results(): ?CompositeAttributeModel {\n return this._results;\n }\n\n /**\n */\n get hasEventData(): boolean {\n return (\n has(this.contributions, \"eventdata\") &&\n has(this.data, \"eventdata\") &&\n this.data.eventdata != null &&\n this.contributions.eventdata != null\n );\n }\n\n /**\n */\n addAttributes(key: string, eventData: Object, eventContributions: Object) {\n this._eventdata.push(\n new AttributeSetModel(key, eventData, eventContributions)\n );\n }\n\n /**\n */\n setEventData() {\n if (this.hasEventData) {\n this._eventdata = [];\n\n this.contributions.eventdata.forEach((eventDataContribution) => {\n const [key] = Object.keys(eventDataContribution);\n if (key in this.data.eventdata) {\n if (Array.isArray(this.data.eventdata[key])) {\n this.data.eventdata[key].forEach((eventDataData, i) => {\n this.addAttributes(\n `${key}-${i + 1}`,\n {\n ...eventDataData,\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key]\n );\n });\n } else {\n this.addAttributes(\n key,\n {\n ...this.data.eventdata[key],\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key]\n );\n }\n }\n });\n }\n }\n\n /**\n */\n get eventdata(): Array<AttributeSetModel> {\n return this._eventdata;\n }\n}\n"],"file":"ListDetailModel.js"}
@@ -176,13 +176,17 @@ export type FilesizeConstraintsType = {
176
176
  };
177
177
 
178
178
  export type PropertyData = { type: string, label: string, value: string };
179
- export type TextFragmentData = { type: string, label: string, text: string };
179
+ export type TextFragmentData = {
180
+ type: string,
181
+ label: string,
182
+ text: string | { id?: string, message: string, properties?: Object },
183
+ };
180
184
  export type SectionData = {
181
185
  id: string,
182
186
  type: string,
183
187
  label?: string,
184
188
  number?: string,
185
- body: string,
189
+ body: string | { id?: string, message: string, properties?: Object },
186
190
  _links: { self: { href: string } },
187
191
  childSections: Array<SectionData>,
188
192
  subSections: Array<SectionData>,
@@ -208,10 +212,6 @@ export type ContentElement = {
208
212
  sections: Array<SectionData>,
209
213
  },
210
214
  };
211
- export type ContentData = {
212
- label: string | null,
213
- elements: Array<PropertiesElement | TextFragmentElement | ContentElement>,
214
- };
215
215
 
216
216
  type ContentElementMapped = {
217
217
  contentElement: {
@@ -219,6 +219,15 @@ type ContentElementMapped = {
219
219
  sections: Array<SectionModel>,
220
220
  },
221
221
  };
222
+
222
223
  export type ContentAll = Array<
223
224
  PropertiesElement | TextFragmentElement | ContentElementMapped
224
225
  >;
226
+
227
+ export type ContentData = {
228
+ header: {
229
+ label?: string,
230
+ description?: { id?: string, message: string, properties?: Object },
231
+ },
232
+ elements: Array<PropertiesElement | TextFragmentElement | ContentElement>,
233
+ };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.retrieveText = void 0;
7
+
8
+ var _objects = require("./objects");
9
+
10
+ /**
11
+ * Handles text that is in the ApplicationMessage form ({ id: string, message: string, properties: object })
12
+ * @param text
13
+ * @returns {string}
14
+ */
15
+ var retrieveText = function retrieveText(text) {
16
+ if (typeof text === "string") {
17
+ return text;
18
+ }
19
+
20
+ if ((0, _objects.isPlainObject)(text) && "message" in text) {
21
+ return text.message;
22
+ }
23
+
24
+ return "";
25
+ };
26
+
27
+ exports.retrieveText = retrieveText;
28
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1,23 @@
1
+ // @flow
2
+ import { isPlainObject } from "./objects";
3
+
4
+ /**
5
+ * Handles text that is in the ApplicationMessage form ({ id: string, message: string, properties: object })
6
+ * @param text
7
+ * @returns {string}
8
+ */
9
+ export const retrieveText = (
10
+ text:
11
+ | string
12
+ | { id?: string, message: string, properties?: { [key: string]: any } }
13
+ ): string => {
14
+ if (typeof text === "string") {
15
+ return text;
16
+ }
17
+
18
+ if (isPlainObject(text) && "message" in text) {
19
+ return text.message;
20
+ }
21
+
22
+ return "";
23
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/helpers/text.js"],"names":["retrieveText","text","message"],"mappings":";;;;;;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAC1BC,IAD0B,EAIf;AACX,MAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AAC5B,WAAOA,IAAP;AACD;;AAED,MAAI,4BAAcA,IAAd,KAAuB,aAAaA,IAAxC,EAA8C;AAC5C,WAAOA,IAAI,CAACC,OAAZ;AACD;;AAED,SAAO,EAAP;AACD,CAdM","sourcesContent":["// @flow\nimport { isPlainObject } from \"./objects\";\n\n/**\n * Handles text that is in the ApplicationMessage form ({ id: string, message: string, properties: object })\n * @param text\n * @returns {string}\n */\nexport const retrieveText = (\n text:\n | string\n | { id?: string, message: string, properties?: { [key: string]: any } }\n): string => {\n if (typeof text === \"string\") {\n return text;\n }\n\n if (isPlainObject(text) && \"message\" in text) {\n return text.message;\n }\n\n return \"\";\n};\n"],"file":"text.js"}
@@ -139,6 +139,20 @@ _Object$keys(_objects).forEach(function (key) {
139
139
  });
140
140
  });
141
141
 
142
+ var _text = require("./helpers/text");
143
+
144
+ _Object$keys(_text).forEach(function (key) {
145
+ if (key === "default" || key === "__esModule") return;
146
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
147
+ if (key in exports && exports[key] === _text[key]) return;
148
+ Object.defineProperty(exports, key, {
149
+ enumerable: true,
150
+ get: function get() {
151
+ return _text[key];
152
+ }
153
+ });
154
+ });
155
+
142
156
  var _DecimalFormat = _interopRequireDefault(require("./number/DecimalFormat"));
143
157
 
144
158
  var _formatValue = _interopRequireDefault(require("./number/formatValue"));
@@ -18,6 +18,7 @@ export * from "./helpers/createHash";
18
18
  export { default as createUUID } from "./helpers/createUUID";
19
19
  export * from "./helpers/sanitizeHtml";
20
20
  export * from "./helpers/objects";
21
+ export * from "./helpers/text";
21
22
 
22
23
  // number
23
24
  export { default as DecimalFormat } from "./number/DecimalFormat";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAIA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// @flow\n\n// browser\nexport { default as Cache } from \"./browser/Cache\";\nexport * from \"./browser/Cookies\";\n\n// datetime\nexport * from \"./datetime/DateTimeUtil\";\n\n// fetch\nexport { default as serverFetch } from \"./fetch/serverFetch\";\nexport { default as universalFetch } from \"./fetch/universalFetch\";\nexport { default as xhr } from \"./fetch/xhr\";\nexport type * from \"./fetch/types\";\n\n// helpers\nexport * from \"./helpers/createHash\";\nexport { default as createUUID } from \"./helpers/createUUID\";\nexport * from \"./helpers/sanitizeHtml\";\nexport * from \"./helpers/objects\";\n\n// number\nexport { default as DecimalFormat } from \"./number/DecimalFormat\";\nexport { default as formatValue } from \"./number/formatValue\";\nexport * from \"./number/parseNumbers\";\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAIA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// @flow\n\n// browser\nexport { default as Cache } from \"./browser/Cache\";\nexport * from \"./browser/Cookies\";\n\n// datetime\nexport * from \"./datetime/DateTimeUtil\";\n\n// fetch\nexport { default as serverFetch } from \"./fetch/serverFetch\";\nexport { default as universalFetch } from \"./fetch/universalFetch\";\nexport { default as xhr } from \"./fetch/xhr\";\nexport type * from \"./fetch/types\";\n\n// helpers\nexport * from \"./helpers/createHash\";\nexport { default as createUUID } from \"./helpers/createUUID\";\nexport * from \"./helpers/sanitizeHtml\";\nexport * from \"./helpers/objects\";\nexport * from \"./helpers/text\";\n\n// number\nexport { default as DecimalFormat } from \"./number/DecimalFormat\";\nexport { default as formatValue } from \"./number/formatValue\";\nexport * from \"./number/parseNumbers\";\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.9.0-beta.4",
3
+ "version": "1.9.0-beta.9",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -78,7 +78,7 @@
78
78
  "styled-components": "^5.2.0"
79
79
  },
80
80
  "dependencies": {
81
- "@babel/runtime-corejs3": "^7.15.3",
81
+ "@babel/runtime-corejs3": "^7.15.4",
82
82
  "big.js": "^6.1.1",
83
83
  "date-fns": "^2.23.0",
84
84
  "deepmerge": "^4.2.2",
@@ -94,19 +94,19 @@
94
94
  "setimmediate": "^1.0.5"
95
95
  },
96
96
  "devDependencies": {
97
- "@babel/cli": "^7.14.8",
98
- "@babel/core": "^7.15.0",
99
- "@babel/eslint-parser": "^7.15.0",
97
+ "@babel/cli": "^7.15.4",
98
+ "@babel/core": "^7.15.5",
99
+ "@babel/eslint-parser": "^7.15.4",
100
100
  "@babel/eslint-plugin": "^7.14.5",
101
101
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
102
102
  "@babel/plugin-transform-runtime": "^7.15.0",
103
- "@babel/preset-env": "^7.15.0",
103
+ "@babel/preset-env": "^7.15.4",
104
104
  "@babel/preset-flow": "^7.14.5",
105
105
  "@babel/preset-react": "^7.14.5",
106
106
  "@commitlint/cli": "^13.1.0",
107
107
  "@commitlint/config-conventional": "^13.1.0",
108
108
  "@testing-library/react-hooks": "^7.0.2",
109
- "babel-jest": "^27.1.0",
109
+ "babel-jest": "^27.1.1",
110
110
  "babel-plugin-styled-components": "^1.13.2",
111
111
  "cherry-pick": "^0.5.0",
112
112
  "cross-env": "^7.0.3",
@@ -117,7 +117,7 @@
117
117
  "eslint-plugin-flowtype": "^5.9.2",
118
118
  "eslint-plugin-import": "^2.24.2",
119
119
  "eslint-plugin-jest": "^24.4.0",
120
- "eslint-plugin-jsdoc": "^36.0.8",
120
+ "eslint-plugin-jsdoc": "^36.1.0",
121
121
  "eslint-plugin-react": "^7.25.1",
122
122
  "eslint-plugin-react-hooks": "^4.2.0",
123
123
  "flow-bin": "0.152.0",
@@ -126,7 +126,7 @@
126
126
  "glob": "^7.1.7",
127
127
  "history": "^4.0.0",
128
128
  "husky": "^7.0.2",
129
- "jest": "^27.1.0",
129
+ "jest": "^27.1.1",
130
130
  "jest-junit": "^12.2.0",
131
131
  "jest-sonar-reporter": "^2.0.0",
132
132
  "jscodeshift": "^0.13.0",
@@ -136,8 +136,8 @@
136
136
  "react": "^17.0.2",
137
137
  "react-dom": "^17.0.2",
138
138
  "react-helmet-async": "^1.1.2",
139
- "react-redux": "^7.2.4",
140
- "react-router-dom": "^5.2.1",
139
+ "react-redux": "^7.2.5",
140
+ "react-router-dom": "^5.3.0",
141
141
  "react-test-renderer": "^17.0.2",
142
142
  "redux": "^4.1.1",
143
143
  "redux-mock-store": "^1.5.4",
@@ -1,5 +1,6 @@
1
1
  // @flow
2
2
  import { isPlainObject, has } from "../utils/helpers/objects";
3
+ import { ALL_CONTENT_IN_DATA_SETTING } from "./Constants";
3
4
 
4
5
  type Setting = boolean | string | number | Array<string>;
5
6
 
@@ -69,7 +70,7 @@ let settings = defaultSettings;
69
70
 
70
71
  /**
71
72
  */
72
- const setSettings = (config: Object) => {
73
+ export const setSettings = (config: Object) => {
73
74
  if (isPlainObject(config)) {
74
75
  settings = Object.assign(defaultSettings, config);
75
76
  }
@@ -77,7 +78,7 @@ const setSettings = (config: Object) => {
77
78
 
78
79
  /**
79
80
  */
80
- const getSetting = (key: string, defaultValue?: any): any => {
81
+ export const getSetting = (key: string, defaultValue?: any): any => {
81
82
  if (!has(settings, key) && defaultValue === undefined) {
82
83
  throw new Error(
83
84
  `Setting with name ${key} not found and no defaultValue given`
@@ -89,12 +90,15 @@ const getSetting = (key: string, defaultValue?: any): any => {
89
90
 
90
91
  /**
91
92
  */
92
- const setSetting = (key: string, value: any) => {
93
+ export const setSetting = (key: string, value: any) => {
93
94
  settings[key] = value;
94
95
  };
95
96
 
96
97
  /**
97
98
  */
98
- const allSettings = (): { [name: string]: Setting } => settings;
99
+ export const allSettings = (): { [name: string]: Setting } => settings;
99
100
 
100
- export { getSetting, setSetting, setSettings, allSettings };
101
+ /**
102
+ */
103
+ export const hasAllContentInData = (): boolean =>
104
+ getSetting(ALL_CONTENT_IN_DATA_SETTING, true);
@@ -1,5 +1,6 @@
1
1
  // @flow
2
- import { ALL_CONTENT_IN_DATA_SETTING, getSetting } from "../../constants";
2
+ import { retrieveText } from "../../utils/helpers/text";
3
+ import { hasAllContentInData } from "../../constants/Settings";
3
4
  import SectionModel from "../content/SectionModel";
4
5
 
5
6
  import type {
@@ -20,35 +21,88 @@ class AttributeContent {
20
21
  /**
21
22
  */
22
23
  get fromData(): boolean {
23
- return getSetting(ALL_CONTENT_IN_DATA_SETTING, true);
24
+ return hasAllContentInData();
24
25
  }
25
26
 
26
27
  /**
27
28
  */
28
- get label(): ?string {
29
- return this._content?.label;
29
+ get header(): {
30
+ label: ?string,
31
+ description: ?string,
32
+ } {
33
+ const label = this._content?.header?.label;
34
+ const description = this._content?.header?.description?.message;
35
+
36
+ return { label, description };
30
37
  }
31
38
 
32
39
  /**
33
40
  */
34
- getContentElements<T>(elementName: string, collectionName: string): Array<T> {
41
+ get elements(): ContentAll {
35
42
  if (this._content?.elements) {
36
- return this._content.elements
37
- .filter((element) => {
38
- return elementName in element;
39
- })
40
- .map((element) => element[elementName][collectionName])
41
- .flat();
43
+ return this._content.elements?.map((element) => {
44
+ if ("textFragmentElement" in element) {
45
+ // $FlowIssue
46
+ const { label, id, textfragments } = element.textFragmentElement;
47
+ return {
48
+ textFragmentElement: {
49
+ id,
50
+ label,
51
+ textfragments: textfragments.map((textfragment) => ({
52
+ ...textfragment,
53
+ text: retrieveText(textfragment.text),
54
+ })),
55
+ },
56
+ };
57
+ }
58
+
59
+ if ("contentElement" in element) {
60
+ // $FlowIssue
61
+ const { label, sections } = element.contentElement;
62
+ return {
63
+ contentElement: {
64
+ label,
65
+ sections: sections.map(
66
+ (section) => new SectionModel(section, null)
67
+ ),
68
+ },
69
+ };
70
+ }
71
+
72
+ // $FlowIssue
73
+ return element;
74
+ });
42
75
  }
43
76
 
44
77
  return [];
45
78
  }
46
79
 
80
+ /**
81
+ */
82
+ get label(): ?string {
83
+ return this.header.label;
84
+ }
85
+
86
+ /**
87
+ */
88
+ get description(): ?string {
89
+ return this.header.description;
90
+ }
91
+
92
+ /**
93
+ */
94
+ getContentElements<T>(elementName: string, collectionName: string): Array<T> {
95
+ return this.elements
96
+ .filter((element) => elementName in element)
97
+ .map((element) => element[elementName][collectionName])
98
+ .flat();
99
+ }
100
+
47
101
  /**
48
102
  */
49
103
  get properties(): Array<PropertyData> {
50
104
  return this.getContentElements<PropertyData>(
51
- "propertiesElement",
105
+ "propertyElement",
52
106
  "properties"
53
107
  );
54
108
  }
@@ -81,10 +135,7 @@ class AttributeContent {
81
135
  /**
82
136
  */
83
137
  get sections(): Array<SectionModel> {
84
- return this.getContentElements<SectionModel>(
85
- "contentElement",
86
- "sections"
87
- ).map((section) => new SectionModel(section, null));
138
+ return this.getContentElements<SectionModel>("contentElement", "sections");
88
139
  }
89
140
 
90
141
  /**
@@ -104,32 +155,6 @@ class AttributeContent {
104
155
 
105
156
  return referredSections;
106
157
  }
107
-
108
- /**
109
- */
110
- get all(): ContentAll {
111
- if (this._content?.elements) {
112
- return this._content.elements?.map((element) => {
113
- if ("contentElement" in element) {
114
- // $FlowIssue
115
- const { label, sections } = element.contentElement;
116
- return {
117
- contentElement: {
118
- label,
119
- sections: sections.map(
120
- (section) => new SectionModel(section, null)
121
- ),
122
- },
123
- };
124
- }
125
-
126
- // $FlowIssue
127
- return element;
128
- });
129
- }
130
-
131
- return [];
132
- }
133
158
  }
134
159
 
135
160
  export default AttributeContent;
@@ -63,7 +63,11 @@ class AttributeDataHelper {
63
63
  );
64
64
  }
65
65
  } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {
66
- return data[parentKey];
66
+ const parentData = data[parentKey];
67
+ if (isPlainObject(parentData) && data.content?.[childKey]) {
68
+ return { ...parentData, content: data.content[childKey] };
69
+ }
70
+ return parentData;
67
71
  } else if (has(data, childKey) && isPlainObject(data[childKey])) {
68
72
  return data[childKey];
69
73
  }
@@ -87,13 +91,22 @@ class AttributeDataHelper {
87
91
  ? data.dynamicschema
88
92
  : undefined;
89
93
 
94
+ let dynamicschemaId = null;
95
+ if (keyObject.dynamicschemaId) {
96
+ dynamicschemaId = keyObject.dynamicschemaId;
97
+ } else if (
98
+ isPlainObject(data) &&
99
+ typeof data.key === "string" &&
100
+ keyObject.key
101
+ ) {
102
+ dynamicschemaId = `${data.key}.${keyObject.key}`;
103
+ }
104
+
90
105
  return new AttributeDataHelper(
91
106
  {
92
107
  ...childData,
93
108
  dynamicschema,
94
- dynamicschemaId: keyObject.dynamicschemaId
95
- ? keyObject.dynamicschemaId
96
- : void 0,
109
+ dynamicschemaId,
97
110
  },
98
111
  keyObject.key,
99
112
  keyObject.children
@@ -250,7 +263,19 @@ class AttributeDataHelper {
250
263
  /**
251
264
  */
252
265
  get content(): Object {
253
- return this._attribute.content ?? null;
266
+ if (this._attribute.content) {
267
+ const pickedContent = pick(this._attribute.content, [
268
+ "header",
269
+ "label",
270
+ "description",
271
+ "elements",
272
+ ]);
273
+ if (Object.keys(pickedContent).length > 0) {
274
+ return pickedContent;
275
+ }
276
+ }
277
+
278
+ return null;
254
279
  }
255
280
 
256
281
  /**