@beinformed/ui 1.21.1 → 1.21.4

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 (60) hide show
  1. package/CHANGELOG.md +20 -4
  2. package/esm/models/attributes/AttributeModel.js +2 -2
  3. package/esm/models/attributes/AttributeModel.js.map +1 -1
  4. package/esm/models/attributes/ChoiceAttributeModel.js +2 -1
  5. package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
  6. package/esm/models/attributes/DatetimeAttributeModel.js +2 -1
  7. package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
  8. package/esm/models/error/ErrorCollection.js +7 -6
  9. package/esm/models/error/ErrorCollection.js.map +1 -1
  10. package/esm/models/error/ErrorModel.js +2 -1
  11. package/esm/models/error/ErrorModel.js.map +1 -1
  12. package/esm/models/error/ErrorResponse.js +46 -32
  13. package/esm/models/error/ErrorResponse.js.map +1 -1
  14. package/esm/models/form/FormModel.js +5 -4
  15. package/esm/models/form/FormModel.js.map +1 -1
  16. package/esm/models/form/FormObjectModel.js +1 -1
  17. package/esm/models/form/FormObjectModel.js.map +1 -1
  18. package/esm/models/grouping/GroupingModel.js +36 -8
  19. package/esm/models/grouping/GroupingModel.js.map +1 -1
  20. package/esm/models/types.js.map +1 -1
  21. package/lib/models/attributes/AttributeModel.js +2 -2
  22. package/lib/models/attributes/AttributeModel.js.flow +2 -0
  23. package/lib/models/attributes/AttributeModel.js.map +1 -1
  24. package/lib/models/attributes/ChoiceAttributeModel.js +2 -1
  25. package/lib/models/attributes/ChoiceAttributeModel.js.flow +2 -2
  26. package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
  27. package/lib/models/attributes/DatetimeAttributeModel.js +2 -1
  28. package/lib/models/attributes/DatetimeAttributeModel.js.flow +2 -2
  29. package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
  30. package/lib/models/error/ErrorCollection.js +7 -5
  31. package/lib/models/error/ErrorCollection.js.flow +6 -3
  32. package/lib/models/error/ErrorCollection.js.map +1 -1
  33. package/lib/models/error/ErrorModel.js +2 -1
  34. package/lib/models/error/ErrorModel.js.flow +5 -2
  35. package/lib/models/error/ErrorModel.js.map +1 -1
  36. package/lib/models/error/ErrorResponse.js +46 -32
  37. package/lib/models/error/ErrorResponse.js.flow +31 -24
  38. package/lib/models/error/ErrorResponse.js.map +1 -1
  39. package/lib/models/form/FormModel.js +5 -3
  40. package/lib/models/form/FormModel.js.flow +8 -1
  41. package/lib/models/form/FormModel.js.map +1 -1
  42. package/lib/models/form/FormObjectModel.js +1 -1
  43. package/lib/models/form/FormObjectModel.js.flow +1 -0
  44. package/lib/models/form/FormObjectModel.js.map +1 -1
  45. package/lib/models/grouping/GroupingModel.js +36 -8
  46. package/lib/models/grouping/GroupingModel.js.flow +38 -10
  47. package/lib/models/grouping/GroupingModel.js.map +1 -1
  48. package/lib/models/types.js.flow +1 -1
  49. package/lib/models/types.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/models/attributes/AttributeModel.js +2 -0
  52. package/src/models/attributes/ChoiceAttributeModel.js +2 -2
  53. package/src/models/attributes/DatetimeAttributeModel.js +2 -2
  54. package/src/models/error/ErrorCollection.js +6 -3
  55. package/src/models/error/ErrorModel.js +5 -2
  56. package/src/models/error/ErrorResponse.js +31 -24
  57. package/src/models/form/FormModel.js +8 -1
  58. package/src/models/form/FormObjectModel.js +1 -0
  59. package/src/models/grouping/GroupingModel.js +38 -10
  60. package/src/models/types.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FormObjectModel.js","names":["FormObjectModel","BaseModel","constructor","object","objectContributions","getElements","length","_attributeCollection","AttributeCollection","getApplicableAttributeContributions","_contentConfiguration","ContentConfiguration","content","_errorCollection","ErrorCollection","has","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","createEmpty","formObjectModel","IllegalArgumentException","contributions","equals","withRepeatIndex","key","objectContainsOneOfTheAttributes","all","attribute","isResult","some","hasAttributeByKey","hasSameRepeatIndex","repeatIndex","getAttributeByAttribute","getAttributeByKey","elements","push","results","dataResults","result","elementid","dataElementIds","element","getAttributesInData","attributes","isDynamic","attributeKey","mandatory","attributesContributions","attributeContributions","dataElementId","split","getInitialChildModelLinks","setChildModels","models","objectid","hasEndResultConfiguration","getContribution","hasDynamicValidations","isRepeatable","_repeatIndex","index","maxRepeats","hasFixedNrOfRepeats","isRepeatWithUnknownTotal","isLastRepeat","last","repeatIndexLabel","label","introText","text","message","assistent","buttonLabels","mergeObject","oldObject","forEach","mergeWithAttribute","mergeAttribute","updateAttribute","value","attributeToUpdate","Error","name","CompositeAttributeModel","update","isChangedSince","timestamp","resetErrors","errorCollection","addServerError","error","anchor","id","properties","hasServerErrors","hasItems","hasErrors","isValid","visible","every","dynamicValidationsLoaded","_dynamicValidationsLoaded","updateValidations","attributeErrors","Array","isArray","errors","missing","anchors","formdata","getFormData","validationData"],"sources":["../../../src/models/form/FormObjectModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport ErrorCollection from \"../error/ErrorCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type { AttributeType, ModularUIModel, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Form Object\n */\nexport default class FormObjectModel extends BaseModel {\n _attributeCollection: AttributeCollection;\n _contentConfiguration: ContentConfiguration;\n _errorCollection: ErrorCollection;\n _repeatIndex: number;\n _dynamicValidationsLoaded: boolean;\n\n /**\n * Construct FormObjectModel\n */\n constructor(object: Object, objectContributions: Object) {\n super(object, objectContributions);\n\n if (object && this.getElements().length > 0) {\n this._attributeCollection = new AttributeCollection(\n this.getElements(),\n this.getApplicableAttributeContributions()\n );\n } else {\n this._attributeCollection = new AttributeCollection();\n }\n\n this._contentConfiguration = new ContentConfiguration(\n objectContributions ? objectContributions.content : {}\n );\n\n this._errorCollection = new ErrorCollection(\"formobject\");\n\n if (has(this.data, \"referenceDate\")) {\n this.attributeCollection.setReferenceDate(this.getData(\"referenceDate\"));\n }\n\n this.attributeCollection.indicateContentConfiguration(\n this.contentConfiguration\n );\n }\n\n /**\n */\n static createEmpty(formObjectModel: FormObjectModel): FormObjectModel {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\n \"createEmpty method needs a FormObjectModel as input argument to create a new version of the object\"\n );\n }\n return new FormObjectModel(\n formObjectModel.data,\n formObjectModel.contributions\n );\n }\n\n /**\n */\n equals(object: ?FormObjectModel, withRepeatIndex: boolean = true): boolean {\n if (!object || this.key !== object.key) {\n return false;\n }\n\n const objectContainsOneOfTheAttributes = this.attributeCollection.all\n .filter((attribute) => !attribute.isResult)\n .some(\n (attribute) =>\n object && object.attributeCollection.hasAttributeByKey(attribute.key)\n );\n\n const hasSameRepeatIndex = withRepeatIndex\n ? this.repeatIndex === object.repeatIndex\n : true;\n\n return hasSameRepeatIndex && objectContainsOneOfTheAttributes;\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.attributeCollection.getAttributeByAttribute(attribute);\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.attributeCollection.hasAttributeByKey(key);\n }\n\n /**\n * Get elements from both the missing attributes and the result attributes\n */\n getElements(): Array<Object> {\n const elements = [];\n\n if (this.data.elements) {\n elements.push(...this.data.elements);\n }\n\n if (this.data.results) {\n const dataResults = this.data.results.map((result) => ({\n ...result,\n isResult: true,\n }));\n\n elements.push(...dataResults);\n }\n\n if (this.data.elementid) {\n elements.push({\n ...this.data,\n });\n }\n\n return elements;\n }\n\n /**\n * Map available contributions on the available data. Only use contributions that are needed for the data\n */\n getApplicableAttributeContributions(): Array<Object> {\n if (this.data && this.contributions) {\n const dataElementIds = this.getElements().map(\n (element) => element.elementid\n );\n\n const contributions = this.getAttributesInData(\n dataElementIds,\n this.contributions.attributes\n );\n\n // set all attribute mandatory for dynamic object\n if (this.isDynamic) {\n return contributions.map((attribute) => {\n const [attributeKey] = Object.keys(attribute);\n return {\n [attributeKey]: {\n ...attribute[attributeKey],\n mandatory: true,\n },\n };\n });\n }\n\n return contributions;\n }\n\n return [];\n }\n\n /**\n * Recursevily check if an attribute id occurs in the tree of attribute contributions.\n * The complete leaf of the tree is returned when an attribute id matches\n */\n getAttributesInData(\n dataElementIds: Array<string>,\n attributesContributions: Object\n ): Array<Object> {\n return attributesContributions.filter((attributeContributions) => {\n const [attributeKey] = Object.keys(attributeContributions);\n\n return dataElementIds.some(\n (dataElementId) => dataElementId.split(\".\")[0] === attributeKey\n );\n });\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this._attributeCollection.getInitialChildModelLinks();\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this._attributeCollection.setChildModels(models);\n }\n\n /**\n * get key\n */\n get key(): string {\n return this.data.objectid;\n }\n\n /**\n * Get content configuration for form objects\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n get hasEndResultConfiguration(): boolean {\n return this.contributions.content?.results != null;\n }\n\n /**\n * Indicates if object is dynamic. A dynamic object should be submitted on each attribute change\n */\n get isDynamic(): boolean {\n return this.getContribution(\"dynamicObject\", false);\n }\n\n /**\n */\n get hasDynamicValidations(): boolean {\n return this.getContribution(\"dynamicValidations\", false);\n }\n\n /**\n * Indicates if object is repeatable\n */\n get isRepeatable(): boolean {\n return this.getContribution(\"repeatable\", false);\n }\n\n /**\n */\n get repeatIndex(): number {\n return this._repeatIndex ?? this.data.index ?? 1;\n }\n\n /**\n */\n set repeatIndex(repeatIndex: number) {\n this._repeatIndex = repeatIndex;\n }\n\n /**\n */\n get maxRepeats(): number {\n if (this.isRepeatable) {\n return this.getData(\"numberofrepeats\", -1);\n }\n\n return 1;\n }\n\n /**\n */\n get hasFixedNrOfRepeats(): boolean {\n return this.maxRepeats > -1;\n }\n\n /**\n */\n get isRepeatWithUnknownTotal(): boolean {\n return this.isRepeatable && this.maxRepeats === -1;\n }\n\n /**\n */\n get isLastRepeat(): boolean {\n if (this.isRepeatable) {\n return this.data.last || false;\n }\n\n return true;\n }\n\n /**\n */\n get repeatIndexLabel(): string | null {\n return this.data[\"index-identifier\"] || null;\n }\n\n /**\n * Get label of form object\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n * Get introText of form object\n */\n get introText(): string {\n if (this.data.content?.text) {\n return this.data.content.text.message;\n }\n\n if (this.contributions.text?.message) {\n return this.contributions.text.message;\n }\n\n return this.contributions.introText;\n }\n\n /**\n * Get assistent of form object\n */\n get assistent(): string {\n return this.contributions.assistent;\n }\n\n /**\n * Get button labels\n */\n get buttonLabels(): Object {\n return this.getContribution(\"buttonLabels\", {});\n }\n\n /**\n * get attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(attributeCollection: AttributeCollection) {\n this._attributeCollection = attributeCollection;\n }\n\n /**\n */\n mergeObject(oldObject: FormObjectModel) {\n this.attributeCollection.forEach((attribute) => {\n const mergeWithAttribute = oldObject.getAttributeByAttribute(attribute);\n if (mergeWithAttribute) {\n attribute.mergeAttribute(mergeWithAttribute);\n }\n });\n\n this.repeatIndex = oldObject.repeatIndex;\n }\n\n /**\n * Update attribute\n */\n updateAttribute(attribute: AttributeType, value: any): AttributeType {\n const attributeToUpdate =\n this.attributeCollection.getAttributeByAttribute(attribute);\n\n if (attributeToUpdate === null) {\n throw new Error(`Attribute with name: ${attribute.name} not found.`);\n }\n\n if (attributeToUpdate instanceof CompositeAttributeModel) {\n attributeToUpdate.update(value, attribute);\n } else {\n attributeToUpdate.update(value);\n }\n\n return attributeToUpdate;\n }\n\n /**\n * Inidicates if Form is changed since a given timestamp (Date.now)\n */\n isChangedSince(timestamp: number): boolean {\n return (\n this.attributeCollection.find((attribute) =>\n attribute.isChangedSince(timestamp)\n ) !== null\n );\n }\n\n /**\n * Reset all errors on Form Object\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"formobject\");\n this.attributeCollection.forEach((attribute) => attribute.resetErrors());\n }\n\n /**\n * Get error messages\n */\n get errorCollection(): ErrorCollection {\n return this._errorCollection;\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n if (error.anchor?.elementid != null) {\n this.attributeCollection.addServerError(error);\n } else {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n error.properties\n );\n }\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.attributeCollection.hasServerErrors()\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems || this.attributeCollection.hasErrors()\n );\n }\n\n /**\n */\n get isValid(): boolean {\n return (\n this.attributeCollection.visible.every(\n (attribute) => attribute.isValid\n ) && !this.errorCollection.hasItems\n );\n }\n\n /**\n */\n get dynamicValidationsLoaded(): boolean {\n return this._dynamicValidationsLoaded;\n }\n\n /**\n */\n set dynamicValidationsLoaded(dynamicValidationsLoaded: boolean) {\n this._dynamicValidationsLoaded = dynamicValidationsLoaded;\n }\n\n /**\n */\n updateValidations(data: any): FormObjectModel {\n this.resetErrors();\n\n const attributeErrors = [];\n\n if (Array.isArray(data.errors)) {\n data.errors.forEach((error) => {\n if (error.anchor?.objectid === this.key) {\n if (has(error.anchor, \"elementid\")) {\n attributeErrors.push(error);\n } else {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties\n );\n }\n }\n });\n }\n\n // missing attribute errors\n if (Array.isArray(data.missing?.anchors)) {\n attributeErrors.push(\n ...data.missing.anchors.map((anchor) => ({\n anchor,\n id: \"Constraint.Mandatory\",\n }))\n );\n }\n\n this.attributeCollection.updateValidations(attributeErrors);\n\n this.dynamicValidationsLoaded = true;\n\n return this;\n }\n\n /**\n * Generate formdata object for current formobject based on formdata of attributes\n */\n get formdata(): { [string]: any } | null {\n return this.attributeCollection.formdata;\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n return this.attributeCollection.getFormData(validationData);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;AACA;AACA;AACe,MAAMA,eAAN,SAA8BC,kBAA9B,CAAwC;EAOrD;AACF;AACA;EACEC,WAAW,CAACC,MAAD,EAAiBC,mBAAjB,EAA8C;IACvD,MAAMD,MAAN,EAAcC,mBAAd;IADuD;IAAA;IAAA;IAAA;IAAA;;IAGvD,IAAID,MAAM,IAAI,KAAKE,WAAL,GAAmBC,MAAnB,GAA4B,CAA1C,EAA6C;MAC3C,KAAKC,oBAAL,GAA4B,IAAIC,4BAAJ,CAC1B,KAAKH,WAAL,EAD0B,EAE1B,KAAKI,mCAAL,EAF0B,CAA5B;IAID,CALD,MAKO;MACL,KAAKF,oBAAL,GAA4B,IAAIC,4BAAJ,EAA5B;IACD;;IAED,KAAKE,qBAAL,GAA6B,IAAIC,6BAAJ,CAC3BP,mBAAmB,GAAGA,mBAAmB,CAACQ,OAAvB,GAAiC,EADzB,CAA7B;IAIA,KAAKC,gBAAL,GAAwB,IAAIC,wBAAJ,CAAoB,YAApB,CAAxB;;IAEA,IAAI,IAAAC,YAAA,EAAI,KAAKC,IAAT,EAAe,eAAf,CAAJ,EAAqC;MACnC,KAAKC,mBAAL,CAAyBC,gBAAzB,CAA0C,KAAKC,OAAL,CAAa,eAAb,CAA1C;IACD;;IAED,KAAKF,mBAAL,CAAyBG,4BAAzB,CACE,KAAKC,oBADP;EAGD;EAED;AACF;;;EACoB,OAAXC,WAAW,CAACC,eAAD,EAAoD;IACpE,IAAI,CAACA,eAAL,EAAsB;MACpB,MAAM,IAAIC,oCAAJ,CACJ,oGADI,C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,CAAc9F,IAAI,CAAC+F,MAAnB,CAAJ,EAAgC;MAC9B/F,IAAI,CAAC+F,MAAL,CAAY/B,OAAZ,CAAqBe,KAAD,IAAW;QAAA;;QAC7B,IAAI,mBAAAA,KAAK,CAACC,MAAN,kEAAcrC,QAAd,MAA2B,KAAK/B,GAApC,EAAyC;UACvC,IAAI,IAAAb,YAAA,EAAIgF,KAAK,CAACC,MAAV,EAAkB,WAAlB,CAAJ,EAAoC;YAClCY,eAAe,CAACpE,IAAhB,CAAqBuD,KAArB;UACD,CAFD,MAEO;YACL,KAAKF,eAAL,CAAqBC,cAArB,CACEC,KAAK,CAACE,EADR,EAEEF,KAAK,CAACpB,OAFR,EAGEoB,KAAK,CAACG,UAHR;UAKD;QACF;MACF,CAZD;IAaD,CAnB2C,CAqB5C;;;IACA,IAAIW,KAAK,CAACC,OAAN,kBAAc9F,IAAI,CAACgG,OAAnB,kDAAc,cAAcC,OAA5B,CAAJ,EAA0C;MAAA;;MACxCL,eAAe,CAACpE,IAAhB,CACE,GAAG,8BAAAxB,IAAI,CAACgG,OAAL,CAAaC,OAAb,kBAA0BjB,MAAD,KAAa;QACvCA,MADuC;QAEvCC,EAAE,EAAE;MAFmC,CAAb,CAAzB,CADL;IAMD;;IAED,KAAKhF,mBAAL,CAAyB0F,iBAAzB,CAA2CC,eAA3C;IAEA,KAAKH,wBAAL,GAAgC,IAAhC;IAEA,OAAO,IAAP;EACD;EAED;AACF;AACA;;;EACc,IAARS,QAAQ,GAA6B;IACvC,OAAO,KAAKjG,mBAAL,CAAyBiG,QAAhC;EACD;EAED;AACF;;;EACEC,WAAW,GAA4D;IAAA,IAA3DC,cAA2D,uEAAjC,KAAiC;IACrE,OAAO,KAAKnG,mBAAL,CAAyBkG,WAAzB,CAAqCC,cAArC,CAAP;EACD;;AAneoD"}
1
+ {"version":3,"file":"FormObjectModel.js","names":["FormObjectModel","BaseModel","constructor","object","objectContributions","getElements","length","_attributeCollection","AttributeCollection","getApplicableAttributeContributions","_contentConfiguration","ContentConfiguration","content","_errorCollection","ErrorCollection","has","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","createEmpty","formObjectModel","IllegalArgumentException","contributions","equals","withRepeatIndex","key","objectContainsOneOfTheAttributes","all","attribute","isResult","some","hasAttributeByKey","hasSameRepeatIndex","repeatIndex","getAttributeByAttribute","getAttributeByKey","elements","push","results","dataResults","result","elementid","dataElementIds","element","getAttributesInData","attributes","isDynamic","attributeKey","mandatory","attributesContributions","attributeContributions","dataElementId","split","getInitialChildModelLinks","setChildModels","models","objectid","hasEndResultConfiguration","getContribution","hasDynamicValidations","isRepeatable","_repeatIndex","index","maxRepeats","hasFixedNrOfRepeats","isRepeatWithUnknownTotal","isLastRepeat","last","repeatIndexLabel","label","introText","text","message","assistent","buttonLabels","mergeObject","oldObject","forEach","mergeWithAttribute","mergeAttribute","updateAttribute","value","attributeToUpdate","Error","name","CompositeAttributeModel","update","isChangedSince","timestamp","resetErrors","errorCollection","addServerError","error","anchor","id","layouthint","properties","hasServerErrors","hasItems","hasErrors","isValid","visible","every","dynamicValidationsLoaded","_dynamicValidationsLoaded","updateValidations","attributeErrors","Array","isArray","errors","missing","anchors","formdata","getFormData","validationData"],"sources":["../../../src/models/form/FormObjectModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport ErrorCollection from \"../error/ErrorCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type { AttributeType, ModularUIModel, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Form Object\n */\nexport default class FormObjectModel extends BaseModel {\n _attributeCollection: AttributeCollection;\n _contentConfiguration: ContentConfiguration;\n _errorCollection: ErrorCollection;\n _repeatIndex: number;\n _dynamicValidationsLoaded: boolean;\n\n /**\n * Construct FormObjectModel\n */\n constructor(object: Object, objectContributions: Object) {\n super(object, objectContributions);\n\n if (object && this.getElements().length > 0) {\n this._attributeCollection = new AttributeCollection(\n this.getElements(),\n this.getApplicableAttributeContributions()\n );\n } else {\n this._attributeCollection = new AttributeCollection();\n }\n\n this._contentConfiguration = new ContentConfiguration(\n objectContributions ? objectContributions.content : {}\n );\n\n this._errorCollection = new ErrorCollection(\"formobject\");\n\n if (has(this.data, \"referenceDate\")) {\n this.attributeCollection.setReferenceDate(this.getData(\"referenceDate\"));\n }\n\n this.attributeCollection.indicateContentConfiguration(\n this.contentConfiguration\n );\n }\n\n /**\n */\n static createEmpty(formObjectModel: FormObjectModel): FormObjectModel {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\n \"createEmpty method needs a FormObjectModel as input argument to create a new version of the object\"\n );\n }\n return new FormObjectModel(\n formObjectModel.data,\n formObjectModel.contributions\n );\n }\n\n /**\n */\n equals(object: ?FormObjectModel, withRepeatIndex: boolean = true): boolean {\n if (!object || this.key !== object.key) {\n return false;\n }\n\n const objectContainsOneOfTheAttributes = this.attributeCollection.all\n .filter((attribute) => !attribute.isResult)\n .some(\n (attribute) =>\n object && object.attributeCollection.hasAttributeByKey(attribute.key)\n );\n\n const hasSameRepeatIndex = withRepeatIndex\n ? this.repeatIndex === object.repeatIndex\n : true;\n\n return hasSameRepeatIndex && objectContainsOneOfTheAttributes;\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.attributeCollection.getAttributeByAttribute(attribute);\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.attributeCollection.hasAttributeByKey(key);\n }\n\n /**\n * Get elements from both the missing attributes and the result attributes\n */\n getElements(): Array<Object> {\n const elements = [];\n\n if (this.data.elements) {\n elements.push(...this.data.elements);\n }\n\n if (this.data.results) {\n const dataResults = this.data.results.map((result) => ({\n ...result,\n isResult: true,\n }));\n\n elements.push(...dataResults);\n }\n\n if (this.data.elementid) {\n elements.push({\n ...this.data,\n });\n }\n\n return elements;\n }\n\n /**\n * Map available contributions on the available data. Only use contributions that are needed for the data\n */\n getApplicableAttributeContributions(): Array<Object> {\n if (this.data && this.contributions) {\n const dataElementIds = this.getElements().map(\n (element) => element.elementid\n );\n\n const contributions = this.getAttributesInData(\n dataElementIds,\n this.contributions.attributes\n );\n\n // set all attribute mandatory for dynamic object\n if (this.isDynamic) {\n return contributions.map((attribute) => {\n const [attributeKey] = Object.keys(attribute);\n return {\n [attributeKey]: {\n ...attribute[attributeKey],\n mandatory: true,\n },\n };\n });\n }\n\n return contributions;\n }\n\n return [];\n }\n\n /**\n * Recursevily check if an attribute id occurs in the tree of attribute contributions.\n * The complete leaf of the tree is returned when an attribute id matches\n */\n getAttributesInData(\n dataElementIds: Array<string>,\n attributesContributions: Object\n ): Array<Object> {\n return attributesContributions.filter((attributeContributions) => {\n const [attributeKey] = Object.keys(attributeContributions);\n\n return dataElementIds.some(\n (dataElementId) => dataElementId.split(\".\")[0] === attributeKey\n );\n });\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this._attributeCollection.getInitialChildModelLinks();\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this._attributeCollection.setChildModels(models);\n }\n\n /**\n * get key\n */\n get key(): string {\n return this.data.objectid;\n }\n\n /**\n * Get content configuration for form objects\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n get hasEndResultConfiguration(): boolean {\n return this.contributions.content?.results != null;\n }\n\n /**\n * Indicates if object is dynamic. A dynamic object should be submitted on each attribute change\n */\n get isDynamic(): boolean {\n return this.getContribution(\"dynamicObject\", false);\n }\n\n /**\n */\n get hasDynamicValidations(): boolean {\n return this.getContribution(\"dynamicValidations\", false);\n }\n\n /**\n * Indicates if object is repeatable\n */\n get isRepeatable(): boolean {\n return this.getContribution(\"repeatable\", false);\n }\n\n /**\n */\n get repeatIndex(): number {\n return this._repeatIndex ?? this.data.index ?? 1;\n }\n\n /**\n */\n set repeatIndex(repeatIndex: number) {\n this._repeatIndex = repeatIndex;\n }\n\n /**\n */\n get maxRepeats(): number {\n if (this.isRepeatable) {\n return this.getData(\"numberofrepeats\", -1);\n }\n\n return 1;\n }\n\n /**\n */\n get hasFixedNrOfRepeats(): boolean {\n return this.maxRepeats > -1;\n }\n\n /**\n */\n get isRepeatWithUnknownTotal(): boolean {\n return this.isRepeatable && this.maxRepeats === -1;\n }\n\n /**\n */\n get isLastRepeat(): boolean {\n if (this.isRepeatable) {\n return this.data.last || false;\n }\n\n return true;\n }\n\n /**\n */\n get repeatIndexLabel(): string | null {\n return this.data[\"index-identifier\"] || null;\n }\n\n /**\n * Get label of form object\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n * Get introText of form object\n */\n get introText(): string {\n if (this.data.content?.text) {\n return this.data.content.text.message;\n }\n\n if (this.contributions.text?.message) {\n return this.contributions.text.message;\n }\n\n return this.contributions.introText;\n }\n\n /**\n * Get assistent of form object\n */\n get assistent(): string {\n return this.contributions.assistent;\n }\n\n /**\n * Get button labels\n */\n get buttonLabels(): Object {\n return this.getContribution(\"buttonLabels\", {});\n }\n\n /**\n * get attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(attributeCollection: AttributeCollection) {\n this._attributeCollection = attributeCollection;\n }\n\n /**\n */\n mergeObject(oldObject: FormObjectModel) {\n this.attributeCollection.forEach((attribute) => {\n const mergeWithAttribute = oldObject.getAttributeByAttribute(attribute);\n if (mergeWithAttribute) {\n attribute.mergeAttribute(mergeWithAttribute);\n }\n });\n\n this.repeatIndex = oldObject.repeatIndex;\n }\n\n /**\n * Update attribute\n */\n updateAttribute(attribute: AttributeType, value: any): AttributeType {\n const attributeToUpdate =\n this.attributeCollection.getAttributeByAttribute(attribute);\n\n if (attributeToUpdate === null) {\n throw new Error(`Attribute with name: ${attribute.name} not found.`);\n }\n\n if (attributeToUpdate instanceof CompositeAttributeModel) {\n attributeToUpdate.update(value, attribute);\n } else {\n attributeToUpdate.update(value);\n }\n\n return attributeToUpdate;\n }\n\n /**\n * Inidicates if Form is changed since a given timestamp (Date.now)\n */\n isChangedSince(timestamp: number): boolean {\n return (\n this.attributeCollection.find((attribute) =>\n attribute.isChangedSince(timestamp)\n ) !== null\n );\n }\n\n /**\n * Reset all errors on Form Object\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"formobject\");\n this.attributeCollection.forEach((attribute) => attribute.resetErrors());\n }\n\n /**\n * Get error messages\n */\n get errorCollection(): ErrorCollection {\n return this._errorCollection;\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n if (error.anchor?.elementid != null) {\n this.attributeCollection.addServerError(error);\n } else {\n this._errorCollection.addServerError(\n error.id,\n error.layouthint,\n error.message,\n error.properties\n );\n }\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.attributeCollection.hasServerErrors()\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems || this.attributeCollection.hasErrors()\n );\n }\n\n /**\n */\n get isValid(): boolean {\n return (\n this.attributeCollection.visible.every(\n (attribute) => attribute.isValid\n ) && !this.errorCollection.hasItems\n );\n }\n\n /**\n */\n get dynamicValidationsLoaded(): boolean {\n return this._dynamicValidationsLoaded;\n }\n\n /**\n */\n set dynamicValidationsLoaded(dynamicValidationsLoaded: boolean) {\n this._dynamicValidationsLoaded = dynamicValidationsLoaded;\n }\n\n /**\n */\n updateValidations(data: any): FormObjectModel {\n this.resetErrors();\n\n const attributeErrors = [];\n\n if (Array.isArray(data.errors)) {\n data.errors.forEach((error) => {\n if (error.anchor?.objectid === this.key) {\n if (has(error.anchor, \"elementid\")) {\n attributeErrors.push(error);\n } else {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties\n );\n }\n }\n });\n }\n\n // missing attribute errors\n if (Array.isArray(data.missing?.anchors)) {\n attributeErrors.push(\n ...data.missing.anchors.map((anchor) => ({\n anchor,\n id: \"Constraint.Mandatory\",\n }))\n );\n }\n\n this.attributeCollection.updateValidations(attributeErrors);\n\n this.dynamicValidationsLoaded = true;\n\n return this;\n }\n\n /**\n * Generate formdata object for current formobject based on formdata of attributes\n */\n get formdata(): { [string]: any } | null {\n return this.attributeCollection.formdata;\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n return this.attributeCollection.getFormData(validationData);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;AACA;AACA;AACe,MAAMA,eAAN,SAA8BC,kBAA9B,CAAwC;EAOrD;AACF;AACA;EACEC,WAAW,CAACC,MAAD,EAAiBC,mBAAjB,EAA8C;IACvD,MAAMD,MAAN,EAAcC,mBAAd;IADuD;IAAA;IAAA;IAAA;IAAA;;IAGvD,IAAID,MAAM,IAAI,KAAKE,WAAL,GAAmBC,MAAnB,GAA4B,CAA1C,EAA6C;MAC3C,KAAKC,oBAAL,GAA4B,IAAIC,4BAAJ,CAC1B,KAAKH,WAAL,EAD0B,EAE1B,KAAKI,mCAAL,EAF0B,CAA5B;IAID,CALD,MAKO;MACL,KAAKF,oBAAL,GAA4B,IAAIC,4BAAJ,EAA5B;IACD;;IAED,KAAKE,qBAAL,GAA6B,IAAIC,6BAAJ,CAC3BP,mBAAmB,GAAGA,mBAAmB,CAACQ,OAAvB,GAAiC,EADzB,CAA7B;IAIA,KAAKC,gBAAL,GAAwB,IAAIC,wBAAJ,CAAoB,YAApB,CAAxB;;IAEA,IAAI,IAAAC,YAAA,EAAI,KAAKC,IAAT,EAAe,eAAf,CAAJ,EAAqC;MACnC,KAAKC,mBAAL,CAAyBC,gBAAzB,CAA0C,KAAKC,OAAL,CA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GAA4D;IAAA,IAA3DC,cAA2D,uEAAjC,KAAiC;IACrE,OAAO,KAAKpG,mBAAL,CAAyBmG,WAAzB,CAAqCC,cAArC,CAAP;EACD;;AApeoD"}
@@ -122,16 +122,44 @@ class GroupingModel {
122
122
  /**
123
123
  */
124
124
  constructor(data, contexts) {
125
- var _context;
126
-
127
125
  (0, _defineProperty2.default)(this, "_prefix", void 0);
128
- (0, _defineProperty2.default)(this, "_groups", void 0);
126
+ (0, _defineProperty2.default)(this, "_groups", []);
129
127
  this._prefix = data && data.prefix ? data.prefix : null;
130
- const context = this.getContextFromContributionsByPrefix(contexts, this._prefix);
131
- const dynamicschema = data && data.dynamicschema;
132
- this._groups = data && data.group ? (0, _map.default)(_context = data.group).call(_context, group => new GroupModel({ ...group,
133
- dynamicschema
134
- }, context, contexts)) : [];
128
+
129
+ if (data !== null && data !== void 0 && data.group) {
130
+ this._groups = this.createGroup(data, contexts);
131
+ }
132
+ }
133
+ /**
134
+ */
135
+
136
+
137
+ createGroup(data, contributions) {
138
+ var _context;
139
+
140
+ const context = this.getContextFromContributionsByPrefix(contributions, this._prefix);
141
+ return (0, _map.default)(_context = data.group).call(_context, group => {
142
+ const dynamicschema = this.getDynamicSchema(group, data.dynamicschema);
143
+ return new GroupModel({ ...group,
144
+ dynamicschema
145
+ }, context, contributions);
146
+ });
147
+ }
148
+ /**
149
+ * add grouped prefix to the dynamicschema
150
+ */
151
+
152
+
153
+ getDynamicSchema(group, dynamicschema) {
154
+ if (dynamicschema) {
155
+ if (this._prefix && dynamicschema[group.type] && !dynamicschema[this._prefix + group.type]) {
156
+ dynamicschema[this._prefix + group.type] = dynamicschema[group.type];
157
+ }
158
+
159
+ return dynamicschema;
160
+ }
161
+
162
+ return null;
135
163
  }
136
164
  /**
137
165
  * Retrieve groups of grouping
@@ -109,26 +109,54 @@ type Context = {
109
109
  */
110
110
  export default class GroupingModel {
111
111
  _prefix: string | null;
112
- _groups: Array<GroupModel>;
112
+ _groups: Array<GroupModel> = [];
113
113
 
114
114
  /**
115
115
  */
116
116
  constructor(data: Object, contexts: Array<Context>) {
117
117
  this._prefix = data && data.prefix ? data.prefix : null;
118
118
 
119
+ if (data?.group) {
120
+ this._groups = this.createGroup(data, contexts);
121
+ }
122
+ }
123
+
124
+ /**
125
+ */
126
+ createGroup(data: Object, contributions: Array<Context>): Array<Object> {
119
127
  const context = this.getContextFromContributionsByPrefix(
120
- contexts,
128
+ contributions,
121
129
  this._prefix
122
130
  );
123
131
 
124
- const dynamicschema = data && data.dynamicschema;
125
- this._groups =
126
- data && data.group
127
- ? data.group.map(
128
- (group) =>
129
- new GroupModel({ ...group, dynamicschema }, context, contexts)
130
- )
131
- : [];
132
+ return data.group.map((group) => {
133
+ const dynamicschema = this.getDynamicSchema(group, data.dynamicschema);
134
+ return new GroupModel(
135
+ {
136
+ ...group,
137
+ dynamicschema,
138
+ },
139
+ context,
140
+ contributions
141
+ );
142
+ });
143
+ }
144
+
145
+ /**
146
+ * add grouped prefix to the dynamicschema
147
+ */
148
+ getDynamicSchema(group: Object, dynamicschema: Object): Object {
149
+ if (dynamicschema) {
150
+ if (
151
+ this._prefix &&
152
+ dynamicschema[group.type] &&
153
+ !dynamicschema[this._prefix + group.type]
154
+ ) {
155
+ dynamicschema[this._prefix + group.type] = dynamicschema[group.type];
156
+ }
157
+ return dynamicschema;
158
+ }
159
+ return null;
132
160
  }
133
161
 
134
162
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"GroupingModel.js","names":["GroupModel","constructor","group","context","contributions","_group","_context","_attributeCollection","AttributeCollection","attributes","grouping","_grouping","GroupingModel","dynamicschema","type","id","_id","label","attributeCollection","reference","hasAttributeByKey","key","getAttributeByKey","data","contexts","_prefix","prefix","getContextFromContributionsByPrefix","_groups","groups","hasGroups","length","some","groupByKey","getGroupByAttributeKey"],"sources":["../../../src/models/grouping/GroupingModel.js"],"sourcesContent":["// @flow\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport type { AttributeType } from \"../types\";\n\n/**\n * Group information model\n * Put GroupModel here because of possible circular dependency with GroupingModel below\n */\nexport class GroupModel {\n _group: Object;\n _context: Object;\n _attributeCollection: AttributeCollection;\n _grouping: ?GroupingModel;\n\n /**\n */\n constructor(group: Object, context: Object, contributions: Array<Object>) {\n this._group = group;\n this._context = context;\n\n this._attributeCollection = new AttributeCollection(\n group,\n context.attributes\n );\n\n if (group.grouping) {\n this._grouping = new GroupingModel(\n { ...group.grouping, dynamicschema: group.dynamicschema },\n contributions\n );\n }\n }\n\n /**\n */\n get type(): string {\n return this._group.type;\n }\n\n /**\n */\n get id(): string {\n return this._group._id || \"unknown\";\n }\n\n /**\n */\n get label(): string {\n return this._context.label;\n }\n\n /**\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n get grouping(): ?GroupingModel {\n return this._grouping;\n }\n\n /**\n * Retrieve array of reference id's\n */\n get reference(): Array<number> {\n return this._group.reference || [];\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n if (this.attributeCollection.hasAttributeByKey(key)) {\n return true;\n }\n\n if (this.grouping) {\n return this.grouping.hasAttributeByKey(key);\n }\n\n return false;\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n if (this.attributeCollection.hasAttributeByKey(key)) {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n if (this.grouping) {\n return this.grouping.getAttributeByKey(key);\n }\n\n return null;\n }\n}\n\ntype Context = {\n prefix: string,\n label: string,\n metadata: Object,\n attributes: Array<Object>,\n};\n\n/**\n * Grouping model to group lists\n */\nexport default class GroupingModel {\n _prefix: string | null;\n _groups: Array<GroupModel>;\n\n /**\n */\n constructor(data: Object, contexts: Array<Context>) {\n this._prefix = data && data.prefix ? data.prefix : null;\n\n const context = this.getContextFromContributionsByPrefix(\n contexts,\n this._prefix\n );\n\n const dynamicschema = data && data.dynamicschema;\n this._groups =\n data && data.group\n ? data.group.map(\n (group) =>\n new GroupModel({ ...group, dynamicschema }, context, contexts)\n )\n : [];\n }\n\n /**\n * Retrieve groups of grouping\n */\n get groups(): Array<GroupModel> {\n return this._groups;\n }\n\n /**\n * Inidicates if Grouping has one or more groups\n */\n hasGroups(): boolean {\n return this._groups.length > 0;\n }\n\n /**\n * Get context of grouping\n */\n getContextFromContributionsByPrefix(\n contexts: Array<Object>,\n prefix: string | null\n ): Object {\n if (contexts && prefix !== null) {\n return contexts.find((context) => context.prefix === prefix) || {};\n }\n\n return {};\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.groups.some((group: GroupModel) =>\n group.hasAttributeByKey(key)\n );\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n const groupByKey = this.groups.find((group: GroupModel) =>\n group.hasAttributeByKey(key)\n );\n\n if (groupByKey) {\n return groupByKey.getAttributeByKey(key);\n }\n return null;\n }\n\n /**\n */\n getGroupByAttributeKey(key: string): ?GroupModel {\n return this.groups.find((group) => group.hasAttributeByKey(key));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA;;AAGA;AACA;AACA;AACA;AACO,MAAMA,UAAN,CAAiB;EAMtB;AACF;EACEC,WAAW,CAACC,KAAD,EAAgBC,OAAhB,EAAiCC,aAAjC,EAA+D;IAAA;IAAA;IAAA;IAAA;IACxE,KAAKC,MAAL,GAAcH,KAAd;IACA,KAAKI,QAAL,GAAgBH,OAAhB;IAEA,KAAKI,oBAAL,GAA4B,IAAIC,4BAAJ,CAC1BN,KAD0B,EAE1BC,OAAO,CAACM,UAFkB,CAA5B;;IAKA,IAAIP,KAAK,CAACQ,QAAV,EAAoB;MAClB,KAAKC,SAAL,GAAiB,IAAIC,aAAJ,CACf,EAAE,GAAGV,KAAK,CAACQ,QAAX;QAAqBG,aAAa,EAAEX,KAAK,CAACW;MAA1C,CADe,EAEfT,aAFe,CAAjB;IAID;EACF;EAED;AACF;;;EACU,IAAJU,IAAI,GAAW;IACjB,OAAO,KAAKT,MAAL,CAAYS,IAAnB;EACD;EAED;AACF;;;EACQ,IA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ACF;;;EACEa,sBAAsB,CAACb,GAAD,EAA2B;IAAA;;IAC/C,OAAO,oCAAKQ,MAAL,kBAAkB3B,KAAD,IAAWA,KAAK,CAACkB,iBAAN,CAAwBC,GAAxB,CAA5B,CAAP;EACD;;AA7EgC"}
1
+ {"version":3,"file":"GroupingModel.js","names":["GroupModel","constructor","group","context","contributions","_group","_context","_attributeCollection","AttributeCollection","attributes","grouping","_grouping","GroupingModel","dynamicschema","type","id","_id","label","attributeCollection","reference","hasAttributeByKey","key","getAttributeByKey","data","contexts","_prefix","prefix","_groups","createGroup","getContextFromContributionsByPrefix","getDynamicSchema","groups","hasGroups","length","some","groupByKey","getGroupByAttributeKey"],"sources":["../../../src/models/grouping/GroupingModel.js"],"sourcesContent":["// @flow\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport type { AttributeType } from \"../types\";\n\n/**\n * Group information model\n * Put GroupModel here because of possible circular dependency with GroupingModel below\n */\nexport class GroupModel {\n _group: Object;\n _context: Object;\n _attributeCollection: AttributeCollection;\n _grouping: ?GroupingModel;\n\n /**\n */\n constructor(group: Object, context: Object, contributions: Array<Object>) {\n this._group = group;\n this._context = context;\n\n this._attributeCollection = new AttributeCollection(\n group,\n context.attributes\n );\n\n if (group.grouping) {\n this._grouping = new GroupingModel(\n { ...group.grouping, dynamicschema: group.dynamicschema },\n contributions\n );\n }\n }\n\n /**\n */\n get type(): string {\n return this._group.type;\n }\n\n /**\n */\n get id(): string {\n return this._group._id || \"unknown\";\n }\n\n /**\n */\n get label(): string {\n return this._context.label;\n }\n\n /**\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n get grouping(): ?GroupingModel {\n return this._grouping;\n }\n\n /**\n * Retrieve array of reference id's\n */\n get reference(): Array<number> {\n return this._group.reference || [];\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n if (this.attributeCollection.hasAttributeByKey(key)) {\n return true;\n }\n\n if (this.grouping) {\n return this.grouping.hasAttributeByKey(key);\n }\n\n return false;\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n if (this.attributeCollection.hasAttributeByKey(key)) {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n if (this.grouping) {\n return this.grouping.getAttributeByKey(key);\n }\n\n return null;\n }\n}\n\ntype Context = {\n prefix: string,\n label: string,\n metadata: Object,\n attributes: Array<Object>,\n};\n\n/**\n * Grouping model to group lists\n */\nexport default class GroupingModel {\n _prefix: string | null;\n _groups: Array<GroupModel> = [];\n\n /**\n */\n constructor(data: Object, contexts: Array<Context>) {\n this._prefix = data && data.prefix ? data.prefix : null;\n\n if (data?.group) {\n this._groups = this.createGroup(data, contexts);\n }\n }\n\n /**\n */\n createGroup(data: Object, contributions: Array<Context>): Array<Object> {\n const context = this.getContextFromContributionsByPrefix(\n contributions,\n this._prefix\n );\n\n return data.group.map((group) => {\n const dynamicschema = this.getDynamicSchema(group, data.dynamicschema);\n return new GroupModel(\n {\n ...group,\n dynamicschema,\n },\n context,\n contributions\n );\n });\n }\n\n /**\n * add grouped prefix to the dynamicschema\n */\n getDynamicSchema(group: Object, dynamicschema: Object): Object {\n if (dynamicschema) {\n if (\n this._prefix &&\n dynamicschema[group.type] &&\n !dynamicschema[this._prefix + group.type]\n ) {\n dynamicschema[this._prefix + group.type] = dynamicschema[group.type];\n }\n return dynamicschema;\n }\n return null;\n }\n\n /**\n * Retrieve groups of grouping\n */\n get groups(): Array<GroupModel> {\n return this._groups;\n }\n\n /**\n * Inidicates if Grouping has one or more groups\n */\n hasGroups(): boolean {\n return this._groups.length > 0;\n }\n\n /**\n * Get context of grouping\n */\n getContextFromContributionsByPrefix(\n contexts: Array<Object>,\n prefix: string | null\n ): Object {\n if (contexts && prefix !== null) {\n return contexts.find((context) => context.prefix === prefix) || {};\n }\n\n return {};\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.groups.some((group: GroupModel) =>\n group.hasAttributeByKey(key)\n );\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n const groupByKey = this.groups.find((group: GroupModel) =>\n group.hasAttributeByKey(key)\n );\n\n if (groupByKey) {\n return groupByKey.getAttributeByKey(key);\n }\n return null;\n }\n\n /**\n */\n getGroupByAttributeKey(key: string): ?GroupModel {\n return this.groups.find((group) => group.hasAttributeByKey(key));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AACA;;AAGA;AACA;AACA;AACA;AACO,MAAMA,UAAN,CAAiB;EAMtB;AACF;EACEC,WAAW,CAACC,KAAD,EAAgBC,OAAhB,EAAiCC,aAAjC,EAA+D;IAAA;IAAA;IAAA;IAAA;IACxE,KAAKC,MAAL,GAAcH,KAAd;IACA,KAAKI,QAAL,GAAgBH,OAAhB;IAEA,KAAKI,oBAAL,GAA4B,IAAIC,4BAAJ,CAC1BN,KAD0B,EAE1BC,OAAO,CAACM,UAFkB,CAA5B;;IAKA,IAAIP,KAAK,CAACQ,QAAV,EAAoB;MAClB,KAAKC,SAAL,GAAiB,IAAIC,aAAJ,CACf,EAAE,GAAGV,KAAK,CAACQ,QAAX;QAAqBG,aAAa,EAAEX,KAAK,CAACW;MAA1C,CADe,EAEfT,aAFe,CAAjB;IAID;EACF;EAED;AACF;;;EACU,IAAJU,IAAI,GAAW;IACjB,OAAO,KAAKT,MAAL,CAAYS,IAAnB;EACD;EAED;AACF;;;EACQ,IAAFC,EAAE,GAAW;IACf,OAAO,KAAKV,MAAL,CAAYW,GAAZ,IAAmB,SAA1B;EACD;EAED;AACF;;;EACW,IAALC,KAAK,GAAW;IAClB,OAAO,KAAKX,QAAL,CAAcW,KAArB;EACD;EAED;AACF;;;EACyB,IAAnBC,mBAAmB,GAAwB;IAC7C,OAAO,KAAKX,oBAAZ;EACD;EAED;AACF;;;EACc,IAARG,QAAQ,GAAmB;IAC7B,OAAO,KAAKC,SAAZ;EACD;EAED;AACF;AACA;;;EACe,IAATQ,SAAS,GAAkB;IAC7B,OAAO,KAAKd,MAAL,CAAYc,SAAZ,IAAyB,EAAhC;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AAMc,UAAU,GAAG,oCAAKJ,MAAL,kBAAkB7B,KAAD,IAClCA,KAAK,CAACkB,iBAAN,CAAwBC,GAAxB,CADiB,CAAnB;;IAIA,IAAIc,UAAJ,EAAgB;MACd,OAAOA,UAAU,CAACb,iBAAX,CAA6BD,GAA7B,CAAP;IACD;;IACD,OAAO,IAAP;EACD;EAED;AACF;;;EACEe,sBAAsB,CAACf,GAAD,EAA2B;IAAA;;IAC/C,OAAO,oCAAKU,MAAL,kBAAkB7B,KAAD,IAAWA,KAAK,CAACkB,iBAAN,CAAwBC,GAAxB,CAA5B,CAAP;EACD;;AAzGgC"}
@@ -109,7 +109,7 @@ export type FormErrorAnchor = {
109
109
  index?: number,
110
110
  "index-identifier"?: string,
111
111
  },
112
- layouthint?: LayoutHintCollection,
112
+ layouthint: LayoutHintCollection,
113
113
  message: string,
114
114
  param?: {
115
115
  name: string,
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/models/types.js"],"sourcesContent":["// @flow\nimport type ApplicationModel from \"./application/ApplicationModel\";\nimport type BooleanAttributeModel from \"./attributes/BooleanAttributeModel\";\nimport type CaptchaAttributeModel from \"./attributes/CaptchaAttributeModel\";\nimport type ChoiceAttributeModel from \"./attributes/ChoiceAttributeModel\";\nimport type CompositeAttributeModel from \"./attributes/CompositeAttributeModel\";\nimport type DatetimeAttributeModel from \"./attributes/DatetimeAttributeModel\";\nimport type HelptextAttributeModel from \"./attributes/HelptextAttributeModel\";\nimport type LabelAttributeModel from \"./attributes/LabelAttributeModel\";\nimport type MemoAttributeModel from \"./attributes/MemoAttributeModel\";\nimport type MoneyAttributeModel from \"./attributes/MoneyAttributeModel\";\nimport type NumberAttributeModel from \"./attributes/NumberAttributeModel\";\nimport type PasswordAttributeModel from \"./attributes/PasswordAttributeModel\";\nimport type StringAttributeModel from \"./attributes/StringAttributeModel\";\nimport type UploadAttributeModel from \"./attributes/UploadAttributeModel\";\nimport type XMLAttributeModel from \"./attributes/XMLAttributeModel\";\nimport type CaseViewModel from \"./caseview/CaseViewModel\";\nimport type BusinessScenarioModel from \"./concepts/BusinessScenarioModel\";\nimport type ConceptDetailModel from \"./concepts/ConceptDetailModel\";\nimport type ConceptIndexModel from \"./concepts/ConceptIndexModel\";\nimport type ConceptTypeDetailModel from \"./concepts/ConceptTypeDetailModel\";\nimport type ContentIndexModel from \"./content/ContentIndexModel\";\nimport type ContentModel from \"./content/ContentModel\";\nimport type SectionModel from \"./content/SectionModel\";\nimport type ContentTOCModel from \"./content/ContentTOCModel\";\nimport type ContentTypeModel from \"./content/ContentTypeModel\";\nimport type DetailModel from \"./detail/DetailModel\";\nimport type AssignmentFilterModel from \"./filters/AssignmentFilterModel\";\nimport type FilterModel from \"./filters/FilterModel\";\nimport type RangeFilterModel from \"./filters/RangeFilterModel\";\nimport type ConceptIndexFilterModel from \"./filters/ConceptIndexFilterModel\";\nimport type FormModel from \"./form/FormModel\";\nimport type ListDetailModel from \"./list/ListDetailModel\";\nimport type ListModel from \"./list/ListModel\";\nimport type ModelCatalogModel from \"./modelcatalog/ModelCatalogModel\";\nimport type GroupingPanelModel from \"./panels/GroupingPanelModel\";\nimport type CaseSearchModel from \"./search/CaseSearchModel\";\nimport type TabModel from \"./tab/TabModel\";\nimport type TaskGroupModel from \"./taskgroup/TaskGroupModel\";\nimport type UserModel from \"./user/UserModel\";\nimport type UserServicesModel from \"./user/UserServicesModel\";\nimport type LinkModel from \"./links/LinkModel\";\nimport type LookupOptionsModel from \"./lookup/LookupOptionsModel\";\nimport type BaseFilterModel from \"./filters/BaseFilterModel\";\nimport type AttributeCollection from \"./attributes/AttributeCollection\";\nimport type AttributeModel from \"./attributes/AttributeModel\";\nimport type LayoutHintCollection from \"./layouthint/LayoutHintCollection\";\n\nexport type ModularUIModel =\n | ApplicationModel\n | CaseSearchModel\n | CaseViewModel\n | ListDetailModel\n | DetailModel\n | FormModel\n | GroupingPanelModel\n | ListModel\n | TabModel\n | TaskGroupModel\n | UserModel\n | UserServicesModel\n | ModelCatalogModel\n | ConceptIndexModel\n | ConceptDetailModel\n | BusinessScenarioModel\n | ConceptTypeDetailModel\n | ContentIndexModel\n | ContentTOCModel\n | ContentModel\n | ContentTypeModel\n | LookupOptionsModel;\n\nexport type AttributeType =\n | BooleanAttributeModel\n | CaptchaAttributeModel\n | ChoiceAttributeModel\n | DatetimeAttributeModel\n | HelptextAttributeModel\n | LabelAttributeModel\n | MemoAttributeModel\n | MoneyAttributeModel\n | NumberAttributeModel\n | PasswordAttributeModel\n | CompositeAttributeModel\n | StringAttributeModel\n | UploadAttributeModel\n | XMLAttributeModel;\n\nexport type RangeChildAttributeType =\n | NumberAttributeModel\n | DatetimeAttributeModel;\n\nexport type FilterType =\n | BaseFilterModel\n | FilterModel\n | AssignmentFilterModel\n | RangeFilterModel\n | ConceptIndexFilterModel;\n\nexport type FormErrorAnchor = {\n id: string,\n properties?: {\n [propertyName: string]: string | number,\n },\n anchor?: {\n objectid: string,\n elementid?: string,\n _links?: Object,\n index?: number,\n \"index-identifier\"?: string,\n },\n layouthint?: LayoutHintCollection,\n message: string,\n param?: {\n name: string,\n },\n};\n\nexport type labelsJSON = {|\n _id: string,\n label: string,\n value: string,\n|};\n\nexport type propertyJSON = {|\n _id: string,\n type: string,\n mandatory: string,\n label: string,\n value: string,\n|};\n\nexport type textfragmentJSON = {|\n label: string,\n text: string,\n type: string,\n|};\n\nexport interface IConstraintModel {\n +id: string;\n +defaultMessage: string;\n +parameters: Object;\n +isMandatoryConstraint: boolean;\n validate(value: any): boolean;\n hasValidation(): boolean;\n}\n\nexport interface ILayoutHintRule {\n process(attribute: AttributeModel, attributes: AttributeCollection): void;\n}\n\nexport interface IModelWithChildModels {\n getInitialChildModelLinks(): Array<LinkModel>;\n setChildModels(models: Array<ModularUIModel>): void;\n}\n\nexport type AuthenticationType = {\n name: string,\n authentication: string,\n redirectUri: string,\n isPrimary: boolean,\n};\n\nexport type FileEntryType = {\n name: string,\n size?: number,\n progress: number,\n error?: string,\n token?: string,\n};\n\nexport type FilesType = {\n [filename: string]: FileEntryType,\n};\n\nexport type FiletypeConstraintsType = Array<{|\n extensions: Array<string>,\n mimeTypes: Array<string>,\n|}>;\n\nexport type FilesizeConstraintsType = {\n fileSize: ?number,\n maxTotalFileSize: ?number,\n isMaxTotal: boolean,\n};\n\nexport type PropertyData = { type: string, label: string, value: string };\nexport type TextFragmentData = {\n type: string,\n label: string,\n text: string | { id?: string, message: string, properties?: Object },\n};\nexport type SectionData = {\n id: string,\n type: string,\n label?: string,\n number?: string,\n body: string | { id?: string, message: string, properties?: Object },\n _links: { self: { href: string } },\n childSections: Array<SectionData>,\n subSections: Array<SectionData>,\n};\n\nexport type PropertyElement = {\n propertyElement: {\n label: string,\n layouthint: Array<string>,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElement = {\n textFragmentElement: {\n label: string,\n layouthint: Array<string>,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElement = {\n contentElement: {\n label: string,\n layouthint: Array<string>,\n sections: Array<SectionData>,\n },\n};\n\nexport type PropertyElementMapped = {\n propertyElement: {\n label: string,\n layouthint: LayoutHintCollection,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElementMapped = {\n textFragmentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElementMapped = {\n contentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n sections: Array<SectionModel>,\n },\n};\n\nexport type ContentAll = Array<\n PropertyElementMapped | TextFragmentElementMapped | ContentElementMapped\n>;\n\nexport type ContentData = {\n header: {\n label?: string,\n description?: { id?: string, message: string, properties?: Object },\n },\n label?: string,\n elements: Array<PropertyElement | TextFragmentElement | ContentElement>,\n};\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/models/types.js"],"sourcesContent":["// @flow\nimport type ApplicationModel from \"./application/ApplicationModel\";\nimport type BooleanAttributeModel from \"./attributes/BooleanAttributeModel\";\nimport type CaptchaAttributeModel from \"./attributes/CaptchaAttributeModel\";\nimport type ChoiceAttributeModel from \"./attributes/ChoiceAttributeModel\";\nimport type CompositeAttributeModel from \"./attributes/CompositeAttributeModel\";\nimport type DatetimeAttributeModel from \"./attributes/DatetimeAttributeModel\";\nimport type HelptextAttributeModel from \"./attributes/HelptextAttributeModel\";\nimport type LabelAttributeModel from \"./attributes/LabelAttributeModel\";\nimport type MemoAttributeModel from \"./attributes/MemoAttributeModel\";\nimport type MoneyAttributeModel from \"./attributes/MoneyAttributeModel\";\nimport type NumberAttributeModel from \"./attributes/NumberAttributeModel\";\nimport type PasswordAttributeModel from \"./attributes/PasswordAttributeModel\";\nimport type StringAttributeModel from \"./attributes/StringAttributeModel\";\nimport type UploadAttributeModel from \"./attributes/UploadAttributeModel\";\nimport type XMLAttributeModel from \"./attributes/XMLAttributeModel\";\nimport type CaseViewModel from \"./caseview/CaseViewModel\";\nimport type BusinessScenarioModel from \"./concepts/BusinessScenarioModel\";\nimport type ConceptDetailModel from \"./concepts/ConceptDetailModel\";\nimport type ConceptIndexModel from \"./concepts/ConceptIndexModel\";\nimport type ConceptTypeDetailModel from \"./concepts/ConceptTypeDetailModel\";\nimport type ContentIndexModel from \"./content/ContentIndexModel\";\nimport type ContentModel from \"./content/ContentModel\";\nimport type SectionModel from \"./content/SectionModel\";\nimport type ContentTOCModel from \"./content/ContentTOCModel\";\nimport type ContentTypeModel from \"./content/ContentTypeModel\";\nimport type DetailModel from \"./detail/DetailModel\";\nimport type AssignmentFilterModel from \"./filters/AssignmentFilterModel\";\nimport type FilterModel from \"./filters/FilterModel\";\nimport type RangeFilterModel from \"./filters/RangeFilterModel\";\nimport type ConceptIndexFilterModel from \"./filters/ConceptIndexFilterModel\";\nimport type FormModel from \"./form/FormModel\";\nimport type ListDetailModel from \"./list/ListDetailModel\";\nimport type ListModel from \"./list/ListModel\";\nimport type ModelCatalogModel from \"./modelcatalog/ModelCatalogModel\";\nimport type GroupingPanelModel from \"./panels/GroupingPanelModel\";\nimport type CaseSearchModel from \"./search/CaseSearchModel\";\nimport type TabModel from \"./tab/TabModel\";\nimport type TaskGroupModel from \"./taskgroup/TaskGroupModel\";\nimport type UserModel from \"./user/UserModel\";\nimport type UserServicesModel from \"./user/UserServicesModel\";\nimport type LinkModel from \"./links/LinkModel\";\nimport type LookupOptionsModel from \"./lookup/LookupOptionsModel\";\nimport type BaseFilterModel from \"./filters/BaseFilterModel\";\nimport type AttributeCollection from \"./attributes/AttributeCollection\";\nimport type AttributeModel from \"./attributes/AttributeModel\";\nimport type LayoutHintCollection from \"./layouthint/LayoutHintCollection\";\n\nexport type ModularUIModel =\n | ApplicationModel\n | CaseSearchModel\n | CaseViewModel\n | ListDetailModel\n | DetailModel\n | FormModel\n | GroupingPanelModel\n | ListModel\n | TabModel\n | TaskGroupModel\n | UserModel\n | UserServicesModel\n | ModelCatalogModel\n | ConceptIndexModel\n | ConceptDetailModel\n | BusinessScenarioModel\n | ConceptTypeDetailModel\n | ContentIndexModel\n | ContentTOCModel\n | ContentModel\n | ContentTypeModel\n | LookupOptionsModel;\n\nexport type AttributeType =\n | BooleanAttributeModel\n | CaptchaAttributeModel\n | ChoiceAttributeModel\n | DatetimeAttributeModel\n | HelptextAttributeModel\n | LabelAttributeModel\n | MemoAttributeModel\n | MoneyAttributeModel\n | NumberAttributeModel\n | PasswordAttributeModel\n | CompositeAttributeModel\n | StringAttributeModel\n | UploadAttributeModel\n | XMLAttributeModel;\n\nexport type RangeChildAttributeType =\n | NumberAttributeModel\n | DatetimeAttributeModel;\n\nexport type FilterType =\n | BaseFilterModel\n | FilterModel\n | AssignmentFilterModel\n | RangeFilterModel\n | ConceptIndexFilterModel;\n\nexport type FormErrorAnchor = {\n id: string,\n properties?: {\n [propertyName: string]: string | number,\n },\n anchor?: {\n objectid: string,\n elementid?: string,\n _links?: Object,\n index?: number,\n \"index-identifier\"?: string,\n },\n layouthint: LayoutHintCollection,\n message: string,\n param?: {\n name: string,\n },\n};\n\nexport type labelsJSON = {|\n _id: string,\n label: string,\n value: string,\n|};\n\nexport type propertyJSON = {|\n _id: string,\n type: string,\n mandatory: string,\n label: string,\n value: string,\n|};\n\nexport type textfragmentJSON = {|\n label: string,\n text: string,\n type: string,\n|};\n\nexport interface IConstraintModel {\n +id: string;\n +defaultMessage: string;\n +parameters: Object;\n +isMandatoryConstraint: boolean;\n validate(value: any): boolean;\n hasValidation(): boolean;\n}\n\nexport interface ILayoutHintRule {\n process(attribute: AttributeModel, attributes: AttributeCollection): void;\n}\n\nexport interface IModelWithChildModels {\n getInitialChildModelLinks(): Array<LinkModel>;\n setChildModels(models: Array<ModularUIModel>): void;\n}\n\nexport type AuthenticationType = {\n name: string,\n authentication: string,\n redirectUri: string,\n isPrimary: boolean,\n};\n\nexport type FileEntryType = {\n name: string,\n size?: number,\n progress: number,\n error?: string,\n token?: string,\n};\n\nexport type FilesType = {\n [filename: string]: FileEntryType,\n};\n\nexport type FiletypeConstraintsType = Array<{|\n extensions: Array<string>,\n mimeTypes: Array<string>,\n|}>;\n\nexport type FilesizeConstraintsType = {\n fileSize: ?number,\n maxTotalFileSize: ?number,\n isMaxTotal: boolean,\n};\n\nexport type PropertyData = { type: string, label: string, value: string };\nexport type TextFragmentData = {\n type: string,\n label: string,\n text: string | { id?: string, message: string, properties?: Object },\n};\nexport type SectionData = {\n id: string,\n type: string,\n label?: string,\n number?: string,\n body: string | { id?: string, message: string, properties?: Object },\n _links: { self: { href: string } },\n childSections: Array<SectionData>,\n subSections: Array<SectionData>,\n};\n\nexport type PropertyElement = {\n propertyElement: {\n label: string,\n layouthint: Array<string>,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElement = {\n textFragmentElement: {\n label: string,\n layouthint: Array<string>,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElement = {\n contentElement: {\n label: string,\n layouthint: Array<string>,\n sections: Array<SectionData>,\n },\n};\n\nexport type PropertyElementMapped = {\n propertyElement: {\n label: string,\n layouthint: LayoutHintCollection,\n properties: Array<PropertyData>,\n },\n};\nexport type TextFragmentElementMapped = {\n textFragmentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n textfragments: Array<TextFragmentData>,\n },\n};\nexport type ContentElementMapped = {\n contentElement: {\n label: string,\n layouthint: LayoutHintCollection,\n sections: Array<SectionModel>,\n },\n};\n\nexport type ContentAll = Array<\n PropertyElementMapped | TextFragmentElementMapped | ContentElementMapped\n>;\n\nexport type ContentData = {\n header: {\n label?: string,\n description?: { id?: string, message: string, properties?: Object },\n },\n label?: string,\n elements: Array<PropertyElement | TextFragmentElement | ContentElement>,\n};\n"],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.21.1",
3
+ "version": "1.21.4",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -710,6 +710,7 @@ export default class AttributeModel
710
710
  addServerError(error: FormErrorAnchor) {
711
711
  this._errorCollection.addServerError(
712
712
  error.id,
713
+ error.layouthint,
713
714
  error.message,
714
715
  error.properties
715
716
  );
@@ -812,6 +813,7 @@ export default class AttributeModel
812
813
  if (this.hasValue()) {
813
814
  this._errorCollection.addServerError(
814
815
  error.id,
816
+ error.layouthint,
815
817
  error.message,
816
818
  this.formatParameters(error.properties)
817
819
  );
@@ -396,7 +396,7 @@ export default class ChoiceAttributeModel extends AttributeModel {
396
396
  * Registers an error that was received from a server response
397
397
  */
398
398
  addServerError(error: FormErrorAnchor) {
399
- const { id, message, properties } = error;
399
+ const { id, layouthint, message, properties } = error;
400
400
 
401
401
  const ANSWER_OPTION_KEY = "answer-option-key";
402
402
 
@@ -412,7 +412,7 @@ export default class ChoiceAttributeModel extends AttributeModel {
412
412
  }
413
413
  }
414
414
 
415
- this._errorCollection.addServerError(id, message, properties);
415
+ this._errorCollection.addServerError(id, layouthint, message, properties);
416
416
  }
417
417
 
418
418
  /**
@@ -425,12 +425,12 @@ class DatetimeAttributeModel extends StringAttributeModel {
425
425
  * Registers an error that was received from a server response
426
426
  */
427
427
  addServerError(error: FormErrorAnchor) {
428
- const { id, message, properties } = error;
428
+ const { id, layouthint, message, properties } = error;
429
429
  if (properties && has(properties, "format") && this.formatLabel) {
430
430
  properties.format = this.formatLabel;
431
431
  }
432
432
 
433
- this._errorCollection.addServerError(id, message, properties);
433
+ this._errorCollection.addServerError(id, layouthint, message, properties);
434
434
  }
435
435
 
436
436
  /**
@@ -4,6 +4,7 @@ import ErrorModel from "./ErrorModel";
4
4
 
5
5
  import type { MessageParameters } from "../../i18n/types";
6
6
  import type { IConstraintModel } from "../types";
7
+ import LayoutHintCollection from "../layouthint/LayoutHintCollection";
7
8
 
8
9
  /**
9
10
  * Form Objects
@@ -42,6 +43,7 @@ export default class ErrorCollection extends BaseCollection<ErrorModel> {
42
43
  */
43
44
  addError(
44
45
  id: string,
46
+ layouthint?: LayoutHintCollection,
45
47
  defaultMessage?: string,
46
48
  parameters?: MessageParameters
47
49
  ) {
@@ -51,7 +53,7 @@ export default class ErrorCollection extends BaseCollection<ErrorModel> {
51
53
  this.removeByIndex(itemIdx);
52
54
  }
53
55
 
54
- this.add(new ErrorModel(id, defaultMessage, parameters));
56
+ this.add(new ErrorModel(id, defaultMessage, parameters, false, layouthint));
55
57
  }
56
58
 
57
59
  /**
@@ -66,13 +68,14 @@ export default class ErrorCollection extends BaseCollection<ErrorModel> {
66
68
  */
67
69
  addServerError(
68
70
  id: string,
71
+ layouthint?: LayoutHintCollection,
69
72
  defaultMessage?: string,
70
73
  parameters?: MessageParameters
71
74
  ) {
72
75
  if (parameters) {
73
- this.addError(id, defaultMessage, parameters);
76
+ this.addError(id, layouthint, defaultMessage, parameters);
74
77
  } else {
75
- this.addError(id, defaultMessage);
78
+ this.addError(id, layouthint, defaultMessage);
76
79
  }
77
80
  }
78
81
 
@@ -19,13 +19,16 @@ class ErrorModel {
19
19
  id: string,
20
20
  defaultMessage: ?string,
21
21
  parameters: ?MessageParameters,
22
- isClientConstraint: boolean = false
22
+ isClientConstraint: boolean = false,
23
+ layouthint: LayoutHintCollection = new LayoutHintCollection()
23
24
  ) {
24
25
  this._id = id;
25
26
  this._parameters = parameters;
26
27
  this._defaultMessage = defaultMessage;
27
28
  this._isClientConstraint = isClientConstraint;
28
- this._layouthint = new LayoutHintCollection();
29
+ this._layouthint = Array.isArray(layouthint)
30
+ ? new LayoutHintCollection(layouthint)
31
+ : layouthint;
29
32
  }
30
33
 
31
34
  /**
@@ -89,88 +89,95 @@ export default class ErrorResponse {
89
89
  }
90
90
 
91
91
  /**
92
- * Return error title
92
+ * Return response error message
93
+ */
94
+ get responseMessage(): string {
95
+ return this.response.message || this.id;
96
+ }
97
+
98
+ /**
99
+ * Return response error title
93
100
  */
94
101
  get title(): TitleObject {
95
- return this.error.title || null;
102
+ return this.response.title || null;
96
103
  }
97
104
 
98
105
  /**
99
- * Return error title message
106
+ * Return response error title message
100
107
  */
101
108
  get titleMessage(): string {
102
- return this.error.title?.message || undefined;
109
+ return this.response.title?.message || undefined;
103
110
  }
104
111
 
105
112
  /**
106
- * Return error title Id
113
+ * Return response error title Id
107
114
  */
108
115
  get titleId(): string {
109
- return this.error.title?.id || undefined;
116
+ return this.response.title?.id || undefined;
110
117
  }
111
118
 
112
119
  /**
113
- * Return error title properties
120
+ * Return response error title properties
114
121
  */
115
122
  get titleProperties(): Object {
116
- return this.error.title?.properties || null;
123
+ return this.response.title?.properties || null;
117
124
  }
118
125
 
119
126
  /**
120
- * Return error redirect
127
+ * Return response error redirect
121
128
  */
122
129
  get redirect(): RedirectObject {
123
- return this.error.redirect || null;
130
+ return this.response.redirect || null;
124
131
  }
125
132
  /**
126
- * Return error redirect text
133
+ * Return response error redirect text
127
134
  */
128
135
  get redirectText(): RedirectTextObject {
129
- return this.error.redirect?.text || null;
136
+ return this.response?.redirect?.text || null;
130
137
  }
131
138
 
132
139
  /**
133
- * Return error redirect text id
140
+ * Return response error redirect text id
134
141
  */
135
142
  get redirectTextID(): string {
136
- return this.error.redirect?.text?.id || undefined;
143
+ return this.response.redirect?.text?.id || undefined;
137
144
  }
138
145
 
139
146
  /**
140
- * Return error redirect text properties
147
+ * Return response error redirect text properties
141
148
  */
142
149
  get redirectTextProperties(): Object {
143
- return this.error.redirect?.text?.properties || null;
150
+ return this.response.redirect?.text?.properties || null;
144
151
  }
145
152
 
146
153
  /**
147
- * Return error redirect text message
154
+ * Return response error redirect text message
148
155
  */
149
156
  get redirectMessage(): string {
150
- return this.error.redirect?.text?.message || undefined;
157
+ return this.response.redirect?.text?.message || undefined;
151
158
  }
152
159
 
153
160
  /**
154
- * Return error redirect href
161
+ * Return response error redirect href
155
162
  */
156
163
  get redirectHref(): Href {
157
- if (this.error.redirect?.href) {
158
- return new Href(this.error.redirect.href);
164
+ if (this.response.redirect?.href) {
165
+ return new Href(this.response.redirect?.href);
159
166
  }
160
167
  return new Href();
161
168
  }
162
169
 
163
170
  /**
164
- * Return error layouthint
171
+ * Return error response layouthint
165
172
  */
166
173
  get layouthint(): LayoutHintCollection {
167
- return new LayoutHintCollection(this.error.layouthint);
174
+ return new LayoutHintCollection(this.response?.layouthint);
168
175
  }
169
176
 
170
177
  /**
171
178
  */
172
179
  get response(): Object {
173
- return this.error.response || {};
180
+ return this.error?.response?.error || {};
174
181
  }
175
182
 
176
183
  /**
@@ -26,6 +26,7 @@ import type { AttributeType, ModularUIModel } from "../types";
26
26
  import type { ModularUIResponse } from "../../modularui";
27
27
  import type ErrorResponse from "../error/ErrorResponse";
28
28
  import type LinkModel from "../links/LinkModel";
29
+ import LayoutHintCollection from "../layouthint/LayoutHintCollection";
29
30
 
30
31
  /**
31
32
  */
@@ -512,11 +513,16 @@ class FormModel extends ResourceModel {
512
513
  if (error.parameters) {
513
514
  this.errorCollection.addServerError(
514
515
  error.id,
516
+ error.layouthint,
515
517
  error.message,
516
518
  error.parameters
517
519
  );
518
520
  } else {
519
- this.errorCollection.addServerError(error.id, error.message);
521
+ this.errorCollection.addServerError(
522
+ error.id,
523
+ error.layouthint,
524
+ error.message
525
+ );
520
526
  }
521
527
  }
522
528
 
@@ -1018,6 +1024,7 @@ class FormModel extends ResourceModel {
1018
1024
  } else {
1019
1025
  this.errorCollection.addServerError(
1020
1026
  error.id,
1027
+ new LayoutHintCollection(error.layouthint),
1021
1028
  error.message,
1022
1029
  error.properties
1023
1030
  );
@@ -401,6 +401,7 @@ export default class FormObjectModel extends BaseModel {
401
401
  } else {
402
402
  this._errorCollection.addServerError(
403
403
  error.id,
404
+ error.layouthint,
404
405
  error.message,
405
406
  error.properties
406
407
  );