@beinformed/ui 1.43.7 → 1.44.0

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 (38) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/esm/models/attributes/AttributeModel.js +0 -7
  3. package/esm/models/attributes/AttributeModel.js.map +1 -1
  4. package/esm/models/attributes/ChoiceAttributeModel.js +22 -24
  5. package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
  6. package/esm/models/attributes/ChoiceAttributeOptionCollection.js +2 -1
  7. package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  8. package/esm/models/attributes/ChoiceAttributeOptionModel.js +8 -0
  9. package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  10. package/esm/models/detail/DetailModel.js +2 -6
  11. package/esm/models/detail/DetailModel.js.map +1 -1
  12. package/esm/models/user/UserModel.js.map +1 -1
  13. package/lib/models/attributes/AttributeModel.js +0 -7
  14. package/lib/models/attributes/AttributeModel.js.flow +0 -7
  15. package/lib/models/attributes/AttributeModel.js.map +1 -1
  16. package/lib/models/attributes/ChoiceAttributeModel.js +22 -24
  17. package/lib/models/attributes/ChoiceAttributeModel.js.flow +6 -10
  18. package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
  19. package/lib/models/attributes/ChoiceAttributeOptionCollection.js +2 -1
  20. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.flow +1 -0
  21. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  22. package/lib/models/attributes/ChoiceAttributeOptionModel.js +8 -0
  23. package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +9 -0
  24. package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  25. package/lib/models/attributes/__tests__/ChoiceAttributeModel.spec.js.flow +27 -0
  26. package/lib/models/detail/DetailModel.js +2 -6
  27. package/lib/models/detail/DetailModel.js.flow +8 -16
  28. package/lib/models/detail/DetailModel.js.map +1 -1
  29. package/lib/models/user/UserModel.js.flow +1 -1
  30. package/lib/models/user/UserModel.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/models/attributes/AttributeModel.js +0 -7
  33. package/src/models/attributes/ChoiceAttributeModel.js +6 -10
  34. package/src/models/attributes/ChoiceAttributeOptionCollection.js +1 -0
  35. package/src/models/attributes/ChoiceAttributeOptionModel.js +9 -0
  36. package/src/models/attributes/__tests__/ChoiceAttributeModel.spec.js +27 -0
  37. package/src/models/detail/DetailModel.js +8 -16
  38. package/src/models/user/UserModel.js +1 -1
@@ -71,6 +71,12 @@ export default class ChoiceAttributeModel extends AttributeModel {
71
71
  return "choice";
72
72
  }
73
73
 
74
+ /**
75
+ */
76
+ get optionType(): string {
77
+ return this.contributions?.optionType ?? "generic";
78
+ }
79
+
74
80
  /**
75
81
  */
76
82
  getInitialChildModelLinks(): Array<LinkModel> {
@@ -122,16 +128,6 @@ export default class ChoiceAttributeModel extends AttributeModel {
122
128
  return this.contributions.lookupList?.label ?? "";
123
129
  }
124
130
 
125
- /**
126
- *
127
- */
128
- get avatarLink(): LinkModel | null {
129
- return (
130
- this.options.collection.find((option) => option.code === this.value)
131
- ?.avatarLink || null
132
- );
133
- }
134
-
135
131
  /**
136
132
  * Retrieve reference date of attribute which can be used as entryDate for content
137
133
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceAttributeModel.js","names":["_objects","require","_DateTimeUtil","_AttributeModel","_interopRequireDefault","_ChoiceAttributeOptionCollection","_ChoiceAttributeOptionModel","_ContentConfigurationElements","_LayoutHints","_constants","ChoiceAttributeModel","AttributeModel","constructor","attribute","attributeContributions","_defineProperty2","default","_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","_find","call","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","avatarLink","_context","collection","option","code","value","date","selected","_context2","_map","readonlyvalue","_context3","join","initvalue","Array","isArray","_initvalue","length","getValue","_context4","hasValue","getInputValue","toggleOption","_context5","_includes","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","_context6","opt","choicetype","_context7","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","readonly","mergeOptions","isValid","update","updateLastModification","values","split","forEach","val","isChoiceAttributeOptionModel","equals","add","toString","_hasContentConfiguration","contentConfiguration","_context8","content","optionElements","optionElementConfig","optionElement","contentElement","RENDER_SECTION_LABEL","ContentConfigurationElements","placeholder","addServerError","error","id","message","properties","ANSWER_OPTION_KEY","_context9","optionKey","foundOption","getContentConfiguredLabel","_errorCollection","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM","exports"],"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 *\n */\n get avatarLink(): LinkModel | null {\n return (\n this.options.collection.find((option) => option.code === this.value)\n ?.avatarLink || null\n );\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 (typeof val === \"object\" && val.isChoiceAttributeOptionModel) {\n // option does not exist in existing options, add it. This can happen when lookup list has other options then lookup options\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, layouthint } = 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, layouthint);\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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,gCAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,2BAAA,GAA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1G,IAAI,KAAK,QAAQ,EAAE;MAC1B,OAAO2G,0BAAe,CAACC,KAAK;IAC9B;IAEA,OAAOD,0BAAe,CAACE,MAAM;EAC/B;AACF;AAACC,OAAA,CAAA7H,OAAA,GAAAN,oBAAA","ignoreList":[]}
1
+ {"version":3,"file":"ChoiceAttributeModel.js","names":["_objects","require","_DateTimeUtil","_AttributeModel","_interopRequireDefault","_ChoiceAttributeOptionCollection","_ChoiceAttributeOptionModel","_ContentConfigurationElements","_LayoutHints","_constants","ChoiceAttributeModel","AttributeModel","constructor","attribute","attributeContributions","_defineProperty2","default","_referenceDate","getData","DateUtil","now","_options","ChoiceAttributeOptionCollection","create","referenceDate","layouthint","has","SORT_OPTIONS","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","optionType","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","conceptLinkHref","href","concept","_find","call","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","date","selected","_context","_map","option","code","readonlyvalue","_context2","join","initvalue","Array","isArray","_initvalue","length","getValue","_context3","hasValue","getInputValue","toggleOption","_context4","_includes","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","_context5","opt","choicetype","_context6","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","readonly","mergeOptions","isValid","update","value","updateLastModification","values","split","forEach","val","isChoiceAttributeOptionModel","equals","add","toString","_hasContentConfiguration","contentConfiguration","_context7","content","optionElements","optionElementConfig","optionElement","contentElement","RENDER_SECTION_LABEL","ContentConfigurationElements","placeholder","addServerError","error","id","message","properties","ANSWER_OPTION_KEY","_context8","optionKey","foundOption","getContentConfiguredLabel","_errorCollection","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM","exports"],"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 get optionType(): string {\n return this.contributions?.optionType ?? \"generic\";\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 (typeof val === \"object\" && val.isChoiceAttributeOptionModel) {\n // option does not exist in existing options, add it. This can happen when lookup list has other options then lookup options\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, layouthint } = 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, layouthint);\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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,gCAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,2BAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,6BAAA,GAAAH,sBAAA,CAAAH,OAAA;AAEA,IAAAO,YAAA,GAAAP,OAAA;AAIA,IAAAQ,UAAA,GAAAR,OAAA;AAKA;AACA;AACA;AACe,MAAMS,oBAAoB,SAASC,uBAAc,CAAC;EAK/D;AACF;AACA;EACEC,WAAWA,CAACC,SAAiB,EAAEC,sBAA8B,EAAE;IAC7D,KAAK,CAACD,SAAS,EAAEC,sBAAsB,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEzC,IAAI,CAACC,cAAc,GAAG,IAAI,CAACC,OAAO,CAAC,eAAe,EAAEC,sBAAQ,CAACC,GAAG,CAAC,CAAC,CAAC;IACnE,IAAI,CAACC,QAAQ,GAAGC,wCAA+B,CAACC,MAAM,CACpDV,SAAS,EACTC,sBAAsB,EACtB,IAAI,CAACU,aACP,CAAC;IAED,IAAI,IAAI,CAACC,UAAU,CAACC,GAAG,CAACC,yBAAY,CAAC,EAAE;MACrC,IAAI,C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I,KAAKmE,SAC9B,CAAC;MACD,IAAIC,WAAW,EAAE;QACfJ,UAAU,CAACC,iBAAiB,CAAC,GAAGG,WAAW,CAACC,yBAAyB,CACnE,IAAI,CAACnB,oBACP,CAAC;MACH;IACF;IAEA,IAAI,CAACoB,gBAAgB,CAACV,cAAc,CAACE,EAAE,EAAEC,OAAO,EAAEC,UAAU,EAAEvG,UAAU,CAAC;EAC3E;;EAEA;AACF;EACE,IAAI8G,aAAaA,CAAA,EAAkC;IACjD,IAAI,IAAI,CAACxG,IAAI,KAAK,QAAQ,EAAE;MAC1B,OAAOyG,0BAAe,CAACC,KAAK;IAC9B;IAEA,OAAOD,0BAAe,CAACE,MAAM;EAC/B;AACF;AAACC,OAAA,CAAA3H,OAAA,GAAAN,oBAAA","ignoreList":[]}
@@ -105,7 +105,8 @@ class ChoiceAttributeOptionCollection extends _ResourceCollection.default {
105
105
  const optionCode = optionContributions.code || optionContributions.key;
106
106
  this.addOption(selectedValues, {
107
107
  ...optionContributions,
108
- count: this.getOptionCount(optionCode, data.options)
108
+ count: this.getOptionCount(optionCode, data.options),
109
+ optionType: contributions.optionType ?? "generic"
109
110
  }, referenceDate);
110
111
  });
111
112
  return this;
@@ -114,6 +114,7 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
114
114
  {
115
115
  ...optionContributions,
116
116
  count: this.getOptionCount(optionCode, data.options),
117
+ optionType: contributions.optionType ?? "generic",
117
118
  },
118
119
  referenceDate,
119
120
  );
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceAttributeOptionCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ChoiceAttributeOptionModel","_ListHeaderModel","_DateTimeUtil","ChoiceAttributeOptionCollection","ResourceCollection","constructor","arguments","_defineProperty2","default","sortOptions","_sortOptions","collection","forEach","option","children","create","data","length","undefined","contributions","referenceDate","DateUtil","now","type","addBooleanOptions","value","dynamicschema","addDynamicSchema","options","addOptions","addHeaders","all","_context","_sort","call","a","b","label","localeCompare","getSelectedOptions","selectedOptions","Array","isArray","_context2","_context3","push","_map","_filter","selected","key","toString","getOptionCount","code","foundOption","_find","count","selectedValues","optionContributions","optionCode","addOption","optionDynamicschema","elementsContributions","addBooleanOption","defaultLabel","isBooleanType","hasAlternativeLabel","optionValue","optionModel","ChoiceAttributeOptionModel","add","deselectAll","_context4","newOption","clone","select","toggle","deselect","action","_context5","setReferenceDate","date","_context6","headers","_headers","child","ListHeaderModel","mergeOptions","withOptions","addNotExistingOptions","some","opt","withOption","mergeOption","callbackfn","thisArg","optionIndex","collectionArray","result","_default","exports"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ListHeaderModel from \"../list/ListHeaderModel\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n _headers: Array<ListHeaderModel> = [];\n _sortOptions: boolean = false;\n\n /**\n */\n set sortOptions(sortOptions: boolean) {\n this._sortOptions = sortOptions;\n\n this.collection.forEach((option) => {\n if (option.children) {\n option.children.sortOptions = sortOptions;\n }\n });\n }\n\n /**\n */\n get sortOptions(): boolean {\n return this._sortOptions;\n }\n\n /**\n */\n static create(\n data: Object = {},\n contributions: Object = {},\n referenceDate: ISO_DATE = DateUtil.now(),\n ): ChoiceAttributeOptionCollection {\n const collection = new ChoiceAttributeOptionCollection();\n\n if (contributions.type === \"boolean\") {\n collection.addBooleanOptions(data.value, contributions);\n } else if (data.dynamicschema != null) {\n collection.addDynamicSchema(data, contributions, referenceDate);\n } else if (contributions.options != null) {\n collection.addOptions(data, contributions, referenceDate);\n }\n\n if (contributions.children != null) {\n collection.addHeaders(contributions.children);\n }\n\n return collection;\n }\n\n /**\n * Retrieve all items in collection\n */\n get all(): Array<ChoiceAttributeOptionModel> {\n return this.sortOptions\n ? this.collection.sort((a, b) => a.label.localeCompare(b.label))\n : this.collection;\n }\n\n /**\n */\n getSelectedOptions(data: Object): Array<string> {\n const selectedOptions = [];\n\n if (Array.isArray(data.options)) {\n selectedOptions.push(\n ...data.options\n .filter((option) => option.selected)\n .map((option) => option.key),\n );\n } else if (Array.isArray(data.value)) {\n selectedOptions.push(...data.value);\n } else if (typeof data.value === \"boolean\") {\n selectedOptions.push(data.value.toString());\n } else {\n selectedOptions.push(data.value);\n }\n\n return selectedOptions;\n }\n\n /**\n */\n getOptionCount(code: string, options: Array<Object>): number | null {\n if (Array.isArray(options)) {\n const foundOption = options.find((option) => option.key === code);\n if (foundOption) {\n return foundOption.count;\n }\n }\n\n return null;\n }\n\n /**\n */\n addOptions(\n data: Object,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now(),\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n\n contributions.options.forEach((optionContributions) => {\n const optionCode = optionContributions.code || optionContributions.key;\n\n this.addOption(\n selectedValues,\n {\n ...optionContributions,\n count: this.getOptionCount(optionCode, data.options),\n },\n referenceDate,\n );\n });\n\n return this;\n }\n\n /**\n * Create options based on data and dynamischema\n */\n addDynamicSchema(\n data: Object,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now(),\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n data.dynamicschema.forEach((optionDynamicschema) => {\n this.addOption(\n selectedValues,\n {\n ...optionDynamicschema,\n count: this.getOptionCount(optionDynamicschema.code, data.options),\n elementsContributions: contributions.children,\n },\n referenceDate,\n );\n });\n\n return this;\n }\n\n /**\n */\n addBooleanOption(\n code: \"true\" | \"false\",\n defaultLabel: string,\n data: string | Array<string>,\n options: Array<Object> = [],\n ) {\n const foundOption = options.find((option) => option.code === code);\n\n const label = foundOption ? foundOption.label : defaultLabel;\n\n this.addOption(data, {\n code,\n label,\n isBooleanType: true,\n hasAlternativeLabel: foundOption != null,\n });\n }\n\n /**\n * Create two static options for true and false,\n * there might be alternative labels configured for each option value\n */\n addBooleanOptions(\n value: any,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const optionValue = value == null ? [] : [value.toString()];\n\n this.addBooleanOption(\"true\", \"Yes\", optionValue, contributions.options);\n this.addBooleanOption(\"false\", \"No\", optionValue, contributions.options);\n\n return this;\n }\n\n /**\n */\n addOption(\n data: string | Array<string>,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now(),\n ): ChoiceAttributeOptionCollection {\n const optionModel = new ChoiceAttributeOptionModel(\n Array.isArray(data) ? data : [data],\n contributions,\n referenceDate,\n );\n\n this.add(optionModel);\n\n return this;\n }\n\n /**\n * Get all options that have selected property true\n */\n get selected(): Array<ChoiceAttributeOptionModel> {\n const selectedOptions = [];\n\n this.collection.forEach((option: ChoiceAttributeOptionModel) => {\n if (option.selected && option.selected === true) {\n selectedOptions.push(option);\n }\n\n if (option.children) {\n selectedOptions.push(...option.children.selected);\n }\n });\n\n return selectedOptions;\n }\n\n /**\n * Deselect all options\n */\n deselectAll() {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n newOption.selected = false;\n\n if (newOption.children) {\n newOption.children.deselectAll();\n }\n\n return newOption;\n });\n }\n\n /**\n * Select an option by it's code\n */\n select(optionCode: string) {\n this.toggle(optionCode, \"select\");\n }\n\n /**\n * Deselect an option by it's code\n */\n deselect(optionCode: string) {\n this.toggle(optionCode, \"deselect\");\n }\n\n /**\n * Toggle an option by it's code\n */\n toggle(optionCode: string, action: \"select\" | \"deselect\") {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n if (newOption.code === optionCode) {\n newOption.selected = action === \"select\";\n } else if (newOption.children) {\n newOption.children.toggle(optionCode, action);\n }\n\n return newOption;\n });\n }\n\n /**\n */\n setReferenceDate(date: ISO_DATE): Array<ChoiceAttributeOptionModel> {\n return this.collection.map((option) => {\n option.referenceDate = date;\n if (option.children) {\n option.children.referenceDate = date;\n }\n\n return option;\n });\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this.collection = this.setReferenceDate(date);\n }\n\n /**\n */\n addHeaders(headers: Array<Object>) {\n this._headers = headers.map((child) => new ListHeaderModel(child));\n }\n\n /**\n */\n get headers(): Array<ListHeaderModel> {\n if (this._headers) {\n return this._headers;\n }\n\n return [];\n }\n\n /**\n */\n mergeOptions(\n withOptions: ChoiceAttributeOptionCollection,\n addNotExistingOptions: boolean = false,\n ) {\n if (addNotExistingOptions) {\n this.collection = [\n ...this.collection,\n ...withOptions.filter(\n (option) => !this.collection.some((opt) => opt.code === option.code),\n ),\n ];\n }\n\n this.collection.forEach((option) => {\n const foundOption = withOptions.find(\n (withOption) => withOption.code === option.code,\n );\n if (foundOption) {\n option.mergeOption(foundOption);\n }\n });\n }\n\n /**\n */\n some(\n callbackfn: (\n value: ChoiceAttributeOptionModel,\n index: number,\n array: Array<ChoiceAttributeOptionModel>,\n ) => any,\n thisArg?: any,\n ): boolean {\n return this.collection.some((option, optionIndex, collectionArray) => {\n const result = callbackfn(option, optionIndex, collectionArray);\n if (!result && option.children) {\n return option.children.some(callbackfn, thisArg);\n }\n return result;\n });\n }\n}\n\nexport default ChoiceAttributeOptionCollection;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,aAAA,GAAAH,OAAA;AAEA;AACA;AACA,MAAMI,+BAA+B,SAASC,2BAAkB,CAA6B;EAAAC,YAAA;IAAA,SAAAC,SAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,oBACxD,EAAE;IAAA,IAAAD,gBAAA,CAAAC,OAAA,wBACb,KAAK;EAAA;EAE7B;AACF;EACE,IAAIC,WAAWA,CAACA,WAAoB,EAAE;IACpC,IAAI,CAACC,YAAY,GAAGD,WAA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MAAM,CAACuC,IAC7C,CAAC;MACD,IAAIC,WAAW,EAAE;QACfxC,MAAM,CAAC+E,WAAW,CAACvC,WAAW,CAAC;MACjC;IACF,CAAC,CAAC;EACJ;;EAEA;AACF;EACEoC,IAAIA,CACFI,UAIQ,EACRC,OAAa,EACJ;IACT,OAAO,IAAI,CAACnF,UAAU,CAAC8E,IAAI,CAAC,CAAC5E,MAAM,EAAEkF,WAAW,EAAEC,eAAe,KAAK;MACpE,MAAMC,MAAM,GAAGJ,UAAU,CAAChF,MAAM,EAAEkF,WAAW,EAAEC,eAAe,CAAC;MAC/D,IAAI,CAACC,MAAM,IAAIpF,MAAM,CAACC,QAAQ,EAAE;QAC9B,OAAOD,MAAM,CAACC,QAAQ,CAAC2E,IAAI,CAACI,UAAU,EAAEC,OAAO,CAAC;MAClD;MACA,OAAOG,MAAM;IACf,CAAC,CAAC;EACJ;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3F,OAAA,GAEcL,+BAA+B","ignoreList":[]}
1
+ {"version":3,"file":"ChoiceAttributeOptionCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ChoiceAttributeOptionModel","_ListHeaderModel","_DateTimeUtil","ChoiceAttributeOptionCollection","ResourceCollection","constructor","arguments","_defineProperty2","default","sortOptions","_sortOptions","collection","forEach","option","children","create","data","length","undefined","contributions","referenceDate","DateUtil","now","type","addBooleanOptions","value","dynamicschema","addDynamicSchema","options","addOptions","addHeaders","all","_context","_sort","call","a","b","label","localeCompare","getSelectedOptions","selectedOptions","Array","isArray","_context2","_context3","push","_map","_filter","selected","key","toString","getOptionCount","code","foundOption","_find","count","selectedValues","optionContributions","optionCode","addOption","optionType","optionDynamicschema","elementsContributions","addBooleanOption","defaultLabel","isBooleanType","hasAlternativeLabel","optionValue","optionModel","ChoiceAttributeOptionModel","add","deselectAll","_context4","newOption","clone","select","toggle","deselect","action","_context5","setReferenceDate","date","_context6","headers","_headers","child","ListHeaderModel","mergeOptions","withOptions","addNotExistingOptions","some","opt","withOption","mergeOption","callbackfn","thisArg","optionIndex","collectionArray","result","_default","exports"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ListHeaderModel from \"../list/ListHeaderModel\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n _headers: Array<ListHeaderModel> = [];\n _sortOptions: boolean = false;\n\n /**\n */\n set sortOptions(sortOptions: boolean) {\n this._sortOptions = sortOptions;\n\n this.collection.forEach((option) => {\n if (option.children) {\n option.children.sortOptions = sortOptions;\n }\n });\n }\n\n /**\n */\n get sortOptions(): boolean {\n return this._sortOptions;\n }\n\n /**\n */\n static create(\n data: Object = {},\n contributions: Object = {},\n referenceDate: ISO_DATE = DateUtil.now(),\n ): ChoiceAttributeOptionCollection {\n const collection = new ChoiceAttributeOptionCollection();\n\n if (contributions.type === \"boolean\") {\n collection.addBooleanOptions(data.value, contributions);\n } else if (data.dynamicschema != null) {\n collection.addDynamicSchema(data, contributions, referenceDate);\n } else if (contributions.options != null) {\n collection.addOptions(data, contributions, referenceDate);\n }\n\n if (contributions.children != null) {\n collection.addHeaders(contributions.children);\n }\n\n return collection;\n }\n\n /**\n * Retrieve all items in collection\n */\n get all(): Array<ChoiceAttributeOptionModel> {\n return this.sortOptions\n ? this.collection.sort((a, b) => a.label.localeCompare(b.label))\n : this.collection;\n }\n\n /**\n */\n getSelectedOptions(data: Object): Array<string> {\n const selectedOptions = [];\n\n if (Array.isArray(data.options)) {\n selectedOptions.push(\n ...data.options\n .filter((option) => option.selected)\n .map((option) => option.key),\n );\n } else if (Array.isArray(data.value)) {\n selectedOptions.push(...data.value);\n } else if (typeof data.value === \"boolean\") {\n selectedOptions.push(data.value.toString());\n } else {\n selectedOptions.push(data.value);\n }\n\n return selectedOptions;\n }\n\n /**\n */\n getOptionCount(code: string, options: Array<Object>): number | null {\n if (Array.isArray(options)) {\n const foundOption = options.find((option) => option.key === code);\n if (foundOption) {\n return foundOption.count;\n }\n }\n\n return null;\n }\n\n /**\n */\n addOptions(\n data: Object,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now(),\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n\n contributions.options.forEach((optionContributions) => {\n const optionCode = optionContributions.code || optionContributions.key;\n\n this.addOption(\n selectedValues,\n {\n ...optionContributions,\n count: this.getOptionCount(optionCode, data.options),\n optionType: contributions.optionType ?? \"generic\",\n },\n referenceDate,\n );\n });\n\n return this;\n }\n\n /**\n * Create options based on data and dynamischema\n */\n addDynamicSchema(\n data: Object,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now(),\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n data.dynamicschema.forEach((optionDynamicschema) => {\n this.addOption(\n selectedValues,\n {\n ...optionDynamicschema,\n count: this.getOptionCount(optionDynamicschema.code, data.options),\n elementsContributions: contributions.children,\n },\n referenceDate,\n );\n });\n\n return this;\n }\n\n /**\n */\n addBooleanOption(\n code: \"true\" | \"false\",\n defaultLabel: string,\n data: string | Array<string>,\n options: Array<Object> = [],\n ) {\n const foundOption = options.find((option) => option.code === code);\n\n const label = foundOption ? foundOption.label : defaultLabel;\n\n this.addOption(data, {\n code,\n label,\n isBooleanType: true,\n hasAlternativeLabel: foundOption != null,\n });\n }\n\n /**\n * Create two static options for true and false,\n * there might be alternative labels configured for each option value\n */\n addBooleanOptions(\n value: any,\n contributions: Object,\n ): ChoiceAttributeOptionCollection {\n const optionValue = value == null ? [] : [value.toString()];\n\n this.addBooleanOption(\"true\", \"Yes\", optionValue, contributions.options);\n this.addBooleanOption(\"false\", \"No\", optionValue, contributions.options);\n\n return this;\n }\n\n /**\n */\n addOption(\n data: string | Array<string>,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now(),\n ): ChoiceAttributeOptionCollection {\n const optionModel = new ChoiceAttributeOptionModel(\n Array.isArray(data) ? data : [data],\n contributions,\n referenceDate,\n );\n\n this.add(optionModel);\n\n return this;\n }\n\n /**\n * Get all options that have selected property true\n */\n get selected(): Array<ChoiceAttributeOptionModel> {\n const selectedOptions = [];\n\n this.collection.forEach((option: ChoiceAttributeOptionModel) => {\n if (option.selected && option.selected === true) {\n selectedOptions.push(option);\n }\n\n if (option.children) {\n selectedOptions.push(...option.children.selected);\n }\n });\n\n return selectedOptions;\n }\n\n /**\n * Deselect all options\n */\n deselectAll() {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n newOption.selected = false;\n\n if (newOption.children) {\n newOption.children.deselectAll();\n }\n\n return newOption;\n });\n }\n\n /**\n * Select an option by it's code\n */\n select(optionCode: string) {\n this.toggle(optionCode, \"select\");\n }\n\n /**\n * Deselect an option by it's code\n */\n deselect(optionCode: string) {\n this.toggle(optionCode, \"deselect\");\n }\n\n /**\n * Toggle an option by it's code\n */\n toggle(optionCode: string, action: \"select\" | \"deselect\") {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n if (newOption.code === optionCode) {\n newOption.selected = action === \"select\";\n } else if (newOption.children) {\n newOption.children.toggle(optionCode, action);\n }\n\n return newOption;\n });\n }\n\n /**\n */\n setReferenceDate(date: ISO_DATE): Array<ChoiceAttributeOptionModel> {\n return this.collection.map((option) => {\n option.referenceDate = date;\n if (option.children) {\n option.children.referenceDate = date;\n }\n\n return option;\n });\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this.collection = this.setReferenceDate(date);\n }\n\n /**\n */\n addHeaders(headers: Array<Object>) {\n this._headers = headers.map((child) => new ListHeaderModel(child));\n }\n\n /**\n */\n get headers(): Array<ListHeaderModel> {\n if (this._headers) {\n return this._headers;\n }\n\n return [];\n }\n\n /**\n */\n mergeOptions(\n withOptions: ChoiceAttributeOptionCollection,\n addNotExistingOptions: boolean = false,\n ) {\n if (addNotExistingOptions) {\n this.collection = [\n ...this.collection,\n ...withOptions.filter(\n (option) => !this.collection.some((opt) => opt.code === option.code),\n ),\n ];\n }\n\n this.collection.forEach((option) => {\n const foundOption = withOptions.find(\n (withOption) => withOption.code === option.code,\n );\n if (foundOption) {\n option.mergeOption(foundOption);\n }\n });\n }\n\n /**\n */\n some(\n callbackfn: (\n value: ChoiceAttributeOptionModel,\n index: number,\n array: Array<ChoiceAttributeOptionModel>,\n ) => any,\n thisArg?: any,\n ): boolean {\n return this.collection.some((option, optionIndex, collectionArray) => {\n const result = callbackfn(option, optionIndex, collectionArray);\n if (!result && option.children) {\n return option.children.some(callbackfn, thisArg);\n }\n return result;\n });\n }\n}\n\nexport default ChoiceAttributeOptionCollection;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,aAAA,GAAAH,OAAA;AAEA;AACA;AACA,MAAMI,+BAA+B,SAASC,2BAAkB,CAA6B;EAAAC,YAAA;IAAA,SAAAC,SAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,oBACxD,EAAE;IAAA,IAAAD,gBAAA,CAAAC,OAAA,wBACb,KAAK;EAAA;EAE7B;AACF;EACE,IAAIC,WAAWA,CAACA,WAAoB,EAAE;IACpC,IAAI,CAACC,YAAY,GAAGD,WAAW;IAE/B,IAAI,CAACE,UAAU,CAACC,OAAO,CAAEC,MAAM,IAAK;MAClC,IAAIA,MAAM,CAACC,QAAQ,EAAE;QACnBD,MAAM,CAACC,QAAQ,CAACL,WAAW,GAAGA,WAAW;MAC3C;IACF,CAAC,CAAC;EACJ;;EAEA;AACF;EACE,IAAIA,WAAWA,CAAA,EAAY;IACzB,OAAO,IAAI,CAACC,YAAY;EAC1B;;EAEA;AACF;EACE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C+E,IAAI,CAAC,CAAC7E,MAAM,EAAEmF,WAAW,EAAEC,eAAe,KAAK;MACpE,MAAMC,MAAM,GAAGJ,UAAU,CAACjF,MAAM,EAAEmF,WAAW,EAAEC,eAAe,CAAC;MAC/D,IAAI,CAACC,MAAM,IAAIrF,MAAM,CAACC,QAAQ,EAAE;QAC9B,OAAOD,MAAM,CAACC,QAAQ,CAAC4E,IAAI,CAACI,UAAU,EAAEC,OAAO,CAAC;MAClD;MACA,OAAOG,MAAM;IACf,CAAC,CAAC;EACJ;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA5F,OAAA,GAEcL,+BAA+B","ignoreList":[]}
@@ -40,6 +40,7 @@ class ChoiceAttributeOptionModel extends _BaseModel.default {
40
40
  (0, _defineProperty2.default)(this, "_links", void 0);
41
41
  (0, _defineProperty2.default)(this, "_attributeCollection", void 0);
42
42
  (0, _defineProperty2.default)(this, "_content", void 0);
43
+ (0, _defineProperty2.default)(this, "_isUser", false);
43
44
  this.code = this.contributions.code ?? this.contributions.key ?? "";
44
45
  this._isSelected = (0, _includes.default)(selectedValues).call(selectedValues, this.code);
45
46
  this._referenceDate = referenceDate;
@@ -48,6 +49,7 @@ class ChoiceAttributeOptionModel extends _BaseModel.default {
48
49
  this._children = this.addChildren(selectedValues, option, referenceDate);
49
50
  this._links = new _LinkCollection.default(this.contributions._links);
50
51
  this._content = new _AttributeContent.default(option.content);
52
+ this._isUser = option.optionType === "user";
51
53
  }
52
54
 
53
55
  /**
@@ -323,6 +325,12 @@ class ChoiceAttributeOptionModel extends _BaseModel.default {
323
325
  get content() {
324
326
  return this._content;
325
327
  }
328
+
329
+ /**
330
+ */
331
+ get isUser() {
332
+ return this._isUser;
333
+ }
326
334
  }
327
335
  var _default = exports.default = ChoiceAttributeOptionModel;
328
336
  //# sourceMappingURL=ChoiceAttributeOptionModel.js.map
@@ -32,6 +32,7 @@ class ChoiceAttributeOptionModel
32
32
  _links: LinkCollection;
33
33
  _attributeCollection: AttributeCollection;
34
34
  _content: AttributeContent;
35
+ _isUser: boolean = false;
35
36
 
36
37
  /**
37
38
  */
@@ -56,6 +57,8 @@ class ChoiceAttributeOptionModel
56
57
  this._links = new LinkCollection(this.contributions._links);
57
58
 
58
59
  this._content = new AttributeContent(option.content);
60
+
61
+ this._isUser = option.optionType === "user";
59
62
  }
60
63
 
61
64
  /**
@@ -381,6 +384,12 @@ class ChoiceAttributeOptionModel
381
384
  get content(): AttributeContent {
382
385
  return this._content;
383
386
  }
387
+
388
+ /**
389
+ */
390
+ get isUser(): boolean {
391
+ return this._isUser;
392
+ }
384
393
  }
385
394
 
386
395
  export default ChoiceAttributeOptionModel;
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceAttributeOptionModel.js","names":["_BaseModel","_interopRequireDefault","require","_ChoiceAttributeOptionCollection","_DateTimeUtil","_objects","_Constants","_LayoutHints","_Settings","_LinkCollection","_AttributeCollection","_ConceptDetailModel","_AttributeContent","ChoiceAttributeOptionModel","BaseModel","constructor","selectedValues","arguments","length","undefined","option","referenceDate","DateUtil","now","_defineProperty2","default","code","contributions","key","_isSelected","_includes","call","_referenceDate","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","LinkCollection","_content","AttributeContent","content","createFromListItemModel","listitem","id","toString","attributeCollection","clone","links","isChoiceAttributeOptionModel","getInitialChildModelLinks","initialLinks","hasContentFromData","conceptLink","push","children","setChildModels","models","conceptHref","href","concept","_find","model","selfhref","equalsWithParameters","_code","equals","getContribution","has","data","AttributeCollection","label","hasItems","title","getAttributeByLayoutHint","TITLE","readonlyvalue","first","getContentConfiguredLabel","contentConfiguration","configuredLabelProperties","labelConfig","types","_context","configuredLabels","_filter","getLabelElementByIds","configuredLabel","value","_context2","_map","configuredLabelProperty","some","_id","selected","count","ChoiceAttributeOptionCollection","create","options","date","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","avatarLink","_concept","ConceptDetailModel","level","isBooleanType","hasAlternativeLabel","mergeOption","withOption","mergeOptions","hasAllContentInData","_default","exports"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\nimport { has } from \"../../utils/helpers/objects\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport { TITLE } from \"../../constants/LayoutHints\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\n\nimport LinkCollection from \"../links/LinkCollection\";\nimport AttributeCollection from \"./AttributeCollection\";\nimport ConceptDetailModel from \"../concepts/ConceptDetailModel\";\nimport AttributeContent from \"./AttributeContent\";\n\nimport type { IModelWithChildModels, ModularUIModel } from \"../types\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n */\nclass ChoiceAttributeOptionModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _code: string;\n _isSelected: boolean;\n _referenceDate: ISO_DATE;\n _level: number;\n _children: ChoiceAttributeOptionCollection;\n _concept: ?ConceptDetailModel;\n _links: LinkCollection;\n _attributeCollection: AttributeCollection;\n _content: AttributeContent;\n\n /**\n */\n constructor(\n selectedValues: Array<string> = [],\n option: Object = {},\n referenceDate: ISO_DATE = DateUtil.now(),\n ) {\n super({}, option);\n\n this.code = this.contributions.code ?? this.contributions.key ?? \"\";\n\n this._isSelected = selectedValues.includes(this.code);\n\n this._referenceDate = referenceDate;\n\n this._level = 0;\n\n this._attributeCollection = this.createAttributeCollection();\n this._children = this.addChildren(selectedValues, option, referenceDate);\n\n this._links = new LinkCollection(this.contributions._links);\n\n this._content = new AttributeContent(option.content);\n }\n\n /**\n */\n static createFromListItemModel(\n listitem: ListItemModel,\n ): ChoiceAttributeOptionModel {\n const option = new ChoiceAttributeOptionModel();\n\n option.code = listitem.id.toString();\n option.attributeCollection = listitem.attributeCollection.clone();\n option.links = listitem.links.clone();\n\n return option;\n }\n\n /**\n * Indicates that this a choice attribute option model, used when adding options to a choice attribute\n * @returns {boolean}\n */\n get isChoiceAttributeOptionModel(): boolean {\n return true;\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const initialLinks = [];\n\n if (!this.hasContentFromData && this.conceptLink !== null) {\n initialLinks.push(this.conceptLink);\n }\n\n if (this.children) {\n initialLinks.push(...this.children.getInitialChildModelLinks());\n }\n\n return initialLinks;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n if (this.conceptLink !== null) {\n const conceptHref = this.conceptLink.href;\n\n this.concept = models.find((model) =>\n model.selfhref.equalsWithParameters(conceptHref),\n );\n }\n\n if (this.children) {\n this.children.setChildModels(models);\n }\n }\n\n /**\n * Get code of option\n */\n get code(): string {\n return this._code;\n }\n\n /**\n */\n set code(code: string) {\n this._code = code;\n }\n\n /**\n */\n equals(model: ChoiceAttributeOptionModel): boolean {\n return this.code.toString() === model.code.toString();\n }\n\n /**\n * Retrieve attributes for Composite codemaps (e.g. table and case list codemaps)\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 createAttributeCollection(): AttributeCollection {\n const contributions = this.getContribution(\"elementsContributions\", []);\n\n if (has(this.contributions, \"elements\")) {\n const data = this.getContribution(\"elements\", {});\n return new AttributeCollection(data, contributions, true);\n }\n\n return new AttributeCollection();\n }\n\n /**\n * Get label of option for simple codemaps (e.g. static codemap)\n */\n get label(): string {\n if (this.contributions.label) {\n return this.contributions.label;\n }\n\n if (this.attributeCollection.hasItems) {\n const title = this.attributeCollection.getAttributeByLayoutHint(TITLE);\n\n if (title) {\n return title.readonlyvalue;\n }\n\n if (this.attributeCollection.first) {\n return this.attributeCollection.first.readonlyvalue;\n }\n }\n\n return \"\";\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(contentConfiguration: Object): string {\n const configuredLabelProperties =\n contentConfiguration?.labelConfig?.[0]?.types ?? [];\n\n if (\n !this.hasContentFromData &&\n this.concept &&\n configuredLabelProperties.length > 0\n ) {\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 return 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 )[0].value;\n }\n }\n\n return this.label;\n }\n\n /**\n * Indicates if option is selected\n */\n get selected(): boolean {\n return this._isSelected;\n }\n\n /**\n * Set selected property of option\n */\n set selected(selected: boolean) {\n this._isSelected = selected;\n }\n\n /**\n * Retrieve count of filter for option\n */\n get count(): number | null {\n return this.getContribution(\"count\");\n }\n\n /**\n */\n addChildren(\n selectedValues: Array<string> = [],\n option: Object = {},\n referenceDate: ISO_DATE = DateUtil.now(),\n ): ChoiceAttributeOptionCollection {\n // When contributions contain elements this is a list not nested options\n if (has(option, \"elements\")) {\n return new ChoiceAttributeOptionCollection();\n }\n\n return ChoiceAttributeOptionCollection.create(\n {\n value: selectedValues,\n },\n { options: option?.children ?? [] },\n referenceDate,\n );\n }\n\n /**\n * get children of option\n */\n get children(): ChoiceAttributeOptionCollection {\n return this._children;\n }\n\n /**\n * Retrieve links of attribute\n */\n get links(): LinkCollection {\n return this._links;\n }\n\n /**\n */\n set links(links: LinkCollection) {\n this._links = links;\n }\n\n /**\n * referenceDate received from attribute\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this._referenceDate = date;\n }\n\n /**\n * Retrieve concept link of attribute when available\n */\n get conceptLink(): LinkModel | null {\n const conceptLink = this.links.getLinkByKey(\"concept\");\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 *\n */\n get avatarLink(): LinkModel | null {\n return this.links.getLinkByKey(\"avatar\");\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 * Get level of option, used in tree view choice attributes (taxonomy)\n */\n get level(): number {\n return this._level;\n }\n\n /**\n * Set level of option\n */\n set level(level: number) {\n this._level = level;\n }\n\n /**\n */\n get isBooleanType(): boolean {\n return this.getContribution(\"isBooleanType\", false);\n }\n\n /**\n */\n get hasAlternativeLabel(): boolean {\n return this.getContribution(\"hasAlternativeLabel\", false);\n }\n\n /**\n */\n mergeOption(withOption: ChoiceAttributeOptionModel) {\n this.concept = withOption.concept;\n\n if (this.children != null && withOption.children != null) {\n this.children.mergeOptions(withOption.children);\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 this._content;\n }\n}\n\nexport default ChoiceAttributeOptionModel;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gCAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAEA,IAAAO,eAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,oBAAA,GAAAT,sBAA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AAE;IACpC,IAAI,CAAC6C,QAAQ,GAAG7C,OAAO,YAAY8C,2BAAkB,GAAG9C,OAAO,GAAG,IAAI;EACxE;;EAEA;AACF;AACA;EACE,IAAI+C,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAAC3E,MAAM;EACpB;;EAEA;AACF;AACA;EACE,IAAI2E,KAAKA,CAACA,KAAa,EAAE;IACvB,IAAI,CAAC3E,MAAM,GAAG2E,KAAK;EACrB;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAY;IAC3B,OAAO,IAAI,CAACzC,eAAe,CAAC,eAAe,EAAE,KAAK,CAAC;EACrD;;EAEA;AACF;EACE,IAAI0C,mBAAmBA,CAAA,EAAY;IACjC,OAAO,IAAI,CAAC1C,eAAe,CAAC,qBAAqB,EAAE,KAAK,CAAC;EAC3D;;EAEA;AACF;EACE2C,WAAWA,CAACC,UAAsC,EAAE;IAClD,IAAI,CAACnD,OAAO,GAAGmD,UAAU,CAACnD,OAAO;IAEjC,IAAI,IAAI,CAACL,QAAQ,IAAI,IAAI,IAAIwD,UAAU,CAACxD,QAAQ,IAAI,IAAI,EAAE;MACxD,IAAI,CAACA,QAAQ,CAACyD,YAAY,CAACD,UAAU,CAACxD,QAAQ,CAAC;IACjD;EACF;;EAEA;AACF;AACA;EACE,IAAIH,kBAAkBA,CAAA,EAAY;IAChC,OAAO,IAAA6D,6BAAmB,EAAC,CAAC;EAC9B;;EAEA;AACF;EACE,IAAIxE,OAAOA,CAAA,EAAqB;IAC9B,OAAO,IAAI,CAACF,QAAQ;EACtB;AACF;AAAC,IAAA2E,QAAA,GAAAC,OAAA,CAAA3F,OAAA,GAEcZ,0BAA0B","ignoreList":[]}
1
+ {"version":3,"file":"ChoiceAttributeOptionModel.js","names":["_BaseModel","_interopRequireDefault","require","_ChoiceAttributeOptionCollection","_DateTimeUtil","_objects","_Constants","_LayoutHints","_Settings","_LinkCollection","_AttributeCollection","_ConceptDetailModel","_AttributeContent","ChoiceAttributeOptionModel","BaseModel","constructor","selectedValues","arguments","length","undefined","option","referenceDate","DateUtil","now","_defineProperty2","default","code","contributions","key","_isSelected","_includes","call","_referenceDate","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","LinkCollection","_content","AttributeContent","content","_isUser","optionType","createFromListItemModel","listitem","id","toString","attributeCollection","clone","links","isChoiceAttributeOptionModel","getInitialChildModelLinks","initialLinks","hasContentFromData","conceptLink","push","children","setChildModels","models","conceptHref","href","concept","_find","model","selfhref","equalsWithParameters","_code","equals","getContribution","has","data","AttributeCollection","label","hasItems","title","getAttributeByLayoutHint","TITLE","readonlyvalue","first","getContentConfiguredLabel","contentConfiguration","configuredLabelProperties","labelConfig","types","_context","configuredLabels","_filter","getLabelElementByIds","configuredLabel","value","_context2","_map","configuredLabelProperty","some","_id","selected","count","ChoiceAttributeOptionCollection","create","options","date","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","avatarLink","_concept","ConceptDetailModel","level","isBooleanType","hasAlternativeLabel","mergeOption","withOption","mergeOptions","hasAllContentInData","isUser","_default","exports"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\nimport { has } from \"../../utils/helpers/objects\";\nimport { TIMEVERSION_FILTER_NAME } from \"../../constants/Constants\";\nimport { TITLE } from \"../../constants/LayoutHints\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\n\nimport LinkCollection from \"../links/LinkCollection\";\nimport AttributeCollection from \"./AttributeCollection\";\nimport ConceptDetailModel from \"../concepts/ConceptDetailModel\";\nimport AttributeContent from \"./AttributeContent\";\n\nimport type { IModelWithChildModels, ModularUIModel } from \"../types\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n */\nclass ChoiceAttributeOptionModel\n extends BaseModel\n implements IModelWithChildModels\n{\n _code: string;\n _isSelected: boolean;\n _referenceDate: ISO_DATE;\n _level: number;\n _children: ChoiceAttributeOptionCollection;\n _concept: ?ConceptDetailModel;\n _links: LinkCollection;\n _attributeCollection: AttributeCollection;\n _content: AttributeContent;\n _isUser: boolean = false;\n\n /**\n */\n constructor(\n selectedValues: Array<string> = [],\n option: Object = {},\n referenceDate: ISO_DATE = DateUtil.now(),\n ) {\n super({}, option);\n\n this.code = this.contributions.code ?? this.contributions.key ?? \"\";\n\n this._isSelected = selectedValues.includes(this.code);\n\n this._referenceDate = referenceDate;\n\n this._level = 0;\n\n this._attributeCollection = this.createAttributeCollection();\n this._children = this.addChildren(selectedValues, option, referenceDate);\n\n this._links = new LinkCollection(this.contributions._links);\n\n this._content = new AttributeContent(option.content);\n\n this._isUser = option.optionType === \"user\";\n }\n\n /**\n */\n static createFromListItemModel(\n listitem: ListItemModel,\n ): ChoiceAttributeOptionModel {\n const option = new ChoiceAttributeOptionModel();\n\n option.code = listitem.id.toString();\n option.attributeCollection = listitem.attributeCollection.clone();\n option.links = listitem.links.clone();\n\n return option;\n }\n\n /**\n * Indicates that this a choice attribute option model, used when adding options to a choice attribute\n * @returns {boolean}\n */\n get isChoiceAttributeOptionModel(): boolean {\n return true;\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const initialLinks = [];\n\n if (!this.hasContentFromData && this.conceptLink !== null) {\n initialLinks.push(this.conceptLink);\n }\n\n if (this.children) {\n initialLinks.push(...this.children.getInitialChildModelLinks());\n }\n\n return initialLinks;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n if (this.conceptLink !== null) {\n const conceptHref = this.conceptLink.href;\n\n this.concept = models.find((model) =>\n model.selfhref.equalsWithParameters(conceptHref),\n );\n }\n\n if (this.children) {\n this.children.setChildModels(models);\n }\n }\n\n /**\n * Get code of option\n */\n get code(): string {\n return this._code;\n }\n\n /**\n */\n set code(code: string) {\n this._code = code;\n }\n\n /**\n */\n equals(model: ChoiceAttributeOptionModel): boolean {\n return this.code.toString() === model.code.toString();\n }\n\n /**\n * Retrieve attributes for Composite codemaps (e.g. table and case list codemaps)\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 createAttributeCollection(): AttributeCollection {\n const contributions = this.getContribution(\"elementsContributions\", []);\n\n if (has(this.contributions, \"elements\")) {\n const data = this.getContribution(\"elements\", {});\n return new AttributeCollection(data, contributions, true);\n }\n\n return new AttributeCollection();\n }\n\n /**\n * Get label of option for simple codemaps (e.g. static codemap)\n */\n get label(): string {\n if (this.contributions.label) {\n return this.contributions.label;\n }\n\n if (this.attributeCollection.hasItems) {\n const title = this.attributeCollection.getAttributeByLayoutHint(TITLE);\n\n if (title) {\n return title.readonlyvalue;\n }\n\n if (this.attributeCollection.first) {\n return this.attributeCollection.first.readonlyvalue;\n }\n }\n\n return \"\";\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(contentConfiguration: Object): string {\n const configuredLabelProperties =\n contentConfiguration?.labelConfig?.[0]?.types ?? [];\n\n if (\n !this.hasContentFromData &&\n this.concept &&\n configuredLabelProperties.length > 0\n ) {\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 return 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 )[0].value;\n }\n }\n\n return this.label;\n }\n\n /**\n * Indicates if option is selected\n */\n get selected(): boolean {\n return this._isSelected;\n }\n\n /**\n * Set selected property of option\n */\n set selected(selected: boolean) {\n this._isSelected = selected;\n }\n\n /**\n * Retrieve count of filter for option\n */\n get count(): number | null {\n return this.getContribution(\"count\");\n }\n\n /**\n */\n addChildren(\n selectedValues: Array<string> = [],\n option: Object = {},\n referenceDate: ISO_DATE = DateUtil.now(),\n ): ChoiceAttributeOptionCollection {\n // When contributions contain elements this is a list not nested options\n if (has(option, \"elements\")) {\n return new ChoiceAttributeOptionCollection();\n }\n\n return ChoiceAttributeOptionCollection.create(\n {\n value: selectedValues,\n },\n { options: option?.children ?? [] },\n referenceDate,\n );\n }\n\n /**\n * get children of option\n */\n get children(): ChoiceAttributeOptionCollection {\n return this._children;\n }\n\n /**\n * Retrieve links of attribute\n */\n get links(): LinkCollection {\n return this._links;\n }\n\n /**\n */\n set links(links: LinkCollection) {\n this._links = links;\n }\n\n /**\n * referenceDate received from attribute\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this._referenceDate = date;\n }\n\n /**\n * Retrieve concept link of attribute when available\n */\n get conceptLink(): LinkModel | null {\n const conceptLink = this.links.getLinkByKey(\"concept\");\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 *\n */\n get avatarLink(): LinkModel | null {\n return this.links.getLinkByKey(\"avatar\");\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 * Get level of option, used in tree view choice attributes (taxonomy)\n */\n get level(): number {\n return this._level;\n }\n\n /**\n * Set level of option\n */\n set level(level: number) {\n this._level = level;\n }\n\n /**\n */\n get isBooleanType(): boolean {\n return this.getContribution(\"isBooleanType\", false);\n }\n\n /**\n */\n get hasAlternativeLabel(): boolean {\n return this.getContribution(\"hasAlternativeLabel\", false);\n }\n\n /**\n */\n mergeOption(withOption: ChoiceAttributeOptionModel) {\n this.concept = withOption.concept;\n\n if (this.children != null && withOption.children != null) {\n this.children.mergeOptions(withOption.children);\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 this._content;\n }\n\n /**\n */\n get isUser(): boolean {\n return this._isUser;\n }\n}\n\nexport default ChoiceAttributeOptionModel;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gCAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAEA,IAAAO,eAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,oBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,mBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,iBAAA,GAAAX,sBAAA,CAAAC,OAAA;AAMA;AACA;AACA,MAAMW,0BAA0B,SACtBC,kBAAS,CAEnB;EAYE;AACF;EACEC,WAAWA,CAAA,EAIT;IAAA,IAHAC,cAA6B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IAClCG,MAAc,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IACnBI,aAAuB,GAAAJ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGK,sBAAQ,CA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ACrD;;EAEA;AACF;EACE,IAAI0C,mBAAmBA,CAAA,EAAY;IACjC,OAAO,IAAI,CAAC1C,eAAe,CAAC,qBAAqB,EAAE,KAAK,CAAC;EAC3D;;EAEA;AACF;EACE2C,WAAWA,CAACC,UAAsC,EAAE;IAClD,IAAI,CAACnD,OAAO,GAAGmD,UAAU,CAACnD,OAAO;IAEjC,IAAI,IAAI,CAACL,QAAQ,IAAI,IAAI,IAAIwD,UAAU,CAACxD,QAAQ,IAAI,IAAI,EAAE;MACxD,IAAI,CAACA,QAAQ,CAACyD,YAAY,CAACD,UAAU,CAACxD,QAAQ,CAAC;IACjD;EACF;;EAEA;AACF;AACA;EACE,IAAIH,kBAAkBA,CAAA,EAAY;IAChC,OAAO,IAAA6D,6BAAmB,EAAC,CAAC;EAC9B;;EAEA;AACF;EACE,IAAI1E,OAAOA,CAAA,EAAqB;IAC9B,OAAO,IAAI,CAACF,QAAQ;EACtB;;EAEA;AACF;EACE,IAAI6E,MAAMA,CAAA,EAAY;IACpB,OAAO,IAAI,CAAC1E,OAAO;EACrB;AACF;AAAC,IAAA2E,QAAA,GAAAC,OAAA,CAAA9F,OAAA,GAEcZ,0BAA0B","ignoreList":[]}
@@ -677,4 +677,31 @@ describe("choiceAttributeModel", () => {
677
677
  "answer-option-key": "book-label",
678
678
  });
679
679
  });
680
+
681
+ it("sets isUser on options where attribute has optionType user", () => {
682
+ const data = {
683
+ key: "Users",
684
+ value: [],
685
+ };
686
+
687
+ const contributions = {
688
+ label: "Users",
689
+ type: "choice",
690
+ optionType: "user",
691
+ options: [
692
+ {
693
+ code: "user1",
694
+ label: "User 1",
695
+ },
696
+ {
697
+ code: "user2",
698
+ label: "User 2",
699
+ },
700
+ ],
701
+ };
702
+
703
+ const attribute = new ChoiceAttributeModel(data, contributions);
704
+
705
+ expect(attribute.options.first.isUser).toBe(true);
706
+ });
680
707
  });
@@ -178,9 +178,7 @@ class DetailModel extends _ResourceModel.default {
178
178
  */
179
179
  get avatarForTitleAttribute() {
180
180
  var _context5;
181
- const avatarAttributes = (0, _filter.default)(_context5 = this._attributeCollection.all).call(_context5, attribute => attribute.layouthint.hasExact(_LayoutHints.AVATAR));
182
- const avatarForTitleAttribute = (0, _find.default)(avatarAttributes).call(avatarAttributes, attribute => attribute.layouthint.hasExact(_LayoutHints.AVATAR_IN_TITLE));
183
- return avatarForTitleAttribute || null;
181
+ return (0, _find.default)(_context5 = this._attributeCollection).call(_context5, attribute => attribute.layouthint.hasExact(_LayoutHints.AVATAR_IN_TITLE) && attribute.layouthint.hasExact(_LayoutHints.AVATAR));
184
182
  }
185
183
 
186
184
  /**
@@ -188,9 +186,7 @@ class DetailModel extends _ResourceModel.default {
188
186
  */
189
187
  get titleAttribute() {
190
188
  var _context6;
191
- const nonAvatarAttributes = (0, _filter.default)(_context6 = this._attributeCollection.all).call(_context6, attribute => !attribute.layouthint.hasExact(_LayoutHints.AVATAR));
192
- const titleAttribute = (0, _find.default)(nonAvatarAttributes).call(nonAvatarAttributes, attribute => attribute.layouthint.has(_LayoutHints.TITLE));
193
- return titleAttribute || null;
189
+ return (0, _find.default)(_context6 = this._attributeCollection).call(_context6, attribute => attribute.layouthint.has(_LayoutHints.TITLE) && !attribute.layouthint.hasExact(_LayoutHints.AVATAR));
194
190
  }
195
191
 
196
192
  /**
@@ -196,30 +196,22 @@ export default class DetailModel extends ResourceModel {
196
196
  * Getting the attribute that has as layout hint 'avatar-for-title'
197
197
  */
198
198
  get avatarForTitleAttribute(): ?AttributeType {
199
- const avatarAttributes = this._attributeCollection.all.filter((attribute) =>
200
- attribute.layouthint.hasExact(AVATAR),
199
+ return this._attributeCollection.find(
200
+ (attribute) =>
201
+ attribute.layouthint.hasExact(AVATAR_IN_TITLE) &&
202
+ attribute.layouthint.hasExact(AVATAR),
201
203
  );
202
-
203
- const avatarForTitleAttribute = avatarAttributes.find((attribute) =>
204
- attribute.layouthint.hasExact(AVATAR_IN_TITLE),
205
- );
206
-
207
- return avatarForTitleAttribute || null;
208
204
  }
209
205
 
210
206
  /**
211
207
  * Getting the attribute that has as layout hint 'title'
212
208
  */
213
209
  get titleAttribute(): ?AttributeType {
214
- const nonAvatarAttributes = this._attributeCollection.all.filter(
215
- (attribute) => !attribute.layouthint.hasExact(AVATAR),
210
+ return this._attributeCollection.find(
211
+ (attribute) =>
212
+ attribute.layouthint.has(TITLE) &&
213
+ !attribute.layouthint.hasExact(AVATAR),
216
214
  );
217
-
218
- const titleAttribute = nonAvatarAttributes.find((attribute) =>
219
- attribute.layouthint.has(TITLE),
220
- );
221
-
222
- return titleAttribute || null;
223
215
  }
224
216
 
225
217
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"DetailModel.js","names":["_objects","require","_ActionCollection","_interopRequireDefault","_AttributeCollection","_ResourceModel","_LayoutHints","DetailModel","ResourceModel","constructor","modularuiResponse","_defineProperty2","default","createAttributeCollection","createMetadataCollection","createActionCollection","type","modelName","isApplicableModel","data","_context","resourceType","contributions","resourcetype","_endsWith","call","_includes","getInitialChildModelLinks","_attributeCollection","setChildModels","models","id","getData","key","label","getContribution","_context2","attributeContributions","attributes","_filter","contribution","_keys","has","attributeCollection","AttributeCollection","collection","_context3","all","attribute","hasTitle","layouthint","hasExact","TITLE","hasAvatar","AVATAR","hasAvatarForTitle","AVATAR_IN_TITLE","isHidden","getAttributeByKey","_context4","metadataContributions","metadata","_map","metadataKey","metadataCollection","_metadataCollection","_actionCollection","ActionCollection","actions","actionCollection","isCase","avatarForTitleAttribute","_context5","avatarAttributes","_find","titleAttribute","_context6","nonAvatarAttributes","update","model","clonedModel","clone","equals","toString","exports"],"sources":["../../../src/models/detail/DetailModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport { AVATAR, AVATAR_IN_TITLE, TITLE } from \"../../constants/LayoutHints\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type { ModularUIModel, AttributeType } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Base class for details<br/>\n * For instance the details of case 1<br/>\n * For instance the details of record 12<br/>\n */\nexport default class DetailModel extends ResourceModel {\n _attributeCollection: AttributeCollection;\n _metadataCollection: AttributeCollection;\n _actionCollection: ActionCollection;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this.createAttributeCollection();\n this.createMetadataCollection();\n this.createActionCollection();\n }\n\n /**\n */\n get type(): string {\n return \"Detail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"DetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourceType = data.contributions?.resourcetype;\n return (\n resourceType &&\n (resourceType.endsWith(\"DetailPanel\") ||\n [\"Detail\", \"CasePropertiesPanel\", \"CasePropertiesPanelDetail\"].includes(\n resourceType,\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 * Getting the unique identifier of the details\n */\n get id(): string {\n return this.getData(\"_id\", this.key);\n }\n\n /**\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Attribute collection\n */\n createAttributeCollection() {\n const attributeContributions = this.contributions.attributes\n ? this.contributions.attributes.filter((contribution) => {\n const [key] = Object.keys(contribution);\n return has(this.data, key);\n })\n : [];\n\n this.attributeCollection = new AttributeCollection(\n this.data,\n attributeContributions,\n true,\n );\n }\n\n /**\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(collection: AttributeCollection) {\n this._attributeCollection = collection;\n }\n\n /**\n * Retrieve list of visible attributes\n */\n get attributes(): Array<AttributeType> {\n return this.attributeCollection.all.filter((attribute) => {\n const hasTitle = attribute.layouthint.hasExact(TITLE);\n const hasAvatar = attribute.layouthint.hasExact(AVATAR);\n const hasAvatarForTitle = attribute.layouthint.hasExact(AVATAR_IN_TITLE);\n return (\n !attribute.isHidden &&\n (!hasTitle || (hasTitle && hasAvatar)) &&\n (!hasAvatarForTitle || (hasAvatarForTitle && !hasAvatar))\n );\n });\n }\n\n /**\n * Retrieve an attribute by it's key\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this._attributeCollection.getAttributeByKey(key);\n }\n\n /**\n * Metadata collection\n */\n createMetadataCollection() {\n const metadataContributions = this.contributions.metadata\n ? Object.keys(this.contributions.metadata).map((metadataKey) => ({\n [metadataKey]: this.contributions.metadata[metadataKey],\n }))\n : [];\n\n this.metadataCollection = new AttributeCollection(\n this.data,\n metadataContributions,\n true,\n );\n }\n\n /**\n */\n get metadataCollection(): AttributeCollection {\n return this._metadataCollection;\n }\n\n /**\n */\n set metadataCollection(collection: AttributeCollection) {\n this._metadataCollection = collection;\n }\n\n /**\n * Action collection\n */\n createActionCollection() {\n this._actionCollection = new ActionCollection(\n this.data.actions,\n this.contributions.actions,\n );\n }\n\n /**\n */\n get actionCollection(): ActionCollection {\n return this._actionCollection;\n }\n\n /**\n */\n set actionCollection(actionCollection: ActionCollection) {\n this._actionCollection = actionCollection;\n }\n\n /**\n * Determines if this is a case\n */\n get isCase(): boolean {\n return this.contributions.resourcetype === \"CaseView\";\n }\n\n /**\n * Getting the attribute that has as layout hint 'avatar-for-title'\n */\n get avatarForTitleAttribute(): ?AttributeType {\n const avatarAttributes = this._attributeCollection.all.filter((attribute) =>\n attribute.layouthint.hasExact(AVATAR),\n );\n\n const avatarForTitleAttribute = avatarAttributes.find((attribute) =>\n attribute.layouthint.hasExact(AVATAR_IN_TITLE),\n );\n\n return avatarForTitleAttribute || null;\n }\n\n /**\n * Getting the attribute that has as layout hint 'title'\n */\n get titleAttribute(): ?AttributeType {\n const nonAvatarAttributes = this._attributeCollection.all.filter(\n (attribute) => !attribute.layouthint.hasExact(AVATAR),\n );\n\n const titleAttribute = nonAvatarAttributes.find((attribute) =>\n attribute.layouthint.has(TITLE),\n );\n\n return titleAttribute || null;\n }\n\n /**\n * Update current detail with a new detail model and return a cloned version of the model\n */\n update(model: ModularUIModel): DetailModel {\n if (model instanceof DetailModel) {\n const clonedModel = this.clone();\n\n clonedModel.attributeCollection = model._attributeCollection;\n clonedModel.metadataCollection = model._metadataCollection;\n clonedModel.actionCollection = model._actionCollection;\n\n return clonedModel;\n }\n\n return this;\n }\n\n /**\n */\n equals(model: DetailModel): boolean {\n return this.id.toString() === model.id.toString();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,cAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AAMA;AACA;AACA;AACA;AACA;AACe,MAAMM,WAAW,SAASC,sBAAa,CAAC;EAKrD;AACF;EACEC,WAAWA,CAACC,iBAAoC,EAAE;IAChD,KAAK,CAACA,iBAAiB,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEzB,IAAI,CAACC,yBAAyB,CAAC,CAAC;IAChC,IAAI,CAACC,wBAAwB,CAAC,CAAC;IAC/B,IAAI,CAACC,sBAAsB,CAAC,CAAC;EAC/B;;EAEA;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,QAAQ;EACjB;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,aAAa;EACtB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IAAA,IAAAC,QAAA;IACzD,MAAMC,YAAY,GAAGF,IAAI,CAACG,aAAa,EAAEC,YAAY;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OAAA,CAAAxE,OAAA,GAAAL,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"DetailModel.js","names":["_objects","require","_ActionCollection","_interopRequireDefault","_AttributeCollection","_ResourceModel","_LayoutHints","DetailModel","ResourceModel","constructor","modularuiResponse","_defineProperty2","default","createAttributeCollection","createMetadataCollection","createActionCollection","type","modelName","isApplicableModel","data","_context","resourceType","contributions","resourcetype","_endsWith","call","_includes","getInitialChildModelLinks","_attributeCollection","setChildModels","models","id","getData","key","label","getContribution","_context2","attributeContributions","attributes","_filter","contribution","_keys","has","attributeCollection","AttributeCollection","collection","_context3","all","attribute","hasTitle","layouthint","hasExact","TITLE","hasAvatar","AVATAR","hasAvatarForTitle","AVATAR_IN_TITLE","isHidden","getAttributeByKey","_context4","metadataContributions","metadata","_map","metadataKey","metadataCollection","_metadataCollection","_actionCollection","ActionCollection","actions","actionCollection","isCase","avatarForTitleAttribute","_context5","_find","titleAttribute","_context6","update","model","clonedModel","clone","equals","toString","exports"],"sources":["../../../src/models/detail/DetailModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport { AVATAR, AVATAR_IN_TITLE, TITLE } from \"../../constants/LayoutHints\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type { ModularUIModel, AttributeType } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Base class for details<br/>\n * For instance the details of case 1<br/>\n * For instance the details of record 12<br/>\n */\nexport default class DetailModel extends ResourceModel {\n _attributeCollection: AttributeCollection;\n _metadataCollection: AttributeCollection;\n _actionCollection: ActionCollection;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this.createAttributeCollection();\n this.createMetadataCollection();\n this.createActionCollection();\n }\n\n /**\n */\n get type(): string {\n return \"Detail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"DetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourceType = data.contributions?.resourcetype;\n return (\n resourceType &&\n (resourceType.endsWith(\"DetailPanel\") ||\n [\"Detail\", \"CasePropertiesPanel\", \"CasePropertiesPanelDetail\"].includes(\n resourceType,\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 * Getting the unique identifier of the details\n */\n get id(): string {\n return this.getData(\"_id\", this.key);\n }\n\n /**\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Attribute collection\n */\n createAttributeCollection() {\n const attributeContributions = this.contributions.attributes\n ? this.contributions.attributes.filter((contribution) => {\n const [key] = Object.keys(contribution);\n return has(this.data, key);\n })\n : [];\n\n this.attributeCollection = new AttributeCollection(\n this.data,\n attributeContributions,\n true,\n );\n }\n\n /**\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(collection: AttributeCollection) {\n this._attributeCollection = collection;\n }\n\n /**\n * Retrieve list of visible attributes\n */\n get attributes(): Array<AttributeType> {\n return this.attributeCollection.all.filter((attribute) => {\n const hasTitle = attribute.layouthint.hasExact(TITLE);\n const hasAvatar = attribute.layouthint.hasExact(AVATAR);\n const hasAvatarForTitle = attribute.layouthint.hasExact(AVATAR_IN_TITLE);\n return (\n !attribute.isHidden &&\n (!hasTitle || (hasTitle && hasAvatar)) &&\n (!hasAvatarForTitle || (hasAvatarForTitle && !hasAvatar))\n );\n });\n }\n\n /**\n * Retrieve an attribute by it's key\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this._attributeCollection.getAttributeByKey(key);\n }\n\n /**\n * Metadata collection\n */\n createMetadataCollection() {\n const metadataContributions = this.contributions.metadata\n ? Object.keys(this.contributions.metadata).map((metadataKey) => ({\n [metadataKey]: this.contributions.metadata[metadataKey],\n }))\n : [];\n\n this.metadataCollection = new AttributeCollection(\n this.data,\n metadataContributions,\n true,\n );\n }\n\n /**\n */\n get metadataCollection(): AttributeCollection {\n return this._metadataCollection;\n }\n\n /**\n */\n set metadataCollection(collection: AttributeCollection) {\n this._metadataCollection = collection;\n }\n\n /**\n * Action collection\n */\n createActionCollection() {\n this._actionCollection = new ActionCollection(\n this.data.actions,\n this.contributions.actions,\n );\n }\n\n /**\n */\n get actionCollection(): ActionCollection {\n return this._actionCollection;\n }\n\n /**\n */\n set actionCollection(actionCollection: ActionCollection) {\n this._actionCollection = actionCollection;\n }\n\n /**\n * Determines if this is a case\n */\n get isCase(): boolean {\n return this.contributions.resourcetype === \"CaseView\";\n }\n\n /**\n * Getting the attribute that has as layout hint 'avatar-for-title'\n */\n get avatarForTitleAttribute(): ?AttributeType {\n return this._attributeCollection.find(\n (attribute) =>\n attribute.layouthint.hasExact(AVATAR_IN_TITLE) &&\n attribute.layouthint.hasExact(AVATAR),\n );\n }\n\n /**\n * Getting the attribute that has as layout hint 'title'\n */\n get titleAttribute(): ?AttributeType {\n return this._attributeCollection.find(\n (attribute) =>\n attribute.layouthint.has(TITLE) &&\n !attribute.layouthint.hasExact(AVATAR),\n );\n }\n\n /**\n * Update current detail with a new detail model and return a cloned version of the model\n */\n update(model: ModularUIModel): DetailModel {\n if (model instanceof DetailModel) {\n const clonedModel = this.clone();\n\n clonedModel.attributeCollection = model._attributeCollection;\n clonedModel.metadataCollection = model._metadataCollection;\n clonedModel.actionCollection = model._actionCollection;\n\n return clonedModel;\n }\n\n return this;\n }\n\n /**\n */\n equals(model: DetailModel): boolean {\n return this.id.toString() === model.id.toString();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAD,sBAAA,CAAAF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jD,oBAAoB;MAC5DkD,WAAW,CAACd,kBAAkB,GAAGa,KAAK,CAACZ,mBAAmB;MAC1Da,WAAW,CAACT,gBAAgB,GAAGQ,KAAK,CAACX,iBAAiB;MAEtD,OAAOY,WAAW;IACpB;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACEE,MAAMA,CAACH,KAAkB,EAAW;IAClC,OAAO,IAAI,CAAC9C,EAAE,CAACkD,QAAQ,CAAC,CAAC,KAAKJ,KAAK,CAAC9C,EAAE,CAACkD,QAAQ,CAAC,CAAC;EACnD;AACF;AAACC,OAAA,CAAAtE,OAAA,GAAAL,WAAA","ignoreList":[]}
@@ -31,7 +31,7 @@ export default class UserModel extends ResourceModel {
31
31
  /**
32
32
  * Retrieve username of user
33
33
  */
34
- get avatar(): string {
34
+ get avatar(): string | null {
35
35
  return this.data.Avatar;
36
36
  }
37
37
 
@@ -1 +1 @@
1
- {"version":3,"file":"UserModel.js","names":["_ResourceModel","_interopRequireDefault","require","UserModel","ResourceModel","type","modelName","isApplicableModel","data","contributions","resourcetype","avatar","Avatar","username","Username","fullname","Fullname","label","exports","default"],"sources":["../../../src/models/user/UserModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * User model\n */\nexport default class UserModel extends ResourceModel {\n /**\n */\n get type(): string {\n return \"User\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"UserModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"userdata\"\n );\n }\n\n /**\n * Retrieve username of user\n */\n get avatar(): string {\n return this.data.Avatar;\n }\n\n /**\n * Retrieve username of user\n */\n get username(): string {\n return this.data.Username || \"Guest\";\n }\n\n /**\n * retrieve the fullname of the user\n */\n get fullname(): string {\n return this.data.Fullname || \"Guest\";\n }\n\n /**\n */\n get label(): string {\n return this.contributions.label;\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACe,MAAMC,SAAS,SAASC,sBAAa,CAAC;EACnD;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,MAAM;EACf;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,WAAW;EACpB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aAAa,CAACC,YAAY,KAAK,UAAU;EAElD;;EAEA;AACF;AACA;EACE,IAAIC,MAAMA,CAAA,EAAW;IACnB,OAAO,IAAI,CAACH,IAAI,CAACI,MAAM;EACzB;;EAEA;AACF;AACA;EACE,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACL,IAAI,CAACM,QAAQ,IAAI,OAAO;EACtC;;EAEA;AACF;AACA;EACE,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACP,IAAI,CAACQ,QAAQ,IAAI,OAAO;EACtC;;EAEA;AACF;EACE,IAAIC,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACR,aAAa,CAACQ,KAAK;EACjC;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAhB,SAAA","ignoreList":[]}
1
+ {"version":3,"file":"UserModel.js","names":["_ResourceModel","_interopRequireDefault","require","UserModel","ResourceModel","type","modelName","isApplicableModel","data","contributions","resourcetype","avatar","Avatar","username","Username","fullname","Fullname","label","exports","default"],"sources":["../../../src/models/user/UserModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * User model\n */\nexport default class UserModel extends ResourceModel {\n /**\n */\n get type(): string {\n return \"User\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"UserModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"userdata\"\n );\n }\n\n /**\n * Retrieve username of user\n */\n get avatar(): string | null {\n return this.data.Avatar;\n }\n\n /**\n * Retrieve username of user\n */\n get username(): string {\n return this.data.Username || \"Guest\";\n }\n\n /**\n * retrieve the fullname of the user\n */\n get fullname(): string {\n return this.data.Fullname || \"Guest\";\n }\n\n /**\n */\n get label(): string {\n return this.contributions.label;\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACe,MAAMC,SAAS,SAASC,sBAAa,CAAC;EACnD;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,MAAM;EACf;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,WAAW;EACpB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aAAa,CAACC,YAAY,KAAK,UAAU;EAElD;;EAEA;AACF;AACA;EACE,IAAIC,MAAMA,CAAA,EAAkB;IAC1B,OAAO,IAAI,CAACH,IAAI,CAACI,MAAM;EACzB;;EAEA;AACF;AACA;EACE,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACL,IAAI,CAACM,QAAQ,IAAI,OAAO;EACtC;;EAEA;AACF;AACA;EACE,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACP,IAAI,CAACQ,QAAQ,IAAI,OAAO;EACtC;;EAEA;AACF;EACE,IAAIC,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACR,aAAa,CAACQ,KAAK;EACjC;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAhB,SAAA","ignoreList":[]}