@beinformed/ui 1.21.1 → 1.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +20 -4
  2. package/esm/models/attributes/AttributeModel.js +2 -2
  3. package/esm/models/attributes/AttributeModel.js.map +1 -1
  4. package/esm/models/attributes/ChoiceAttributeModel.js +2 -1
  5. package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
  6. package/esm/models/attributes/DatetimeAttributeModel.js +2 -1
  7. package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
  8. package/esm/models/error/ErrorCollection.js +7 -6
  9. package/esm/models/error/ErrorCollection.js.map +1 -1
  10. package/esm/models/error/ErrorModel.js +2 -1
  11. package/esm/models/error/ErrorModel.js.map +1 -1
  12. package/esm/models/error/ErrorResponse.js +46 -32
  13. package/esm/models/error/ErrorResponse.js.map +1 -1
  14. package/esm/models/form/FormModel.js +5 -4
  15. package/esm/models/form/FormModel.js.map +1 -1
  16. package/esm/models/form/FormObjectModel.js +1 -1
  17. package/esm/models/form/FormObjectModel.js.map +1 -1
  18. package/esm/models/grouping/GroupingModel.js +36 -8
  19. package/esm/models/grouping/GroupingModel.js.map +1 -1
  20. package/esm/models/types.js.map +1 -1
  21. package/lib/models/attributes/AttributeModel.js +2 -2
  22. package/lib/models/attributes/AttributeModel.js.flow +2 -0
  23. package/lib/models/attributes/AttributeModel.js.map +1 -1
  24. package/lib/models/attributes/ChoiceAttributeModel.js +2 -1
  25. package/lib/models/attributes/ChoiceAttributeModel.js.flow +2 -2
  26. package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
  27. package/lib/models/attributes/DatetimeAttributeModel.js +2 -1
  28. package/lib/models/attributes/DatetimeAttributeModel.js.flow +2 -2
  29. package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
  30. package/lib/models/error/ErrorCollection.js +7 -5
  31. package/lib/models/error/ErrorCollection.js.flow +6 -3
  32. package/lib/models/error/ErrorCollection.js.map +1 -1
  33. package/lib/models/error/ErrorModel.js +2 -1
  34. package/lib/models/error/ErrorModel.js.flow +5 -2
  35. package/lib/models/error/ErrorModel.js.map +1 -1
  36. package/lib/models/error/ErrorResponse.js +46 -32
  37. package/lib/models/error/ErrorResponse.js.flow +31 -24
  38. package/lib/models/error/ErrorResponse.js.map +1 -1
  39. package/lib/models/form/FormModel.js +5 -3
  40. package/lib/models/form/FormModel.js.flow +8 -1
  41. package/lib/models/form/FormModel.js.map +1 -1
  42. package/lib/models/form/FormObjectModel.js +1 -1
  43. package/lib/models/form/FormObjectModel.js.flow +1 -0
  44. package/lib/models/form/FormObjectModel.js.map +1 -1
  45. package/lib/models/grouping/GroupingModel.js +36 -8
  46. package/lib/models/grouping/GroupingModel.js.flow +38 -10
  47. package/lib/models/grouping/GroupingModel.js.map +1 -1
  48. package/lib/models/types.js.flow +1 -1
  49. package/lib/models/types.js.map +1 -1
  50. package/package.json +1 -1
  51. package/src/models/attributes/AttributeModel.js +2 -0
  52. package/src/models/attributes/ChoiceAttributeModel.js +2 -2
  53. package/src/models/attributes/DatetimeAttributeModel.js +2 -2
  54. package/src/models/error/ErrorCollection.js +6 -3
  55. package/src/models/error/ErrorModel.js +5 -2
  56. package/src/models/error/ErrorResponse.js +31 -24
  57. package/src/models/form/FormModel.js +8 -1
  58. package/src/models/form/FormObjectModel.js +1 -0
  59. package/src/models/grouping/GroupingModel.js +38 -10
  60. package/src/models/types.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceAttributeModel.js","names":["ChoiceAttributeModel","AttributeModel","constructor","attribute","attributeContributions","_referenceDate","getData","DateUtil","now","_options","ChoiceAttributeOptionCollection","create","referenceDate","layouthint","has","SORT_OPTIONS","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","conceptLinkHref","href","concept","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","date","selected","option","code","readonlyvalue","join","initvalue","Array","isArray","_initvalue","length","getValue","hasValue","getInputValue","toggleOption","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","opt","choicetype","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","readonly","mergeOptions","isValid","update","value","updateLastModification","values","split","forEach","val","ChoiceAttributeOptionModel","equals","add","toString","_hasContentConfiguration","contentConfiguration","content","optionElements","optionElementConfig","optionElement","contentElement","RENDER_SECTION_LABEL","ContentConfigurationElements","placeholder","addServerError","error","id","message","properties","ANSWER_OPTION_KEY","optionKey","foundOption","getContentConfiguredLabel","_errorCollection","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/ChoiceAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\nimport AttributeModel from \"./AttributeModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ContentConfigurationElements from \"../contentconfiguration/ContentConfigurationElements\";\n\nimport {\n RENDER_SECTION_LABEL,\n SORT_OPTIONS,\n} from \"../../constants/LayoutHints\";\nimport { ATTRIBUTE_WIDTH } from \"../../constants\";\n\nimport type { ModularUIModel, AttributeType, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Model for a choice attribute\n */\nexport default class ChoiceAttributeModel extends AttributeModel {\n _referenceDate: ISO_DATE;\n _options: ChoiceAttributeOptionCollection;\n _hasContentConfiguration: boolean;\n\n /**\n * Constructs a choice attribute\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n this._options = ChoiceAttributeOptionCollection.create(\n attribute,\n attributeContributions,\n this.referenceDate\n );\n\n if (this.layouthint.has(SORT_OPTIONS)) {\n this._options.sortOptions = true;\n }\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return (\n contributions.type !== \"composite\" &&\n contributions.type !== \"boolean\" &&\n (contributions.type === \"choice\" ||\n contributions.type === \"array\" ||\n has(contributions, \"enumerated\") ||\n has(contributions, \"options\"))\n );\n }\n\n /**\n */\n get type(): string {\n const optionMode = this.getContribution(\"optionMode\", \"\");\n const hasLookupLink = this.lookupLink || this.lookupListLink;\n\n if (\n optionMode === \"lookup\" ||\n (optionMode === \"dynamicWithThreshold\" && hasLookupLink)\n ) {\n return \"lookup\";\n }\n\n return \"choice\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const links = [];\n\n if (this.hasContentConfiguration) {\n if (!this.hasContentFromData && this.conceptLink) {\n links.push(this.conceptLink);\n }\n\n links.push(...this.options.getInitialChildModelLinks());\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const conceptLinkHref = this.conceptLink?.href;\n if (conceptLinkHref) {\n this.concept = models.find(\n (model) =>\n model.type === \"ConceptDetail\" &&\n model.selfhref.equalsWithParameters(conceptLinkHref)\n );\n }\n\n this.options.setChildModels(models);\n }\n\n /**\n * Retrieve lookup service link\n */\n get lookupLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupOptions\");\n }\n\n /**\n * Retrieve lookup service as list link\n */\n get lookupListLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupList\");\n }\n\n /**\n */\n get lookupListLabel(): string {\n return this.contributions.lookupList?.label ?? \"\";\n }\n\n /**\n * Retrieve reference date of attribute which can be used as entryDate for content\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: string) {\n this._referenceDate = date;\n\n this.options.referenceDate = date;\n }\n\n /**\n * Retrieve available choice options\n */\n get options(): ChoiceAttributeOptionCollection {\n return this._options;\n }\n\n /**\n * Getting all enabled options\n */\n get selected(): Array<string> {\n // $FlowFixMe[incompatible-call]\n return this.options.selected.map<string, ChoiceAttributeOptionModel>(\n (option: ChoiceAttributeOptionModel) => option.code\n );\n }\n\n /**\n * Flatten options and filter out the options that are not selected\n */\n get readonlyvalue(): string {\n return this.options.selected.map((option) => option.label).join(\", \");\n }\n\n /**\n */\n get initvalue(): any {\n if (Array.isArray(this._initvalue) && this._initvalue.length === 0) {\n return null;\n }\n\n return this._initvalue;\n }\n\n /**\n * Retrieve list of selected options, joined with comma\n */\n getValue(): string | null {\n return this.options.selected.length > 0\n ? this.options.selected.map((option) => option.code).join(\",\")\n : null;\n }\n\n /**\n */\n hasValue(): boolean {\n return this.options.selected.length > 0;\n }\n\n /**\n * Get input value of attribute\n */\n getInputValue(): string {\n return this.selected.join(\",\");\n }\n\n /**\n * Setting an option selected or unselected based on the current state\n */\n toggleOption(code: string) {\n if (this.selected.includes(code)) {\n this.disableOption(code);\n } else {\n this.enableOption(code);\n }\n }\n\n /**\n * Enable a option\n */\n enableOption(code: string) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n this.options.select(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Disable a option\n */\n disableOption(code: string) {\n this.options.deselect(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Add a new option to the collection of lookup options\n */\n addOption(option: Object) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n if (this.options.find((opt) => opt.code === option.code) === null) {\n this.options.addOption(option.code, option);\n }\n }\n\n /**\n * Getting the type of choice filter. For instance checkbox, radiobutton, combobox.\n */\n get choicetype():\n | \"checkbox\"\n | \"radiobutton\"\n | \"combobox\"\n | \"list\"\n | \"listview\"\n | \"table\"\n | \"longlist\"\n | \"toggle\" {\n return (\n [\n \"checkbox\",\n \"radiobutton\",\n \"combobox\",\n \"list\",\n \"listview\",\n \"table\",\n \"longlist\",\n \"toggle\",\n ].find((hint) => this.layouthint.has(hint)) || \"checkbox\"\n );\n }\n\n /**\n * Can multiple options be selected\n */\n get isMultiple(): boolean {\n return this.contributions.multiplechoice || this.choicetype === \"checkbox\";\n }\n\n /**\n * Check if options need to be rendered as tree\n */\n get isTree(): boolean {\n return (\n has(this.contributions, \"options\") &&\n this.contributions.options.some((option) => has(option, \"children\"))\n );\n }\n\n /**\n * Reset choice attribute to unselected list\n */\n reset() {\n this.options.deselectAll();\n }\n\n /**\n */\n mergeAttribute(oldAttribute: AttributeType) {\n // when attribute is readonly, don't merge the options no modifications necessary\n if (!this.readonly && oldAttribute instanceof ChoiceAttributeModel) {\n this.concept = oldAttribute.concept;\n this.options.mergeOptions(oldAttribute.options, this.type === \"lookup\");\n this.options.deselectAll();\n\n if (oldAttribute.isValid && oldAttribute.inputvalue !== null) {\n this.update(oldAttribute.inputvalue);\n }\n }\n }\n\n /**\n * Update attribute by name and value\n */\n update(value: any): ChoiceAttributeModel {\n if (this.readonly) {\n return this;\n }\n\n this.updateLastModification();\n\n let values;\n\n if (Array.isArray(value)) {\n values = value;\n } else if (typeof value === \"string\" && this.isMultiple) {\n values = value.split(\",\");\n } else {\n values = [value];\n }\n values.forEach((val) => {\n if (val instanceof ChoiceAttributeOptionModel) {\n if (!this.options.some((option) => option.equals(val))) {\n this.options.add(val);\n }\n\n this.toggleOption(val.code);\n } else if (\n typeof val === \"string\" &&\n this.options.some((option) => option.code.toString() === val)\n ) {\n this.toggleOption(val);\n }\n });\n\n return this;\n }\n\n /**\n */\n set hasContentConfiguration(hasContentConfiguration: boolean) {\n this._hasContentConfiguration =\n this.contentConfiguration !== null || hasContentConfiguration;\n }\n\n /**\n */\n get hasContentConfiguration(): boolean {\n return this._hasContentConfiguration;\n }\n\n /**\n * Get content configuration configured on the attribute.\n * Only applicable for taxonomy element and knowledge codemaps,\n * content configuration for instrument questions is available on the form object\n */\n get contentConfiguration(): ContentConfigurationElements | null {\n if (\n !this.contributions.content ||\n !this.contributions.content.optionElements\n ) {\n return null;\n }\n\n // Add RENDER_SECTION_LABEL to all content configuration to make sure the label of a section is always rendered on taxonomy and knowlege codemaps\n const optionElementConfig = this.contributions.content.optionElements.map(\n (optionElement) => {\n if (\"contentElement\" in optionElement) {\n return {\n contentElement: {\n ...optionElement.contentElement,\n layouthint: [RENDER_SECTION_LABEL],\n },\n };\n }\n\n return optionElement;\n }\n );\n\n return new ContentConfigurationElements(optionElementConfig);\n }\n\n /**\n * Get placeholder text\n */\n get placeholder(): string {\n return this.getContribution(\"placeholder\", \"\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties } = error;\n\n const ANSWER_OPTION_KEY = \"answer-option-key\";\n\n if (properties && has(properties, ANSWER_OPTION_KEY)) {\n const optionKey = properties[ANSWER_OPTION_KEY];\n const foundOption = this.options.find(\n (option) => option.code === optionKey\n );\n if (foundOption) {\n properties[ANSWER_OPTION_KEY] = foundOption.getContentConfiguredLabel(\n this.contentConfiguration\n );\n }\n }\n\n this._errorCollection.addServerError(id, message, properties);\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"lookup\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAIA;;AAKA;AACA;AACA;AACe,MAAMA,oBAAN,SAAmCC,uBAAnC,CAAkD;EAK/D;AACF;AACA;EACEC,WAAW,CAACC,SAAD,EAAoBC,sBAApB,EAAoD;IAC7D,MAAMD,SAAN,EAAiBC,sBAAjB;IAD6D;IAAA;IAAA;IAG7D,KAAKC,cAAL,GAAsB,KAAKC,OAAL,CAAa,eAAb,EAA8BC,sBAAA,CAASC,GAAT,EAA9B,CAAtB;IACA,KAAKC,QAAL,GAAgBC,wCAAA,CAAgCC,MAAhC,CACdR,SADc,EAEdC,sBAFc,EAGd,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WAAJ,EAAiB;QACfH,UAAU,CAACC,iBAAD,CAAV,GAAgCE,WAAW,CAACC,yBAAZ,CAC9B,KAAKjB,oBADyB,CAAhC;MAGD;IACF;;IAED,KAAKkB,gBAAL,CAAsBT,cAAtB,CAAqCE,EAArC,EAAyCC,OAAzC,EAAkDC,UAAlD;EACD;EAED;AACF;;;EACmB,IAAbM,aAAa,GAAkC;IACjD,IAAI,KAAK3F,IAAL,KAAc,QAAlB,EAA4B;MAC1B,OAAO4F,0BAAA,CAAgBC,KAAvB;IACD;;IAED,OAAOD,0BAAA,CAAgBE,MAAvB;EACD;;AApZ8D"}
1
+ {"version":3,"file":"ChoiceAttributeModel.js","names":["ChoiceAttributeModel","AttributeModel","constructor","attribute","attributeContributions","_referenceDate","getData","DateUtil","now","_options","ChoiceAttributeOptionCollection","create","referenceDate","layouthint","has","SORT_OPTIONS","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","conceptLinkHref","href","concept","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","date","selected","option","code","readonlyvalue","join","initvalue","Array","isArray","_initvalue","length","getValue","hasValue","getInputValue","toggleOption","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","opt","choicetype","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","readonly","mergeOptions","isValid","update","value","updateLastModification","values","split","forEach","val","ChoiceAttributeOptionModel","equals","add","toString","_hasContentConfiguration","contentConfiguration","content","optionElements","optionElementConfig","optionElement","contentElement","RENDER_SECTION_LABEL","ContentConfigurationElements","placeholder","addServerError","error","id","message","properties","ANSWER_OPTION_KEY","optionKey","foundOption","getContentConfiguredLabel","_errorCollection","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/ChoiceAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\nimport AttributeModel from \"./AttributeModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ContentConfigurationElements from \"../contentconfiguration/ContentConfigurationElements\";\n\nimport {\n RENDER_SECTION_LABEL,\n SORT_OPTIONS,\n} from \"../../constants/LayoutHints\";\nimport { ATTRIBUTE_WIDTH } from \"../../constants\";\n\nimport type { ModularUIModel, AttributeType, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Model for a choice attribute\n */\nexport default class ChoiceAttributeModel extends AttributeModel {\n _referenceDate: ISO_DATE;\n _options: ChoiceAttributeOptionCollection;\n _hasContentConfiguration: boolean;\n\n /**\n * Constructs a choice attribute\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n this._options = ChoiceAttributeOptionCollection.create(\n attribute,\n attributeContributions,\n this.referenceDate\n );\n\n if (this.layouthint.has(SORT_OPTIONS)) {\n this._options.sortOptions = true;\n }\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return (\n contributions.type !== \"composite\" &&\n contributions.type !== \"boolean\" &&\n (contributions.type === \"choice\" ||\n contributions.type === \"array\" ||\n has(contributions, \"enumerated\") ||\n has(contributions, \"options\"))\n );\n }\n\n /**\n */\n get type(): string {\n const optionMode = this.getContribution(\"optionMode\", \"\");\n const hasLookupLink = this.lookupLink || this.lookupListLink;\n\n if (\n optionMode === \"lookup\" ||\n (optionMode === \"dynamicWithThreshold\" && hasLookupLink)\n ) {\n return \"lookup\";\n }\n\n return \"choice\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const links = [];\n\n if (this.hasContentConfiguration) {\n if (!this.hasContentFromData && this.conceptLink) {\n links.push(this.conceptLink);\n }\n\n links.push(...this.options.getInitialChildModelLinks());\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const conceptLinkHref = this.conceptLink?.href;\n if (conceptLinkHref) {\n this.concept = models.find(\n (model) =>\n model.type === \"ConceptDetail\" &&\n model.selfhref.equalsWithParameters(conceptLinkHref)\n );\n }\n\n this.options.setChildModels(models);\n }\n\n /**\n * Retrieve lookup service link\n */\n get lookupLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupOptions\");\n }\n\n /**\n * Retrieve lookup service as list link\n */\n get lookupListLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupList\");\n }\n\n /**\n */\n get lookupListLabel(): string {\n return this.contributions.lookupList?.label ?? \"\";\n }\n\n /**\n * Retrieve reference date of attribute which can be used as entryDate for content\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: string) {\n this._referenceDate = date;\n\n this.options.referenceDate = date;\n }\n\n /**\n * Retrieve available choice options\n */\n get options(): ChoiceAttributeOptionCollection {\n return this._options;\n }\n\n /**\n * Getting all enabled options\n */\n get selected(): Array<string> {\n // $FlowFixMe[incompatible-call]\n return this.options.selected.map<string, ChoiceAttributeOptionModel>(\n (option: ChoiceAttributeOptionModel) => option.code\n );\n }\n\n /**\n * Flatten options and filter out the options that are not selected\n */\n get readonlyvalue(): string {\n return this.options.selected.map((option) => option.label).join(\", \");\n }\n\n /**\n */\n get initvalue(): any {\n if (Array.isArray(this._initvalue) && this._initvalue.length === 0) {\n return null;\n }\n\n return this._initvalue;\n }\n\n /**\n * Retrieve list of selected options, joined with comma\n */\n getValue(): string | null {\n return this.options.selected.length > 0\n ? this.options.selected.map((option) => option.code).join(\",\")\n : null;\n }\n\n /**\n */\n hasValue(): boolean {\n return this.options.selected.length > 0;\n }\n\n /**\n * Get input value of attribute\n */\n getInputValue(): string {\n return this.selected.join(\",\");\n }\n\n /**\n * Setting an option selected or unselected based on the current state\n */\n toggleOption(code: string) {\n if (this.selected.includes(code)) {\n this.disableOption(code);\n } else {\n this.enableOption(code);\n }\n }\n\n /**\n * Enable a option\n */\n enableOption(code: string) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n this.options.select(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Disable a option\n */\n disableOption(code: string) {\n this.options.deselect(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Add a new option to the collection of lookup options\n */\n addOption(option: Object) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n if (this.options.find((opt) => opt.code === option.code) === null) {\n this.options.addOption(option.code, option);\n }\n }\n\n /**\n * Getting the type of choice filter. For instance checkbox, radiobutton, combobox.\n */\n get choicetype():\n | \"checkbox\"\n | \"radiobutton\"\n | \"combobox\"\n | \"list\"\n | \"listview\"\n | \"table\"\n | \"longlist\"\n | \"toggle\" {\n return (\n [\n \"checkbox\",\n \"radiobutton\",\n \"combobox\",\n \"list\",\n \"listview\",\n \"table\",\n \"longlist\",\n \"toggle\",\n ].find((hint) => this.layouthint.has(hint)) || \"checkbox\"\n );\n }\n\n /**\n * Can multiple options be selected\n */\n get isMultiple(): boolean {\n return this.contributions.multiplechoice || this.choicetype === \"checkbox\";\n }\n\n /**\n * Check if options need to be rendered as tree\n */\n get isTree(): boolean {\n return (\n has(this.contributions, \"options\") &&\n this.contributions.options.some((option) => has(option, \"children\"))\n );\n }\n\n /**\n * Reset choice attribute to unselected list\n */\n reset() {\n this.options.deselectAll();\n }\n\n /**\n */\n mergeAttribute(oldAttribute: AttributeType) {\n // when attribute is readonly, don't merge the options no modifications necessary\n if (!this.readonly && oldAttribute instanceof ChoiceAttributeModel) {\n this.concept = oldAttribute.concept;\n this.options.mergeOptions(oldAttribute.options, this.type === \"lookup\");\n this.options.deselectAll();\n\n if (oldAttribute.isValid && oldAttribute.inputvalue !== null) {\n this.update(oldAttribute.inputvalue);\n }\n }\n }\n\n /**\n * Update attribute by name and value\n */\n update(value: any): ChoiceAttributeModel {\n if (this.readonly) {\n return this;\n }\n\n this.updateLastModification();\n\n let values;\n\n if (Array.isArray(value)) {\n values = value;\n } else if (typeof value === \"string\" && this.isMultiple) {\n values = value.split(\",\");\n } else {\n values = [value];\n }\n values.forEach((val) => {\n if (val instanceof ChoiceAttributeOptionModel) {\n if (!this.options.some((option) => option.equals(val))) {\n this.options.add(val);\n }\n\n this.toggleOption(val.code);\n } else if (\n typeof val === \"string\" &&\n this.options.some((option) => option.code.toString() === val)\n ) {\n this.toggleOption(val);\n }\n });\n\n return this;\n }\n\n /**\n */\n set hasContentConfiguration(hasContentConfiguration: boolean) {\n this._hasContentConfiguration =\n this.contentConfiguration !== null || hasContentConfiguration;\n }\n\n /**\n */\n get hasContentConfiguration(): boolean {\n return this._hasContentConfiguration;\n }\n\n /**\n * Get content configuration configured on the attribute.\n * Only applicable for taxonomy element and knowledge codemaps,\n * content configuration for instrument questions is available on the form object\n */\n get contentConfiguration(): ContentConfigurationElements | null {\n if (\n !this.contributions.content ||\n !this.contributions.content.optionElements\n ) {\n return null;\n }\n\n // Add RENDER_SECTION_LABEL to all content configuration to make sure the label of a section is always rendered on taxonomy and knowlege codemaps\n const optionElementConfig = this.contributions.content.optionElements.map(\n (optionElement) => {\n if (\"contentElement\" in optionElement) {\n return {\n contentElement: {\n ...optionElement.contentElement,\n layouthint: [RENDER_SECTION_LABEL],\n },\n };\n }\n\n return optionElement;\n }\n );\n\n return new ContentConfigurationElements(optionElementConfig);\n }\n\n /**\n * Get placeholder text\n */\n get placeholder(): string {\n return this.getContribution(\"placeholder\", \"\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, layouthint, message, properties } = error;\n\n const ANSWER_OPTION_KEY = \"answer-option-key\";\n\n if (properties && has(properties, ANSWER_OPTION_KEY)) {\n const optionKey = properties[ANSWER_OPTION_KEY];\n const foundOption = this.options.find(\n (option) => option.code === optionKey\n );\n if (foundOption) {\n properties[ANSWER_OPTION_KEY] = foundOption.getContentConfiguredLabel(\n this.contentConfiguration\n );\n }\n }\n\n this._errorCollection.addServerError(id, layouthint, message, properties);\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"lookup\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAIA;;AAKA;AACA;AACA;AACe,MAAMA,oBAAN,SAAmCC,uBAAnC,CAAkD;EAK/D;AACF;AACA;EACEC,WAAW,CAACC,SAAD,EAAoBC,sBAApB,EAAoD;IAC7D,MAAMD,SAAN,EAAiBC,sBAAjB;IAD6D;IAAA;IAAA;IAG7D,KAAKC,cAAL,GAAsB,KAAKC,OAAL,CAAa,eAAb,EAA8BC,sBAAA,CAASC,GAAT,EAA9B,CAAtB;IACA,KAAKC,QAAL,GAAgBC,wCAAA,CAAgCC,MAAhC,CACdR,SADc,EAEdC,sBAFc,EAGd,KAAKQ,aAHS,CAAhB;;IAMA,IAAI,KAAKC,UAAL,CAAgBC,GAAhB,CAAoBC,yBAApB,CAAJ,EAAuC;MACrC,KAAKN,QAAL,CAAcO,WAAd,GAA4B,IAA5B;IACD;EACF;EAED;AACF;;;EAC0B,OAAjBC,iBAAiB,CAACC,aAAD,EAAiC;IACvD,OACEA,aAAa,CAACC,IAAd,KAAuB,WAAvB,IACAD,aAAa,CAACC,IAAd,KAAuB,SADvB,KAECD,aAAa,CAACC,IAAd,KAAuB,QAAvB,IACCD,aAAa,CAACC,IAAd,KAAuB,OADxB,IAEC,IAAAL,YAAA,EAAII,aAAJ,EAAmB,YAAnB,CAFD,IAGC,IAAAJ,YAAA,EAAII,aAAJ,EAAmB,SAAnB,CALF,CADF;EAQD;EAED;AACF;;;EACU,IAAJC,IAAI,GAAW;IACjB,MAAMC,UAAU,GAA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AAGD,aAAa,CAACC,cADH;YAEdnF,UAAU,EAAE,CAACoF,iCAAD;UAFE;QADX,CAAP;MAMD;;MAED,OAAOF,aAAP;IACD,CAZyB,CAA5B;IAeA,OAAO,IAAIG,qCAAJ,CAAiCJ,mBAAjC,CAAP;EACD;EAED;AACF;AACA;;;EACiB,IAAXK,WAAW,GAAW;IACxB,OAAO,KAAK9E,eAAL,CAAqB,aAArB,EAAoC,EAApC,CAAP;EACD;EAED;AACF;AACA;;;EACE+E,cAAc,CAACC,KAAD,EAAyB;IACrC,MAAM;MAAEC,EAAF;MAAMzF,UAAN;MAAkB0F,OAAlB;MAA2BC;IAA3B,IAA0CH,KAAhD;IAEA,MAAMI,iBAAiB,GAAG,mBAA1B;;IAEA,IAAID,UAAU,IAAI,IAAA1F,YAAA,EAAI0F,UAAJ,EAAgBC,iBAAhB,CAAlB,EAAsD;MAAA;;MACpD,MAAMC,SAAS,GAAGF,UAAU,CAACC,iBAAD,CAA5B;MACA,MAAME,WAAW,GAAG,oCAAK5E,OAAL,kBACjBe,MAAD,IAAYA,MAAM,CAACC,IAAP,KAAgB2D,SADV,CAApB;;MAGA,IAAIC,WAAJ,EAAiB;QACfH,UAAU,CAACC,iBAAD,CAAV,GAAgCE,WAAW,CAACC,yBAAZ,CAC9B,KAAKjB,oBADyB,CAAhC;MAGD;IACF;;IAED,KAAKkB,gBAAL,CAAsBT,cAAtB,CAAqCE,EAArC,EAAyCzF,UAAzC,EAAqD0F,OAArD,EAA8DC,UAA9D;EACD;EAED;AACF;;;EACmB,IAAbM,aAAa,GAAkC;IACjD,IAAI,KAAK3F,IAAL,KAAc,QAAlB,EAA4B;MAC1B,OAAO4F,0BAAA,CAAgBC,KAAvB;IACD;;IAED,OAAOD,0BAAA,CAAgBE,MAAvB;EACD;;AApZ8D"}
@@ -466,6 +466,7 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
466
466
  addServerError(error) {
467
467
  const {
468
468
  id,
469
+ layouthint,
469
470
  message,
470
471
  properties
471
472
  } = error;
@@ -474,7 +475,7 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
474
475
  properties.format = this.formatLabel;
475
476
  }
476
477
 
477
- this._errorCollection.addServerError(id, message, properties);
478
+ this._errorCollection.addServerError(id, layouthint, message, properties);
478
479
  }
479
480
  /**
480
481
  */
@@ -425,12 +425,12 @@ class DatetimeAttributeModel extends StringAttributeModel {
425
425
  * Registers an error that was received from a server response
426
426
  */
427
427
  addServerError(error: FormErrorAnchor) {
428
- const { id, message, properties } = error;
428
+ const { id, layouthint, message, properties } = error;
429
429
  if (properties && has(properties, "format") && this.formatLabel) {
430
430
  properties.format = this.formatLabel;
431
431
  }
432
432
 
433
- this._errorCollection.addServerError(id, message, properties);
433
+ this._errorCollection.addServerError(id, layouthint, message, properties);
434
434
  }
435
435
 
436
436
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"DatetimeAttributeModel.js","names":["PRODUCT_DEFAULT_DATE_FORMAT","DatetimeAttributeModel","StringAttributeModel","constructor","attribute","attributeContributions","updateInitValue","isApplicableModel","contributions","type","formatUtil","TimeUtil","TimestampUtil","DateTimeUtil","DateUtil","getInitValue","value","data","length","split","hasTime","getTimeValue","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","toFormat","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","toISO","format","convertFormat","operator","hasDate","formatLabel","dateInputFormat","ignoreFormatSetting","layouthint","has","IGNORE_FORMAT_SETTING","dateInputFormatSetting","getSetting","dateFormat","replace","dateReadonlyFormat","readonlyFormatSetting","placeholder","_placeholder","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","ISO_DATE_FORMAT","dateTimeReadonlyFormat","readonlyvalue","mindate","maxdate","addServerError","error","id","message","properties","_errorCollection","getFormatConstraint","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","addConstraints","constraints","ConstraintCollection","add","DateBoundaryConstraint","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport { ATTRIBUTE_WIDTH, ISO_DATE_FORMAT } from \"../../constants\";\nimport { getSetting } from \"../../constants/Settings\";\nimport { IGNORE_FORMAT_SETTING } from \"../../constants/LayoutHints\";\n\nimport type { FormErrorAnchor, IConstraintModel } from \"../types\";\n\n// date format of default\nconst PRODUCT_DEFAULT_DATE_FORMAT = \"dd-MM-yyyy\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n /**\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = value.split(\".\")[0];\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\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 getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get operator(): string {\n return this.getContribution(\"operator\", \"\");\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormat(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n // setting for date input\n const ignoreFormatSetting = this.layouthint.has(IGNORE_FORMAT_SETTING);\n if (!ignoreFormatSetting) {\n const dateInputFormatSetting = getSetting(\"DATE_INPUT_FORMAT\", \"\");\n if (dateInputFormatSetting) {\n return dateInputFormatSetting;\n }\n }\n\n let format = this.format;\n\n let dateFormat = this.hasTime\n ? format.replace(this.timeInputFormat, \"\").trim()\n : format;\n\n return dateFormat;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n let format = this.format;\n\n let dateFormat = this.hasTime\n ? format.replace(this.timeInputFormat, \"\").trim()\n : format;\n\n const readonlyFormatSetting = getSetting(\"DATE_READONLY_FORMAT\", \"\");\n\n if (dateFormat === PRODUCT_DEFAULT_DATE_FORMAT && readonlyFormatSetting) {\n dateFormat = readonlyFormatSetting;\n }\n\n return dateFormat;\n }\n\n /**\n * return attribute placeholder or, if DATE_INPUT_FORMAT setting is used, lowercased setting, otherwise return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const dateInputFormatSetting = getSetting(\"DATE_INPUT_FORMAT\", \"\");\n\n if (dateInputFormatSetting) {\n return dateInputFormatSetting.toLowerCase();\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n return `${timeFormat} a`;\n }\n return timeFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n // format value in readonly rendering\n /**\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n if (this.hasDate && this.hasTime) {\n const dateTimeReadonlyFormat = `${this.dateReadonlyFormat} ${this.timeReadonlyFormat}`;\n return this.formatUtil.toFormat(value, dateTimeReadonlyFormat);\n }\n\n if (this.type === \"date\") {\n return this.formatUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties } = error;\n if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat\n )\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}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ACE,GAAZ,CACE,IAAIC,+BAAJ,CACE,KAAK/E,IADP,EAEE,KAAK+D,OAFP,EAGE,KAAKC,OAHP,EAIE,KAAKtC,WAJP,CADF;IAQD;;IAED,OAAOkD,WAAP;EACD;EAED;AACF;;;EACmB,IAAbI,aAAa,GAAkC;IACjD,IAAI,KAAKhF,IAAL,KAAc,MAAd,IAAwB,KAAKA,IAAL,KAAc,MAA1C,EAAkD;MAChD,OAAOiF,0BAAA,CAAgBC,KAAvB;IACD;;IAED,OAAOD,0BAAA,CAAgBE,MAAvB;EACD;;AA3cuD;;eA8c3C3F,sB"}
1
+ {"version":3,"file":"DatetimeAttributeModel.js","names":["PRODUCT_DEFAULT_DATE_FORMAT","DatetimeAttributeModel","StringAttributeModel","constructor","attribute","attributeContributions","updateInitValue","isApplicableModel","contributions","type","formatUtil","TimeUtil","TimestampUtil","DateTimeUtil","DateUtil","getInitValue","value","data","length","split","hasTime","getTimeValue","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","toFormat","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","toISO","format","convertFormat","operator","hasDate","formatLabel","dateInputFormat","ignoreFormatSetting","layouthint","has","IGNORE_FORMAT_SETTING","dateInputFormatSetting","getSetting","dateFormat","replace","dateReadonlyFormat","readonlyFormatSetting","placeholder","_placeholder","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","ISO_DATE_FORMAT","dateTimeReadonlyFormat","readonlyvalue","mindate","maxdate","addServerError","error","id","message","properties","_errorCollection","getFormatConstraint","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","addConstraints","constraints","ConstraintCollection","add","DateBoundaryConstraint","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport { ATTRIBUTE_WIDTH, ISO_DATE_FORMAT } from \"../../constants\";\nimport { getSetting } from \"../../constants/Settings\";\nimport { IGNORE_FORMAT_SETTING } from \"../../constants/LayoutHints\";\n\nimport type { FormErrorAnchor, IConstraintModel } from \"../types\";\n\n// date format of default\nconst PRODUCT_DEFAULT_DATE_FORMAT = \"dd-MM-yyyy\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n /**\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = value.split(\".\")[0];\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\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 getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get operator(): string {\n return this.getContribution(\"operator\", \"\");\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormat(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n // setting for date input\n const ignoreFormatSetting = this.layouthint.has(IGNORE_FORMAT_SETTING);\n if (!ignoreFormatSetting) {\n const dateInputFormatSetting = getSetting(\"DATE_INPUT_FORMAT\", \"\");\n if (dateInputFormatSetting) {\n return dateInputFormatSetting;\n }\n }\n\n let format = this.format;\n\n let dateFormat = this.hasTime\n ? format.replace(this.timeInputFormat, \"\").trim()\n : format;\n\n return dateFormat;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n let format = this.format;\n\n let dateFormat = this.hasTime\n ? format.replace(this.timeInputFormat, \"\").trim()\n : format;\n\n const readonlyFormatSetting = getSetting(\"DATE_READONLY_FORMAT\", \"\");\n\n if (dateFormat === PRODUCT_DEFAULT_DATE_FORMAT && readonlyFormatSetting) {\n dateFormat = readonlyFormatSetting;\n }\n\n return dateFormat;\n }\n\n /**\n * return attribute placeholder or, if DATE_INPUT_FORMAT setting is used, lowercased setting, otherwise return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const dateInputFormatSetting = getSetting(\"DATE_INPUT_FORMAT\", \"\");\n\n if (dateInputFormatSetting) {\n return dateInputFormatSetting.toLowerCase();\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n return `${timeFormat} a`;\n }\n return timeFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n // format value in readonly rendering\n /**\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n if (this.hasDate && this.hasTime) {\n const dateTimeReadonlyFormat = `${this.dateReadonlyFormat} ${this.timeReadonlyFormat}`;\n return this.formatUtil.toFormat(value, dateTimeReadonlyFormat);\n }\n\n if (this.type === \"date\") {\n return this.formatUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, layouthint, message, properties } = error;\n if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, layouthint, message, properties);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat\n )\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;;;;;;;;;;;;;;AACA;;AAEA;;AAOA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAIA;AACA,MAAMA,2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WAJP,CADF;IAQD;;IAED,OAAOkD,WAAP;EACD;EAED;AACF;;;EACmB,IAAbI,aAAa,GAAkC;IACjD,IAAI,KAAKhF,IAAL,KAAc,MAAd,IAAwB,KAAKA,IAAL,KAAc,MAA1C,EAAkD;MAChD,OAAOiF,0BAAA,CAAgBC,KAAvB;IACD;;IAED,OAAOD,0BAAA,CAAgBE,MAAvB;EACD;;AA3cuD;;eA8c3C3F,sB"}
@@ -19,6 +19,8 @@ var _BaseCollection = _interopRequireDefault(require("../base/BaseCollection"));
19
19
 
20
20
  var _ErrorModel = _interopRequireDefault(require("./ErrorModel"));
21
21
 
22
+ var _LayoutHintCollection = _interopRequireDefault(require("../layouthint/LayoutHintCollection"));
23
+
22
24
  /**
23
25
  * Form Objects
24
26
  */
@@ -59,14 +61,14 @@ class ErrorCollection extends _BaseCollection.default {
59
61
  */
60
62
 
61
63
 
62
- addError(id, defaultMessage, parameters) {
64
+ addError(id, layouthint, defaultMessage, parameters) {
63
65
  const itemIdx = this.findById(id);
64
66
 
65
67
  if (itemIdx > -1) {
66
68
  this.removeByIndex(itemIdx);
67
69
  }
68
70
 
69
- this.add(new _ErrorModel.default(id, defaultMessage, parameters));
71
+ this.add(new _ErrorModel.default(id, defaultMessage, parameters, false, layouthint));
70
72
  }
71
73
  /**
72
74
  */
@@ -81,11 +83,11 @@ class ErrorCollection extends _BaseCollection.default {
81
83
  */
82
84
 
83
85
 
84
- addServerError(id, defaultMessage, parameters) {
86
+ addServerError(id, layouthint, defaultMessage, parameters) {
85
87
  if (parameters) {
86
- this.addError(id, defaultMessage, parameters);
88
+ this.addError(id, layouthint, defaultMessage, parameters);
87
89
  } else {
88
- this.addError(id, defaultMessage);
90
+ this.addError(id, layouthint, defaultMessage);
89
91
  }
90
92
  }
91
93
  /**
@@ -4,6 +4,7 @@ import ErrorModel from "./ErrorModel";
4
4
 
5
5
  import type { MessageParameters } from "../../i18n/types";
6
6
  import type { IConstraintModel } from "../types";
7
+ import LayoutHintCollection from "../layouthint/LayoutHintCollection";
7
8
 
8
9
  /**
9
10
  * Form Objects
@@ -42,6 +43,7 @@ export default class ErrorCollection extends BaseCollection<ErrorModel> {
42
43
  */
43
44
  addError(
44
45
  id: string,
46
+ layouthint?: LayoutHintCollection,
45
47
  defaultMessage?: string,
46
48
  parameters?: MessageParameters
47
49
  ) {
@@ -51,7 +53,7 @@ export default class ErrorCollection extends BaseCollection<ErrorModel> {
51
53
  this.removeByIndex(itemIdx);
52
54
  }
53
55
 
54
- this.add(new ErrorModel(id, defaultMessage, parameters));
56
+ this.add(new ErrorModel(id, defaultMessage, parameters, false, layouthint));
55
57
  }
56
58
 
57
59
  /**
@@ -66,13 +68,14 @@ export default class ErrorCollection extends BaseCollection<ErrorModel> {
66
68
  */
67
69
  addServerError(
68
70
  id: string,
71
+ layouthint?: LayoutHintCollection,
69
72
  defaultMessage?: string,
70
73
  parameters?: MessageParameters
71
74
  ) {
72
75
  if (parameters) {
73
- this.addError(id, defaultMessage, parameters);
76
+ this.addError(id, layouthint, defaultMessage, parameters);
74
77
  } else {
75
- this.addError(id, defaultMessage);
78
+ this.addError(id, layouthint, defaultMessage);
76
79
  }
77
80
  }
78
81
 
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorCollection.js","names":["ErrorCollection","BaseCollection","constructor","type","errorCollection","_type","collection","serverErrors","error","isClientConstraint","findById","id","item","addError","defaultMessage","parameters","itemIdx","removeByIndex","add","ErrorModel","removeError","addServerError","removeServerError","removeServerErrors","forEach","addErrors","errors","addConstraints","constraints","constraint","hasMandatoryError","some","isMandatoryConstraint"],"sources":["../../../src/models/error/ErrorCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport ErrorModel from \"./ErrorModel\";\n\nimport type { MessageParameters } from \"../../i18n/types\";\nimport type { IConstraintModel } from \"../types\";\n\n/**\n * Form Objects\n */\nexport default class ErrorCollection extends BaseCollection<ErrorModel> {\n _type: string;\n\n /**\n * constructor\n */\n constructor(type: string, errorCollection?: ErrorCollection) {\n super();\n\n this._type = type;\n this.collection = [];\n\n if (errorCollection) {\n this.collection = [...errorCollection.collection];\n }\n }\n\n /**\n */\n get serverErrors(): Array<ErrorModel> {\n return this.collection.filter((error) => !error.isClientConstraint);\n }\n\n /**\n */\n findById(id: string): number {\n return this.collection.findIndex((item) => item.id === id);\n }\n\n /**\n * Add an error to the collection\n */\n addError(\n id: string,\n defaultMessage?: string,\n parameters?: MessageParameters\n ) {\n const itemIdx = this.findById(id);\n\n if (itemIdx > -1) {\n this.removeByIndex(itemIdx);\n }\n\n this.add(new ErrorModel(id, defaultMessage, parameters));\n }\n\n /**\n */\n removeError(id: string) {\n const itemIdx = this.findById(id);\n this.removeByIndex(itemIdx);\n }\n\n /**\n * Add a server error to the collection\n */\n addServerError(\n id: string,\n defaultMessage?: string,\n parameters?: MessageParameters\n ) {\n if (parameters) {\n this.addError(id, defaultMessage, parameters);\n } else {\n this.addError(id, defaultMessage);\n }\n }\n\n /**\n */\n removeServerError(id: string) {\n this.removeError(id);\n }\n\n /**\n */\n removeServerErrors() {\n this.serverErrors.forEach((error) => {\n this.removeError(error.id);\n });\n }\n\n /**\n */\n addErrors(errors: Array<ErrorModel>) {\n this.collection = [...this.collection, ...errors];\n }\n\n /**\n * Add constraints to error collection\n */\n addConstraints(constraints: Array<IConstraintModel>) {\n this.collection = [\n ...this.collection,\n ...constraints.map(\n (constraint) =>\n new ErrorModel(\n constraint.id,\n constraint.defaultMessage,\n constraint.parameters,\n true\n )\n ),\n ];\n }\n\n /**\n * Indicates if a mandatory constraint is available and if it is in error.\n * Rationale: When a mandatory constraint is in error other constraint probably don't mather because there is no value to check\n */\n hasMandatoryError(): boolean {\n return this.collection.some((error) => error.isMandatoryConstraint);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AACA;;AAKA;AACA;AACA;AACe,MAAMA,eAAN,SAA8BC,uBAA9B,CAAyD;EAGtE;AACF;AACA;EACEC,WAAW,CAACC,IAAD,EAAeC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iBT,EAAjB;EACD;EAED;AACF;;;EACEY,kBAAkB,GAAG;IACnB,KAAKhB,YAAL,CAAkBiB,OAAlB,CAA2BhB,KAAD,IAAW;MACnC,KAAKY,WAAL,CAAiBZ,KAAK,CAACG,EAAvB;IACD,CAFD;EAGD;EAED;AACF;;;EACEc,SAAS,CAACC,MAAD,EAA4B;IACnC,KAAKpB,UAAL,GAAkB,CAAC,GAAG,KAAKA,UAAT,EAAqB,GAAGoB,MAAxB,CAAlB;EACD;EAED;AACF;AACA;;;EACEC,cAAc,CAACC,WAAD,EAAuC;IACnD,KAAKtB,UAAL,GAAkB,CAChB,GAAG,KAAKA,UADQ,EAEhB,GAAG,kBAAAsB,WAAW,MAAX,CAAAA,WAAW,EACXC,UAAD,IACE,IAAIV,mBAAJ,CACEU,UAAU,CAAClB,EADb,EAEEkB,UAAU,CAACf,cAFb,EAGEe,UAAU,CAACd,UAHb,EAIE,IAJF,CAFU,CAFE,CAAlB;EAYD;EAED;AACF;AACA;AACA;;;EACEe,iBAAiB,GAAY;IAC3B,OAAO,KAAKxB,UAAL,CAAgByB,IAAhB,CAAsBvB,KAAD,IAAWA,KAAK,CAACwB,qBAAtC,CAAP;EACD;;AAhHqE"}
1
+ {"version":3,"file":"ErrorCollection.js","names":["ErrorCollection","BaseCollection","constructor","type","errorCollection","_type","collection","serverErrors","error","isClientConstraint","findById","id","item","addError","layouthint","defaultMessage","parameters","itemIdx","removeByIndex","add","ErrorModel","removeError","addServerError","removeServerError","removeServerErrors","forEach","addErrors","errors","addConstraints","constraints","constraint","hasMandatoryError","some","isMandatoryConstraint"],"sources":["../../../src/models/error/ErrorCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport ErrorModel from \"./ErrorModel\";\n\nimport type { MessageParameters } from \"../../i18n/types\";\nimport type { IConstraintModel } from \"../types\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\n\n/**\n * Form Objects\n */\nexport default class ErrorCollection extends BaseCollection<ErrorModel> {\n _type: string;\n\n /**\n * constructor\n */\n constructor(type: string, errorCollection?: ErrorCollection) {\n super();\n\n this._type = type;\n this.collection = [];\n\n if (errorCollection) {\n this.collection = [...errorCollection.collection];\n }\n }\n\n /**\n */\n get serverErrors(): Array<ErrorModel> {\n return this.collection.filter((error) => !error.isClientConstraint);\n }\n\n /**\n */\n findById(id: string): number {\n return this.collection.findIndex((item) => item.id === id);\n }\n\n /**\n * Add an error to the collection\n */\n addError(\n id: string,\n layouthint?: LayoutHintCollection,\n defaultMessage?: string,\n parameters?: MessageParameters\n ) {\n const itemIdx = this.findById(id);\n\n if (itemIdx > -1) {\n this.removeByIndex(itemIdx);\n }\n\n this.add(new ErrorModel(id, defaultMessage, parameters, false, layouthint));\n }\n\n /**\n */\n removeError(id: string) {\n const itemIdx = this.findById(id);\n this.removeByIndex(itemIdx);\n }\n\n /**\n * Add a server error to the collection\n */\n addServerError(\n id: string,\n layouthint?: LayoutHintCollection,\n defaultMessage?: string,\n parameters?: MessageParameters\n ) {\n if (parameters) {\n this.addError(id, layouthint, defaultMessage, parameters);\n } else {\n this.addError(id, layouthint, defaultMessage);\n }\n }\n\n /**\n */\n removeServerError(id: string) {\n this.removeError(id);\n }\n\n /**\n */\n removeServerErrors() {\n this.serverErrors.forEach((error) => {\n this.removeError(error.id);\n });\n }\n\n /**\n */\n addErrors(errors: Array<ErrorModel>) {\n this.collection = [...this.collection, ...errors];\n }\n\n /**\n * Add constraints to error collection\n */\n addConstraints(constraints: Array<IConstraintModel>) {\n this.collection = [\n ...this.collection,\n ...constraints.map(\n (constraint) =>\n new ErrorModel(\n constraint.id,\n constraint.defaultMessage,\n constraint.parameters,\n true\n )\n ),\n ];\n }\n\n /**\n * Indicates if a mandatory constraint is available and if it is in error.\n * Rationale: When a mandatory constraint is in error other constraint probably don't mather because there is no value to check\n */\n hasMandatoryError(): boolean {\n return this.collection.some((error) => error.isMandatoryConstraint);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;A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Ad,EAAkBG,UAAlB,EAA8BC,cAA9B,EAA8CC,UAA9C;IACD,CAFD,MAEO;MACL,KAAKH,QAAL,CAAcF,EAAd,EAAkBG,UAAlB,EAA8BC,cAA9B;IACD;EACF;EAED;AACF;;;EACEQ,iBAAiB,CAACZ,EAAD,EAAa;IAC5B,KAAKU,WAAL,CAAiBV,EAAjB;EACD;EAED;AACF;;;EACEa,kBAAkB,GAAG;IACnB,KAAKjB,YAAL,CAAkBkB,OAAlB,CAA2BjB,KAAD,IAAW;MACnC,KAAKa,WAAL,CAAiBb,KAAK,CAACG,EAAvB;IACD,CAFD;EAGD;EAED;AACF;;;EACEe,SAAS,CAACC,MAAD,EAA4B;IACnC,KAAKrB,UAAL,GAAkB,CAAC,GAAG,KAAKA,UAAT,EAAqB,GAAGqB,MAAxB,CAAlB;EACD;EAED;AACF;AACA;;;EACEC,cAAc,CAACC,WAAD,EAAuC;IACnD,KAAKvB,UAAL,GAAkB,CAChB,GAAG,KAAKA,UADQ,EAEhB,GAAG,kBAAAuB,WAAW,MAAX,CAAAA,WAAW,EACXC,UAAD,IACE,IAAIV,mBAAJ,CACEU,UAAU,CAACnB,EADb,EAEEmB,UAAU,CAACf,cAFb,EAGEe,UAAU,CAACd,UAHb,EAIE,IAJF,CAFU,CAFE,CAAlB;EAYD;EAED;AACF;AACA;AACA;;;EACEe,iBAAiB,GAAY;IAC3B,OAAO,KAAKzB,UAAL,CAAgB0B,IAAhB,CAAsBxB,KAAD,IAAWA,KAAK,CAACyB,qBAAtC,CAAP;EACD;;AAlHqE"}
@@ -20,6 +20,7 @@ class ErrorModel {
20
20
  */
21
21
  constructor(id, defaultMessage, parameters) {
22
22
  let isClientConstraint = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
23
+ let layouthint = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new _LayoutHintCollection.default();
23
24
  (0, _defineProperty2.default)(this, "_id", void 0);
24
25
  (0, _defineProperty2.default)(this, "_defaultMessage", void 0);
25
26
  (0, _defineProperty2.default)(this, "_parameters", void 0);
@@ -29,7 +30,7 @@ class ErrorModel {
29
30
  this._parameters = parameters;
30
31
  this._defaultMessage = defaultMessage;
31
32
  this._isClientConstraint = isClientConstraint;
32
- this._layouthint = new _LayoutHintCollection.default();
33
+ this._layouthint = Array.isArray(layouthint) ? new _LayoutHintCollection.default(layouthint) : layouthint;
33
34
  }
34
35
  /**
35
36
  * Get id of error
@@ -19,13 +19,16 @@ class ErrorModel {
19
19
  id: string,
20
20
  defaultMessage: ?string,
21
21
  parameters: ?MessageParameters,
22
- isClientConstraint: boolean = false
22
+ isClientConstraint: boolean = false,
23
+ layouthint: LayoutHintCollection = new LayoutHintCollection()
23
24
  ) {
24
25
  this._id = id;
25
26
  this._parameters = parameters;
26
27
  this._defaultMessage = defaultMessage;
27
28
  this._isClientConstraint = isClientConstraint;
28
- this._layouthint = new LayoutHintCollection();
29
+ this._layouthint = Array.isArray(layouthint)
30
+ ? new LayoutHintCollection(layouthint)
31
+ : layouthint;
29
32
  }
30
33
 
31
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorModel.js","names":["ErrorModel","constructor","id","defaultMessage","parameters","isClientConstraint","_id","_parameters","_defaultMessage","_isClientConstraint","_layouthint","LayoutHintCollection","layouthint","isMandatoryConstraint"],"sources":["../../../src/models/error/ErrorModel.js"],"sourcesContent":["// @flow\nimport type { MessageParameters } from \"../../i18n/types\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\n\n/**\n * Wrapper around an error message / object\n */\nclass ErrorModel {\n _id: string;\n _defaultMessage: ?string;\n _parameters: ?MessageParameters;\n _isClientConstraint: boolean;\n _layouthint: LayoutHintCollection;\n\n /**\n * Contruct\n */\n constructor(\n id: string,\n defaultMessage: ?string,\n parameters: ?MessageParameters,\n isClientConstraint: boolean = false\n ) {\n this._id = id;\n this._parameters = parameters;\n this._defaultMessage = defaultMessage;\n this._isClientConstraint = isClientConstraint;\n this._layouthint = new LayoutHintCollection();\n }\n\n /**\n * Get id of error\n */\n get id(): string {\n return this._id;\n }\n\n /**\n */\n get defaultMessage(): ?string {\n return this._defaultMessage;\n }\n\n /**\n */\n get parameters(): ?MessageParameters {\n return this._parameters;\n }\n\n /**\n */\n get isClientConstraint(): boolean {\n return this._isClientConstraint || false;\n }\n\n /**\n */\n get layouthint(): LayoutHintCollection {\n return this._layouthint;\n }\n\n /**\n */\n get isMandatoryConstraint(): boolean {\n return this.id === \"Constraint.Mandatory\";\n }\n}\n\nexport default ErrorModel;\n"],"mappings":";;;;;;;;;;;AAEA;;AAEA;AACA;AACA;AACA,MAAMA,UAAN,CAAiB;EAOf;AACF;AACA;EACEC,WAAW,CACTC,EADS,EAETC,cAFS,EAGTC,UAHS,EAKT;IAAA,IADAC,kBACA,uEAD8B,KAC9B;IAAA;IAAA;IAAA;IAAA;IAAA;IACA,KAAKC,GAAL,GAAWJ,EAAX;IACA,KAAKK,WAAL,GAAmBH,UAAnB;IACA,KAAKI,eAAL,GAAuBL,cAAvB;IACA,KAAKM,mBAAL,GAA2BJ,kBAA3B;IACA,KAAKK,WAAL,GAAmB,IAAIC,6BAAJ,EAAnB;EACD;EAED;AACF;AACA;;;EACQ,IAAFT,EAAE,GAAW;IACf,OAAO,KAAKI,GAAZ;EACD;EAED;AACF;;;EACoB,IAAdH,cAAc,GAAY;IAC5B,OAAO,KAAKK,eAAZ;EACD;EAED;AACF;;;EACgB,IAAVJ,UAAU,GAAuB;IACnC,OAAO,KAAKG,WAAZ;EACD;EAED;AACF;;;EACwB,IAAlBF,kBAAkB,GAAY;IAChC,OAAO,KAAKI,mBAAL,IAA4B,KAAnC;EACD;EAED;AACF;;;EACgB,IAAVG,UAAU,GAAyB;IACrC,OAAO,KAAKF,WAAZ;EACD;EAED;AACF;;;EAC2B,IAArBG,qBAAqB,GAAY;IACnC,OAAO,KAAKX,EAAL,KAAY,sBAAnB;EACD;;AA1Dc;;eA6DFF,U"}
1
+ {"version":3,"file":"ErrorModel.js","names":["ErrorModel","constructor","id","defaultMessage","parameters","isClientConstraint","layouthint","LayoutHintCollection","_id","_parameters","_defaultMessage","_isClientConstraint","_layouthint","Array","isArray","isMandatoryConstraint"],"sources":["../../../src/models/error/ErrorModel.js"],"sourcesContent":["// @flow\nimport type { MessageParameters } from \"../../i18n/types\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\n\n/**\n * Wrapper around an error message / object\n */\nclass ErrorModel {\n _id: string;\n _defaultMessage: ?string;\n _parameters: ?MessageParameters;\n _isClientConstraint: boolean;\n _layouthint: LayoutHintCollection;\n\n /**\n * Contruct\n */\n constructor(\n id: string,\n defaultMessage: ?string,\n parameters: ?MessageParameters,\n isClientConstraint: boolean = false,\n layouthint: LayoutHintCollection = new LayoutHintCollection()\n ) {\n this._id = id;\n this._parameters = parameters;\n this._defaultMessage = defaultMessage;\n this._isClientConstraint = isClientConstraint;\n this._layouthint = Array.isArray(layouthint)\n ? new LayoutHintCollection(layouthint)\n : layouthint;\n }\n\n /**\n * Get id of error\n */\n get id(): string {\n return this._id;\n }\n\n /**\n */\n get defaultMessage(): ?string {\n return this._defaultMessage;\n }\n\n /**\n */\n get parameters(): ?MessageParameters {\n return this._parameters;\n }\n\n /**\n */\n get isClientConstraint(): boolean {\n return this._isClientConstraint || false;\n }\n\n /**\n */\n get layouthint(): LayoutHintCollection {\n return this._layouthint;\n }\n\n /**\n */\n get isMandatoryConstraint(): boolean {\n return this.id === \"Constraint.Mandatory\";\n }\n}\n\nexport default ErrorModel;\n"],"mappings":";;;;;;;;;;;AAEA;;AAEA;AACA;AACA;AACA,MAAMA,UAAN,CAAiB;EAOf;AACF;AACA;EACEC,WAAW,CACTC,EADS,EAETC,cAFS,EAGTC,UAHS,EAMT;IAAA,IAFAC,kBAEA,uEAF8B,KAE9B;IAAA,IADAC,UACA,uEADmC,IAAIC,6BAAJ,EACnC;IAAA;IAAA;IAAA;IAAA;IAAA;IACA,KAAKC,GAAL,GAAWN,EAAX;IACA,KAAKO,WAAL,GAAmBL,UAAnB;IACA,KAAKM,eAAL,GAAuBP,cAAvB;IACA,KAAKQ,mBAAL,GAA2BN,kBAA3B;IACA,KAAKO,WAAL,GAAmBC,KAAK,CAACC,OAAN,CAAcR,UAAd,IACf,IAAIC,6BAAJ,CAAyBD,UAAzB,CADe,GAEfA,UAFJ;EAGD;EAED;AACF;AACA;;;EACQ,IAAFJ,EAAE,GAAW;IACf,OAAO,KAAKM,GAAZ;EACD;EAED;AACF;;;EACoB,IAAdL,cAAc,GAAY;IAC5B,OAAO,KAAKO,eAAZ;EACD;EAED;AACF;;;EACgB,IAAVN,UAAU,GAAuB;IACnC,OAAO,KAAKK,WAAZ;EACD;EAED;AACF;;;EACwB,IAAlBJ,kBAAkB,GAAY;IAChC,OAAO,KAAKM,mBAAL,IAA4B,KAAnC;EACD;EAED;AACF;;;EACgB,IAAVL,UAAU,GAAyB;IACrC,OAAO,KAAKM,WAAZ;EACD;EAED;AACF;;;EAC2B,IAArBG,qBAAqB,GAAY;IACnC,OAAO,KAAKb,EAAL,KAAY,sBAAnB;EACD;;AA7Dc;;eAgEFF,U"}
@@ -80,119 +80,133 @@ class ErrorResponse {
80
80
  return this.error.message || this.id;
81
81
  }
82
82
  /**
83
- * Return error title
83
+ * Return response error message
84
+ */
85
+
86
+
87
+ get responseMessage() {
88
+ return this.response.message || this.id;
89
+ }
90
+ /**
91
+ * Return response error title
84
92
  */
85
93
 
86
94
 
87
95
  get title() {
88
- return this.error.title || null;
96
+ return this.response.title || null;
89
97
  }
90
98
  /**
91
- * Return error title message
99
+ * Return response error title message
92
100
  */
93
101
 
94
102
 
95
103
  get titleMessage() {
96
- var _this$error$title;
104
+ var _this$response$title;
97
105
 
98
- return ((_this$error$title = this.error.title) === null || _this$error$title === void 0 ? void 0 : _this$error$title.message) || undefined;
106
+ return ((_this$response$title = this.response.title) === null || _this$response$title === void 0 ? void 0 : _this$response$title.message) || undefined;
99
107
  }
100
108
  /**
101
- * Return error title Id
109
+ * Return response error title Id
102
110
  */
103
111
 
104
112
 
105
113
  get titleId() {
106
- var _this$error$title2;
114
+ var _this$response$title2;
107
115
 
108
- return ((_this$error$title2 = this.error.title) === null || _this$error$title2 === void 0 ? void 0 : _this$error$title2.id) || undefined;
116
+ return ((_this$response$title2 = this.response.title) === null || _this$response$title2 === void 0 ? void 0 : _this$response$title2.id) || undefined;
109
117
  }
110
118
  /**
111
- * Return error title properties
119
+ * Return response error title properties
112
120
  */
113
121
 
114
122
 
115
123
  get titleProperties() {
116
- var _this$error$title3;
124
+ var _this$response$title3;
117
125
 
118
- return ((_this$error$title3 = this.error.title) === null || _this$error$title3 === void 0 ? void 0 : _this$error$title3.properties) || null;
126
+ return ((_this$response$title3 = this.response.title) === null || _this$response$title3 === void 0 ? void 0 : _this$response$title3.properties) || null;
119
127
  }
120
128
  /**
121
- * Return error redirect
129
+ * Return response error redirect
122
130
  */
123
131
 
124
132
 
125
133
  get redirect() {
126
- return this.error.redirect || null;
134
+ return this.response.redirect || null;
127
135
  }
128
136
  /**
129
- * Return error redirect text
137
+ * Return response error redirect text
130
138
  */
131
139
 
132
140
 
133
141
  get redirectText() {
134
- var _this$error$redirect;
142
+ var _this$response, _this$response$redire;
135
143
 
136
- return ((_this$error$redirect = this.error.redirect) === null || _this$error$redirect === void 0 ? void 0 : _this$error$redirect.text) || null;
144
+ return ((_this$response = this.response) === null || _this$response === void 0 ? void 0 : (_this$response$redire = _this$response.redirect) === null || _this$response$redire === void 0 ? void 0 : _this$response$redire.text) || null;
137
145
  }
138
146
  /**
139
- * Return error redirect text id
147
+ * Return response error redirect text id
140
148
  */
141
149
 
142
150
 
143
151
  get redirectTextID() {
144
- var _this$error$redirect2, _this$error$redirect3;
152
+ var _this$response$redire2, _this$response$redire3;
145
153
 
146
- return ((_this$error$redirect2 = this.error.redirect) === null || _this$error$redirect2 === void 0 ? void 0 : (_this$error$redirect3 = _this$error$redirect2.text) === null || _this$error$redirect3 === void 0 ? void 0 : _this$error$redirect3.id) || undefined;
154
+ return ((_this$response$redire2 = this.response.redirect) === null || _this$response$redire2 === void 0 ? void 0 : (_this$response$redire3 = _this$response$redire2.text) === null || _this$response$redire3 === void 0 ? void 0 : _this$response$redire3.id) || undefined;
147
155
  }
148
156
  /**
149
- * Return error redirect text properties
157
+ * Return response error redirect text properties
150
158
  */
151
159
 
152
160
 
153
161
  get redirectTextProperties() {
154
- var _this$error$redirect4, _this$error$redirect5;
162
+ var _this$response$redire4, _this$response$redire5;
155
163
 
156
- return ((_this$error$redirect4 = this.error.redirect) === null || _this$error$redirect4 === void 0 ? void 0 : (_this$error$redirect5 = _this$error$redirect4.text) === null || _this$error$redirect5 === void 0 ? void 0 : _this$error$redirect5.properties) || null;
164
+ return ((_this$response$redire4 = this.response.redirect) === null || _this$response$redire4 === void 0 ? void 0 : (_this$response$redire5 = _this$response$redire4.text) === null || _this$response$redire5 === void 0 ? void 0 : _this$response$redire5.properties) || null;
157
165
  }
158
166
  /**
159
- * Return error redirect text message
167
+ * Return response error redirect text message
160
168
  */
161
169
 
162
170
 
163
171
  get redirectMessage() {
164
- var _this$error$redirect6, _this$error$redirect7;
172
+ var _this$response$redire6, _this$response$redire7;
165
173
 
166
- return ((_this$error$redirect6 = this.error.redirect) === null || _this$error$redirect6 === void 0 ? void 0 : (_this$error$redirect7 = _this$error$redirect6.text) === null || _this$error$redirect7 === void 0 ? void 0 : _this$error$redirect7.message) || undefined;
174
+ return ((_this$response$redire6 = this.response.redirect) === null || _this$response$redire6 === void 0 ? void 0 : (_this$response$redire7 = _this$response$redire6.text) === null || _this$response$redire7 === void 0 ? void 0 : _this$response$redire7.message) || undefined;
167
175
  }
168
176
  /**
169
- * Return error redirect href
177
+ * Return response error redirect href
170
178
  */
171
179
 
172
180
 
173
181
  get redirectHref() {
174
- var _this$error$redirect8;
182
+ var _this$response$redire8;
183
+
184
+ if ((_this$response$redire8 = this.response.redirect) !== null && _this$response$redire8 !== void 0 && _this$response$redire8.href) {
185
+ var _this$response$redire9;
175
186
 
176
- if ((_this$error$redirect8 = this.error.redirect) !== null && _this$error$redirect8 !== void 0 && _this$error$redirect8.href) {
177
- return new _Href.default(this.error.redirect.href);
187
+ return new _Href.default((_this$response$redire9 = this.response.redirect) === null || _this$response$redire9 === void 0 ? void 0 : _this$response$redire9.href);
178
188
  }
179
189
 
180
190
  return new _Href.default();
181
191
  }
182
192
  /**
183
- * Return error layouthint
193
+ * Return error response layouthint
184
194
  */
185
195
 
186
196
 
187
197
  get layouthint() {
188
- return new _LayoutHintCollection.default(this.error.layouthint);
198
+ var _this$response2;
199
+
200
+ return new _LayoutHintCollection.default((_this$response2 = this.response) === null || _this$response2 === void 0 ? void 0 : _this$response2.layouthint);
189
201
  }
190
202
  /**
191
203
  */
192
204
 
193
205
 
194
206
  get response() {
195
- return this.error.response || {};
207
+ var _this$error, _this$error$response;
208
+
209
+ return ((_this$error = this.error) === null || _this$error === void 0 ? void 0 : (_this$error$response = _this$error.response) === null || _this$error$response === void 0 ? void 0 : _this$error$response.error) || {};
196
210
  }
197
211
  /**
198
212
  */