@beinformed/ui 1.21.2 → 1.21.3

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 (54) hide show
  1. package/CHANGELOG.md +7 -0
  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 +11 -5
  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/types.js.map +1 -1
  19. package/lib/models/attributes/AttributeModel.js +2 -2
  20. package/lib/models/attributes/AttributeModel.js.flow +2 -0
  21. package/lib/models/attributes/AttributeModel.js.map +1 -1
  22. package/lib/models/attributes/ChoiceAttributeModel.js +2 -1
  23. package/lib/models/attributes/ChoiceAttributeModel.js.flow +2 -2
  24. package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
  25. package/lib/models/attributes/DatetimeAttributeModel.js +2 -1
  26. package/lib/models/attributes/DatetimeAttributeModel.js.flow +2 -2
  27. package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
  28. package/lib/models/error/ErrorCollection.js +7 -5
  29. package/lib/models/error/ErrorCollection.js.flow +6 -3
  30. package/lib/models/error/ErrorCollection.js.map +1 -1
  31. package/lib/models/error/ErrorModel.js +2 -1
  32. package/lib/models/error/ErrorModel.js.flow +5 -2
  33. package/lib/models/error/ErrorModel.js.map +1 -1
  34. package/lib/models/error/ErrorResponse.js +11 -5
  35. package/lib/models/error/ErrorResponse.js.flow +4 -4
  36. package/lib/models/error/ErrorResponse.js.map +1 -1
  37. package/lib/models/form/FormModel.js +5 -3
  38. package/lib/models/form/FormModel.js.flow +8 -1
  39. package/lib/models/form/FormModel.js.map +1 -1
  40. package/lib/models/form/FormObjectModel.js +1 -1
  41. package/lib/models/form/FormObjectModel.js.flow +1 -0
  42. package/lib/models/form/FormObjectModel.js.map +1 -1
  43. package/lib/models/types.js.flow +1 -1
  44. package/lib/models/types.js.map +1 -1
  45. package/package.json +1 -1
  46. package/src/models/attributes/AttributeModel.js +2 -0
  47. package/src/models/attributes/ChoiceAttributeModel.js +2 -2
  48. package/src/models/attributes/DatetimeAttributeModel.js +2 -2
  49. package/src/models/error/ErrorCollection.js +6 -3
  50. package/src/models/error/ErrorModel.js +5 -2
  51. package/src/models/error/ErrorResponse.js +4 -4
  52. package/src/models/form/FormModel.js +8 -1
  53. package/src/models/form/FormObjectModel.js +1 -0
  54. package/src/models/types.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FormModel.js","names":["FormModel","ResourceModel","constructor","modularuiResponse","getSetting","ErrorCollection","lastUpdate","currentFormObject","createFormObject","endResultFormObjects","setEndResultFormObjects","parameters","setParameters","isComplete","getData","data","errors","handleRootErrors","type","actiontype","layouthint","has","CREATE_ACTION","UPDATE_ACTION","DELETE_ACTION","getContribution","isApplicableModel","contributions","resourcetype","getInitialChildModelLinks","endResultChildLinks","flattenDeep","endResultFormObject","setChildModels","models","forEach","label","buttonLabels","getButtonLabel","buttonType","cancel","allObjects","completedFormObjects","objectKeys","objects","numberOfExpectedQuestions","length","hasNoQuestionsConfigured","addGlobalDynamicSchema","anchor","dynamicschema","elements","element","item","getMissingAnchors","missingAnchors","missing","anchors","results","resultObject","result","objectid","objectId","FormObjectModel","addEmptyFormObject","formObjectModel","emptyFormObject","createEmpty","repeatIndex","getHighestRepeatIndex","addFormObject","Math","max","formObject","equals","IllegalArgumentException","getFormObjectByKey","key","getFormObjectByLayoutHint","hint","removeFormObject","_currentFormObject","_completedFormObjects","formObjects","previouslyEnteredFormObjects","_previouslyEnteredFormObjects","missingObjects","missingObjectIds","endResultAnchors","otherProps","endResult","expectsEndResultFormObjects","endResultKeys","some","objectKey","content","_endResultFormObjects","getEndResultFormObjects","previousEndResultKeys","_previousEndResultKeys","endResultFormObjectKeys","isValid","isRepeatable","hasOneValidQuestion","object","hasServerErrors","errorCollection","hasItems","hasErrors","addServerError","error","id","message","resetErrors","_errorCollection","commit","_commit","isFinished","_isFinished","_isComplete","successRedirect","success","Href","redirect","redirectLocation","_redirectLocation","getSuccessData","par","Parameter","_prefix","_name","_value","_parameters","selfhrefNoCommitParam","selfhref","selflink","href","method","HTTP_METHODS","POST","parameter","name","selfhrefWithCommitParam","addParameter","Error","tokens","_tokens","removeTokens","isChanged","isChangedSince","_lastUpdate","getFormDataObjects","validOnly","validationData","formdata","index","hasFixedNrOfRepeats","isLastRepeat","objectFormData","getFormData","existingObjectIndex","obj","deepmerge","push","withConcurrencyToken","setUseClientsideValidation","enabled","_useClientsideValidation","attributeCollection","all","useClientsideValidation","hasPreviousStep","currentFormObjectKey","isRepeatWithUnknownTotal","setPreviousObject","oldCurrentFormObject","completedFormObjectKeys","formObjectKey","hasNextStep","isDynamic","currentObjectIndex","isLastObject","update","receivedForm","Date","now","lastServerUpdate","receivedFormData","hasMissing","handleFinished","handleErrors","handleMissing","updateValidations","_data","properties","errorAnchors","handleMissingErrors","handleNewFormObject","processMissingErrors","attribute","hasAttributeByKey","addMissingError","removeMissingError","receivedCurrentFormObject","handlePreviouslyEnteredFormObjects","mergePreviouslyEnteredObjects","_mergePreviouslyEnteredObjects","previouslyEnteredFormObject","mergedObject","mergeObjects","hasPreviouslyEnteredObject","newObject","oldObject","mergedFormObject","mergeObject","findAttribute","findMethod","foundAttribute"],"sources":["../../../src/models/form/FormModel.js"],"sourcesContent":["// @flow\nimport flattenDeep from \"lodash/flattenDeep\";\nimport deepmerge from \"deepmerge\";\n\nimport { has } from \"../../utils/helpers/objects\";\n\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport ErrorCollection from \"../error/ErrorCollection\";\n\nimport Href from \"../href/Href\";\nimport Parameter from \"../parameter/Parameter\";\n\nimport FormObjectModel from \"./FormObjectModel\";\n\nimport { HTTP_METHODS } from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\nimport {\n CREATE_ACTION,\n DELETE_ACTION,\n UPDATE_ACTION,\n} from \"../../constants/LayoutHints\";\n\nimport type { AttributeType, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n */\nclass FormModel extends ResourceModel {\n _lastUpdate: number;\n\n _completedFormObjects: Array<FormObjectModel> = [];\n _currentFormObject: FormObjectModel | null = null;\n _previouslyEnteredFormObjects: Array<FormObjectModel> = [];\n\n _mergePreviouslyEnteredObjects: boolean = true;\n\n _endResultFormObjects: Array<FormObjectModel> = [];\n _previousEndResultKeys: Array<string> = [];\n\n _useClientsideValidation: boolean = getSetting(\"USE_CLIENTSIDE_VALIDATION\");\n _errorCollection: ErrorCollection = new ErrorCollection(\"form\");\n\n _redirectLocation: Href;\n\n _commit: boolean;\n _isFinished: boolean;\n _isComplete: boolean;\n\n _parameters: Array<Parameter>;\n _tokens: Array<string>;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this.lastUpdate = 0;\n\n this.currentFormObject = this.createFormObject();\n this.endResultFormObjects = this.setEndResultFormObjects();\n\n this.parameters = this.setParameters(modularuiResponse);\n\n this.isComplete = this.getData(\"complete\", false);\n\n if (this.data.errors) {\n this.handleRootErrors(this.data.errors);\n }\n }\n\n /**\n */\n get type(): string {\n return \"Form\";\n }\n\n /**\n */\n get actiontype(): string {\n if (this.layouthint.has(CREATE_ACTION)) {\n return \"create\";\n }\n if (this.layouthint.has(UPDATE_ACTION)) {\n return \"update\";\n }\n if (this.layouthint.has(DELETE_ACTION)) {\n return \"delete\";\n }\n\n return this.getContribution(\"actiontype\", \"form\");\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Form\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const endResultChildLinks = flattenDeep(\n this.endResultFormObjects.map((endResultFormObject) =>\n endResultFormObject.getInitialChildModelLinks()\n )\n );\n\n if (this.currentFormObject === null) {\n return endResultChildLinks;\n }\n\n return [\n ...this.currentFormObject.getInitialChildModelLinks(),\n ...endResultChildLinks,\n ];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n if (this.currentFormObject) {\n this.currentFormObject.setChildModels(models);\n }\n\n this.endResultFormObjects.forEach((endResultFormObject) => {\n endResultFormObject.setChildModels(models);\n });\n }\n\n /**\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Get form level button labels\n */\n get buttonLabels(): Object {\n return this.getContribution(\"buttonLabels\", {});\n }\n\n /**\n * @returns button label from contributions;\n */\n getButtonLabel(\n buttonType: \"cancel\" | \"previous\" | \"next\" | \"finish\"\n ): string | null {\n // cancel button labels are defined on the form\n if (buttonType === \"cancel\") {\n return this.buttonLabels?.cancel ?? null;\n }\n\n // all other form related button labels are defined on the object\n return this.currentFormObject?.buttonLabels?.[buttonType] ?? null;\n }\n\n /**\n * Get all applicable objects\n */\n get allObjects(): Array<FormObjectModel> {\n if (this.currentFormObject === null) {\n return this.completedFormObjects;\n }\n\n return [...this.completedFormObjects, this.currentFormObject];\n }\n\n /**\n */\n get objectKeys(): Array<string> {\n if (has(this.contributions, \"objects\")) {\n return Object.keys(this.contributions.objects);\n }\n\n return [];\n }\n\n /**\n */\n get numberOfExpectedQuestions(): number {\n return this.objectKeys.length;\n }\n\n /**\n * Has questions configured on form\n */\n get hasNoQuestionsConfigured(): boolean {\n return (\n this.isComplete &&\n (this.objectKeys.length === 0 ||\n (!(\"missing\" in this.data) &&\n !(\"results\" in this.data) &&\n !(\"errors\" in this.data)))\n );\n }\n\n /**\n */\n addGlobalDynamicSchema(anchor: Object, dynamicschema: Object): Object {\n if (!dynamicschema) {\n return anchor;\n }\n\n return {\n ...anchor,\n elements: anchor.elements.map((element) => ({\n ...element,\n dynamicschema: element.dynamicschema\n ? element.dynamicschema.map((item) => ({\n ...item,\n elements: { ...item.elements, dynamicschema },\n }))\n : null,\n })),\n };\n }\n\n /**\n */\n getMissingAnchors(): Array<Object> {\n const missingAnchors = this.data.missing?.anchors ?? [];\n\n // Add intermediate result data to anchor\n return missingAnchors.map((anchor) => {\n if (this.data.results) {\n const resultObject = this.data.results.find(\n (result) =>\n result.objectid === anchor.objectid && \"elements\" in result\n );\n\n if (resultObject) {\n anchor.results = resultObject.elements;\n }\n }\n\n return this.addGlobalDynamicSchema(anchor, this.data.dynamicschema);\n });\n }\n\n /**\n * Create form object based on the data and contributions available in this form\n */\n createFormObject(): FormObjectModel | null {\n if (this.data && this.contributions) {\n const missingAnchors = this.getMissingAnchors();\n\n // Get object id from first anchor\n const objectId = missingAnchors?.[0]?.objectid ?? \"\";\n const contributions = this.contributions.objects?.[objectId];\n if (contributions) {\n return new FormObjectModel(missingAnchors[0], contributions);\n }\n }\n\n return null;\n }\n\n /**\n */\n addEmptyFormObject(\n formObjectModel: FormObjectModel | null = this.currentFormObject\n ) {\n if (formObjectModel) {\n const emptyFormObject = FormObjectModel.createEmpty(formObjectModel);\n\n emptyFormObject.repeatIndex =\n this.getHighestRepeatIndex(formObjectModel) + 1;\n\n this.addFormObject(emptyFormObject);\n }\n }\n\n /**\n */\n getHighestRepeatIndex(formObjectModel: FormObjectModel): number {\n return Math.max(\n ...this.allObjects\n .filter((formObject) => formObject.equals(formObjectModel, false))\n .map((formObject) => formObject.repeatIndex)\n );\n }\n\n /**\n */\n addFormObject(formObjectModel: FormObjectModel) {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\"Missing form object to add\");\n }\n\n this.completedFormObjects = [...this.allObjects];\n this.currentFormObject = formObjectModel;\n }\n\n /**\n * Retrieve a form object by the key\n */\n getFormObjectByKey(key: string): ?FormObjectModel {\n return this.allObjects.find((formObject) => formObject.key === key);\n }\n\n /**\n * Retrieve a form object by a layouthint\n */\n getFormObjectByLayoutHint(hint: string): ?FormObjectModel {\n return this.allObjects.find((formObject) =>\n formObject.layouthint.has(hint)\n );\n }\n\n /**\n */\n removeFormObject(formObjectModel: ?FormObjectModel) {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\"Missing form object to remove\");\n }\n if (formObjectModel.equals(this.currentFormObject)) {\n throw new IllegalArgumentException(\n \"Can not remove the current form object\"\n );\n }\n\n this.completedFormObjects = this.completedFormObjects.filter(\n (formObject) => !formObject.equals(formObjectModel)\n );\n }\n\n /**\n */\n get currentFormObject(): FormObjectModel | null {\n return this._currentFormObject;\n }\n\n /**\n */\n set currentFormObject(formObject: FormObjectModel | null) {\n this._currentFormObject = formObject;\n }\n\n /**\n * Completed objects are previously entered questions\n */\n get completedFormObjects(): Array<FormObjectModel> {\n return this._completedFormObjects;\n }\n\n /**\n */\n set completedFormObjects(formObjects: Array<FormObjectModel>) {\n this._completedFormObjects = formObjects;\n }\n\n /**\n * Previously entered objects are questions that have been entered before,\n * but are currently not applicable for the form.\n * For example because of previous navigation\n */\n get previouslyEnteredFormObjects(): Array<FormObjectModel> {\n return this._previouslyEnteredFormObjects;\n }\n\n /**\n */\n set previouslyEnteredFormObjects(formObjects: Array<FormObjectModel>) {\n this._previouslyEnteredFormObjects = formObjects;\n }\n\n /**\n * Handle end results\n */\n setEndResultFormObjects(): Array<FormObjectModel> {\n if (this.data && this.data.results) {\n const missingObjects = this.data.missing?.anchors ?? [];\n const missingObjectIds = missingObjects.map((anchor) => anchor.objectid);\n\n // Filter out intermediate results and rename elements property to result property\n const endResultAnchors = this.data.results\n .filter((result) => !missingObjectIds.includes(result.objectid))\n .map((result) => {\n const { elements, ...otherProps } = result;\n\n return {\n ...otherProps,\n results: elements,\n };\n });\n\n if (endResultAnchors.length > 0) {\n return endResultAnchors.map(\n (endResult) =>\n new FormObjectModel(\n endResult,\n this.contributions.objects[endResult.objectid]\n )\n );\n }\n }\n\n return [];\n }\n\n /**\n */\n get expectsEndResultFormObjects(): boolean {\n const endResultKeys = this.endResultFormObjects.map(\n (endResult) => endResult.key\n );\n\n return this.objectKeys.some(\n (objectKey) =>\n this.contributions.objects?.[objectKey]?.content?.results &&\n !endResultKeys.includes(objectKey)\n );\n }\n\n /**\n */\n get endResultFormObjects(): Array<FormObjectModel> {\n return this._endResultFormObjects;\n }\n\n /**\n */\n getEndResultFormObjects(): Array<FormObjectModel> {\n return this.endResultFormObjects.filter(\n (endResult) => !this.previousEndResultKeys.includes(endResult.key)\n );\n }\n\n /**\n */\n set endResultFormObjects(endResultFormObjects: Array<FormObjectModel>) {\n this.previousEndResultKeys = this.endResultFormObjects.map(\n (endResult) => endResult.key\n );\n this._endResultFormObjects = endResultFormObjects;\n }\n\n /**\n */\n get previousEndResultKeys(): Array<string> {\n return this._previousEndResultKeys;\n }\n\n /**\n */\n set previousEndResultKeys(endResultFormObjectKeys: Array<string>) {\n this._previousEndResultKeys = endResultFormObjectKeys;\n }\n\n /**\n * Error handling\n */\n get isValid(): boolean {\n if (this.currentFormObject) {\n if (this.currentFormObject.isRepeatable) {\n // repeating objects need at least one valid form object\n const hasOneValidQuestion = this.allObjects\n .filter((object) => object.equals(this.currentFormObject, false))\n .find((object) => object.isValid);\n\n if (hasOneValidQuestion) {\n return true;\n }\n }\n\n return this.currentFormObject?.isValid ?? true;\n }\n\n return true;\n }\n\n /**\n */\n hasServerErrors(): boolean {\n if (this.errorCollection.hasItems) {\n return true;\n }\n\n if (this.currentFormObject) {\n return this.currentFormObject.hasServerErrors();\n }\n\n return false;\n }\n\n /**\n */\n hasErrors(): boolean {\n if (this.errorCollection.hasItems) {\n return true;\n }\n\n if (this.currentFormObject) {\n return this.currentFormObject.hasErrors();\n }\n\n return false;\n }\n\n /**\n * Add an error to the error collection of this form\n */\n addServerError(error: ErrorResponse) {\n if (error.parameters) {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.parameters\n );\n } else {\n this.errorCollection.addServerError(error.id, error.message);\n }\n }\n\n /**\n * Reset error messages\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"form\");\n\n if (this.currentFormObject) {\n this.currentFormObject.resetErrors();\n }\n }\n\n /**\n */\n get errorCollection(): ErrorCollection {\n return this._errorCollection;\n }\n\n /**\n */\n set errorCollection(errorCollection: ErrorCollection) {\n this._errorCollection = errorCollection;\n }\n\n /**\n * Indicates if the form needs to be committed\n */\n get commit(): boolean {\n return this._commit || false;\n }\n\n /**\n */\n set commit(commit: boolean) {\n this._commit = commit;\n }\n\n /**\n * Inidicates if form is finished: Form is completely entered and committed\n */\n get isFinished(): boolean {\n return this._isFinished || \"success\" in this.data;\n }\n\n /**\n */\n set isFinished(isFinished: boolean) {\n this._isFinished = isFinished;\n }\n\n /**\n * Indicates if form is completely entered\n */\n get isComplete(): boolean {\n return this._isComplete;\n }\n\n /**\n */\n set isComplete(isComplete: boolean) {\n this._isComplete = isComplete;\n }\n\n /**\n * Handle success redirects\n */\n get successRedirect(): Href | null {\n return this.isFinished && this.data.success\n ? new Href(this.data.success.redirect)\n : null;\n }\n\n /**\n */\n get redirectLocation(): Href {\n return this._redirectLocation || this.successRedirect;\n }\n\n /**\n */\n getSuccessData(): Object {\n return this.data.success?.data;\n }\n\n /**\n * Href handling\n */\n setParameters(modularuiResponse: ModularUIResponse): Array<Parameter> {\n const parameters = modularuiResponse?.parameters ?? [];\n return parameters.map(\n (par) => new Parameter(par._prefix, par._name, par._value)\n );\n }\n\n /**\n */\n get parameters(): Array<Parameter> {\n return this._parameters;\n }\n\n /**\n */\n set parameters(parameters: Array<Parameter>) {\n this._parameters = parameters;\n }\n\n /**\n */\n selfhrefNoCommitParam(): Href {\n const selfhref = this.selflink.href;\n selfhref.method = HTTP_METHODS.POST;\n\n selfhref.parameters = this.parameters.filter(\n (parameter) => parameter.name !== \"commit\"\n );\n\n return selfhref;\n }\n\n /**\n */\n selfhrefWithCommitParam(): Href {\n const selfhref = this.selfhrefNoCommitParam();\n\n if (this.expectsEndResultFormObjects && !this.isComplete && !this.commit) {\n selfhref.addParameter(\"commit\", \"false\");\n }\n\n return selfhref;\n }\n\n /**\n * Create a selfhref including the parameters that are used to start this form\n */\n get selfhref(): Href {\n if (!this.selflink) {\n throw new Error(\"No self link found for form\");\n }\n\n if (getSetting(\"ALWAYS_COMMIT_FORM\")) {\n return this.selfhrefNoCommitParam();\n }\n\n return this.selfhrefWithCommitParam();\n }\n\n /**\n * Handle form tokens to indicate concurrent form use\n */\n get tokens(): Array<string> {\n if (!this._tokens) {\n this._tokens = this.data.tokens ?? [];\n }\n return this._tokens;\n }\n\n /**\n * Replaces all tokens with the given collection of tokens\n */\n set tokens(tokens: Array<string>) {\n this._tokens = tokens;\n }\n\n /**\n * Removes all tokens from the form\n */\n removeTokens() {\n this._tokens = [];\n }\n\n /**\n * Keep track of changed form\n */\n isChanged(): boolean {\n return (\n this.currentFormObject !== null &&\n this.currentFormObject.isChangedSince(this.lastUpdate)\n );\n }\n\n /**\n */\n get lastUpdate(): number {\n return this._lastUpdate;\n }\n\n /**\n */\n set lastUpdate(lastUpdate: number) {\n this._lastUpdate = lastUpdate;\n }\n\n /**\n */\n getFormDataObjects(\n validOnly: boolean = true,\n validationData: boolean = false\n ): Array<Object> {\n const formdata = [];\n\n const formObjects = this.allObjects.filter((formObject, index) => {\n // repeatabe object without fixed nr of repeats, remove last form object from formdata,\n // because this is the formobject that is used as a placeholder for the create object\n // of the collection of repeats\n if (formObject.isRepeatable && !formObject.hasFixedNrOfRepeats) {\n const isLastRepeat =\n index === this.allObjects.length - 1 ||\n this.allObjects[index + 1].key !== formObject.key;\n\n if (isLastRepeat) {\n return false;\n }\n }\n\n return formObject.isValid || !validOnly;\n });\n\n formObjects.forEach((formObject) => {\n const objectFormData = formObject.getFormData(validationData);\n\n const existingObjectIndex = formdata.findIndex(\n (obj) =>\n obj.key === formObject.key &&\n obj.repeatIndex === formObject.repeatIndex\n );\n\n /*\n * when the object already exists in the formdata with the same key and index,\n * merge the attributes of both objects together\n */\n if (existingObjectIndex > -1) {\n formdata[existingObjectIndex].formdata = deepmerge(\n formdata[existingObjectIndex].formdata,\n objectFormData\n );\n } else {\n formdata.push({\n key: formObject.key,\n repeatIndex: formObject.repeatIndex,\n formdata: objectFormData,\n });\n }\n });\n\n return formdata.map((obj) => ({ [obj.key]: obj.formdata }));\n }\n\n /**\n */\n getFormData(\n validOnly: boolean = true,\n withConcurrencyToken: boolean = true,\n validationData: boolean = false\n ): string {\n if (withConcurrencyToken && this.tokens.length > 0) {\n return JSON.stringify({\n objects: this.getFormDataObjects(validOnly, validationData),\n tokens: this.tokens,\n });\n }\n\n return JSON.stringify({\n objects: this.getFormDataObjects(validOnly, validationData),\n });\n }\n\n /**\n * Used to programmatically overwrite the setting USE_CLIENTSIDE_VALIDATION\n */\n setUseClientsideValidation(enabled: boolean) {\n this._useClientsideValidation = enabled;\n\n this.allObjects.forEach((formObject) => {\n formObject.attributeCollection.all.forEach((item: AttributeType) =>\n item.setUseClientsideValidation(enabled)\n );\n });\n }\n\n /**\n * Indicates if client side validation is enabled\n * @returns {boolean}\n */\n useClientsideValidation(): boolean {\n return this._useClientsideValidation ?? true;\n }\n\n /**\n * Get form data for submitting\n */\n get formdata(): string {\n return this.getFormData(this.useClientsideValidation());\n }\n\n /**\n */\n get validationData(): string {\n return this.getFormData(false, false, true);\n }\n\n /**\n * Form navigation: Go one object back (previous button)\n */\n get hasPreviousStep(): boolean {\n const currentFormObjectKey =\n this.currentFormObject != null ? this.currentFormObject.key : \"\";\n\n return (\n this.completedFormObjects.filter(\n (formObject) =>\n !formObject.isRepeatWithUnknownTotal ||\n formObject.key !== currentFormObjectKey\n ).length > 0\n );\n }\n\n /**\n * Go one form-object back,\n * for repeating object this means go back\n * until we get at a form object that had\n * a different key than the current form object\n */\n setPreviousObject() {\n this.isComplete = false;\n\n const oldCurrentFormObject = this.currentFormObject;\n\n if (this.currentFormObject !== null) {\n this.previouslyEnteredFormObjects = [\n this.currentFormObject,\n ...this.previouslyEnteredFormObjects,\n ];\n }\n\n this.currentFormObject =\n this.completedFormObjects[this.completedFormObjects.length - 1];\n this.completedFormObjects = this.completedFormObjects.slice(0, -1);\n\n const completedFormObjectKeys = this.completedFormObjects\n .map((formObject) => formObject.key)\n .filter((formObjectKey) => formObjectKey !== this.currentFormObject?.key);\n\n this.endResultFormObjects = this._endResultFormObjects.filter((endResult) =>\n completedFormObjectKeys.includes(endResult.key)\n );\n this.previousEndResultKeys = this.endResultFormObjects.map(\n (endResult) => endResult.key\n );\n\n // while we are at the same repeating form object, go a step back\n if (\n this.currentFormObject &&\n this.currentFormObject.equals(\n oldCurrentFormObject,\n this.currentFormObject.hasFixedNrOfRepeats\n )\n ) {\n this.setPreviousObject();\n }\n }\n\n /**\n * Form navigation: has next step or is last\n */\n get hasNextStep(): boolean {\n if (\n this.isComplete ||\n this.isFinished ||\n this.hasNoQuestionsConfigured ||\n !this.contributions.objects\n ) {\n return false;\n }\n\n // current object is a dynamic object\n if (this.currentFormObject && this.currentFormObject.isDynamic) {\n return true;\n }\n\n if (this.expectsEndResultFormObjects) {\n return true;\n }\n\n const currentObjectIndex = this.objectKeys.findIndex(\n (objectKey) => objectKey === this.currentFormObject?.key\n );\n const isLastObject = this.objectKeys.length - 1 === currentObjectIndex;\n\n // current object is a repeating question but it is not the last one\n if (\n isLastObject &&\n this.currentFormObject &&\n this.currentFormObject.isRepeatable &&\n !this.currentFormObject.isLastRepeat\n ) {\n return true;\n }\n\n // current object is not repeatable and the last object\n if (isLastObject) {\n return false;\n }\n\n // can't determine if this is te last, render a next button\n return true;\n }\n\n /**\n * Merge existing form with new form\n */\n update(receivedForm: ModularUIModel): FormModel {\n if (receivedForm instanceof FormModel) {\n this.resetErrors();\n\n this.lastUpdate = Date.now();\n this.lastServerUpdate = receivedForm.lastServerUpdate;\n\n this.tokens = receivedForm.tokens;\n\n this.isComplete = receivedForm.isComplete;\n this.isFinished = receivedForm.isFinished;\n\n const receivedFormData = receivedForm.data ?? {};\n const hasMissing = has(receivedFormData, \"missing\");\n const hasErrors = has(receivedFormData, \"errors\");\n\n if (!hasMissing && !hasErrors) {\n this.handleFinished(receivedForm);\n }\n\n if (hasErrors) {\n this.handleErrors(receivedForm);\n }\n\n if (hasMissing) {\n this.handleMissing(receivedForm);\n }\n }\n\n return this;\n }\n\n /**\n */\n updateValidations(data: any): FormModel {\n if (this.currentFormObject) {\n this.currentFormObject.updateValidations(data);\n }\n\n return this;\n }\n\n /**\n * Process finished form\n */\n handleFinished(receivedForm: FormModel) {\n if (this.currentFormObject) {\n this.completedFormObjects = [\n ...this.completedFormObjects,\n this.currentFormObject,\n ];\n }\n\n this.currentFormObject = receivedForm.currentFormObject;\n this.endResultFormObjects = receivedForm.endResultFormObjects;\n\n this._data = receivedForm._data;\n }\n\n /**\n */\n handleRootErrors(errors: Array<Object>) {\n errors\n .filter((error) => !error.anchor)\n .forEach((error) => {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties\n );\n });\n }\n\n /**\n * Process errors from received form\n */\n handleErrors(receivedForm: FormModel) {\n const errorAnchors = receivedForm.data.errors;\n if (errorAnchors) {\n errorAnchors.forEach((error) => {\n if (\n error.anchor &&\n this.currentFormObject &&\n this.currentFormObject.key === error.anchor.objectid\n ) {\n this.currentFormObject.addServerError(error);\n } else {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties\n );\n }\n });\n }\n }\n\n /**\n * Process missing from received form\n */\n handleMissing(receivedForm: FormModel) {\n if (\n this.currentFormObject &&\n this.currentFormObject.equals(receivedForm.currentFormObject)\n ) {\n this.handleMissingErrors(receivedForm);\n } else {\n this.handleNewFormObject(receivedForm);\n }\n }\n\n /**\n * Received missing anchors in the response with an object id that is the current form object\n */\n processMissingErrors(receivedForm: FormModel): FormObjectModel | null {\n if (this.currentFormObject === null) {\n return null;\n }\n\n this.currentFormObject.attributeCollection.map((attribute) => {\n if (\n receivedForm.currentFormObject &&\n receivedForm.currentFormObject.hasAttributeByKey(attribute.key)\n ) {\n attribute.addMissingError();\n } else {\n attribute.removeMissingError();\n }\n\n return attribute;\n });\n\n return this.currentFormObject;\n }\n\n /**\n */\n handleMissingErrors(receivedForm: FormModel) {\n this.currentFormObject = this.processMissingErrors(receivedForm);\n }\n\n /**\n */\n handleNewFormObject(receivedForm: FormModel) {\n this.endResultFormObjects = receivedForm.endResultFormObjects;\n\n const receivedCurrentFormObject = receivedForm.currentFormObject;\n\n if (receivedCurrentFormObject === null) {\n this.completedFormObjects = [...this.allObjects];\n this.currentFormObject = null;\n } else {\n // check if received form exists in the previously entered form objects\n const previouslyEnteredFormObjects =\n this.previouslyEnteredFormObjects.filter((formObject) =>\n formObject.equals(\n receivedCurrentFormObject,\n formObject.hasFixedNrOfRepeats\n )\n );\n\n if (previouslyEnteredFormObjects.length > 0) {\n this.handlePreviouslyEnteredFormObjects(\n receivedCurrentFormObject,\n previouslyEnteredFormObjects\n );\n } else {\n this.completedFormObjects = [...this.allObjects];\n this.currentFormObject = receivedCurrentFormObject;\n }\n }\n }\n\n /**\n * Indicate if a new form object model should be merged with a previousled entered form object model\n * Set this property to false on the form that receives the new form to skip the merge behavior\n */\n get mergePreviouslyEnteredObjects(): boolean {\n return this._mergePreviouslyEnteredObjects;\n }\n\n /**\n */\n set mergePreviouslyEnteredObjects(mergePreviouslyEnteredObjects: boolean) {\n this._mergePreviouslyEnteredObjects = mergePreviouslyEnteredObjects;\n }\n\n /**\n */\n handlePreviouslyEnteredFormObjects(\n receivedCurrentFormObject: FormObjectModel,\n previouslyEnteredFormObjects: Array<FormObjectModel>\n ) {\n previouslyEnteredFormObjects.forEach((previouslyEnteredFormObject) => {\n const mergedObject = this.mergePreviouslyEnteredObjects\n ? this.mergeObjects(\n receivedCurrentFormObject,\n previouslyEnteredFormObject\n )\n : receivedCurrentFormObject;\n\n this.addFormObject(mergedObject);\n });\n\n // remove the previously entered form object\n this.previouslyEnteredFormObjects =\n this.previouslyEnteredFormObjects.filter((formObject) => {\n const hasPreviouslyEnteredObject = previouslyEnteredFormObjects.find(\n (previouslyEnteredFormObject) =>\n formObject.equals(previouslyEnteredFormObject)\n );\n\n return !hasPreviouslyEnteredObject;\n });\n }\n\n /**\n */\n mergeObjects(\n newObject: FormObjectModel,\n oldObject: FormObjectModel\n ): FormObjectModel {\n const mergedFormObject = FormObjectModel.createEmpty(newObject);\n\n mergedFormObject.mergeObject(oldObject);\n\n return mergedFormObject;\n }\n\n /**\n */\n findAttribute(findMethod: Function): AttributeType | null {\n let foundAttribute = null;\n\n this.allObjects.forEach((formObject) => {\n if (foundAttribute === null) {\n foundAttribute =\n formObject.attributeCollection.all.find((item) => findMethod(item)) ||\n null;\n }\n });\n\n return foundAttribute;\n }\n}\n\nexport default FormModel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAWA;AACA;AACA,MAAMA,SAAN,SAAwBC,sBAAxB,CAAsC;EAwBpC;AACF;EACEC,WAAW,CAACC,iBAAD,EAAuC;IAChD,MAAMA,iBAAN;IADgD;IAAA,6DAvBF,EAuBE;IAAA,0DAtBL,IAsBK;IAAA,qEArBM,EAqBN;IAAA,sEAnBR,IAmBQ;IAAA,6DAjBF,EAiBE;IAAA,8DAhBV,EAgBU;IAAA,gEAdd,IAAAC,oBAAA,EAAW,2BAAX,CAcc;IAAA,wDAbd,IAAIC,wBAAJ,CAAoB,MAApB,CAac;IAAA;IAAA;IAAA;IAAA;IAA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CAACG,0BAAR;IACD,CAPD,CADF;EASD;EAED;AACF;;;EACED,YAAY,CACVE,SADU,EAEVC,SAFU,EAGO;IACjB,MAAMC,gBAAgB,GAAGtJ,wBAAA,CAAgBI,WAAhB,CAA4BgJ,SAA5B,CAAzB;;IAEAE,gBAAgB,CAACC,WAAjB,CAA6BF,SAA7B;IAEA,OAAOC,gBAAP;EACD;EAED;AACF;;;EACEE,aAAa,CAACC,UAAD,EAA6C;IACxD,IAAIC,cAAc,GAAG,IAArB;IAEA,KAAKhL,UAAL,CAAgBN,OAAhB,CAAyBsC,UAAD,IAAgB;MACtC,IAAIgJ,cAAc,KAAK,IAAvB,EAA6B;QAAA;;QAC3BA,cAAc,GACZ,gCAAAhJ,UAAU,CAAC+F,mBAAX,CAA+BC,GAA/B,mBAAyCpH,IAAD,IAAUmK,UAAU,CAACnK,IAAD,CAA5D,KACA,IAFF;MAGD;IACF,CAND;IAQA,OAAOoK,cAAP;EACD;;AAvnCmC;;eA0nCvBzN,S"}
1
+ {"version":3,"file":"FormModel.js","names":["FormModel","ResourceModel","constructor","modularuiResponse","getSetting","ErrorCollection","lastUpdate","currentFormObject","createFormObject","endResultFormObjects","setEndResultFormObjects","parameters","setParameters","isComplete","getData","data","errors","handleRootErrors","type","actiontype","layouthint","has","CREATE_ACTION","UPDATE_ACTION","DELETE_ACTION","getContribution","isApplicableModel","contributions","resourcetype","getInitialChildModelLinks","endResultChildLinks","flattenDeep","endResultFormObject","setChildModels","models","forEach","label","buttonLabels","getButtonLabel","buttonType","cancel","allObjects","completedFormObjects","objectKeys","objects","numberOfExpectedQuestions","length","hasNoQuestionsConfigured","addGlobalDynamicSchema","anchor","dynamicschema","elements","element","item","getMissingAnchors","missingAnchors","missing","anchors","results","resultObject","result","objectid","objectId","FormObjectModel","addEmptyFormObject","formObjectModel","emptyFormObject","createEmpty","repeatIndex","getHighestRepeatIndex","addFormObject","Math","max","formObject","equals","IllegalArgumentException","getFormObjectByKey","key","getFormObjectByLayoutHint","hint","removeFormObject","_currentFormObject","_completedFormObjects","formObjects","previouslyEnteredFormObjects","_previouslyEnteredFormObjects","missingObjects","missingObjectIds","endResultAnchors","otherProps","endResult","expectsEndResultFormObjects","endResultKeys","some","objectKey","content","_endResultFormObjects","getEndResultFormObjects","previousEndResultKeys","_previousEndResultKeys","endResultFormObjectKeys","isValid","isRepeatable","hasOneValidQuestion","object","hasServerErrors","errorCollection","hasItems","hasErrors","addServerError","error","id","message","resetErrors","_errorCollection","commit","_commit","isFinished","_isFinished","_isComplete","successRedirect","success","Href","redirect","redirectLocation","_redirectLocation","getSuccessData","par","Parameter","_prefix","_name","_value","_parameters","selfhrefNoCommitParam","selfhref","selflink","href","method","HTTP_METHODS","POST","parameter","name","selfhrefWithCommitParam","addParameter","Error","tokens","_tokens","removeTokens","isChanged","isChangedSince","_lastUpdate","getFormDataObjects","validOnly","validationData","formdata","index","hasFixedNrOfRepeats","isLastRepeat","objectFormData","getFormData","existingObjectIndex","obj","deepmerge","push","withConcurrencyToken","setUseClientsideValidation","enabled","_useClientsideValidation","attributeCollection","all","useClientsideValidation","hasPreviousStep","currentFormObjectKey","isRepeatWithUnknownTotal","setPreviousObject","oldCurrentFormObject","completedFormObjectKeys","formObjectKey","hasNextStep","isDynamic","currentObjectIndex","isLastObject","update","receivedForm","Date","now","lastServerUpdate","receivedFormData","hasMissing","handleFinished","handleErrors","handleMissing","updateValidations","_data","properties","errorAnchors","LayoutHintCollection","handleMissingErrors","handleNewFormObject","processMissingErrors","attribute","hasAttributeByKey","addMissingError","removeMissingError","receivedCurrentFormObject","handlePreviouslyEnteredFormObjects","mergePreviouslyEnteredObjects","_mergePreviouslyEnteredObjects","previouslyEnteredFormObject","mergedObject","mergeObjects","hasPreviouslyEnteredObject","newObject","oldObject","mergedFormObject","mergeObject","findAttribute","findMethod","foundAttribute"],"sources":["../../../src/models/form/FormModel.js"],"sourcesContent":["// @flow\nimport flattenDeep from \"lodash/flattenDeep\";\nimport deepmerge from \"deepmerge\";\n\nimport { has } from \"../../utils/helpers/objects\";\n\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport ResourceModel from \"../base/ResourceModel\";\nimport ErrorCollection from \"../error/ErrorCollection\";\n\nimport Href from \"../href/Href\";\nimport Parameter from \"../parameter/Parameter\";\n\nimport FormObjectModel from \"./FormObjectModel\";\n\nimport { HTTP_METHODS } from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\nimport {\n CREATE_ACTION,\n DELETE_ACTION,\n UPDATE_ACTION,\n} from \"../../constants/LayoutHints\";\n\nimport type { AttributeType, ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\nimport type LinkModel from \"../links/LinkModel\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\n\n/**\n */\nclass FormModel extends ResourceModel {\n _lastUpdate: number;\n\n _completedFormObjects: Array<FormObjectModel> = [];\n _currentFormObject: FormObjectModel | null = null;\n _previouslyEnteredFormObjects: Array<FormObjectModel> = [];\n\n _mergePreviouslyEnteredObjects: boolean = true;\n\n _endResultFormObjects: Array<FormObjectModel> = [];\n _previousEndResultKeys: Array<string> = [];\n\n _useClientsideValidation: boolean = getSetting(\"USE_CLIENTSIDE_VALIDATION\");\n _errorCollection: ErrorCollection = new ErrorCollection(\"form\");\n\n _redirectLocation: Href;\n\n _commit: boolean;\n _isFinished: boolean;\n _isComplete: boolean;\n\n _parameters: Array<Parameter>;\n _tokens: Array<string>;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this.lastUpdate = 0;\n\n this.currentFormObject = this.createFormObject();\n this.endResultFormObjects = this.setEndResultFormObjects();\n\n this.parameters = this.setParameters(modularuiResponse);\n\n this.isComplete = this.getData(\"complete\", false);\n\n if (this.data.errors) {\n this.handleRootErrors(this.data.errors);\n }\n }\n\n /**\n */\n get type(): string {\n return \"Form\";\n }\n\n /**\n */\n get actiontype(): string {\n if (this.layouthint.has(CREATE_ACTION)) {\n return \"create\";\n }\n if (this.layouthint.has(UPDATE_ACTION)) {\n return \"update\";\n }\n if (this.layouthint.has(DELETE_ACTION)) {\n return \"delete\";\n }\n\n return this.getContribution(\"actiontype\", \"form\");\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Form\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const endResultChildLinks = flattenDeep(\n this.endResultFormObjects.map((endResultFormObject) =>\n endResultFormObject.getInitialChildModelLinks()\n )\n );\n\n if (this.currentFormObject === null) {\n return endResultChildLinks;\n }\n\n return [\n ...this.currentFormObject.getInitialChildModelLinks(),\n ...endResultChildLinks,\n ];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n if (this.currentFormObject) {\n this.currentFormObject.setChildModels(models);\n }\n\n this.endResultFormObjects.forEach((endResultFormObject) => {\n endResultFormObject.setChildModels(models);\n });\n }\n\n /**\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Get form level button labels\n */\n get buttonLabels(): Object {\n return this.getContribution(\"buttonLabels\", {});\n }\n\n /**\n * @returns button label from contributions;\n */\n getButtonLabel(\n buttonType: \"cancel\" | \"previous\" | \"next\" | \"finish\"\n ): string | null {\n // cancel button labels are defined on the form\n if (buttonType === \"cancel\") {\n return this.buttonLabels?.cancel ?? null;\n }\n\n // all other form related button labels are defined on the object\n return this.currentFormObject?.buttonLabels?.[buttonType] ?? null;\n }\n\n /**\n * Get all applicable objects\n */\n get allObjects(): Array<FormObjectModel> {\n if (this.currentFormObject === null) {\n return this.completedFormObjects;\n }\n\n return [...this.completedFormObjects, this.currentFormObject];\n }\n\n /**\n */\n get objectKeys(): Array<string> {\n if (has(this.contributions, \"objects\")) {\n return Object.keys(this.contributions.objects);\n }\n\n return [];\n }\n\n /**\n */\n get numberOfExpectedQuestions(): number {\n return this.objectKeys.length;\n }\n\n /**\n * Has questions configured on form\n */\n get hasNoQuestionsConfigured(): boolean {\n return (\n this.isComplete &&\n (this.objectKeys.length === 0 ||\n (!(\"missing\" in this.data) &&\n !(\"results\" in this.data) &&\n !(\"errors\" in this.data)))\n );\n }\n\n /**\n */\n addGlobalDynamicSchema(anchor: Object, dynamicschema: Object): Object {\n if (!dynamicschema) {\n return anchor;\n }\n\n return {\n ...anchor,\n elements: anchor.elements.map((element) => ({\n ...element,\n dynamicschema: element.dynamicschema\n ? element.dynamicschema.map((item) => ({\n ...item,\n elements: { ...item.elements, dynamicschema },\n }))\n : null,\n })),\n };\n }\n\n /**\n */\n getMissingAnchors(): Array<Object> {\n const missingAnchors = this.data.missing?.anchors ?? [];\n\n // Add intermediate result data to anchor\n return missingAnchors.map((anchor) => {\n if (this.data.results) {\n const resultObject = this.data.results.find(\n (result) =>\n result.objectid === anchor.objectid && \"elements\" in result\n );\n\n if (resultObject) {\n anchor.results = resultObject.elements;\n }\n }\n\n return this.addGlobalDynamicSchema(anchor, this.data.dynamicschema);\n });\n }\n\n /**\n * Create form object based on the data and contributions available in this form\n */\n createFormObject(): FormObjectModel | null {\n if (this.data && this.contributions) {\n const missingAnchors = this.getMissingAnchors();\n\n // Get object id from first anchor\n const objectId = missingAnchors?.[0]?.objectid ?? \"\";\n const contributions = this.contributions.objects?.[objectId];\n if (contributions) {\n return new FormObjectModel(missingAnchors[0], contributions);\n }\n }\n\n return null;\n }\n\n /**\n */\n addEmptyFormObject(\n formObjectModel: FormObjectModel | null = this.currentFormObject\n ) {\n if (formObjectModel) {\n const emptyFormObject = FormObjectModel.createEmpty(formObjectModel);\n\n emptyFormObject.repeatIndex =\n this.getHighestRepeatIndex(formObjectModel) + 1;\n\n this.addFormObject(emptyFormObject);\n }\n }\n\n /**\n */\n getHighestRepeatIndex(formObjectModel: FormObjectModel): number {\n return Math.max(\n ...this.allObjects\n .filter((formObject) => formObject.equals(formObjectModel, false))\n .map((formObject) => formObject.repeatIndex)\n );\n }\n\n /**\n */\n addFormObject(formObjectModel: FormObjectModel) {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\"Missing form object to add\");\n }\n\n this.completedFormObjects = [...this.allObjects];\n this.currentFormObject = formObjectModel;\n }\n\n /**\n * Retrieve a form object by the key\n */\n getFormObjectByKey(key: string): ?FormObjectModel {\n return this.allObjects.find((formObject) => formObject.key === key);\n }\n\n /**\n * Retrieve a form object by a layouthint\n */\n getFormObjectByLayoutHint(hint: string): ?FormObjectModel {\n return this.allObjects.find((formObject) =>\n formObject.layouthint.has(hint)\n );\n }\n\n /**\n */\n removeFormObject(formObjectModel: ?FormObjectModel) {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\"Missing form object to remove\");\n }\n if (formObjectModel.equals(this.currentFormObject)) {\n throw new IllegalArgumentException(\n \"Can not remove the current form object\"\n );\n }\n\n this.completedFormObjects = this.completedFormObjects.filter(\n (formObject) => !formObject.equals(formObjectModel)\n );\n }\n\n /**\n */\n get currentFormObject(): FormObjectModel | null {\n return this._currentFormObject;\n }\n\n /**\n */\n set currentFormObject(formObject: FormObjectModel | null) {\n this._currentFormObject = formObject;\n }\n\n /**\n * Completed objects are previously entered questions\n */\n get completedFormObjects(): Array<FormObjectModel> {\n return this._completedFormObjects;\n }\n\n /**\n */\n set completedFormObjects(formObjects: Array<FormObjectModel>) {\n this._completedFormObjects = formObjects;\n }\n\n /**\n * Previously entered objects are questions that have been entered before,\n * but are currently not applicable for the form.\n * For example because of previous navigation\n */\n get previouslyEnteredFormObjects(): Array<FormObjectModel> {\n return this._previouslyEnteredFormObjects;\n }\n\n /**\n */\n set previouslyEnteredFormObjects(formObjects: Array<FormObjectModel>) {\n this._previouslyEnteredFormObjects = formObjects;\n }\n\n /**\n * Handle end results\n */\n setEndResultFormObjects(): Array<FormObjectModel> {\n if (this.data && this.data.results) {\n const missingObjects = this.data.missing?.anchors ?? [];\n const missingObjectIds = missingObjects.map((anchor) => anchor.objectid);\n\n // Filter out intermediate results and rename elements property to result property\n const endResultAnchors = this.data.results\n .filter((result) => !missingObjectIds.includes(result.objectid))\n .map((result) => {\n const { elements, ...otherProps } = result;\n\n return {\n ...otherProps,\n results: elements,\n };\n });\n\n if (endResultAnchors.length > 0) {\n return endResultAnchors.map(\n (endResult) =>\n new FormObjectModel(\n endResult,\n this.contributions.objects[endResult.objectid]\n )\n );\n }\n }\n\n return [];\n }\n\n /**\n */\n get expectsEndResultFormObjects(): boolean {\n const endResultKeys = this.endResultFormObjects.map(\n (endResult) => endResult.key\n );\n\n return this.objectKeys.some(\n (objectKey) =>\n this.contributions.objects?.[objectKey]?.content?.results &&\n !endResultKeys.includes(objectKey)\n );\n }\n\n /**\n */\n get endResultFormObjects(): Array<FormObjectModel> {\n return this._endResultFormObjects;\n }\n\n /**\n */\n getEndResultFormObjects(): Array<FormObjectModel> {\n return this.endResultFormObjects.filter(\n (endResult) => !this.previousEndResultKeys.includes(endResult.key)\n );\n }\n\n /**\n */\n set endResultFormObjects(endResultFormObjects: Array<FormObjectModel>) {\n this.previousEndResultKeys = this.endResultFormObjects.map(\n (endResult) => endResult.key\n );\n this._endResultFormObjects = endResultFormObjects;\n }\n\n /**\n */\n get previousEndResultKeys(): Array<string> {\n return this._previousEndResultKeys;\n }\n\n /**\n */\n set previousEndResultKeys(endResultFormObjectKeys: Array<string>) {\n this._previousEndResultKeys = endResultFormObjectKeys;\n }\n\n /**\n * Error handling\n */\n get isValid(): boolean {\n if (this.currentFormObject) {\n if (this.currentFormObject.isRepeatable) {\n // repeating objects need at least one valid form object\n const hasOneValidQuestion = this.allObjects\n .filter((object) => object.equals(this.currentFormObject, false))\n .find((object) => object.isValid);\n\n if (hasOneValidQuestion) {\n return true;\n }\n }\n\n return this.currentFormObject?.isValid ?? true;\n }\n\n return true;\n }\n\n /**\n */\n hasServerErrors(): boolean {\n if (this.errorCollection.hasItems) {\n return true;\n }\n\n if (this.currentFormObject) {\n return this.currentFormObject.hasServerErrors();\n }\n\n return false;\n }\n\n /**\n */\n hasErrors(): boolean {\n if (this.errorCollection.hasItems) {\n return true;\n }\n\n if (this.currentFormObject) {\n return this.currentFormObject.hasErrors();\n }\n\n return false;\n }\n\n /**\n * Add an error to the error collection of this form\n */\n addServerError(error: ErrorResponse) {\n if (error.parameters) {\n this.errorCollection.addServerError(\n error.id,\n error.layouthint,\n error.message,\n error.parameters\n );\n } else {\n this.errorCollection.addServerError(\n error.id,\n error.layouthint,\n error.message\n );\n }\n }\n\n /**\n * Reset error messages\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"form\");\n\n if (this.currentFormObject) {\n this.currentFormObject.resetErrors();\n }\n }\n\n /**\n */\n get errorCollection(): ErrorCollection {\n return this._errorCollection;\n }\n\n /**\n */\n set errorCollection(errorCollection: ErrorCollection) {\n this._errorCollection = errorCollection;\n }\n\n /**\n * Indicates if the form needs to be committed\n */\n get commit(): boolean {\n return this._commit || false;\n }\n\n /**\n */\n set commit(commit: boolean) {\n this._commit = commit;\n }\n\n /**\n * Inidicates if form is finished: Form is completely entered and committed\n */\n get isFinished(): boolean {\n return this._isFinished || \"success\" in this.data;\n }\n\n /**\n */\n set isFinished(isFinished: boolean) {\n this._isFinished = isFinished;\n }\n\n /**\n * Indicates if form is completely entered\n */\n get isComplete(): boolean {\n return this._isComplete;\n }\n\n /**\n */\n set isComplete(isComplete: boolean) {\n this._isComplete = isComplete;\n }\n\n /**\n * Handle success redirects\n */\n get successRedirect(): Href | null {\n return this.isFinished && this.data.success\n ? new Href(this.data.success.redirect)\n : null;\n }\n\n /**\n */\n get redirectLocation(): Href {\n return this._redirectLocation || this.successRedirect;\n }\n\n /**\n */\n getSuccessData(): Object {\n return this.data.success?.data;\n }\n\n /**\n * Href handling\n */\n setParameters(modularuiResponse: ModularUIResponse): Array<Parameter> {\n const parameters = modularuiResponse?.parameters ?? [];\n return parameters.map(\n (par) => new Parameter(par._prefix, par._name, par._value)\n );\n }\n\n /**\n */\n get parameters(): Array<Parameter> {\n return this._parameters;\n }\n\n /**\n */\n set parameters(parameters: Array<Parameter>) {\n this._parameters = parameters;\n }\n\n /**\n */\n selfhrefNoCommitParam(): Href {\n const selfhref = this.selflink.href;\n selfhref.method = HTTP_METHODS.POST;\n\n selfhref.parameters = this.parameters.filter(\n (parameter) => parameter.name !== \"commit\"\n );\n\n return selfhref;\n }\n\n /**\n */\n selfhrefWithCommitParam(): Href {\n const selfhref = this.selfhrefNoCommitParam();\n\n if (this.expectsEndResultFormObjects && !this.isComplete && !this.commit) {\n selfhref.addParameter(\"commit\", \"false\");\n }\n\n return selfhref;\n }\n\n /**\n * Create a selfhref including the parameters that are used to start this form\n */\n get selfhref(): Href {\n if (!this.selflink) {\n throw new Error(\"No self link found for form\");\n }\n\n if (getSetting(\"ALWAYS_COMMIT_FORM\")) {\n return this.selfhrefNoCommitParam();\n }\n\n return this.selfhrefWithCommitParam();\n }\n\n /**\n * Handle form tokens to indicate concurrent form use\n */\n get tokens(): Array<string> {\n if (!this._tokens) {\n this._tokens = this.data.tokens ?? [];\n }\n return this._tokens;\n }\n\n /**\n * Replaces all tokens with the given collection of tokens\n */\n set tokens(tokens: Array<string>) {\n this._tokens = tokens;\n }\n\n /**\n * Removes all tokens from the form\n */\n removeTokens() {\n this._tokens = [];\n }\n\n /**\n * Keep track of changed form\n */\n isChanged(): boolean {\n return (\n this.currentFormObject !== null &&\n this.currentFormObject.isChangedSince(this.lastUpdate)\n );\n }\n\n /**\n */\n get lastUpdate(): number {\n return this._lastUpdate;\n }\n\n /**\n */\n set lastUpdate(lastUpdate: number) {\n this._lastUpdate = lastUpdate;\n }\n\n /**\n */\n getFormDataObjects(\n validOnly: boolean = true,\n validationData: boolean = false\n ): Array<Object> {\n const formdata = [];\n\n const formObjects = this.allObjects.filter((formObject, index) => {\n // repeatabe object without fixed nr of repeats, remove last form object from formdata,\n // because this is the formobject that is used as a placeholder for the create object\n // of the collection of repeats\n if (formObject.isRepeatable && !formObject.hasFixedNrOfRepeats) {\n const isLastRepeat =\n index === this.allObjects.length - 1 ||\n this.allObjects[index + 1].key !== formObject.key;\n\n if (isLastRepeat) {\n return false;\n }\n }\n\n return formObject.isValid || !validOnly;\n });\n\n formObjects.forEach((formObject) => {\n const objectFormData = formObject.getFormData(validationData);\n\n const existingObjectIndex = formdata.findIndex(\n (obj) =>\n obj.key === formObject.key &&\n obj.repeatIndex === formObject.repeatIndex\n );\n\n /*\n * when the object already exists in the formdata with the same key and index,\n * merge the attributes of both objects together\n */\n if (existingObjectIndex > -1) {\n formdata[existingObjectIndex].formdata = deepmerge(\n formdata[existingObjectIndex].formdata,\n objectFormData\n );\n } else {\n formdata.push({\n key: formObject.key,\n repeatIndex: formObject.repeatIndex,\n formdata: objectFormData,\n });\n }\n });\n\n return formdata.map((obj) => ({ [obj.key]: obj.formdata }));\n }\n\n /**\n */\n getFormData(\n validOnly: boolean = true,\n withConcurrencyToken: boolean = true,\n validationData: boolean = false\n ): string {\n if (withConcurrencyToken && this.tokens.length > 0) {\n return JSON.stringify({\n objects: this.getFormDataObjects(validOnly, validationData),\n tokens: this.tokens,\n });\n }\n\n return JSON.stringify({\n objects: this.getFormDataObjects(validOnly, validationData),\n });\n }\n\n /**\n * Used to programmatically overwrite the setting USE_CLIENTSIDE_VALIDATION\n */\n setUseClientsideValidation(enabled: boolean) {\n this._useClientsideValidation = enabled;\n\n this.allObjects.forEach((formObject) => {\n formObject.attributeCollection.all.forEach((item: AttributeType) =>\n item.setUseClientsideValidation(enabled)\n );\n });\n }\n\n /**\n * Indicates if client side validation is enabled\n * @returns {boolean}\n */\n useClientsideValidation(): boolean {\n return this._useClientsideValidation ?? true;\n }\n\n /**\n * Get form data for submitting\n */\n get formdata(): string {\n return this.getFormData(this.useClientsideValidation());\n }\n\n /**\n */\n get validationData(): string {\n return this.getFormData(false, false, true);\n }\n\n /**\n * Form navigation: Go one object back (previous button)\n */\n get hasPreviousStep(): boolean {\n const currentFormObjectKey =\n this.currentFormObject != null ? this.currentFormObject.key : \"\";\n\n return (\n this.completedFormObjects.filter(\n (formObject) =>\n !formObject.isRepeatWithUnknownTotal ||\n formObject.key !== currentFormObjectKey\n ).length > 0\n );\n }\n\n /**\n * Go one form-object back,\n * for repeating object this means go back\n * until we get at a form object that had\n * a different key than the current form object\n */\n setPreviousObject() {\n this.isComplete = false;\n\n const oldCurrentFormObject = this.currentFormObject;\n\n if (this.currentFormObject !== null) {\n this.previouslyEnteredFormObjects = [\n this.currentFormObject,\n ...this.previouslyEnteredFormObjects,\n ];\n }\n\n this.currentFormObject =\n this.completedFormObjects[this.completedFormObjects.length - 1];\n this.completedFormObjects = this.completedFormObjects.slice(0, -1);\n\n const completedFormObjectKeys = this.completedFormObjects\n .map((formObject) => formObject.key)\n .filter((formObjectKey) => formObjectKey !== this.currentFormObject?.key);\n\n this.endResultFormObjects = this._endResultFormObjects.filter((endResult) =>\n completedFormObjectKeys.includes(endResult.key)\n );\n this.previousEndResultKeys = this.endResultFormObjects.map(\n (endResult) => endResult.key\n );\n\n // while we are at the same repeating form object, go a step back\n if (\n this.currentFormObject &&\n this.currentFormObject.equals(\n oldCurrentFormObject,\n this.currentFormObject.hasFixedNrOfRepeats\n )\n ) {\n this.setPreviousObject();\n }\n }\n\n /**\n * Form navigation: has next step or is last\n */\n get hasNextStep(): boolean {\n if (\n this.isComplete ||\n this.isFinished ||\n this.hasNoQuestionsConfigured ||\n !this.contributions.objects\n ) {\n return false;\n }\n\n // current object is a dynamic object\n if (this.currentFormObject && this.currentFormObject.isDynamic) {\n return true;\n }\n\n if (this.expectsEndResultFormObjects) {\n return true;\n }\n\n const currentObjectIndex = this.objectKeys.findIndex(\n (objectKey) => objectKey === this.currentFormObject?.key\n );\n const isLastObject = this.objectKeys.length - 1 === currentObjectIndex;\n\n // current object is a repeating question but it is not the last one\n if (\n isLastObject &&\n this.currentFormObject &&\n this.currentFormObject.isRepeatable &&\n !this.currentFormObject.isLastRepeat\n ) {\n return true;\n }\n\n // current object is not repeatable and the last object\n if (isLastObject) {\n return false;\n }\n\n // can't determine if this is te last, render a next button\n return true;\n }\n\n /**\n * Merge existing form with new form\n */\n update(receivedForm: ModularUIModel): FormModel {\n if (receivedForm instanceof FormModel) {\n this.resetErrors();\n\n this.lastUpdate = Date.now();\n this.lastServerUpdate = receivedForm.lastServerUpdate;\n\n this.tokens = receivedForm.tokens;\n\n this.isComplete = receivedForm.isComplete;\n this.isFinished = receivedForm.isFinished;\n\n const receivedFormData = receivedForm.data ?? {};\n const hasMissing = has(receivedFormData, \"missing\");\n const hasErrors = has(receivedFormData, \"errors\");\n\n if (!hasMissing && !hasErrors) {\n this.handleFinished(receivedForm);\n }\n\n if (hasErrors) {\n this.handleErrors(receivedForm);\n }\n\n if (hasMissing) {\n this.handleMissing(receivedForm);\n }\n }\n\n return this;\n }\n\n /**\n */\n updateValidations(data: any): FormModel {\n if (this.currentFormObject) {\n this.currentFormObject.updateValidations(data);\n }\n\n return this;\n }\n\n /**\n * Process finished form\n */\n handleFinished(receivedForm: FormModel) {\n if (this.currentFormObject) {\n this.completedFormObjects = [\n ...this.completedFormObjects,\n this.currentFormObject,\n ];\n }\n\n this.currentFormObject = receivedForm.currentFormObject;\n this.endResultFormObjects = receivedForm.endResultFormObjects;\n\n this._data = receivedForm._data;\n }\n\n /**\n */\n handleRootErrors(errors: Array<Object>) {\n errors\n .filter((error) => !error.anchor)\n .forEach((error) => {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties\n );\n });\n }\n\n /**\n * Process errors from received form\n */\n handleErrors(receivedForm: FormModel) {\n const errorAnchors = receivedForm.data.errors;\n if (errorAnchors) {\n errorAnchors.forEach((error) => {\n if (\n error.anchor &&\n this.currentFormObject &&\n this.currentFormObject.key === error.anchor.objectid\n ) {\n this.currentFormObject.addServerError(error);\n } else {\n this.errorCollection.addServerError(\n error.id,\n new LayoutHintCollection(error.layouthint),\n error.message,\n error.properties\n );\n }\n });\n }\n }\n\n /**\n * Process missing from received form\n */\n handleMissing(receivedForm: FormModel) {\n if (\n this.currentFormObject &&\n this.currentFormObject.equals(receivedForm.currentFormObject)\n ) {\n this.handleMissingErrors(receivedForm);\n } else {\n this.handleNewFormObject(receivedForm);\n }\n }\n\n /**\n * Received missing anchors in the response with an object id that is the current form object\n */\n processMissingErrors(receivedForm: FormModel): FormObjectModel | null {\n if (this.currentFormObject === null) {\n return null;\n }\n\n this.currentFormObject.attributeCollection.map((attribute) => {\n if (\n receivedForm.currentFormObject &&\n receivedForm.currentFormObject.hasAttributeByKey(attribute.key)\n ) {\n attribute.addMissingError();\n } else {\n attribute.removeMissingError();\n }\n\n return attribute;\n });\n\n return this.currentFormObject;\n }\n\n /**\n */\n handleMissingErrors(receivedForm: FormModel) {\n this.currentFormObject = this.processMissingErrors(receivedForm);\n }\n\n /**\n */\n handleNewFormObject(receivedForm: FormModel) {\n this.endResultFormObjects = receivedForm.endResultFormObjects;\n\n const receivedCurrentFormObject = receivedForm.currentFormObject;\n\n if (receivedCurrentFormObject === null) {\n this.completedFormObjects = [...this.allObjects];\n this.currentFormObject = null;\n } else {\n // check if received form exists in the previously entered form objects\n const previouslyEnteredFormObjects =\n this.previouslyEnteredFormObjects.filter((formObject) =>\n formObject.equals(\n receivedCurrentFormObject,\n formObject.hasFixedNrOfRepeats\n )\n );\n\n if (previouslyEnteredFormObjects.length > 0) {\n this.handlePreviouslyEnteredFormObjects(\n receivedCurrentFormObject,\n previouslyEnteredFormObjects\n );\n } else {\n this.completedFormObjects = [...this.allObjects];\n this.currentFormObject = receivedCurrentFormObject;\n }\n }\n }\n\n /**\n * Indicate if a new form object model should be merged with a previousled entered form object model\n * Set this property to false on the form that receives the new form to skip the merge behavior\n */\n get mergePreviouslyEnteredObjects(): boolean {\n return this._mergePreviouslyEnteredObjects;\n }\n\n /**\n */\n set mergePreviouslyEnteredObjects(mergePreviouslyEnteredObjects: boolean) {\n this._mergePreviouslyEnteredObjects = mergePreviouslyEnteredObjects;\n }\n\n /**\n */\n handlePreviouslyEnteredFormObjects(\n receivedCurrentFormObject: FormObjectModel,\n previouslyEnteredFormObjects: Array<FormObjectModel>\n ) {\n previouslyEnteredFormObjects.forEach((previouslyEnteredFormObject) => {\n const mergedObject = this.mergePreviouslyEnteredObjects\n ? this.mergeObjects(\n receivedCurrentFormObject,\n previouslyEnteredFormObject\n )\n : receivedCurrentFormObject;\n\n this.addFormObject(mergedObject);\n });\n\n // remove the previously entered form object\n this.previouslyEnteredFormObjects =\n this.previouslyEnteredFormObjects.filter((formObject) => {\n const hasPreviouslyEnteredObject = previouslyEnteredFormObjects.find(\n (previouslyEnteredFormObject) =>\n formObject.equals(previouslyEnteredFormObject)\n );\n\n return !hasPreviouslyEnteredObject;\n });\n }\n\n /**\n */\n mergeObjects(\n newObject: FormObjectModel,\n oldObject: FormObjectModel\n ): FormObjectModel {\n const mergedFormObject = FormObjectModel.createEmpty(newObject);\n\n mergedFormObject.mergeObject(oldObject);\n\n return mergedFormObject;\n }\n\n /**\n */\n findAttribute(findMethod: Function): AttributeType | null {\n let foundAttribute = null;\n\n this.allObjects.forEach((formObject) => {\n if (foundAttribute === null) {\n foundAttribute =\n formObject.attributeCollection.all.find((item) => findMethod(item)) ||\n null;\n }\n });\n\n return foundAttribute;\n }\n}\n\nexport default FormModel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAUA;;AAEA;AACA;AACA,MAAMA,SAAN,SAAwBC,sBAAxB,CAAsC;EAwBpC;AACF;EACEC,WAAW,CAACC,iBAAD,EAAuC;IAChD,MAAMA,iBAAN;IADgD;IAAA,6DAvBF,EAuBE;IAAA,0DAtBL,IAsBK;IAAA,qEArBM,EAqBN;IAAA,sEAnBR,IAmBQ;IAAA,6DAjBF,EAiBE;IAAA,8DAhBV,EAgBU;IAAA,gEAdd,IAAAC,oBAAA,EAAW,2BAAX,CAcc;IAAA,wDAbd,IAAIC,wBAAJ,CAAoB,MAApB,CAac;IAAA;IAAA;IAAA;IAA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AAA/H,4BAA4B,MAA5B,CAAAA,4BAA4B,EAC5D4H,2BAAD,IACEvI,UAAU,CAACC,MAAX,CAAkBsI,2BAAlB,CAF2D,CAA/D;MAKA,OAAO,CAACG,0BAAR;IACD,CAPD,CADF;EASD;EAED;AACF;;;EACED,YAAY,CACVE,SADU,EAEVC,SAFU,EAGO;IACjB,MAAMC,gBAAgB,GAAGvJ,wBAAA,CAAgBI,WAAhB,CAA4BiJ,SAA5B,CAAzB;;IAEAE,gBAAgB,CAACC,WAAjB,CAA6BF,SAA7B;IAEA,OAAOC,gBAAP;EACD;EAED;AACF;;;EACEE,aAAa,CAACC,UAAD,EAA6C;IACxD,IAAIC,cAAc,GAAG,IAArB;IAEA,KAAKjL,UAAL,CAAgBN,OAAhB,CAAyBsC,UAAD,IAAgB;MACtC,IAAIiJ,cAAc,KAAK,IAAvB,EAA6B;QAAA;;QAC3BA,cAAc,GACZ,gCAAAjJ,UAAU,CAAC+F,mBAAX,CAA+BC,GAA/B,mBAAyCpH,IAAD,IAAUoK,UAAU,CAACpK,IAAD,CAA5D,KACA,IAFF;MAGD;IACF,CAND;IAQA,OAAOqK,cAAP;EACD;;AA7nCmC;;eAgoCvB1N,S"}
@@ -428,7 +428,7 @@ class FormObjectModel extends _BaseModel.default {
428
428
  if (((_error$anchor = error.anchor) === null || _error$anchor === void 0 ? void 0 : _error$anchor.elementid) != null) {
429
429
  this.attributeCollection.addServerError(error);
430
430
  } else {
431
- this._errorCollection.addServerError(error.id, error.message, error.properties);
431
+ this._errorCollection.addServerError(error.id, error.layouthint, error.message, error.properties);
432
432
  }
433
433
  }
434
434
  /**
@@ -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
  );
@@ -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,KAAK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A3DC,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,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F,mBAAL,CAAyB2F,iBAAzB,CAA2CC,eAA3C;IAEA,KAAKH,wBAAL,GAAgC,IAAhC;IAEA,OAAO,IAAP;EACD;EAED;AACF;AACA;;;EACc,IAARS,QAAQ,GAA6B;IACvC,OAAO,KAAKlG,mBAAL,CAAyBkG,QAAhC;EACD;EAED;AACF;;;EACEC,WAAW,GAA4D;IAAA,IAA3DC,cAA2D,uEAAjC,KAAiC;IACrE,OAAO,KAAKpG,mBAAL,CAAyBmG,WAAzB,CAAqCC,cAArC,CAAP;EACD;;AApeoD"}
@@ -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.2",
3
+ "version": "1.21.3",
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
  /**