@beinformed/ui 1.21.2 → 1.21.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -6
- package/esm/models/attributes/AttributeModel.js +2 -2
- package/esm/models/attributes/AttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +3 -2
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/attributes/DatetimeAttributeModel.js +3 -2
- package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/esm/models/error/ErrorCollection.js +7 -6
- package/esm/models/error/ErrorCollection.js.map +1 -1
- package/esm/models/error/ErrorModel.js +2 -1
- package/esm/models/error/ErrorModel.js.map +1 -1
- package/esm/models/error/ErrorResponse.js +11 -5
- package/esm/models/error/ErrorResponse.js.map +1 -1
- package/esm/models/form/FormModel.js +5 -4
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/form/FormObjectModel.js +1 -1
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/esm/models/grouping/GroupingModel.js +36 -8
- package/esm/models/grouping/GroupingModel.js.map +1 -1
- package/esm/models/types.js.map +1 -1
- package/lib/models/attributes/AttributeModel.js +2 -2
- package/lib/models/attributes/AttributeModel.js.flow +4 -2
- package/lib/models/attributes/AttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +3 -2
- package/lib/models/attributes/ChoiceAttributeModel.js.flow +2 -2
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/attributes/DatetimeAttributeModel.js +3 -2
- package/lib/models/attributes/DatetimeAttributeModel.js.flow +2 -2
- package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/lib/models/error/ErrorCollection.js +7 -5
- package/lib/models/error/ErrorCollection.js.flow +8 -5
- package/lib/models/error/ErrorCollection.js.map +1 -1
- package/lib/models/error/ErrorModel.js +2 -1
- package/lib/models/error/ErrorModel.js.flow +5 -2
- package/lib/models/error/ErrorModel.js.map +1 -1
- package/lib/models/error/ErrorResponse.js +11 -5
- package/lib/models/error/ErrorResponse.js.flow +4 -4
- package/lib/models/error/ErrorResponse.js.map +1 -1
- package/lib/models/form/FormModel.js +5 -3
- package/lib/models/form/FormModel.js.flow +11 -3
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/form/FormObjectModel.js +1 -1
- package/lib/models/form/FormObjectModel.js.flow +2 -1
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/grouping/GroupingModel.js +36 -8
- package/lib/models/grouping/GroupingModel.js.flow +38 -10
- package/lib/models/grouping/GroupingModel.js.map +1 -1
- package/lib/models/types.js.flow +1 -1
- package/lib/models/types.js.map +1 -1
- package/package.json +1 -1
- package/src/models/attributes/AttributeModel.js +4 -2
- package/src/models/attributes/ChoiceAttributeModel.js +2 -2
- package/src/models/attributes/DatetimeAttributeModel.js +2 -2
- package/src/models/error/ErrorCollection.js +8 -5
- package/src/models/error/ErrorModel.js +5 -2
- package/src/models/error/ErrorResponse.js +4 -4
- package/src/models/form/FormModel.js +11 -3
- package/src/models/form/FormObjectModel.js +2 -1
- package/src/models/grouping/GroupingModel.js +38 -10
- package/src/models/types.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormObjectModel.js","names":["has","BaseModel","AttributeCollection","CompositeAttributeModel","ContentConfiguration","ErrorCollection","IllegalArgumentException","FormObjectModel","constructor","object","objectContributions","getElements","length","_attributeCollection","getApplicableAttributeContributions","_contentConfiguration","content","_errorCollection","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","createEmpty","formObjectModel","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","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,SAASA,GAAT,QAAoB,6BAApB;AAEA,OAAOC,SAAP,MAAsB,mBAAtB;AACA,OAAOC,mBAAP,MAAgC,mCAAhC;AACA,OAAOC,uBAAP,MAAoC,uCAApC;AACA,OAAOC,oBAAP,MAAiC,8CAAjC;AACA,OAAOC,eAAP,MAA4B,0BAA5B;AACA,SAASC,wBAAT,QAAyC,kBAAzC;;AAKA;AACA;AACA;AACA,eAAe,MAAMC,eAAN,SAA8BN,SAA9B,CAAwC;EAOrD;AACF;AACA;EACEO,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,IAAIX,mBAAJ,CAC1B,KAAKS,WAAL,EAD0B,EAE1B,KAAKG,mCAAL,EAF0B,CAA5B;IAID,CALD,MAKO;MACL,KAAKD,oBAAL,GAA4B,IAAIX,mBAAJ,EAA5B;IACD;;IAED,KAAKa,qBAAL,GAA6B,IAAIX,oBAAJ,CAC3BM,mBAAmB,GAAGA,mBAAmB,CAACM,OAAvB,GAAiC,EADzB,CAA7B;IAIA,KAAKC,gBAAL,GAAwB,IAAIZ,eAAJ,CAAoB,YAApB,CAAxB;;IAEA,IAAIL,GAAG,CAAC,KAAKkB,IAAN,EAAY,eAAZ,CAAP,EAAqC;MACnC,KAAKC,mBAAL,CAAyBC,gBAAzB,CAA0C,KAAKC,OAAL,CAAa,eAAb,CAA1C;IACD;;IAED,KAAKF,mBAAL,CAAyBG,4BAAzB,CACE,KAAKC,oBADP;EAGD;EAED;AACF;;;EACoB,OAAXC,WAAW,CAACC,eAAD,EAAoD;IACpE,IAAI,CAACA,eAAL,EAAsB;MAC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AG,EAAxB;;IAEA,IAAIC,KAAK,CAACC,OAAN,CAAc5F,IAAI,CAAC6F,MAAnB,CAAJ,EAAgC;MAC9B7F,IAAI,CAAC6F,MAAL,CAAY9B,OAAZ,CAAqBc,KAAD,IAAW;QAAA;;QAC7B,IAAI,mBAAAA,KAAK,CAACC,MAAN,kEAAcpC,QAAd,MAA2B,KAAK/B,GAApC,EAAyC;UACvC,IAAI7B,GAAG,CAAC+F,KAAK,CAACC,MAAP,EAAe,WAAf,CAAP,EAAoC;YAClCY,eAAe,CAACnE,IAAhB,CAAqBsD,KAArB;UACD,CAFD,MAEO;YACL,KAAKF,eAAL,CAAqBC,cAArB,CACEC,KAAK,CAACE,EADR,EAEEF,KAAK,CAACnB,OAFR,EAGEmB,KAAK,CAACG,UAHR;UAKD;QACF;MACF,CAZD;IAaD,CAnB2C,CAqB5C;;;IACA,IAAIW,KAAK,CAACC,OAAN,kBAAc5F,IAAI,CAAC8F,OAAnB,kDAAc,cAAcC,OAA5B,CAAJ,EAA0C;MAAA;;MACxCL,eAAe,CAACnE,IAAhB,CACE,GAAG,iCAAAvB,IAAI,CAAC8F,OAAL,CAAaC,OAAb,kBAA0BjB,MAAD,KAAa;QACvCA,MADuC;QAEvCC,EAAE,EAAE;MAFmC,CAAb,CAAzB,CADL;IAMD;;IAED,KAAK9E,mBAAL,CAAyBwF,iBAAzB,CAA2CC,eAA3C;IAEA,KAAKH,wBAAL,GAAgC,IAAhC;IAEA,OAAO,IAAP;EACD;EAED;AACF;AACA;;;EACc,IAARS,QAAQ,GAA6B;IACvC,OAAO,KAAK/F,mBAAL,CAAyB+F,QAAhC;EACD;EAED;AACF;;;EACEC,WAAW,GAA4D;IAAA,IAA3DC,cAA2D,uEAAjC,KAAiC;IACrE,OAAO,KAAKjG,mBAAL,CAAyBgG,WAAzB,CAAqCC,cAArC,CAAP;EACD;;AAneoD"}
|
|
1
|
+
{"version":3,"file":"FormObjectModel.js","names":["has","BaseModel","AttributeCollection","CompositeAttributeModel","ContentConfiguration","ErrorCollection","IllegalArgumentException","FormObjectModel","constructor","object","objectContributions","getElements","length","_attributeCollection","getApplicableAttributeContributions","_contentConfiguration","content","_errorCollection","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","createEmpty","formObjectModel","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","update","isChangedSince","timestamp","resetErrors","errorCollection","addServerError","error","anchor","id","properties","layouthint","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 error.layouthint\n );\n }\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.attributeCollection.hasServerErrors()\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems || this.attributeCollection.hasErrors()\n );\n }\n\n /**\n */\n get isValid(): boolean {\n return (\n this.attributeCollection.visible.every(\n (attribute) => attribute.isValid\n ) && !this.errorCollection.hasItems\n );\n }\n\n /**\n */\n get dynamicValidationsLoaded(): boolean {\n return this._dynamicValidationsLoaded;\n }\n\n /**\n */\n set dynamicValidationsLoaded(dynamicValidationsLoaded: boolean) {\n this._dynamicValidationsLoaded = dynamicValidationsLoaded;\n }\n\n /**\n */\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,SAASA,GAAT,QAAoB,6BAApB;AAEA,OAAOC,SAAP,MAAsB,mBAAtB;AACA,OAAOC,mBAAP,MAAgC,mCAAhC;AACA,OAAOC,uBAAP,MAAoC,uCAApC;AACA,OAAOC,oBAAP,MAAiC,8CAAjC;AACA,OAAOC,eAAP,MAA4B,0BAA5B;AACA,SAASC,wBAAT,QAAyC,kBAAzC;;AAKA;AACA;AACA;AACA,eAAe,MAAMC,eAAN,SAA8BN,SAA9B,CAAwC;EAOrD;AACF;AACA;EACEO,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,IAAIX,mBAAJ,CAC1B,KAAKS,WAAL,EAD0B,EAE1B,KAAKG,mCAAL,EAF0B,CAA5B;IAID,CALD,MAKO;MACL,KAAKD,oBAAL,GAA4B,IAAIX,mBAAJ,EAA5B;IACD;;IAED,KAAKa,qBAAL,GAA6B,IAAIX,oBAAJ,CAC3BM,mBAAmB,GAAGA,mBAAmB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IAED,KAAK9E,mBAAL,CAAyByF,iBAAzB,CAA2CC,eAA3C;IAEA,KAAKH,wBAAL,GAAgC,IAAhC;IAEA,OAAO,IAAP;EACD;EAED;AACF;AACA;;;EACc,IAARS,QAAQ,GAA6B;IACvC,OAAO,KAAKhG,mBAAL,CAAyBgG,QAAhC;EACD;EAED;AACF;;;EACEC,WAAW,GAA4D;IAAA,IAA3DC,cAA2D,uEAAjC,KAAiC;IACrE,OAAO,KAAKlG,mBAAL,CAAyBiG,WAAzB,CAAqCC,cAArC,CAAP;EACD;;AApeoD"}
|
|
@@ -112,18 +112,46 @@ export default class GroupingModel {
|
|
|
112
112
|
/**
|
|
113
113
|
*/
|
|
114
114
|
constructor(data, contexts) {
|
|
115
|
-
var _context;
|
|
116
|
-
|
|
117
115
|
_defineProperty(this, "_prefix", void 0);
|
|
118
116
|
|
|
119
|
-
_defineProperty(this, "_groups",
|
|
117
|
+
_defineProperty(this, "_groups", []);
|
|
120
118
|
|
|
121
119
|
this._prefix = data && data.prefix ? data.prefix : null;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
|
|
121
|
+
if (data !== null && data !== void 0 && data.group) {
|
|
122
|
+
this._groups = this.createGroup(data, contexts);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
createGroup(data, contributions) {
|
|
130
|
+
var _context;
|
|
131
|
+
|
|
132
|
+
const context = this.getContextFromContributionsByPrefix(contributions, this._prefix);
|
|
133
|
+
return _mapInstanceProperty(_context = data.group).call(_context, group => {
|
|
134
|
+
const dynamicschema = this.getDynamicSchema(group, data.dynamicschema);
|
|
135
|
+
return new GroupModel({ ...group,
|
|
136
|
+
dynamicschema
|
|
137
|
+
}, context, contributions);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* add grouped prefix to the dynamicschema
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
getDynamicSchema(group, dynamicschema) {
|
|
146
|
+
if (dynamicschema) {
|
|
147
|
+
if (this._prefix && dynamicschema[group.type] && !dynamicschema[this._prefix + group.type]) {
|
|
148
|
+
dynamicschema[this._prefix + group.type] = dynamicschema[group.type];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return dynamicschema;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return null;
|
|
127
155
|
}
|
|
128
156
|
/**
|
|
129
157
|
* Retrieve groups of grouping
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupingModel.js","names":["AttributeCollection","GroupModel","constructor","group","context","contributions","_group","_context","_attributeCollection","attributes","grouping","_grouping","GroupingModel","dynamicschema","type","id","_id","label","attributeCollection","reference","hasAttributeByKey","key","getAttributeByKey","data","contexts","_prefix","prefix","getContextFromContributionsByPrefix","
|
|
1
|
+
{"version":3,"file":"GroupingModel.js","names":["AttributeCollection","GroupModel","constructor","group","context","contributions","_group","_context","_attributeCollection","attributes","grouping","_grouping","GroupingModel","dynamicschema","type","id","_id","label","attributeCollection","reference","hasAttributeByKey","key","getAttributeByKey","data","contexts","_prefix","prefix","_groups","createGroup","getContextFromContributionsByPrefix","getDynamicSchema","groups","hasGroups","length","some","groupByKey","getGroupByAttributeKey"],"sources":["../../../src/models/grouping/GroupingModel.js"],"sourcesContent":["// @flow\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport type { AttributeType } from \"../types\";\n\n/**\n * Group information model\n * Put GroupModel here because of possible circular dependency with GroupingModel below\n */\nexport class GroupModel {\n _group: Object;\n _context: Object;\n _attributeCollection: AttributeCollection;\n _grouping: ?GroupingModel;\n\n /**\n */\n constructor(group: Object, context: Object, contributions: Array<Object>) {\n this._group = group;\n this._context = context;\n\n this._attributeCollection = new AttributeCollection(\n group,\n context.attributes\n );\n\n if (group.grouping) {\n this._grouping = new GroupingModel(\n { ...group.grouping, dynamicschema: group.dynamicschema },\n contributions\n );\n }\n }\n\n /**\n */\n get type(): string {\n return this._group.type;\n }\n\n /**\n */\n get id(): string {\n return this._group._id || \"unknown\";\n }\n\n /**\n */\n get label(): string {\n return this._context.label;\n }\n\n /**\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n get grouping(): ?GroupingModel {\n return this._grouping;\n }\n\n /**\n * Retrieve array of reference id's\n */\n get reference(): Array<number> {\n return this._group.reference || [];\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n if (this.attributeCollection.hasAttributeByKey(key)) {\n return true;\n }\n\n if (this.grouping) {\n return this.grouping.hasAttributeByKey(key);\n }\n\n return false;\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n if (this.attributeCollection.hasAttributeByKey(key)) {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n if (this.grouping) {\n return this.grouping.getAttributeByKey(key);\n }\n\n return null;\n }\n}\n\ntype Context = {\n prefix: string,\n label: string,\n metadata: Object,\n attributes: Array<Object>,\n};\n\n/**\n * Grouping model to group lists\n */\nexport default class GroupingModel {\n _prefix: string | null;\n _groups: Array<GroupModel> = [];\n\n /**\n */\n constructor(data: Object, contexts: Array<Context>) {\n this._prefix = data && data.prefix ? data.prefix : null;\n\n if (data?.group) {\n this._groups = this.createGroup(data, contexts);\n }\n }\n\n /**\n */\n createGroup(data: Object, contributions: Array<Context>): Array<Object> {\n const context = this.getContextFromContributionsByPrefix(\n contributions,\n this._prefix\n );\n\n return data.group.map((group) => {\n const dynamicschema = this.getDynamicSchema(group, data.dynamicschema);\n return new GroupModel(\n {\n ...group,\n dynamicschema,\n },\n context,\n contributions\n );\n });\n }\n\n /**\n * add grouped prefix to the dynamicschema\n */\n getDynamicSchema(group: Object, dynamicschema: Object): Object {\n if (dynamicschema) {\n if (\n this._prefix &&\n dynamicschema[group.type] &&\n !dynamicschema[this._prefix + group.type]\n ) {\n dynamicschema[this._prefix + group.type] = dynamicschema[group.type];\n }\n return dynamicschema;\n }\n return null;\n }\n\n /**\n * Retrieve groups of grouping\n */\n get groups(): Array<GroupModel> {\n return this._groups;\n }\n\n /**\n * Inidicates if Grouping has one or more groups\n */\n hasGroups(): boolean {\n return this._groups.length > 0;\n }\n\n /**\n * Get context of grouping\n */\n getContextFromContributionsByPrefix(\n contexts: Array<Object>,\n prefix: string | null\n ): Object {\n if (contexts && prefix !== null) {\n return contexts.find((context) => context.prefix === prefix) || {};\n }\n\n return {};\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.groups.some((group: GroupModel) =>\n group.hasAttributeByKey(key)\n );\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n const groupByKey = this.groups.find((group: GroupModel) =>\n group.hasAttributeByKey(key)\n );\n\n if (groupByKey) {\n return groupByKey.getAttributeByKey(key);\n }\n return null;\n }\n\n /**\n */\n getGroupByAttributeKey(key: string): ?GroupModel {\n return this.groups.find((group) => group.hasAttributeByKey(key));\n }\n}\n"],"mappings":";;;AACA,OAAOA,mBAAP,MAAgC,mCAAhC;;AAGA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAN,CAAiB;EAMtB;AACF;EACEC,WAAW,CAACC,KAAD,EAAgBC,OAAhB,EAAiCC,aAAjC,EAA+D;IAAA;;IAAA;;IAAA;;IAAA;;IACxE,KAAKC,MAAL,GAAcH,KAAd;IACA,KAAKI,QAAL,GAAgBH,OAAhB;IAEA,KAAKI,oBAAL,GAA4B,IAAIR,mBAAJ,CAC1BG,KAD0B,EAE1BC,OAAO,CAACK,UAFkB,CAA5B;;IAKA,IAAIN,KAAK,CAACO,QAAV,EAAoB;MAClB,KAAKC,SAAL,GAAiB,IAAIC,aAAJ,CACf,EAAE,GAAGT,KAAK,CAACO,QAAX;QAAqBG,aAAa,EAAEV,KAAK,CAACU;MAA1C,CADe,EAEfR,aAFe,CAAjB;IAID;EACF;EAED;AACF;;;EACU,IAAJS,IAAI,GAAW;IACjB,OAAO,KAAKR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,EAEjCE,MAFiC,EAGzB;IACR,IAAIF,QAAQ,IAAIE,MAAM,KAAK,IAA3B,EAAiC;MAC/B,OAAO,sBAAAF,QAAQ,MAAR,CAAAA,QAAQ,EAAOpB,OAAD,IAAaA,OAAO,CAACsB,MAAR,KAAmBA,MAAtC,CAAR,IAAyD,EAAhE;IACD;;IAED,OAAO,EAAP;EACD;EAED;AACF;;;EACEN,iBAAiB,CAACC,GAAD,EAAuB;IACtC,OAAO,KAAKU,MAAL,CAAYG,IAAZ,CAAkB/B,KAAD,IACtBA,KAAK,CAACiB,iBAAN,CAAwBC,GAAxB,CADK,CAAP;EAGD;EAED;AACF;;;EACEC,iBAAiB,CAACD,GAAD,EAAoC;IAAA;;IACnD,MAAMc,UAAU,GAAG,uCAAKJ,MAAL,kBAAkB5B,KAAD,IAClCA,KAAK,CAACiB,iBAAN,CAAwBC,GAAxB,CADiB,CAAnB;;IAIA,IAAIc,UAAJ,EAAgB;MACd,OAAOA,UAAU,CAACb,iBAAX,CAA6BD,GAA7B,CAAP;IACD;;IACD,OAAO,IAAP;EACD;EAED;AACF;;;EACEe,sBAAsB,CAACf,GAAD,EAA2B;IAAA;;IAC/C,OAAO,uCAAKU,MAAL,kBAAkB5B,KAAD,IAAWA,KAAK,CAACiB,iBAAN,CAAwBC,GAAxB,CAA5B,CAAP;EACD;;AAzGgC"}
|
package/esm/models/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/models/types.js"],"sourcesContent":["// @flow\nimport type ApplicationModel from \"./application/ApplicationModel\";\nimport type BooleanAttributeModel from \"./attributes/BooleanAttributeModel\";\nimport type CaptchaAttributeModel from \"./attributes/CaptchaAttributeModel\";\nimport type ChoiceAttributeModel from \"./attributes/ChoiceAttributeModel\";\nimport type CompositeAttributeModel from \"./attributes/CompositeAttributeModel\";\nimport type DatetimeAttributeModel from \"./attributes/DatetimeAttributeModel\";\nimport type HelptextAttributeModel from \"./attributes/HelptextAttributeModel\";\nimport type LabelAttributeModel from \"./attributes/LabelAttributeModel\";\nimport type MemoAttributeModel from \"./attributes/MemoAttributeModel\";\nimport type MoneyAttributeModel from \"./attributes/MoneyAttributeModel\";\nimport type NumberAttributeModel from \"./attributes/NumberAttributeModel\";\nimport type PasswordAttributeModel from \"./attributes/PasswordAttributeModel\";\nimport type StringAttributeModel from \"./attributes/StringAttributeModel\";\nimport type UploadAttributeModel from \"./attributes/UploadAttributeModel\";\nimport type XMLAttributeModel from \"./attributes/XMLAttributeModel\";\nimport type CaseViewModel from \"./caseview/CaseViewModel\";\nimport type BusinessScenarioModel from \"./concepts/BusinessScenarioModel\";\nimport type ConceptDetailModel from \"./concepts/ConceptDetailModel\";\nimport type ConceptIndexModel from \"./concepts/ConceptIndexModel\";\nimport type ConceptTypeDetailModel from \"./concepts/ConceptTypeDetailModel\";\nimport type ContentIndexModel from \"./content/ContentIndexModel\";\nimport type ContentModel from \"./content/ContentModel\";\nimport type SectionModel from \"./content/SectionModel\";\nimport type ContentTOCModel from \"./content/ContentTOCModel\";\nimport type ContentTypeModel from \"./content/ContentTypeModel\";\nimport type DetailModel from \"./detail/DetailModel\";\nimport type AssignmentFilterModel from \"./filters/AssignmentFilterModel\";\nimport type FilterModel from \"./filters/FilterModel\";\nimport type RangeFilterModel from \"./filters/RangeFilterModel\";\nimport type ConceptIndexFilterModel from \"./filters/ConceptIndexFilterModel\";\nimport type FormModel from \"./form/FormModel\";\nimport type ListDetailModel from \"./list/ListDetailModel\";\nimport type ListModel from \"./list/ListModel\";\nimport type ModelCatalogModel from \"./modelcatalog/ModelCatalogModel\";\nimport type GroupingPanelModel from \"./panels/GroupingPanelModel\";\nimport type CaseSearchModel from \"./search/CaseSearchModel\";\nimport type TabModel from \"./tab/TabModel\";\nimport type TaskGroupModel from \"./taskgroup/TaskGroupModel\";\nimport type UserModel from \"./user/UserModel\";\nimport type UserServicesModel from \"./user/UserServicesModel\";\nimport type LinkModel from \"./links/LinkModel\";\nimport type LookupOptionsModel from \"./lookup/LookupOptionsModel\";\nimport type BaseFilterModel from \"./filters/BaseFilterModel\";\nimport type AttributeCollection from \"./attributes/AttributeCollection\";\nimport type AttributeModel from \"./attributes/AttributeModel\";\nimport type LayoutHintCollection from \"./layouthint/LayoutHintCollection\";\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
|
|
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":""}
|
|
@@ -714,7 +714,7 @@ class AttributeModel extends _BaseModel.default {
|
|
|
714
714
|
|
|
715
715
|
|
|
716
716
|
addServerError(error) {
|
|
717
|
-
this._errorCollection.addServerError(error.id, error.message, error.properties);
|
|
717
|
+
this._errorCollection.addServerError(error.id, error.message, error.properties, error.layouthint);
|
|
718
718
|
}
|
|
719
719
|
/**
|
|
720
720
|
*/
|
|
@@ -802,7 +802,7 @@ class AttributeModel extends _BaseModel.default {
|
|
|
802
802
|
this.resetErrors();
|
|
803
803
|
(0, _filter.default)(errors).call(errors, error => error.id !== "Constraint.Mandatory" || !this.hasValue()).forEach(error => {
|
|
804
804
|
if (this.hasValue()) {
|
|
805
|
-
this._errorCollection.addServerError(error.id, error.message, this.formatParameters(error.properties));
|
|
805
|
+
this._errorCollection.addServerError(error.id, error.message, this.formatParameters(error.properties), error.layouthint);
|
|
806
806
|
} else {
|
|
807
807
|
this.addServerConstraint(error.id, error.message, this.formatParameters(error.properties));
|
|
808
808
|
}
|
|
@@ -711,7 +711,8 @@ export default class AttributeModel
|
|
|
711
711
|
this._errorCollection.addServerError(
|
|
712
712
|
error.id,
|
|
713
713
|
error.message,
|
|
714
|
-
error.properties
|
|
714
|
+
error.properties,
|
|
715
|
+
error.layouthint
|
|
715
716
|
);
|
|
716
717
|
}
|
|
717
718
|
|
|
@@ -813,7 +814,8 @@ export default class AttributeModel
|
|
|
813
814
|
this._errorCollection.addServerError(
|
|
814
815
|
error.id,
|
|
815
816
|
error.message,
|
|
816
|
-
this.formatParameters(error.properties)
|
|
817
|
+
this.formatParameters(error.properties),
|
|
818
|
+
error.layouthint
|
|
817
819
|
);
|
|
818
820
|
} else {
|
|
819
821
|
this.addServerConstraint(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeModel.js","names":["AttributeModel","BaseModel","constructor","attribute","attributeContributions","ConstraintCollection","getSetting","hasContentFromData","content","label","_label","contributions","_initvalue","data","value","_inputvalue","getInitialInputValue","_value","_disabled","layouthint","has","DISABLED","_errorCollection","ErrorCollection","message","addServerError","id","parameters","_referenceDate","getData","DateUtil","now","_isResult","_mandatory","MANDATORY","mandatory","_links","LinkCollection","isApplicableModel","isPlainObject","IllegalArgumentException","getInitialChildModelLinks","hasContentConfiguration","conceptLink","setChildModels","models","conceptHref","href","concept","model","selfhref","equalsWithParameters","key","parentKey","_parentKey","name","type","_hasContentConfiguration","indicateContentConfiguration","contentConfiguration","hasQuestionConfig","questions","hasConfig","hasEndResultConfig","isConfiguredEndResultAttribute","hasIntermediateResultConfig","isConfiguredIntermediateResultAttribute","getContentConfiguredLabel","configuredLabelProperties","labelConfig","length","types","configuredLabels","getLabelElementByIds","configuredLabel","firstConfiguredLabel","configuredLabelProperty","some","_id","defaultAlignment","alignment","alignmentHints","getByLayoutHint","substring","links","downloadLink","getLinksByGroup","first","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","referenceDate","isCacheable","_concept","ConceptDetailModel","date","initvalue","getInputValue","inputvalue","toString","validateValue","validate","hasValue","getValue","getFormData","inError","formdata","getEmptyFormData","updateLastModification","formatValue","readonlyvalue","configuredMandatory","_validatedValue","readonly","_readonly","static","isResult","disabled","format","getContribution","formatLabel","minLength","maxLength","operator","assistantMessage","isValid","constraintCollection","constraints","add","_serverConstraints","MandatoryConstraint","StringLengthConstraint","addConstraints","setUseClientsideValidation","enabled","_useClientsideValidation","useClientsideValidation","isOptionalAndEmpty","_isValid","undefined","errorCollection","collection","invalidConstraints","isChangedSince","resetErrors","error","properties","removeServerError","hasServerErrors","serverErrors","hasErrors","hasItems","addMissingError","removeMissingError","addServerConstraint","defaultMessage","addConstraint","formatParameters","params","forEach","paramKey","paramValue","hasDynamicValidationData","updateValidations","errors","_lastModification","Date","timestamp","reset","UnsupportedOperationException","mergeAttribute","oldAttribute","update","changedAttribute","isEditable","_isEditable","isVisible","_isHidden","isHidden","show","hide","equals","otherAttribute","readonlyWidth","ATTRIBUTE_WIDTH","MEDIUM","layoutHintRules","_layoutHintRules","rules","processLayoutHintRules","attributes","process","hasAllContentInData","AttributeContent"],"sources":["../../../src/models/attributes/AttributeModel.js"],"sourcesContent":["// @flow\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\nimport { isPlainObject } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport ErrorCollection from \"../error/ErrorCollection\";\nimport LinkCollection from \"../links/LinkCollection\";\n\nimport StringLengthConstraint from \"./input-constraints/StringLengthConstraint\";\nimport MandatoryConstraint from \"./input-constraints/MandatoryConstraint\";\n\nimport ConceptDetailModel from \"../concepts/ConceptDetailModel\";\n\nimport { DISABLED, MANDATORY } from \"../../constants/LayoutHints\";\nimport {\n ATTRIBUTE_WIDTH,\n TIMEVERSION_FILTER_NAME,\n} from \"../../constants/Constants\";\n\nimport { getSetting, hasAllContentInData } from \"../../constants/Settings\";\n\nimport {\n IllegalArgumentException,\n UnsupportedOperationException,\n} from \"../../exceptions\";\n\nimport type { MessageParameters } from \"../../i18n/types\";\nimport type {\n AttributeType,\n FormErrorAnchor,\n IModelWithChildModels,\n ModularUIModel,\n} from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport type ContentConfigurationElements from \"../contentconfiguration/ContentConfigurationElements\";\nimport type LayoutHintRuleCollection from \"./layouthint-rules/LayoutHintRuleCollection\";\nimport type AttributeCollection from \"./AttributeCollection\";\nimport AttributeContent from \"./AttributeContent\";\n\n/**\n * Attribute model, base model for all kind of attributes\n */\nexport default class AttributeModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _label: string;\n _lastModification: number = 0;\n\n _initvalue: any;\n _inputvalue: string;\n _value: any;\n\n _errorCollection: ErrorCollection;\n _serverConstraints: ConstraintCollection = new ConstraintCollection();\n _useClientsideValidation: boolean = getSetting(\"USE_CLIENTSIDE_VALIDATION\");\n _isValid: boolean = true;\n _validatedValue: string | null;\n _isEditable: boolean = false;\n _concept: ConceptDetailModel | null = null;\n _referenceDate: ISO_DATE;\n _isResult: boolean;\n _isHidden: boolean = false;\n _readonly: boolean;\n _disabled: boolean = false;\n _mandatory: boolean;\n _links: LinkCollection;\n _parentKey: ?string;\n _hasContentConfiguration: boolean;\n _layoutHintRules: LayoutHintRuleCollection;\n\n /**\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n if (this.hasContentFromData && this.content.label) {\n this._label = this.content.label;\n } else {\n this._label = this.contributions.label;\n }\n\n this._initvalue = this.data.value;\n this._inputvalue = this.getInitialInputValue(this.data.value);\n this._value = this.data.value;\n this._disabled = this.layouthint.has(DISABLED);\n\n this._errorCollection = new ErrorCollection(\"attribute\");\n if (attribute && attribute.message) {\n this._errorCollection.addServerError(\n attribute.message.id,\n attribute.message.message,\n attribute.message.parameters\n );\n }\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n\n this._isResult = this.getData(\"isResult\", false);\n\n this._mandatory =\n this.layouthint.has(MANDATORY) || this.contributions.mandatory;\n\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links\n );\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n if (!isPlainObject(contributions)) {\n throw new IllegalArgumentException(\n \"Given argument for isApplicableModel is not a contributions object\"\n );\n }\n\n return false;\n }\n\n /**\n * Retrieve initial input value\n */\n getInitialInputValue(value: any): any {\n return value;\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n if (\n !this.hasContentFromData &&\n this.hasContentConfiguration &&\n this.conceptLink\n ) {\n return [this.conceptLink];\n }\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const conceptHref = this.conceptLink?.href;\n if (conceptHref) {\n this.concept = models.find((model) =>\n model.selfhref.equalsWithParameters(conceptHref)\n );\n }\n }\n\n /**\n * Getting the attribute key\n */\n get key(): string {\n return this.data.key;\n }\n\n /**\n */\n get parentKey(): string {\n return this._parentKey || \"\";\n }\n\n /**\n */\n set parentKey(parentKey: string) {\n this._parentKey = parentKey;\n }\n\n /**\n * Getting the attribute name\n */\n get name(): string {\n return this.key;\n }\n\n /**\n * Getting the type of the attribute\n */\n get type(): string {\n return this.contributions.type;\n }\n\n /**\n * Getting the label of the attribute\n */\n get label(): string {\n return this._label || \"\";\n }\n\n /**\n * Set the label of this attribute\n */\n set label(label: string) {\n this._label = label;\n }\n\n /**\n */\n set hasContentConfiguration(hasContentConfiguration: boolean) {\n this._hasContentConfiguration = hasContentConfiguration;\n }\n\n /**\n */\n get hasContentConfiguration(): boolean {\n return this._hasContentConfiguration || false;\n }\n\n /**\n */\n indicateContentConfiguration(contentConfiguration: ContentConfiguration) {\n if (contentConfiguration) {\n const hasQuestionConfig = contentConfiguration.questions?.hasConfig();\n\n const hasEndResultConfig =\n contentConfiguration.isConfiguredEndResultAttribute(this.key);\n const hasIntermediateResultConfig =\n contentConfiguration.isConfiguredIntermediateResultAttribute(this.key);\n\n this.hasContentConfiguration =\n hasQuestionConfig || hasEndResultConfig || hasIntermediateResultConfig;\n }\n }\n\n /**\n * Retrieve the first permitted label to render when a concept and contentConfiguration is available\n * Be aware that permission could be in place for labels from a concept.\n */\n getContentConfiguredLabel(\n contentConfiguration: ?ContentConfigurationElements\n ): string {\n if (this.hasContentFromData) {\n return this.content.label ?? this.label;\n }\n\n const configuredLabelProperties =\n contentConfiguration && contentConfiguration.labelConfig.length > 0\n ? contentConfiguration.labelConfig[0].types\n : [];\n\n if (this.concept && configuredLabelProperties.length > 0) {\n const configuredLabels = this.concept\n .getLabelElementByIds(configuredLabelProperties)\n .filter(\n (configuredLabel) =>\n configuredLabel.value && configuredLabel.value !== \"\"\n );\n\n if (configuredLabels.length > 0) {\n const [firstConfiguredLabel] = configuredLabelProperties\n .filter((configuredLabelProperty) =>\n configuredLabels.some(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty\n )\n )\n .map((configuredLabelProperty) =>\n configuredLabels.find(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty\n )\n );\n\n if (firstConfiguredLabel) {\n return firstConfiguredLabel.value;\n }\n }\n }\n\n return this.label;\n }\n\n /**\n */\n get defaultAlignment(): \"left\" | \"center\" | \"right\" {\n return \"left\";\n }\n\n /**\n * Handles layout hint align-left, align-center and align-right\n */\n get alignment(): \"left\" | \"center\" | \"right\" {\n const alignmentHints = this.layouthint.getByLayoutHint(\"align-\");\n\n // return alignment based on layouthint or the default alignment for the attribute\n const alignment = alignmentHints\n ? alignmentHints.substring(\"align-\".length)\n : this.defaultAlignment;\n\n if (\n alignment === \"left\" ||\n alignment === \"center\" ||\n alignment === \"right\"\n ) {\n return alignment;\n }\n\n return this.defaultAlignment;\n }\n\n /**\n * Retrieve links of attribute\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links\n );\n }\n\n return this._links;\n }\n\n /**\n * Retrieve link of attribute when available\n */\n get downloadLink(): ?LinkModel {\n const downloadLink = this.links.getLinksByGroup(\"download\").first;\n\n if (downloadLink && downloadLink.key === this.key) {\n return downloadLink;\n }\n\n return null;\n }\n\n /**\n * Retrieve concept link of attribute when available\n */\n get conceptLink(): ?LinkModel {\n const conceptLink = this.links.getLinkByKey(\"concept\");\n\n if (conceptLink !== null) {\n conceptLink.href = conceptLink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this.referenceDate\n );\n\n conceptLink.isCacheable = true;\n }\n\n return conceptLink;\n }\n\n /**\n * Get concept information\n */\n get concept(): ConceptDetailModel | null {\n return this._concept ?? null;\n }\n\n /**\n * Set the concept\n */\n set concept(concept: ?ModularUIModel) {\n this._concept = concept instanceof ConceptDetailModel ? concept : null;\n }\n\n /**\n * Retrieve reference date of attribute which can be used as entryDate for content\n * to get information in correct time version\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n * Set reference date for concepts and content\n */\n set referenceDate(date: ISO_DATE) {\n this._referenceDate = date;\n }\n\n /**\n * Initial value received from the modular ui service\n */\n get initvalue(): any {\n return this._initvalue;\n }\n\n /**\n * Retrieve input value\n */\n getInputValue(): string {\n const inputvalue = this._inputvalue;\n\n return inputvalue ? inputvalue.toString() : \"\";\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Value that is used when retrieving an error collection of this attribute\n * Mostly this is the input value, but sometimes a different value is needed,\n * for example iban and postcode need to validate length without spaces\n */\n get validateValue(): string {\n return this.inputvalue;\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this._inputvalue = value;\n this.value = value;\n\n this.validate(value);\n }\n\n /**\n */\n hasValue(): boolean {\n return this._value != null && this._value !== \"\";\n }\n\n /**\n * Getting the value of the attribute\n */\n getValue(): any {\n return this.hasValue() ? this._value : null;\n }\n\n /**\n * Getting data ready to be send to the modular ui\n * Returns null when the attribute should not be send to the server\n */\n getFormData(): { [string]: any } | null {\n if (this.inError()) {\n return null;\n }\n\n return {\n [this.name]: this.value,\n };\n }\n\n /**\n */\n get formdata(): { [string]: any } | null {\n return this.getFormData();\n }\n\n /**\n */\n getEmptyFormData(): { [string]: null } {\n return { [this.name]: null };\n }\n\n /**\n * Getting the value of the attribute\n */\n get value(): any {\n return this.getValue();\n }\n\n /**\n * Setting a value in the element\n */\n set value(value: ?string) {\n this.updateLastModification();\n\n this._value = value;\n }\n\n /**\n */\n formatValue(value: string): string {\n return value;\n }\n\n /**\n * Getting the readonly value, iso value converted for human reading\n */\n get readonlyvalue(): string {\n return this.value ? this.value.toString() : \"\";\n }\n\n /**\n * Getting mandatory status of attribute\n */\n get mandatory(): boolean {\n return this._mandatory || false;\n }\n\n /**\n */\n get configuredMandatory(): ?boolean {\n return this.layouthint.has(MANDATORY) || this.contributions.mandatory;\n }\n\n /**\n * Set mandatory status of attribute\n */\n set mandatory(mandatory: boolean) {\n if (mandatory !== this._mandatory) {\n this._validatedValue = null;\n }\n this._mandatory = mandatory;\n }\n\n /**\n */\n get readonly(): boolean {\n return (\n this._readonly ||\n this.contributions.readonly === true ||\n this.data.static === true ||\n this.isResult === true\n );\n }\n\n /**\n */\n set readonly(readonly: boolean) {\n this._readonly = readonly;\n }\n\n /**\n */\n get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n */\n set disabled(disabled: boolean) {\n this._disabled = disabled;\n }\n\n /**\n */\n get isResult(): boolean {\n return this._isResult;\n }\n\n /**\n */\n set isResult(isResult: boolean) {\n this._isResult = isResult;\n }\n\n /**\n * Getting the display and input format of a attribute\n */\n get format(): string | null {\n return this.getContribution(\"format\");\n }\n\n /**\n */\n get formatLabel(): string {\n return this.format || \"\";\n }\n\n /**\n * Get minimum string length\n */\n get minLength(): number | null {\n return this.getContribution(\"minLength\");\n }\n\n /**\n * Get maximum string length\n */\n get maxLength(): number | null {\n return this.getContribution(\"maxLength\");\n }\n\n /**\n */\n get operator(): string {\n return \"\";\n }\n\n /**\n * Get assistant message\n */\n get assistantMessage(): string | null {\n return this.getContribution(\"assistant\");\n }\n\n /**\n * Get valid status\n */\n get isValid(): boolean {\n return this.validate(this.validateValue);\n }\n\n /**\n * Retrieve applicable constraint for this attribute\n */\n get constraintCollection(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this._serverConstraints);\n\n // Mandatory constraint\n if (this.mandatory) {\n constraints.add(new MandatoryConstraint());\n }\n\n if (this.minLength || this.maxLength) {\n constraints.add(\n new StringLengthConstraint(this.minLength, this.maxLength)\n );\n }\n\n constraints.add(this.addConstraints());\n\n return constraints;\n }\n\n /**\n * Template method for class extending this model to add extra constraints\n * @abstract\n */\n addConstraints(): ConstraintCollection {\n return new ConstraintCollection();\n }\n\n /**\n * Used to programmatically overwrite the setting USE_CLIENTSIDE_VALIDATION\n */\n setUseClientsideValidation(enabled: boolean) {\n this._useClientsideValidation = enabled;\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 * Validate input on client side constraint\n */\n validate(value: string): boolean {\n // when client side validation is disabled, this attribute is always valid\n if (!this.useClientsideValidation()) {\n return true;\n }\n\n if (this.isOptionalAndEmpty(value)) {\n this._isValid = true;\n } else if (this._validatedValue !== value) {\n this._isValid = this.constraintCollection.validate(value);\n }\n this._validatedValue = value;\n\n return this._isValid;\n }\n\n /**\n * Indicates if attribute is optional and empty\n */\n isOptionalAndEmpty(value: string): boolean {\n if (value === undefined) {\n throw new IllegalArgumentException(\n \"isOptionalAndEmpty method needs value argument\"\n );\n }\n\n return !this.mandatory && value === \"\";\n }\n\n /**\n * Retrieve error messages of this attribute\n */\n get errorCollection(): ErrorCollection {\n const collection = new ErrorCollection(\"attribute\", this._errorCollection);\n\n collection.addConstraints(\n this.constraintCollection.invalidConstraints(this.validateValue)\n );\n\n return collection;\n }\n\n /**\n * Check if attribute is in error\n */\n inError(): boolean {\n return !this._isValid && this.isChangedSince(0);\n }\n\n /**\n * Reset static error messages on attribute\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"attribute\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n error.properties\n );\n }\n\n /**\n */\n removeServerError(id: string) {\n this._errorCollection.removeServerError(id);\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return this.errorCollection.serverErrors.length > 0;\n }\n\n /**\n */\n hasErrors(): boolean {\n return this.errorCollection.hasItems;\n }\n\n /**\n * Registers a missing error that was received from the server\n */\n addMissingError() {\n this._errorCollection.addServerError(\"Constraint.Missing\");\n }\n\n /**\n */\n removeMissingError() {\n this.removeServerError(\"Constraint.Missing\");\n }\n\n /**\n */\n addServerConstraint(\n id: string,\n defaultMessage?: string,\n parameters?: MessageParameters\n ) {\n this._serverConstraints.addConstraint(\n id,\n null,\n defaultMessage,\n parameters,\n this.useClientsideValidation()\n );\n }\n\n /**\n */\n formatParameters(parameters: Object): { [string]: string | number } {\n if (parameters == null) {\n return {};\n }\n\n const params = {};\n\n Object.keys(parameters).forEach((paramKey: string) => {\n const paramValue = parameters[paramKey];\n if (paramKey.endsWith(\"-number\") || paramKey.endsWith(\"-date\")) {\n params[paramKey] = this.formatValue(paramValue);\n } else {\n params[paramKey] = paramValue;\n }\n });\n\n return params;\n }\n\n /**\n */\n get hasDynamicValidationData(): boolean {\n return true;\n }\n\n /**\n */\n updateValidations(errors: Array<Object>) {\n if (\n errors.some((error) => error.id === \"Constraint.Mandatory\") ||\n this.layouthint.has(MANDATORY)\n ) {\n this.mandatory = true;\n } else if (!this.hasValue()) {\n this.mandatory = false;\n }\n\n this._serverConstraints = new ConstraintCollection();\n this.resetErrors();\n\n errors\n .filter(\n (error) => error.id !== \"Constraint.Mandatory\" || !this.hasValue()\n )\n .forEach((error) => {\n if (this.hasValue()) {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n this.formatParameters(error.properties)\n );\n } else {\n this.addServerConstraint(\n error.id,\n error.message,\n this.formatParameters(error.properties)\n );\n }\n });\n }\n\n /**\n * Set last modification to current timestamp\n */\n updateLastModification() {\n this._lastModification = Date.now();\n }\n\n /**\n * Inidicates if attribute is changed since a given timestamp (Date.now)\n */\n isChangedSince(timestamp: number): boolean {\n return this._lastModification > timestamp;\n }\n\n /**\n * Abstract reset method which should be implemented on each attribute that has this attribute as a base class.\n *\n * @abstract\n */\n reset() {\n throw new UnsupportedOperationException(\n `Reset method not implemented for ${this.type}`\n );\n }\n\n /**\n * Merge old attribute with the attribute from the server.\n * Readonly attributes always need to show the value from the server\n */\n mergeAttribute(oldAttribute: AttributeType) {\n this.concept = oldAttribute.concept;\n\n if (\n !oldAttribute.readonly &&\n oldAttribute.isValid &&\n oldAttribute.inputvalue !== null\n ) {\n this.update(oldAttribute.inputvalue);\n }\n }\n\n /**\n * Abstract update method which should be implemented on each attribute that has this attribute as a base class.\n * @abstract\n */\n // eslint-disable-next-line no-unused-vars\n update(value: string, changedAttribute?: AttributeType): AttributeType {\n throw new UnsupportedOperationException(\n `Update method not implemented for ${this.type}`\n );\n }\n\n /**\n * Indicate if attribute is editable\n */\n set isEditable(isEditable: boolean) {\n this._isEditable = isEditable;\n }\n\n /**\n * Retrieve if attribute is editable\n */\n get isEditable(): boolean {\n return this._isEditable;\n }\n\n /**\n * Indicates if the attribute is visible\n */\n get isVisible(): boolean {\n return !this._isHidden;\n }\n\n /**\n */\n get isHidden(): boolean {\n return this._isHidden;\n }\n\n /**\n */\n set isHidden(isHidden: boolean) {\n this._isHidden = isHidden;\n }\n\n /**\n * Explicitly toggle visibility of this attribute\n */\n show() {\n this.isHidden = false;\n }\n\n /**\n */\n hide() {\n this.isHidden = true;\n }\n\n /**\n */\n equals(otherAttribute: AttributeType): boolean {\n return (\n this.key === otherAttribute.key &&\n this.parentKey === otherAttribute.parentKey\n );\n }\n\n /**\n * Readonly attribute width indicates the proposed width of this attribute\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n\n /**\n */\n get layoutHintRules(): LayoutHintRuleCollection {\n return this._layoutHintRules;\n }\n\n /**\n */\n set layoutHintRules(rules: LayoutHintRuleCollection) {\n this._layoutHintRules = rules;\n }\n\n /**\n */\n processLayoutHintRules(attributes: AttributeCollection) {\n if (this._layoutHintRules) {\n this.layoutHintRules.process(this, attributes);\n }\n }\n\n /**\n * Indicates if content comes from the data service\n */\n get hasContentFromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get content(): AttributeContent {\n return new AttributeContent(this.data.content);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAKA;;AAEA;;AAiBA;;AAEA;AACA;AACA;AACe,MAAMA,cAAN,SACLC,kBADK,CAGf;EA0BE;AACF;EACEC,WAAW,CAACC,SAAD,EAAoBC,sBAApB,EAAoD;IAC7D,MAAMD,SAAN,EAAiBC,sBAAjB;IAD6D;IAAA,yDA1BnC,CA0BmC;IAAA;IAAA;IAAA;IAAA;IAAA,0DAnBpB,IAAIC,6BAAJ,EAmBoB;IAAA,gEAlB3B,IAAAC,oBAAA,EAAW,2BAAX,CAkB2B;IAAA,gDAjB3C,IAiB2C;IAAA;IAAA,mDAfxC,KAewC;IAAA,gDAdzB,IAcyB;IAAA;IAAA;IAAA,iDAX1C,KAW0C;IAAA;IAAA,iDAT1C,KAS0C;IAAA;IAAA;IAAA;IAAA;IAAA;;IAG7D,IAAI,KAAKC,kBAAL,IAA2B,KAAKC,OAAL,CAAaC,KAA5C,EAAmD;MACjD,KAAKC,MAAL,GAAc,KAAKF,OAAL,CAAaC,KAA3B;IACD,CAFD,MAEO;MACL,KAAKC,MAAL,GAAc,KAAKC,aAAL,CAAmBF,KAAjC;IACD;;IAED,KAAKG,UAAL,GAAkB,KAAKC,IAAL,CAAUC,KAA5B;IACA,KAAKC,WAAL,GAAmB,KAAKC,oBAAL,CAA0B,KAAKH,IAAL,CAAUC,KAApC,CAAnB;IACA,KAAKG,MAAL,GAAc,KAAKJ,IAAL,CAAUC,KAAxB;IACA,KAAKI,SAAL,GAAiB,KAAKC,UAAL,CAAgBC,GAAhB,CAAoBC,qBAApB,CAAjB;IAEA,KAAKC,gBAAL,GAAwB,IAAIC,wBAAJ,CAAoB,WAApB,CAAxB;;IACA,IAAIpB,SAAS,IAAIA,SAAS,CAACqB,OAA3B,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AKC,WAAZ;EACD;EAED;AACF;AACA;;;EACe,IAATC,SAAS,GAAY;IACvB,OAAO,CAAC,KAAKC,SAAb;EACD;EAED;AACF;;;EACc,IAARC,QAAQ,GAAY;IACtB,OAAO,KAAKD,SAAZ;EACD;EAED;AACF;;;EACc,IAARC,QAAQ,CAACA,QAAD,EAAoB;IAC9B,KAAKD,SAAL,GAAiBC,QAAjB;EACD;EAED;AACF;AACA;;;EACEC,IAAI,GAAG;IACL,KAAKD,QAAL,GAAgB,KAAhB;EACD;EAED;AACF;;;EACEE,IAAI,GAAG;IACL,KAAKF,QAAL,GAAgB,IAAhB;EACD;EAED;AACF;;;EACEG,MAAM,CAACC,cAAD,EAAyC;IAC7C,OACE,KAAKlI,GAAL,KAAakI,cAAc,CAAClI,GAA5B,IACA,KAAKC,SAAL,KAAmBiI,cAAc,CAACjI,SAFpC;EAID;EAED;AACF;AACA;;;EACmB,IAAbkI,aAAa,GAAkC;IACjD,OAAOC,0BAAA,CAAgBC,MAAvB;EACD;EAED;AACF;;;EACqB,IAAfC,eAAe,GAA6B;IAC9C,OAAO,KAAKC,gBAAZ;EACD;EAED;AACF;;;EACqB,IAAfD,eAAe,CAACE,KAAD,EAAkC;IACnD,KAAKD,gBAAL,GAAwBC,KAAxB;EACD;EAED;AACF;;;EACEC,sBAAsB,CAACC,UAAD,EAAkC;IACtD,IAAI,KAAKH,gBAAT,EAA2B;MACzB,KAAKD,eAAL,CAAqBK,OAArB,CAA6B,IAA7B,EAAmCD,UAAnC;IACD;EACF;EAED;AACF;AACA;;;EACwB,IAAlBvL,kBAAkB,GAAY;IAChC,OAAO,IAAAyL,6BAAA,GAAP;EACD;EAED;AACF;;;EACa,IAAPxL,OAAO,GAAqB;IAC9B,OAAO,IAAIyL,yBAAJ,CAAqB,KAAKpL,IAAL,CAAUL,OAA/B,CAAP;EACD;;AA75BH"}
|
|
1
|
+
{"version":3,"file":"AttributeModel.js","names":["AttributeModel","BaseModel","constructor","attribute","attributeContributions","ConstraintCollection","getSetting","hasContentFromData","content","label","_label","contributions","_initvalue","data","value","_inputvalue","getInitialInputValue","_value","_disabled","layouthint","has","DISABLED","_errorCollection","ErrorCollection","message","addServerError","id","parameters","_referenceDate","getData","DateUtil","now","_isResult","_mandatory","MANDATORY","mandatory","_links","LinkCollection","isApplicableModel","isPlainObject","IllegalArgumentException","getInitialChildModelLinks","hasContentConfiguration","conceptLink","setChildModels","models","conceptHref","href","concept","model","selfhref","equalsWithParameters","key","parentKey","_parentKey","name","type","_hasContentConfiguration","indicateContentConfiguration","contentConfiguration","hasQuestionConfig","questions","hasConfig","hasEndResultConfig","isConfiguredEndResultAttribute","hasIntermediateResultConfig","isConfiguredIntermediateResultAttribute","getContentConfiguredLabel","configuredLabelProperties","labelConfig","length","types","configuredLabels","getLabelElementByIds","configuredLabel","firstConfiguredLabel","configuredLabelProperty","some","_id","defaultAlignment","alignment","alignmentHints","getByLayoutHint","substring","links","downloadLink","getLinksByGroup","first","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","referenceDate","isCacheable","_concept","ConceptDetailModel","date","initvalue","getInputValue","inputvalue","toString","validateValue","validate","hasValue","getValue","getFormData","inError","formdata","getEmptyFormData","updateLastModification","formatValue","readonlyvalue","configuredMandatory","_validatedValue","readonly","_readonly","static","isResult","disabled","format","getContribution","formatLabel","minLength","maxLength","operator","assistantMessage","isValid","constraintCollection","constraints","add","_serverConstraints","MandatoryConstraint","StringLengthConstraint","addConstraints","setUseClientsideValidation","enabled","_useClientsideValidation","useClientsideValidation","isOptionalAndEmpty","_isValid","undefined","errorCollection","collection","invalidConstraints","isChangedSince","resetErrors","error","properties","removeServerError","hasServerErrors","serverErrors","hasErrors","hasItems","addMissingError","removeMissingError","addServerConstraint","defaultMessage","addConstraint","formatParameters","params","forEach","paramKey","paramValue","hasDynamicValidationData","updateValidations","errors","_lastModification","Date","timestamp","reset","UnsupportedOperationException","mergeAttribute","oldAttribute","update","changedAttribute","isEditable","_isEditable","isVisible","_isHidden","isHidden","show","hide","equals","otherAttribute","readonlyWidth","ATTRIBUTE_WIDTH","MEDIUM","layoutHintRules","_layoutHintRules","rules","processLayoutHintRules","attributes","process","hasAllContentInData","AttributeContent"],"sources":["../../../src/models/attributes/AttributeModel.js"],"sourcesContent":["// @flow\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\nimport { isPlainObject } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport ErrorCollection from \"../error/ErrorCollection\";\nimport LinkCollection from \"../links/LinkCollection\";\n\nimport StringLengthConstraint from \"./input-constraints/StringLengthConstraint\";\nimport MandatoryConstraint from \"./input-constraints/MandatoryConstraint\";\n\nimport ConceptDetailModel from \"../concepts/ConceptDetailModel\";\n\nimport { DISABLED, MANDATORY } from \"../../constants/LayoutHints\";\nimport {\n ATTRIBUTE_WIDTH,\n TIMEVERSION_FILTER_NAME,\n} from \"../../constants/Constants\";\n\nimport { getSetting, hasAllContentInData } from \"../../constants/Settings\";\n\nimport {\n IllegalArgumentException,\n UnsupportedOperationException,\n} from \"../../exceptions\";\n\nimport type { MessageParameters } from \"../../i18n/types\";\nimport type {\n AttributeType,\n FormErrorAnchor,\n IModelWithChildModels,\n ModularUIModel,\n} from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport type ContentConfigurationElements from \"../contentconfiguration/ContentConfigurationElements\";\nimport type LayoutHintRuleCollection from \"./layouthint-rules/LayoutHintRuleCollection\";\nimport type AttributeCollection from \"./AttributeCollection\";\nimport AttributeContent from \"./AttributeContent\";\n\n/**\n * Attribute model, base model for all kind of attributes\n */\nexport default class AttributeModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _label: string;\n _lastModification: number = 0;\n\n _initvalue: any;\n _inputvalue: string;\n _value: any;\n\n _errorCollection: ErrorCollection;\n _serverConstraints: ConstraintCollection = new ConstraintCollection();\n _useClientsideValidation: boolean = getSetting(\"USE_CLIENTSIDE_VALIDATION\");\n _isValid: boolean = true;\n _validatedValue: string | null;\n _isEditable: boolean = false;\n _concept: ConceptDetailModel | null = null;\n _referenceDate: ISO_DATE;\n _isResult: boolean;\n _isHidden: boolean = false;\n _readonly: boolean;\n _disabled: boolean = false;\n _mandatory: boolean;\n _links: LinkCollection;\n _parentKey: ?string;\n _hasContentConfiguration: boolean;\n _layoutHintRules: LayoutHintRuleCollection;\n\n /**\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n if (this.hasContentFromData && this.content.label) {\n this._label = this.content.label;\n } else {\n this._label = this.contributions.label;\n }\n\n this._initvalue = this.data.value;\n this._inputvalue = this.getInitialInputValue(this.data.value);\n this._value = this.data.value;\n this._disabled = this.layouthint.has(DISABLED);\n\n this._errorCollection = new ErrorCollection(\"attribute\");\n if (attribute && attribute.message) {\n this._errorCollection.addServerError(\n attribute.message.id,\n attribute.message.message,\n attribute.message.parameters\n );\n }\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n\n this._isResult = this.getData(\"isResult\", false);\n\n this._mandatory =\n this.layouthint.has(MANDATORY) || this.contributions.mandatory;\n\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links\n );\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n if (!isPlainObject(contributions)) {\n throw new IllegalArgumentException(\n \"Given argument for isApplicableModel is not a contributions object\"\n );\n }\n\n return false;\n }\n\n /**\n * Retrieve initial input value\n */\n getInitialInputValue(value: any): any {\n return value;\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n if (\n !this.hasContentFromData &&\n this.hasContentConfiguration &&\n this.conceptLink\n ) {\n return [this.conceptLink];\n }\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const conceptHref = this.conceptLink?.href;\n if (conceptHref) {\n this.concept = models.find((model) =>\n model.selfhref.equalsWithParameters(conceptHref)\n );\n }\n }\n\n /**\n * Getting the attribute key\n */\n get key(): string {\n return this.data.key;\n }\n\n /**\n */\n get parentKey(): string {\n return this._parentKey || \"\";\n }\n\n /**\n */\n set parentKey(parentKey: string) {\n this._parentKey = parentKey;\n }\n\n /**\n * Getting the attribute name\n */\n get name(): string {\n return this.key;\n }\n\n /**\n * Getting the type of the attribute\n */\n get type(): string {\n return this.contributions.type;\n }\n\n /**\n * Getting the label of the attribute\n */\n get label(): string {\n return this._label || \"\";\n }\n\n /**\n * Set the label of this attribute\n */\n set label(label: string) {\n this._label = label;\n }\n\n /**\n */\n set hasContentConfiguration(hasContentConfiguration: boolean) {\n this._hasContentConfiguration = hasContentConfiguration;\n }\n\n /**\n */\n get hasContentConfiguration(): boolean {\n return this._hasContentConfiguration || false;\n }\n\n /**\n */\n indicateContentConfiguration(contentConfiguration: ContentConfiguration) {\n if (contentConfiguration) {\n const hasQuestionConfig = contentConfiguration.questions?.hasConfig();\n\n const hasEndResultConfig =\n contentConfiguration.isConfiguredEndResultAttribute(this.key);\n const hasIntermediateResultConfig =\n contentConfiguration.isConfiguredIntermediateResultAttribute(this.key);\n\n this.hasContentConfiguration =\n hasQuestionConfig || hasEndResultConfig || hasIntermediateResultConfig;\n }\n }\n\n /**\n * Retrieve the first permitted label to render when a concept and contentConfiguration is available\n * Be aware that permission could be in place for labels from a concept.\n */\n getContentConfiguredLabel(\n contentConfiguration: ?ContentConfigurationElements\n ): string {\n if (this.hasContentFromData) {\n return this.content.label ?? this.label;\n }\n\n const configuredLabelProperties =\n contentConfiguration && contentConfiguration.labelConfig.length > 0\n ? contentConfiguration.labelConfig[0].types\n : [];\n\n if (this.concept && configuredLabelProperties.length > 0) {\n const configuredLabels = this.concept\n .getLabelElementByIds(configuredLabelProperties)\n .filter(\n (configuredLabel) =>\n configuredLabel.value && configuredLabel.value !== \"\"\n );\n\n if (configuredLabels.length > 0) {\n const [firstConfiguredLabel] = configuredLabelProperties\n .filter((configuredLabelProperty) =>\n configuredLabels.some(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty\n )\n )\n .map((configuredLabelProperty) =>\n configuredLabels.find(\n (configuredLabel) =>\n configuredLabel._id === configuredLabelProperty\n )\n );\n\n if (firstConfiguredLabel) {\n return firstConfiguredLabel.value;\n }\n }\n }\n\n return this.label;\n }\n\n /**\n */\n get defaultAlignment(): \"left\" | \"center\" | \"right\" {\n return \"left\";\n }\n\n /**\n * Handles layout hint align-left, align-center and align-right\n */\n get alignment(): \"left\" | \"center\" | \"right\" {\n const alignmentHints = this.layouthint.getByLayoutHint(\"align-\");\n\n // return alignment based on layouthint or the default alignment for the attribute\n const alignment = alignmentHints\n ? alignmentHints.substring(\"align-\".length)\n : this.defaultAlignment;\n\n if (\n alignment === \"left\" ||\n alignment === \"center\" ||\n alignment === \"right\"\n ) {\n return alignment;\n }\n\n return this.defaultAlignment;\n }\n\n /**\n * Retrieve links of attribute\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links\n );\n }\n\n return this._links;\n }\n\n /**\n * Retrieve link of attribute when available\n */\n get downloadLink(): ?LinkModel {\n const downloadLink = this.links.getLinksByGroup(\"download\").first;\n\n if (downloadLink && downloadLink.key === this.key) {\n return downloadLink;\n }\n\n return null;\n }\n\n /**\n * Retrieve concept link of attribute when available\n */\n get conceptLink(): ?LinkModel {\n const conceptLink = this.links.getLinkByKey(\"concept\");\n\n if (conceptLink !== null) {\n conceptLink.href = conceptLink.href.addParameter(\n TIMEVERSION_FILTER_NAME,\n this.referenceDate\n );\n\n conceptLink.isCacheable = true;\n }\n\n return conceptLink;\n }\n\n /**\n * Get concept information\n */\n get concept(): ConceptDetailModel | null {\n return this._concept ?? null;\n }\n\n /**\n * Set the concept\n */\n set concept(concept: ?ModularUIModel) {\n this._concept = concept instanceof ConceptDetailModel ? concept : null;\n }\n\n /**\n * Retrieve reference date of attribute which can be used as entryDate for content\n * to get information in correct time version\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n * Set reference date for concepts and content\n */\n set referenceDate(date: ISO_DATE) {\n this._referenceDate = date;\n }\n\n /**\n * Initial value received from the modular ui service\n */\n get initvalue(): any {\n return this._initvalue;\n }\n\n /**\n * Retrieve input value\n */\n getInputValue(): string {\n const inputvalue = this._inputvalue;\n\n return inputvalue ? inputvalue.toString() : \"\";\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Value that is used when retrieving an error collection of this attribute\n * Mostly this is the input value, but sometimes a different value is needed,\n * for example iban and postcode need to validate length without spaces\n */\n get validateValue(): string {\n return this.inputvalue;\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this._inputvalue = value;\n this.value = value;\n\n this.validate(value);\n }\n\n /**\n */\n hasValue(): boolean {\n return this._value != null && this._value !== \"\";\n }\n\n /**\n * Getting the value of the attribute\n */\n getValue(): any {\n return this.hasValue() ? this._value : null;\n }\n\n /**\n * Getting data ready to be send to the modular ui\n * Returns null when the attribute should not be send to the server\n */\n getFormData(): { [string]: any } | null {\n if (this.inError()) {\n return null;\n }\n\n return {\n [this.name]: this.value,\n };\n }\n\n /**\n */\n get formdata(): { [string]: any } | null {\n return this.getFormData();\n }\n\n /**\n */\n getEmptyFormData(): { [string]: null } {\n return { [this.name]: null };\n }\n\n /**\n * Getting the value of the attribute\n */\n get value(): any {\n return this.getValue();\n }\n\n /**\n * Setting a value in the element\n */\n set value(value: ?string) {\n this.updateLastModification();\n\n this._value = value;\n }\n\n /**\n */\n formatValue(value: string): string {\n return value;\n }\n\n /**\n * Getting the readonly value, iso value converted for human reading\n */\n get readonlyvalue(): string {\n return this.value ? this.value.toString() : \"\";\n }\n\n /**\n * Getting mandatory status of attribute\n */\n get mandatory(): boolean {\n return this._mandatory || false;\n }\n\n /**\n */\n get configuredMandatory(): ?boolean {\n return this.layouthint.has(MANDATORY) || this.contributions.mandatory;\n }\n\n /**\n * Set mandatory status of attribute\n */\n set mandatory(mandatory: boolean) {\n if (mandatory !== this._mandatory) {\n this._validatedValue = null;\n }\n this._mandatory = mandatory;\n }\n\n /**\n */\n get readonly(): boolean {\n return (\n this._readonly ||\n this.contributions.readonly === true ||\n this.data.static === true ||\n this.isResult === true\n );\n }\n\n /**\n */\n set readonly(readonly: boolean) {\n this._readonly = readonly;\n }\n\n /**\n */\n get disabled(): boolean {\n return this._disabled;\n }\n\n /**\n */\n set disabled(disabled: boolean) {\n this._disabled = disabled;\n }\n\n /**\n */\n get isResult(): boolean {\n return this._isResult;\n }\n\n /**\n */\n set isResult(isResult: boolean) {\n this._isResult = isResult;\n }\n\n /**\n * Getting the display and input format of a attribute\n */\n get format(): string | null {\n return this.getContribution(\"format\");\n }\n\n /**\n */\n get formatLabel(): string {\n return this.format || \"\";\n }\n\n /**\n * Get minimum string length\n */\n get minLength(): number | null {\n return this.getContribution(\"minLength\");\n }\n\n /**\n * Get maximum string length\n */\n get maxLength(): number | null {\n return this.getContribution(\"maxLength\");\n }\n\n /**\n */\n get operator(): string {\n return \"\";\n }\n\n /**\n * Get assistant message\n */\n get assistantMessage(): string | null {\n return this.getContribution(\"assistant\");\n }\n\n /**\n * Get valid status\n */\n get isValid(): boolean {\n return this.validate(this.validateValue);\n }\n\n /**\n * Retrieve applicable constraint for this attribute\n */\n get constraintCollection(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this._serverConstraints);\n\n // Mandatory constraint\n if (this.mandatory) {\n constraints.add(new MandatoryConstraint());\n }\n\n if (this.minLength || this.maxLength) {\n constraints.add(\n new StringLengthConstraint(this.minLength, this.maxLength)\n );\n }\n\n constraints.add(this.addConstraints());\n\n return constraints;\n }\n\n /**\n * Template method for class extending this model to add extra constraints\n * @abstract\n */\n addConstraints(): ConstraintCollection {\n return new ConstraintCollection();\n }\n\n /**\n * Used to programmatically overwrite the setting USE_CLIENTSIDE_VALIDATION\n */\n setUseClientsideValidation(enabled: boolean) {\n this._useClientsideValidation = enabled;\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 * Validate input on client side constraint\n */\n validate(value: string): boolean {\n // when client side validation is disabled, this attribute is always valid\n if (!this.useClientsideValidation()) {\n return true;\n }\n\n if (this.isOptionalAndEmpty(value)) {\n this._isValid = true;\n } else if (this._validatedValue !== value) {\n this._isValid = this.constraintCollection.validate(value);\n }\n this._validatedValue = value;\n\n return this._isValid;\n }\n\n /**\n * Indicates if attribute is optional and empty\n */\n isOptionalAndEmpty(value: string): boolean {\n if (value === undefined) {\n throw new IllegalArgumentException(\n \"isOptionalAndEmpty method needs value argument\"\n );\n }\n\n return !this.mandatory && value === \"\";\n }\n\n /**\n * Retrieve error messages of this attribute\n */\n get errorCollection(): ErrorCollection {\n const collection = new ErrorCollection(\"attribute\", this._errorCollection);\n\n collection.addConstraints(\n this.constraintCollection.invalidConstraints(this.validateValue)\n );\n\n return collection;\n }\n\n /**\n * Check if attribute is in error\n */\n inError(): boolean {\n return !this._isValid && this.isChangedSince(0);\n }\n\n /**\n * Reset static error messages on attribute\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"attribute\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n error.layouthint\n );\n }\n\n /**\n */\n removeServerError(id: string) {\n this._errorCollection.removeServerError(id);\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return this.errorCollection.serverErrors.length > 0;\n }\n\n /**\n */\n hasErrors(): boolean {\n return this.errorCollection.hasItems;\n }\n\n /**\n * Registers a missing error that was received from the server\n */\n addMissingError() {\n this._errorCollection.addServerError(\"Constraint.Missing\");\n }\n\n /**\n */\n removeMissingError() {\n this.removeServerError(\"Constraint.Missing\");\n }\n\n /**\n */\n addServerConstraint(\n id: string,\n defaultMessage?: string,\n parameters?: MessageParameters\n ) {\n this._serverConstraints.addConstraint(\n id,\n null,\n defaultMessage,\n parameters,\n this.useClientsideValidation()\n );\n }\n\n /**\n */\n formatParameters(parameters: Object): { [string]: string | number } {\n if (parameters == null) {\n return {};\n }\n\n const params = {};\n\n Object.keys(parameters).forEach((paramKey: string) => {\n const paramValue = parameters[paramKey];\n if (paramKey.endsWith(\"-number\") || paramKey.endsWith(\"-date\")) {\n params[paramKey] = this.formatValue(paramValue);\n } else {\n params[paramKey] = paramValue;\n }\n });\n\n return params;\n }\n\n /**\n */\n get hasDynamicValidationData(): boolean {\n return true;\n }\n\n /**\n */\n updateValidations(errors: Array<Object>) {\n if (\n errors.some((error) => error.id === \"Constraint.Mandatory\") ||\n this.layouthint.has(MANDATORY)\n ) {\n this.mandatory = true;\n } else if (!this.hasValue()) {\n this.mandatory = false;\n }\n\n this._serverConstraints = new ConstraintCollection();\n this.resetErrors();\n\n errors\n .filter(\n (error) => error.id !== \"Constraint.Mandatory\" || !this.hasValue()\n )\n .forEach((error) => {\n if (this.hasValue()) {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n this.formatParameters(error.properties),\n error.layouthint\n );\n } else {\n this.addServerConstraint(\n error.id,\n error.message,\n this.formatParameters(error.properties)\n );\n }\n });\n }\n\n /**\n * Set last modification to current timestamp\n */\n updateLastModification() {\n this._lastModification = Date.now();\n }\n\n /**\n * Inidicates if attribute is changed since a given timestamp (Date.now)\n */\n isChangedSince(timestamp: number): boolean {\n return this._lastModification > timestamp;\n }\n\n /**\n * Abstract reset method which should be implemented on each attribute that has this attribute as a base class.\n *\n * @abstract\n */\n reset() {\n throw new UnsupportedOperationException(\n `Reset method not implemented for ${this.type}`\n );\n }\n\n /**\n * Merge old attribute with the attribute from the server.\n * Readonly attributes always need to show the value from the server\n */\n mergeAttribute(oldAttribute: AttributeType) {\n this.concept = oldAttribute.concept;\n\n if (\n !oldAttribute.readonly &&\n oldAttribute.isValid &&\n oldAttribute.inputvalue !== null\n ) {\n this.update(oldAttribute.inputvalue);\n }\n }\n\n /**\n * Abstract update method which should be implemented on each attribute that has this attribute as a base class.\n * @abstract\n */\n // eslint-disable-next-line no-unused-vars\n update(value: string, changedAttribute?: AttributeType): AttributeType {\n throw new UnsupportedOperationException(\n `Update method not implemented for ${this.type}`\n );\n }\n\n /**\n * Indicate if attribute is editable\n */\n set isEditable(isEditable: boolean) {\n this._isEditable = isEditable;\n }\n\n /**\n * Retrieve if attribute is editable\n */\n get isEditable(): boolean {\n return this._isEditable;\n }\n\n /**\n * Indicates if the attribute is visible\n */\n get isVisible(): boolean {\n return !this._isHidden;\n }\n\n /**\n */\n get isHidden(): boolean {\n return this._isHidden;\n }\n\n /**\n */\n set isHidden(isHidden: boolean) {\n this._isHidden = isHidden;\n }\n\n /**\n * Explicitly toggle visibility of this attribute\n */\n show() {\n this.isHidden = false;\n }\n\n /**\n */\n hide() {\n this.isHidden = true;\n }\n\n /**\n */\n equals(otherAttribute: AttributeType): boolean {\n return (\n this.key === otherAttribute.key &&\n this.parentKey === otherAttribute.parentKey\n );\n }\n\n /**\n * Readonly attribute width indicates the proposed width of this attribute\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n\n /**\n */\n get layoutHintRules(): LayoutHintRuleCollection {\n return this._layoutHintRules;\n }\n\n /**\n */\n set layoutHintRules(rules: LayoutHintRuleCollection) {\n this._layoutHintRules = rules;\n }\n\n /**\n */\n processLayoutHintRules(attributes: AttributeCollection) {\n if (this._layoutHintRules) {\n this.layoutHintRules.process(this, attributes);\n }\n }\n\n /**\n * Indicates if content comes from the data service\n */\n get hasContentFromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get content(): AttributeContent {\n return new AttributeContent(this.data.content);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AAKA;;AAE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tB,OAAO,KAAKD,SAAZ;EACD;EAED;AACF;;;EACc,IAARC,QAAQ,CAACA,QAAD,EAAoB;IAC9B,KAAKD,SAAL,GAAiBC,QAAjB;EACD;EAED;AACF;AACA;;;EACEC,IAAI,GAAG;IACL,KAAKD,QAAL,GAAgB,KAAhB;EACD;EAED;AACF;;;EACEE,IAAI,GAAG;IACL,KAAKF,QAAL,GAAgB,IAAhB;EACD;EAED;AACF;;;EACEG,MAAM,CAACC,cAAD,EAAyC;IAC7C,OACE,KAAKlI,GAAL,KAAakI,cAAc,CAAClI,GAA5B,IACA,KAAKC,SAAL,KAAmBiI,cAAc,CAACjI,SAFpC;EAID;EAED;AACF;AACA;;;EACmB,IAAbkI,aAAa,GAAkC;IACjD,OAAOC,0BAAA,CAAgBC,MAAvB;EACD;EAED;AACF;;;EACqB,IAAfC,eAAe,GAA6B;IAC9C,OAAO,KAAKC,gBAAZ;EACD;EAED;AACF;;;EACqB,IAAfD,eAAe,CAACE,KAAD,EAAkC;IACnD,KAAKD,gBAAL,GAAwBC,KAAxB;EACD;EAED;AACF;;;EACEC,sBAAsB,CAACC,UAAD,EAAkC;IACtD,IAAI,KAAKH,gBAAT,EAA2B;MACzB,KAAKD,eAAL,CAAqBK,OAArB,CAA6B,IAA7B,EAAmCD,UAAnC;IACD;EACF;EAED;AACF;AACA;;;EACwB,IAAlBvL,kBAAkB,GAAY;IAChC,OAAO,IAAAyL,6BAAA,GAAP;EACD;EAED;AACF;;;EACa,IAAPxL,OAAO,GAAqB;IAC9B,OAAO,IAAIyL,yBAAJ,CAAqB,KAAKpL,IAAL,CAAUL,OAA/B,CAAP;EACD;;AA/5BH"}
|
|
@@ -405,7 +405,8 @@ class ChoiceAttributeModel extends _AttributeModel.default {
|
|
|
405
405
|
const {
|
|
406
406
|
id,
|
|
407
407
|
message,
|
|
408
|
-
properties
|
|
408
|
+
properties,
|
|
409
|
+
layouthint
|
|
409
410
|
} = error;
|
|
410
411
|
const ANSWER_OPTION_KEY = "answer-option-key";
|
|
411
412
|
|
|
@@ -420,7 +421,7 @@ class ChoiceAttributeModel extends _AttributeModel.default {
|
|
|
420
421
|
}
|
|
421
422
|
}
|
|
422
423
|
|
|
423
|
-
this._errorCollection.addServerError(id, message, properties);
|
|
424
|
+
this._errorCollection.addServerError(id, message, properties, layouthint);
|
|
424
425
|
}
|
|
425
426
|
/**
|
|
426
427
|
*/
|
|
@@ -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, message, properties, layouthint } = 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, message, properties, layouthint);
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
/**
|