@beinformed/ui 1.27.5 → 1.27.6

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 (80) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/esm/hooks/useForm.js.map +1 -1
  3. package/esm/models/attributes/ChoiceAttributeModel.js +1 -0
  4. package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
  5. package/esm/models/attributes/ChoiceAttributeOptionModel.js +2 -2
  6. package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  7. package/esm/redux/_modularui/ModularUIActions.js +7 -0
  8. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  9. package/esm/redux/_modularui/ModularUIReducer.js +1 -0
  10. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  11. package/esm/redux/_modularui/types.js.map +1 -1
  12. package/esm/redux/actions/Form.js +2 -2
  13. package/esm/redux/actions/Form.js.map +1 -1
  14. package/esm/redux/actions/FormAttributeSet.js +2 -2
  15. package/esm/redux/actions/FormAttributeSet.js.map +1 -1
  16. package/esm/redux/actions/FormAttributeSetRepeatable.js +4 -4
  17. package/esm/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
  18. package/esm/redux/actions/FormAutosave.js +2 -2
  19. package/esm/redux/actions/FormAutosave.js.map +1 -1
  20. package/esm/redux/actions/FormValidations.js +2 -2
  21. package/esm/redux/actions/FormValidations.js.map +1 -1
  22. package/esm/redux/connectors/Form.js.map +1 -1
  23. package/esm/redux/connectors/FormAttributeSet.js.map +1 -1
  24. package/esm/redux/types.js.map +1 -1
  25. package/lib/hooks/__tests__/useForm.spec.js.flow +4 -4
  26. package/lib/hooks/useForm.js.flow +5 -5
  27. package/lib/hooks/useForm.js.map +1 -1
  28. package/lib/models/attributes/ChoiceAttributeModel.js +1 -0
  29. package/lib/models/attributes/ChoiceAttributeModel.js.flow +1 -0
  30. package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
  31. package/lib/models/attributes/ChoiceAttributeOptionModel.js +2 -2
  32. package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +2 -2
  33. package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  34. package/lib/redux/_modularui/ModularUIActions.js +9 -1
  35. package/lib/redux/_modularui/ModularUIActions.js.flow +8 -0
  36. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  37. package/lib/redux/_modularui/ModularUIReducer.js +1 -0
  38. package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
  39. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  40. package/lib/redux/_modularui/types.js.flow +5 -0
  41. package/lib/redux/_modularui/types.js.map +1 -1
  42. package/lib/redux/actions/Form.js +1 -1
  43. package/lib/redux/actions/Form.js.flow +4 -4
  44. package/lib/redux/actions/Form.js.map +1 -1
  45. package/lib/redux/actions/FormAttributeSet.js +1 -1
  46. package/lib/redux/actions/FormAttributeSet.js.flow +3 -2
  47. package/lib/redux/actions/FormAttributeSet.js.map +1 -1
  48. package/lib/redux/actions/FormAttributeSetRepeatable.js +3 -3
  49. package/lib/redux/actions/FormAttributeSetRepeatable.js.flow +8 -8
  50. package/lib/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
  51. package/lib/redux/actions/FormAutosave.js +1 -1
  52. package/lib/redux/actions/FormAutosave.js.flow +2 -2
  53. package/lib/redux/actions/FormAutosave.js.map +1 -1
  54. package/lib/redux/actions/FormValidations.js +1 -1
  55. package/lib/redux/actions/FormValidations.js.flow +2 -2
  56. package/lib/redux/actions/FormValidations.js.map +1 -1
  57. package/lib/redux/actions/__tests__/Form.spec.js.flow +1 -1
  58. package/lib/redux/connectors/Form.js.flow +2 -5
  59. package/lib/redux/connectors/Form.js.map +1 -1
  60. package/lib/redux/connectors/FormAttributeSet.js.flow +5 -5
  61. package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
  62. package/lib/redux/types.js.flow +2 -0
  63. package/lib/redux/types.js.map +1 -1
  64. package/package.json +1 -1
  65. package/src/hooks/__tests__/useForm.spec.js +4 -4
  66. package/src/hooks/useForm.js +5 -5
  67. package/src/models/attributes/ChoiceAttributeModel.js +1 -0
  68. package/src/models/attributes/ChoiceAttributeOptionModel.js +2 -2
  69. package/src/redux/_modularui/ModularUIActions.js +8 -0
  70. package/src/redux/_modularui/ModularUIReducer.js +1 -0
  71. package/src/redux/_modularui/types.js +5 -0
  72. package/src/redux/actions/Form.js +4 -4
  73. package/src/redux/actions/FormAttributeSet.js +3 -2
  74. package/src/redux/actions/FormAttributeSetRepeatable.js +8 -8
  75. package/src/redux/actions/FormAutosave.js +2 -2
  76. package/src/redux/actions/FormValidations.js +2 -2
  77. package/src/redux/actions/__tests__/Form.spec.js +1 -1
  78. package/src/redux/connectors/Form.js +2 -5
  79. package/src/redux/connectors/FormAttributeSet.js +5 -5
  80. package/src/redux/types.js +2 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.27.6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.27.5...v1.27.6) (2023-02-07)
6
+
7
+ ### Bug Fixes
8
+
9
+ - **redux:** introduce updateForm action for easier debugging ([7e1550b](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/7e1550b6ed8b082a9e87ccdf84067462f6a36cc1))
10
+
5
11
  ### [1.27.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.27.4...v1.27.5) (2023-02-07)
6
12
 
7
13
  ### Bug Fixes
@@ -1 +1 @@
1
- {"version":3,"file":"useForm.js","names":["useDispatch","Href","getSetting","HTTP_METHODS","loadModularUI","removeModelByKey","useModularUI","addRepeatableAttributeSet","cancelForm","cancelRepeatableAttributeSet","previousObject","removeRepeatableAttributeSet","showFormNotification","updateFormAttribute","FormModel","useForm","href","formHref","addParameter","form","method","POST","targetModel","removeOnUnmount","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","data","formdata","updateModel","remove","showFormNotificationAction","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { FormObjectModel, AttributeType } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\nimport type {\n RemoveModelByKeyAction,\n UpdateModelAction,\n} from \"../redux/_modularui\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateModelAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateModelAction,\n cancel: (object: FormObjectModel) => UpdateModelAction,\n remove: (object: FormObjectModel) => UpdateModelAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateModel: form,\n targetModel: FormModel,\n })\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Update attributes of a form\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,OAAOC,IAAI,MAAM,qBAAqB;AAEtC,SAASC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AAEvD,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,qBAAqB;AACrE,SAASC,YAAY,QAAQ,gBAAgB;AAE7C,SACEC,yBAAyB,EACzBC,UAAU,EACVC,4BAA4B,EAC5BC,cAAc,EACdC,4BAA4B,EAC5BC,oBAAoB,EACpBC,mBAAmB,QACd,kBAAkB;AAEzB,OAAOC,SAAS,MAAM,0BAA0B;AA6BhD;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAIC,IAAmB,IAAiB;EAC1D,MAAMC,QAAQ,GAAG,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AC;AACH,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAG,CAChClB,IAAe,EACfmB,MAAuB,KACC;EACxB,MAAMZ,QAAQ,GAAG1B,WAAW,EAAE;EAE9B,OAAO,CACLuC,SAAwB,EACxBC,KAAa,EACbC,OAA0B,KACvBf,QAAQ,CAACb,mBAAmB,CAACM,IAAI,EAAEmB,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAAC;AAC7E,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAIvB,IAAe,IAAuB;EACpE,MAAMO,QAAQ,GAAG1B,WAAW,EAAE;EAE9B,OAAO;IACL2C,IAAI,EAAE,MAAMjB,QAAQ,CAACnB,yBAAyB,CAACY,IAAI,CAAC,CAAC;IACrDS,MAAM,EAAGU,MAAuB,IAC9BZ,QAAQ,CAACjB,4BAA4B,CAACU,IAAI,EAAEmB,MAAM,CAAC,CAAC;IACtDH,MAAM,EAAGG,MAAuB,IAC9BZ,QAAQ,CAACf,4BAA4B,CAACQ,IAAI,EAAEmB,MAAM,CAAC;EACvD,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"useForm.js","names":["useDispatch","Href","getSetting","HTTP_METHODS","loadModularUI","removeModelByKey","useModularUI","addRepeatableAttributeSet","cancelForm","cancelRepeatableAttributeSet","previousObject","removeRepeatableAttributeSet","showFormNotification","updateFormAttribute","FormModel","useForm","href","formHref","addParameter","form","method","POST","targetModel","removeOnUnmount","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","data","formdata","updateModel","remove","showFormNotificationAction","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { FormObjectModel, AttributeType } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\nimport type {\n RemoveModelByKeyAction,\n UpdateFormAction,\n} from \"../redux/_modularui\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateFormAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateFormAction,\n cancel: (object: FormObjectModel) => UpdateFormAction,\n remove: (object: FormObjectModel) => UpdateFormAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateModel: form,\n targetModel: FormModel,\n })\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Update attributes of a form\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,OAAOC,IAAI,MAAM,qBAAqB;AAEtC,SAASC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AAEvD,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,qBAAqB;AACrE,SAASC,YAAY,QAAQ,gBAAgB;AAE7C,SACEC,yBAAyB,EACzBC,UAAU,EACVC,4BAA4B,EAC5BC,cAAc,EACdC,4BAA4B,EAC5BC,oBAAoB,EACpBC,mBAAmB,QACd,kBAAkB;AAEzB,OAAOC,SAAS,MAAM,0BAA0B;AA6BhD;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAIC,IAAmB,IAAiB;EAC1D,MAAMC,QAAQ,GAAG,IAAIhB,IAAI,CAACe,IAAI,CAAC;EAE/B,IAAI,CAACd,UAAU,CAAC,oBAAoB,CAAC,EAAE;IACrCe,QAAQ,CAACC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;EAC1C;EAEA,MAAMC,IAAI,GAAGb,YAAY,CAAC,MAAM,EAAEW,QAAQ,EAAE;IAC1CG,MAAM,EAAEjB,YAAY,CAACkB,IAAI;IACzBC,WAAW,EAAER,SAAS;IACtBS,eAAe,EAAE;EACnB,CAAC,C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AED;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAIvB,IAAe,IAAuB;EACpE,MAAMO,QAAQ,GAAG1B,WAAW,EAAE;EAE9B,OAAO;IACL2C,IAAI,EAAE,MAAMjB,QAAQ,CAACnB,yBAAyB,CAACY,IAAI,CAAC,CAAC;IACrDS,MAAM,EAAGU,MAAuB,IAC9BZ,QAAQ,CAACjB,4BAA4B,CAACU,IAAI,EAAEmB,MAAM,CAAC,CAAC;IACtDH,MAAM,EAAGG,MAAuB,IAC9BZ,QAAQ,CAACf,4BAA4B,CAACQ,IAAI,EAAEmB,MAAM,CAAC;EACvD,CAAC;AACH,CAAC"}
@@ -263,6 +263,7 @@ export default class ChoiceAttributeModel extends AttributeModel {
263
263
  }
264
264
  values.forEach(val => {
265
265
  if (val instanceof ChoiceAttributeOptionModel) {
266
+ // option does not exist in existing options, add it. This can happen when lookup list has other options then lookup options
266
267
  if (!this.options.some(option => option.equals(val))) {
267
268
  this.options.add(val);
268
269
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceAttributeModel.js","names":["has","DateUtil","AttributeModel","ChoiceAttributeOptionCollection","ChoiceAttributeOptionModel","ContentConfigurationElements","RENDER_SECTION_LABEL","SORT_OPTIONS","ATTRIBUTE_WIDTH","ChoiceAttributeModel","constructor","attribute","attributeContributions","_referenceDate","getData","now","_options","create","referenceDate","layouthint","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","conceptLinkHref","href","concept","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","date","selected","option","code","readonlyvalue","join","initvalue","Array","isArray","_initvalue","length","getValue","hasValue","getInputValue","toggleOption","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","opt","choicetype","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","readonly","mergeOptions","isValid","update","value","updateLastModification","values","split","forEach","val","equals","add","toString","_hasContentConfiguration","contentConfiguration","content","optionElements","optionElementConfig","optionElement","contentElement","placeholder","addServerError","error","id","message","properties","ANSWER_OPTION_KEY","optionKey","foundOption","getContentConfiguredLabel","_errorCollection","readonlyWidth","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/ChoiceAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\nimport AttributeModel from \"./AttributeModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ContentConfigurationElements from \"../contentconfiguration/ContentConfigurationElements\";\n\nimport {\n RENDER_SECTION_LABEL,\n SORT_OPTIONS,\n} from \"../../constants/LayoutHints\";\nimport { ATTRIBUTE_WIDTH } from \"../../constants\";\n\nimport type { ModularUIModel, AttributeType, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Model for a choice attribute\n */\nexport default class ChoiceAttributeModel extends AttributeModel {\n _referenceDate: ISO_DATE;\n _options: ChoiceAttributeOptionCollection;\n _hasContentConfiguration: boolean;\n\n /**\n * Constructs a choice attribute\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n this._options = ChoiceAttributeOptionCollection.create(\n attribute,\n attributeContributions,\n this.referenceDate\n );\n\n if (this.layouthint.has(SORT_OPTIONS)) {\n this._options.sortOptions = true;\n }\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return (\n contributions.type !== \"composite\" &&\n contributions.type !== \"boolean\" &&\n (contributions.type === \"choice\" ||\n contributions.type === \"array\" ||\n has(contributions, \"enumerated\") ||\n has(contributions, \"options\"))\n );\n }\n\n /**\n */\n get type(): string {\n const optionMode = this.getContribution(\"optionMode\", \"\");\n const hasLookupLink = this.lookupLink || this.lookupListLink;\n\n if (\n optionMode === \"lookup\" ||\n (optionMode === \"dynamicWithThreshold\" && hasLookupLink)\n ) {\n return \"lookup\";\n }\n\n return \"choice\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const links = [];\n\n if (this.hasContentConfiguration) {\n if (!this.hasContentFromData && this.conceptLink) {\n links.push(this.conceptLink);\n }\n\n links.push(...this.options.getInitialChildModelLinks());\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const conceptLinkHref = this.conceptLink?.href;\n if (conceptLinkHref) {\n this.concept = models.find(\n (model) =>\n model.type === \"ConceptDetail\" &&\n model.selfhref.equalsWithParameters(conceptLinkHref)\n );\n }\n\n this.options.setChildModels(models);\n }\n\n /**\n * Retrieve lookup service link\n */\n get lookupLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupOptions\");\n }\n\n /**\n * Retrieve lookup service as list link\n */\n get lookupListLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupList\");\n }\n\n /**\n */\n get lookupListLabel(): string {\n return this.contributions.lookupList?.label ?? \"\";\n }\n\n /**\n * Retrieve reference date of attribute which can be used as entryDate for content\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n * Set reference date for concepts and content\n */\n set referenceDate(date: string) {\n this._referenceDate = date;\n\n this.options.referenceDate = date;\n }\n\n /**\n * Retrieve available choice options\n */\n get options(): ChoiceAttributeOptionCollection {\n return this._options;\n }\n\n /**\n * Getting all enabled options\n */\n get selected(): Array<string> {\n // $FlowFixMe[incompatible-call]\n return this.options.selected.map<string, ChoiceAttributeOptionModel>(\n (option: ChoiceAttributeOptionModel) => option.code\n );\n }\n\n /**\n * Flatten options and filter out the options that are not selected\n */\n get readonlyvalue(): string {\n return this.options.selected.map((option) => option.label).join(\", \");\n }\n\n /**\n */\n get initvalue(): any {\n if (Array.isArray(this._initvalue) && this._initvalue.length === 0) {\n return null;\n }\n\n return this._initvalue;\n }\n\n /**\n * Retrieve list of selected options, joined with comma\n */\n getValue(): string | null {\n return this.options.selected.length > 0\n ? this.options.selected.map((option) => option.code).join(\",\")\n : null;\n }\n\n /**\n */\n hasValue(): boolean {\n return this.options.selected.length > 0;\n }\n\n /**\n * Get input value of attribute\n */\n getInputValue(): string {\n return this.selected.join(\",\");\n }\n\n /**\n * Setting an option selected or unselected based on the current state\n */\n toggleOption(code: string) {\n if (this.selected.includes(code)) {\n this.disableOption(code);\n } else {\n this.enableOption(code);\n }\n }\n\n /**\n * Enable a option\n */\n enableOption(code: string) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n this.options.select(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Disable a option\n */\n disableOption(code: string) {\n this.options.deselect(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Add a new option to the collection of lookup options\n */\n addOption(option: Object) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n if (this.options.find((opt) => opt.code === option.code) === null) {\n this.options.addOption(option.code, option);\n }\n }\n\n /**\n * Getting the type of choice filter. For instance checkbox, radiobutton, combobox.\n */\n get choicetype():\n | \"checkbox\"\n | \"radiobutton\"\n | \"combobox\"\n | \"list\"\n | \"listview\"\n | \"table\"\n | \"longlist\"\n | \"toggle\" {\n return (\n [\n \"checkbox\",\n \"radiobutton\",\n \"combobox\",\n \"list\",\n \"listview\",\n \"table\",\n \"longlist\",\n \"toggle\",\n ].find((hint) => this.layouthint.has(hint)) || \"checkbox\"\n );\n }\n\n /**\n * Can multiple options be selected\n */\n get isMultiple(): boolean {\n return this.contributions.multiplechoice || this.choicetype === \"checkbox\";\n }\n\n /**\n * Check if options need to be rendered as tree\n */\n get isTree(): boolean {\n return (\n has(this.contributions, \"options\") &&\n this.contributions.options.some((option) => has(option, \"children\"))\n );\n }\n\n /**\n * Reset choice attribute to unselected list\n */\n reset() {\n this.options.deselectAll();\n }\n\n /**\n */\n mergeAttribute(oldAttribute: AttributeType) {\n // when attribute is readonly, don't merge the options no modifications necessary\n if (!this.readonly && oldAttribute instanceof ChoiceAttributeModel) {\n this.concept = oldAttribute.concept;\n this.options.mergeOptions(oldAttribute.options, this.type === \"lookup\");\n this.options.deselectAll();\n\n if (oldAttribute.isValid && oldAttribute.inputvalue !== null) {\n this.update(oldAttribute.inputvalue);\n }\n }\n }\n\n /**\n * Update attribute by name and value\n */\n update(value: any): ChoiceAttributeModel {\n if (this.readonly) {\n return this;\n }\n\n this.updateLastModification();\n\n let values;\n\n if (Array.isArray(value)) {\n values = value;\n } else if (typeof value === \"string\" && this.isMultiple) {\n values = value.split(\",\");\n } else {\n values = [value];\n }\n values.forEach((val) => {\n if (val instanceof ChoiceAttributeOptionModel) {\n if (!this.options.some((option) => option.equals(val))) {\n this.options.add(val);\n }\n\n this.toggleOption(val.code);\n } else if (\n typeof val === \"string\" &&\n this.options.some((option) => option.code.toString() === val)\n ) {\n this.toggleOption(val);\n }\n });\n\n return this;\n }\n\n /**\n */\n set hasContentConfiguration(hasContentConfiguration: boolean) {\n this._hasContentConfiguration =\n this.contentConfiguration !== null || hasContentConfiguration;\n }\n\n /**\n */\n get hasContentConfiguration(): boolean {\n return this._hasContentConfiguration;\n }\n\n /**\n * Get content configuration configured on the attribute.\n * Only applicable for taxonomy element and knowledge codemaps,\n * content configuration for instrument questions is available on the form object\n */\n get contentConfiguration(): ContentConfigurationElements | null {\n if (\n !this.contributions.content ||\n !this.contributions.content.optionElements\n ) {\n return null;\n }\n\n // Add RENDER_SECTION_LABEL to all content configuration to make sure the label of a section is always rendered on taxonomy and knowlege codemaps\n const optionElementConfig = this.contributions.content.optionElements.map(\n (optionElement) => {\n if (\"contentElement\" in optionElement) {\n return {\n contentElement: {\n ...optionElement.contentElement,\n layouthint: [RENDER_SECTION_LABEL],\n },\n };\n }\n\n return optionElement;\n }\n );\n\n return new ContentConfigurationElements(optionElementConfig);\n }\n\n /**\n * Get placeholder text\n */\n get placeholder(): string {\n return this.getContribution(\"placeholder\", \"\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, 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,SAASA,GAAG,QAAQ,6BAA6B;AACjD,SAASC,QAAQ,QAAQ,mCAAmC;AAE5D,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,+BAA+B,MAAM,mCAAmC;AAC/E,OAAOC,0BAA0B,MAAM,8BAA8B;AACrE,OAAOC,4BAA4B,MAAM,sDAAsD;AAE/F,SACEC,oBAAoB,EACpBC,YAAY,QACP,6BAA6B;AACpC,SAASC,eAAe,QAAQ,iBAAiB;AAKjD;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,SAASP,cAAc,CAAC;EAK/D;AACF;AACA;EACEQ,WAAW,CAACC,SAAiB,EAAEC,sBAA8B,EAAE;IAC7D,KAAK,CAACD,SAAS,EAAEC,sBAAsB,CAAC;IAAC;IAAA;IAAA;IAEzC,IAAI,CAACC,cAAc,GAAG,IAAI,CAACC,OAAO,CAAC,eAAe,EAAEb,QAAQ,CAACc,GAAG,EAAE,CAAC;IACnE,IAAI,CAACC,QAAQ,GAAGb,+BAA+B,CAACc,MAAM,CACpDN,SAAS,EACTC,sBAAsB,EACtB,IAAI,CAACM,aAAa,CACnB;IAED,IAAI,IAAI,CAACC,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AE7C,IAAID,UAAU,IAAIzG,GAAG,CAACyG,UAAU,EAAEC,iBAAiB,CAAC,EAAE;MAAA;MACpD,MAAMC,SAAS,GAAGF,UAAU,CAACC,iBAAiB,CAAC;MAC/C,MAAME,WAAW,GAAG,sCAAI,CAACzE,OAAO,kBAC7Be,MAAM,IAAKA,MAAM,CAACC,IAAI,KAAKwD,SAAS,CACtC;MACD,IAAIC,WAAW,EAAE;QACfH,UAAU,CAACC,iBAAiB,CAAC,GAAGE,WAAW,CAACC,yBAAyB,CACnE,IAAI,CAACf,oBAAoB,CAC1B;MACH;IACF;IAEA,IAAI,CAACgB,gBAAgB,CAACT,cAAc,CAACE,EAAE,EAAEC,OAAO,EAAEC,UAAU,EAAEtF,UAAU,CAAC;EAC3E;;EAEA;AACF;EACE,IAAI4F,aAAa,GAAkC;IACjD,IAAI,IAAI,CAACxF,IAAI,KAAK,QAAQ,EAAE;MAC1B,OAAOf,eAAe,CAACwG,KAAK;IAC9B;IAEA,OAAOxG,eAAe,CAACyG,MAAM;EAC/B;AACF"}
1
+ {"version":3,"file":"ChoiceAttributeModel.js","names":["has","DateUtil","AttributeModel","ChoiceAttributeOptionCollection","ChoiceAttributeOptionModel","ContentConfigurationElements","RENDER_SECTION_LABEL","SORT_OPTIONS","ATTRIBUTE_WIDTH","ChoiceAttributeModel","constructor","attribute","attributeContributions","_referenceDate","getData","now","_options","create","referenceDate","layouthint","sortOptions","isApplicableModel","contributions","type","optionMode","getContribution","hasLookupLink","lookupLink","lookupListLink","getInitialChildModelLinks","links","hasContentConfiguration","hasContentFromData","conceptLink","push","options","setChildModels","models","conceptLinkHref","href","concept","model","selfhref","equalsWithParameters","getLinkByKey","lookupListLabel","lookupList","label","date","selected","option","code","readonlyvalue","join","initvalue","Array","isArray","_initvalue","length","getValue","hasValue","getInputValue","toggleOption","disableOption","enableOption","isMultiple","deselectAll","select","inputvalue","deselect","addOption","opt","choicetype","hint","multiplechoice","isTree","some","reset","mergeAttribute","oldAttribute","readonly","mergeOptions","isValid","update","value","updateLastModification","values","split","forEach","val","equals","add","toString","_hasContentConfiguration","contentConfiguration","content","optionElements","optionElementConfig","optionElement","contentElement","placeholder","addServerError","error","id","message","properties","ANSWER_OPTION_KEY","optionKey","foundOption","getContentConfiguredLabel","_errorCollection","readonlyWidth","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/ChoiceAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\nimport AttributeModel from \"./AttributeModel\";\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ContentConfigurationElements from \"../contentconfiguration/ContentConfigurationElements\";\n\nimport {\n RENDER_SECTION_LABEL,\n SORT_OPTIONS,\n} from \"../../constants/LayoutHints\";\nimport { ATTRIBUTE_WIDTH } from \"../../constants\";\n\nimport type { ModularUIModel, AttributeType, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Model for a choice attribute\n */\nexport default class ChoiceAttributeModel extends AttributeModel {\n _referenceDate: ISO_DATE;\n _options: ChoiceAttributeOptionCollection;\n _hasContentConfiguration: boolean;\n\n /**\n * Constructs a choice attribute\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n this._options = ChoiceAttributeOptionCollection.create(\n attribute,\n attributeContributions,\n this.referenceDate\n );\n\n if (this.layouthint.has(SORT_OPTIONS)) {\n this._options.sortOptions = true;\n }\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return (\n contributions.type !== \"composite\" &&\n contributions.type !== \"boolean\" &&\n (contributions.type === \"choice\" ||\n contributions.type === \"array\" ||\n has(contributions, \"enumerated\") ||\n has(contributions, \"options\"))\n );\n }\n\n /**\n */\n get type(): string {\n const optionMode = this.getContribution(\"optionMode\", \"\");\n const hasLookupLink = this.lookupLink || this.lookupListLink;\n\n if (\n optionMode === \"lookup\" ||\n (optionMode === \"dynamicWithThreshold\" && hasLookupLink)\n ) {\n return \"lookup\";\n }\n\n return \"choice\";\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const links = [];\n\n if (this.hasContentConfiguration) {\n if (!this.hasContentFromData && this.conceptLink) {\n links.push(this.conceptLink);\n }\n\n links.push(...this.options.getInitialChildModelLinks());\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const conceptLinkHref = this.conceptLink?.href;\n if (conceptLinkHref) {\n this.concept = models.find(\n (model) =>\n model.type === \"ConceptDetail\" &&\n model.selfhref.equalsWithParameters(conceptLinkHref)\n );\n }\n\n this.options.setChildModels(models);\n }\n\n /**\n * Retrieve lookup service link\n */\n get lookupLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupOptions\");\n }\n\n /**\n * Retrieve lookup service as list link\n */\n get lookupListLink(): LinkModel | null {\n return this.links.getLinkByKey(\"lookupList\");\n }\n\n /**\n */\n get lookupListLabel(): string {\n return this.contributions.lookupList?.label ?? \"\";\n }\n\n /**\n * Retrieve reference date of attribute which can be used as entryDate for content\n */\n get referenceDate(): ISO_DATE {\n return this._referenceDate;\n }\n\n /**\n * Set reference date for concepts and content\n */\n set referenceDate(date: string) {\n this._referenceDate = date;\n\n this.options.referenceDate = date;\n }\n\n /**\n * Retrieve available choice options\n */\n get options(): ChoiceAttributeOptionCollection {\n return this._options;\n }\n\n /**\n * Getting all enabled options\n */\n get selected(): Array<string> {\n // $FlowFixMe[incompatible-call]\n return this.options.selected.map<string, ChoiceAttributeOptionModel>(\n (option: ChoiceAttributeOptionModel) => option.code\n );\n }\n\n /**\n * Flatten options and filter out the options that are not selected\n */\n get readonlyvalue(): string {\n return this.options.selected.map((option) => option.label).join(\", \");\n }\n\n /**\n */\n get initvalue(): any {\n if (Array.isArray(this._initvalue) && this._initvalue.length === 0) {\n return null;\n }\n\n return this._initvalue;\n }\n\n /**\n * Retrieve list of selected options, joined with comma\n */\n getValue(): string | null {\n return this.options.selected.length > 0\n ? this.options.selected.map((option) => option.code).join(\",\")\n : null;\n }\n\n /**\n */\n hasValue(): boolean {\n return this.options.selected.length > 0;\n }\n\n /**\n * Get input value of attribute\n */\n getInputValue(): string {\n return this.selected.join(\",\");\n }\n\n /**\n * Setting an option selected or unselected based on the current state\n */\n toggleOption(code: string) {\n if (this.selected.includes(code)) {\n this.disableOption(code);\n } else {\n this.enableOption(code);\n }\n }\n\n /**\n * Enable a option\n */\n enableOption(code: string) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n this.options.select(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Disable a option\n */\n disableOption(code: string) {\n this.options.deselect(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Add a new option to the collection of lookup options\n */\n addOption(option: Object) {\n if (!this.isMultiple) {\n this.options.deselectAll();\n }\n\n if (this.options.find((opt) => opt.code === option.code) === null) {\n this.options.addOption(option.code, option);\n }\n }\n\n /**\n * Getting the type of choice filter. For instance checkbox, radiobutton, combobox.\n */\n get choicetype():\n | \"checkbox\"\n | \"radiobutton\"\n | \"combobox\"\n | \"list\"\n | \"listview\"\n | \"table\"\n | \"longlist\"\n | \"toggle\" {\n return (\n [\n \"checkbox\",\n \"radiobutton\",\n \"combobox\",\n \"list\",\n \"listview\",\n \"table\",\n \"longlist\",\n \"toggle\",\n ].find((hint) => this.layouthint.has(hint)) || \"checkbox\"\n );\n }\n\n /**\n * Can multiple options be selected\n */\n get isMultiple(): boolean {\n return this.contributions.multiplechoice || this.choicetype === \"checkbox\";\n }\n\n /**\n * Check if options need to be rendered as tree\n */\n get isTree(): boolean {\n return (\n has(this.contributions, \"options\") &&\n this.contributions.options.some((option) => has(option, \"children\"))\n );\n }\n\n /**\n * Reset choice attribute to unselected list\n */\n reset() {\n this.options.deselectAll();\n }\n\n /**\n */\n mergeAttribute(oldAttribute: AttributeType) {\n // when attribute is readonly, don't merge the options no modifications necessary\n if (!this.readonly && oldAttribute instanceof ChoiceAttributeModel) {\n this.concept = oldAttribute.concept;\n this.options.mergeOptions(oldAttribute.options, this.type === \"lookup\");\n this.options.deselectAll();\n\n if (oldAttribute.isValid && oldAttribute.inputvalue !== null) {\n this.update(oldAttribute.inputvalue);\n }\n }\n }\n\n /**\n * Update attribute by name and value\n */\n update(value: any): ChoiceAttributeModel {\n if (this.readonly) {\n return this;\n }\n\n this.updateLastModification();\n\n let values;\n\n if (Array.isArray(value)) {\n values = value;\n } else if (typeof value === \"string\" && this.isMultiple) {\n values = value.split(\",\");\n } else {\n values = [value];\n }\n values.forEach((val) => {\n if (val instanceof ChoiceAttributeOptionModel) {\n // 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,SAASA,GAAG,QAAQ,6BAA6B;AACjD,SAASC,QAAQ,QAAQ,mCAAmC;AAE5D,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,+BAA+B,MAAM,mCAAmC;AAC/E,OAAOC,0BAA0B,MAAM,8BAA8B;AACrE,OAAOC,4BAA4B,MAAM,sDAAsD;AAE/F,SACEC,oBAAoB,EACpBC,YAAY,QACP,6BAA6B;AACpC,SAASC,eAAe,QAAQ,iBAAiB;AAKjD;AACA;AACA;AACA,eAAe,MAAMC,oBAAoB,SAASP,cAAc,CAAC;EAK/D;AACF;AACA;EACEQ,WAAW,CAACC,SAAiB,EAAEC,sBAA8B,EAAE;IAC7D,KAAK,CAACD,SAAS,EAAEC,sBAAsB,CAAC;IAAC;IAAA;IAAA;IAEzC,IAAI,CAACC,cAAc,GAAG,IAAI,CAACC,OAAO,CAAC,eAAe,EAAEb,QAAQ,CAACc,GAAG,EAAE,CAAC;IACnE,IAAI,CAACC,QAAQ,GAAGb,+BAA+B,CAACc,MAAM,CACpDN,SAAS,EACT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EtF;IAAW,CAAC,GAAGmF,KAAK;IAErD,MAAMI,iBAAiB,GAAG,mBAAmB;IAE7C,IAAID,UAAU,IAAIzG,GAAG,CAACyG,UAAU,EAAEC,iBAAiB,CAAC,EAAE;MAAA;MACpD,MAAMC,SAAS,GAAGF,UAAU,CAACC,iBAAiB,CAAC;MAC/C,MAAME,WAAW,GAAG,sCAAI,CAACzE,OAAO,kBAC7Be,MAAM,IAAKA,MAAM,CAACC,IAAI,KAAKwD,SAAS,CACtC;MACD,IAAIC,WAAW,EAAE;QACfH,UAAU,CAACC,iBAAiB,CAAC,GAAGE,WAAW,CAACC,yBAAyB,CACnE,IAAI,CAACf,oBAAoB,CAC1B;MACH;IACF;IAEA,IAAI,CAACgB,gBAAgB,CAACT,cAAc,CAACE,EAAE,EAAEC,OAAO,EAAEC,UAAU,EAAEtF,UAAU,CAAC;EAC3E;;EAEA;AACF;EACE,IAAI4F,aAAa,GAAkC;IACjD,IAAI,IAAI,CAACxF,IAAI,KAAK,QAAQ,EAAE;MAC1B,OAAOf,eAAe,CAACwG,KAAK;IAC9B;IAEA,OAAOxG,eAAe,CAACyG,MAAM;EAC/B;AACF"}
@@ -48,8 +48,8 @@ class ChoiceAttributeOptionModel extends BaseModel {
48
48
  static createFromListItemModel(listitem) {
49
49
  const option = new ChoiceAttributeOptionModel();
50
50
  option.code = listitem.id.toString();
51
- option.attributeCollection = listitem.attributeCollection;
52
- option.links = listitem.links;
51
+ option.attributeCollection = listitem.attributeCollection.clone();
52
+ option.links = listitem.links.clone();
53
53
  return option;
54
54
  }
55
55
 
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceAttributeOptionModel.js","names":["BaseModel","ChoiceAttributeOptionCollection","DateUtil","has","TIMEVERSION_FILTER_NAME","TITLE","hasAllContentInData","LinkCollection","AttributeCollection","ConceptDetailModel","AttributeContent","ChoiceAttributeOptionModel","constructor","selectedValues","option","referenceDate","now","code","contributions","key","_isSelected","_referenceDate","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","_content","content","createFromListItemModel","listitem","id","toString","attributeCollection","links","getInitialChildModelLinks","initialLinks","hasContentFromData","conceptLink","push","children","setChildModels","models","conceptHref","href","concept","model","selfhref","equalsWithParameters","_code","equals","getContribution","data","label","hasItems","title","getAttributeByLayoutHint","readonlyvalue","first","getContentConfiguredLabel","contentConfiguration","configuredLabelProperties","labelConfig","types","length","configuredLabels","getLabelElementByIds","configuredLabel","value","configuredLabelProperty","some","_id","selected","count","create","options","date","getLinkByKey","addParameter","isCacheable","_concept","level","isBooleanType","hasAlternativeLabel","mergeOption","withOption","mergeOptions"],"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;\n option.links = listitem.links;\n\n return option;\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 * 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,OAAOA,SAAS,MAAM,mBAAmB;AACzC,OAAOC,+BAA+B,MAAM,mCAAmC;AAE/E,SAASC,QAAQ,QAAQ,mCAAmC;AAC5D,SAASC,GAAG,QAAQ,6BAA6B;AACjD,SAASC,uBAAuB,QAAQ,2B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xE;;EAEA;AACF;AACA;EACE,IAAIoC,KAAK,GAAW;IAClB,OAAO,IAAI,CAAC5D,MAAM;EACpB;;EAEA;AACF;AACA;EACE,IAAI4D,KAAK,CAACA,KAAa,EAAE;IACvB,IAAI,CAAC5D,MAAM,GAAG4D,KAAK;EACrB;;EAEA;AACF;EACE,IAAIC,aAAa,GAAY;IAC3B,OAAO,IAAI,CAAC/B,eAAe,CAAC,eAAe,EAAE,KAAK,CAAC;EACrD;;EAEA;AACF;EACE,IAAIgC,mBAAmB,GAAY;IACjC,OAAO,IAAI,CAAChC,eAAe,CAAC,qBAAqB,EAAE,KAAK,CAAC;EAC3D;;EAEA;AACF;EACEiC,WAAW,CAACC,UAAsC,EAAE;IAClD,IAAI,CAACxC,OAAO,GAAGwC,UAAU,CAACxC,OAAO;IAEjC,IAAI,IAAI,CAACL,QAAQ,IAAI,IAAI,IAAI6C,UAAU,CAAC7C,QAAQ,IAAI,IAAI,EAAE;MACxD,IAAI,CAACA,QAAQ,CAAC8C,YAAY,CAACD,UAAU,CAAC7C,QAAQ,CAAC;IACjD;EACF;;EAEA;AACF;AACA;EACE,IAAIH,kBAAkB,GAAY;IAChC,OAAOhC,mBAAmB,EAAE;EAC9B;;EAEA;AACF;EACE,IAAIuB,OAAO,GAAqB;IAC9B,OAAO,IAAI,CAACD,QAAQ;EACtB;AACF;AAEA,eAAejB,0BAA0B"}
1
+ {"version":3,"file":"ChoiceAttributeOptionModel.js","names":["BaseModel","ChoiceAttributeOptionCollection","DateUtil","has","TIMEVERSION_FILTER_NAME","TITLE","hasAllContentInData","LinkCollection","AttributeCollection","ConceptDetailModel","AttributeContent","ChoiceAttributeOptionModel","constructor","selectedValues","option","referenceDate","now","code","contributions","key","_isSelected","_referenceDate","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","_content","content","createFromListItemModel","listitem","id","toString","attributeCollection","clone","links","getInitialChildModelLinks","initialLinks","hasContentFromData","conceptLink","push","children","setChildModels","models","conceptHref","href","concept","model","selfhref","equalsWithParameters","_code","equals","getContribution","data","label","hasItems","title","getAttributeByLayoutHint","readonlyvalue","first","getContentConfiguredLabel","contentConfiguration","configuredLabelProperties","labelConfig","types","length","configuredLabels","getLabelElementByIds","configuredLabel","value","configuredLabelProperty","some","_id","selected","count","create","options","date","getLinkByKey","addParameter","isCacheable","_concept","level","isBooleanType","hasAlternativeLabel","mergeOption","withOption","mergeOptions"],"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 */\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 * 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,OAAOA,SAAS,MAAM,mBAAmB;AACzC,OAAOC,+BAA+B,MAAM,mCAAmC;AAE/E,SAASC,QAAQ,QAAQ,mCAAmC;AAC5D,SAASC,GAAG,QAAQ,6BAA6B;AACjD,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,KAAK,QAAQ,6BAA6B;AACnD,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,OAAOC,cAAc,MAAM,yBAAyB;AACp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EACpB;;EAEA;AACF;AACA;EACE,IAAI6D,KAAK,CAACA,KAAa,EAAE;IACvB,IAAI,CAAC7D,MAAM,GAAG6D,KAAK;EACrB;;EAEA;AACF;EACE,IAAIC,aAAa,GAAY;IAC3B,OAAO,IAAI,CAAC/B,eAAe,CAAC,eAAe,EAAE,KAAK,CAAC;EACrD;;EAEA;AACF;EACE,IAAIgC,mBAAmB,GAAY;IACjC,OAAO,IAAI,CAAChC,eAAe,CAAC,qBAAqB,EAAE,KAAK,CAAC;EAC3D;;EAEA;AACF;EACEiC,WAAW,CAACC,UAAsC,EAAE;IAClD,IAAI,CAACxC,OAAO,GAAGwC,UAAU,CAACxC,OAAO;IAEjC,IAAI,IAAI,CAACL,QAAQ,IAAI,IAAI,IAAI6C,UAAU,CAAC7C,QAAQ,IAAI,IAAI,EAAE;MACxD,IAAI,CAACA,QAAQ,CAAC8C,YAAY,CAACD,UAAU,CAAC7C,QAAQ,CAAC;IACjD;EACF;;EAEA;AACF;AACA;EACE,IAAIH,kBAAkB,GAAY;IAChC,OAAOjC,mBAAmB,EAAE;EAC9B;;EAEA;AACF;EACE,IAAIuB,OAAO,GAAqB;IAC9B,OAAO,IAAI,CAACD,QAAQ;EACtB;AACF;AAEA,eAAejB,0BAA0B"}
@@ -32,6 +32,13 @@ export const updateModel = model => ({
32
32
  payload: model
33
33
  });
34
34
 
35
+ /**
36
+ */
37
+ export const updateForm = model => ({
38
+ type: "MODULARUI/UPDATE_FORM",
39
+ payload: model
40
+ });
41
+
35
42
  /**
36
43
  */
37
44
  export const removeModelByKey = key => ({
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","modelToUpdate","clonedModel","clone","update","Error","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n modelToUpdate: ?ModularUIModel\n): UpdateModelAction | SetModelAction => {\n if (modelToUpdate) {\n // $FlowFixMe[prop-missing]\n if (typeof modelToUpdate[\"update\"] === \"function\") {\n const clonedModel = modelToUpdate.clone();\n clonedModel.update(model);\n\n return updateModel(clonedModel);\n }\n\n throw new Error(\n `loadModel action: updateModel is set as option for ${key}, but the model is missing an update methode`\n );\n }\n\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateModel),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n is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,OAAOU,YAAY,CAACV,GAAG,EAAEP,gBAAgB,CAACyC,KAAK,CAAC;IAClD;EACF;AACF,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,aAAa,GACxB,CACEnC,GAAW,EACXmB,IAAmB,EACnBC,OAAiC,KAElCgB,QAAkB,IAAK;EACtBA,QAAQ,CAAC1B,YAAY,CAACV,GAAG,EAAEP,gBAAgB,CAAC4C,OAAO,CAAC,CAAC;EACrDD,QAAQ,CAACvC,aAAa,EAAE,CAAC;EAEzB,MAAMyC,gBAAgB,GAAGF,QAAQ,CAAClB,SAAS,CAAClB,GAAG,EAAEmB,IAAI,EAAEC,OAAO,CAAC,CAAC;EAEhE,OAAO,SAAQmB,OAAO,CAACD,gBAAgB,CAAC,CACrCE,IAAI,CAAEC,QAAQ,IAAK;IAClB,IAAIA,QAAQ,EAAEtC,IAAI,KAAK,iBAAiB,EAAE;MACxCiC,QAAQ,CAAC1B,YAAY,CAACV,GAAG,EAAEP,gBAAgB,CAACiD,QAAQ,CAAC,CAAC;IACxD;IAEA,OAAON,QAAQ,CAACxC,cAAc,EAAE,CAAC;EACnC,CAAC,CAAC,CACD+C,KAAK,CAAEb,KAAK,IAAKM,QAAQ,CAACtC,WAAW,CAACgC,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMc,WAAW,GAAG,CACzB3C,KAAqB,EACrBmB,OAAiC,KAEjCe,aAAa,CAAClC,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC4C,QAAQ,EAAE;EAC9C,GAAGzB,OAAO;EACV0B,QAAQ,EAAE;AACZ,CAAC,CAAC"}
1
+ {"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","modelToUpdate","clonedModel","clone","update","Error","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n modelToUpdate: ?ModularUIModel\n): UpdateModelAction | SetModelAction => {\n if (modelToUpdate) {\n // $FlowFixMe[prop-missing]\n if (typeof modelToUpdate[\"update\"] === \"function\") {\n const clonedModel = modelToUpdate.clone();\n clonedModel.update(model);\n\n return updateModel(clonedModel);\n }\n\n throw new Error(\n `loadModel action: updateModel is set as option for ${key}, but the model is missing an update methode`\n );\n }\n\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateModel),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";AACA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAgB9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,OAAO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMO,UAAU,GAAIP,KAAqB,KAAwB;EACtEE,IAAI,EAAE,uBAAuB;EAC7BC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMQ,gBAAgB,GAAIT,GAAW,KAA8B;EACxEG,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMU,cAAc,GAAG,OAA6B;EACzDP,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMQ,YAAY,GAAG,CAC1BX,GAAW,EACXY,M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C9C,GAAGzB,OAAO;EACV0B,QAAQ,EAAE;AACZ,CAAC,CAAC"}
@@ -132,6 +132,7 @@ export const ModularUIReducer = function () {
132
132
  case "MODULARUI/SET":
133
133
  return setModel(state, action.payload);
134
134
  case "MODULARUI/UPDATE":
135
+ case "MODULARUI/UPDATE_FORM":
135
136
  return updateModel(state, action.payload);
136
137
  case "MODULARUI/REMOVE_KEY":
137
138
  return removeKey(action.payload, state);
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","key","status","LOADING","lastModification","Date","now","setModel","model","initModularUI","models","newState","forEach","FINISHED","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","initialState","ModularUIReducer","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> }\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel }\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,wBAAwB,QAAQ,kBAAkB;AAC3D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;AAO/C;AACA;AACA,MAAMC,YAAY,GAAG,CACnBC,KAAqB,WAEl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GqB,YAAY;EAAA,IACpBE,MAAM;EAEN,IAAI,CAACA,MAAM,EAAE;IACX,OAAOvB,KAAK;EACd;EAEA,QAAQuB,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOf,aAAa,CAACT,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOL,cAAc,CAACpB,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAOlB,QAAQ,CAACP,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;MACrB,OAAOT,WAAW,CAAChB,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAON,SAAS,CAACI,MAAM,CAACE,OAAO,EAAEzB,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAAC;AAEnB,CAAC"}
1
+ {"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","key","status","LOADING","lastModification","Date","now","setModel","model","initModularUI","models","newState","forEach","FINISHED","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","initialState","ModularUIReducer","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> }\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel }\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n case \"MODULARUI/UPDATE_FORM\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,wBAAwB,QAAQ,kBAAkB;AAC3D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;AAO/C;AACA;AACA,MAAMC,YAAY,GAAG,CACnBC,KAAqB,WAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC;EAExE;EACA,IAAIA,MAAM,KAAKL,gBAAgB,CAACM,OAAO,IAAI,CAACH,KAAK,CAACC,GAAG,CAAC,EAAE;IACtD,OAAOD,KAAK;EACd;EAEA,OAAO;IACL,GAAGA,KAAK;IACR,CAACC,GAAG,GAAG;MACL,GAAGD,KAAK,CAACC,GAAG,CAAC;MACbC,MAAM;MACNE,gBAAgB,EAAEC,IAAI,CAACC,GAAG;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,MAAMC,QAAQ,GAAG,CACfP,KAAqB,YAElB;EAAA,IADH;IAAEC,GAAG;IAAEO;EAA+C,CAAC;EAEvD,IAAI,CAACR,KAAK,CAACC,GAAG,CAAC,EAAE;IACf,OAAOD,KAAK;EACd;EAEA,IAAIQ,KAAK,EAAE;IACT,OAAO;MACL,GAAGR,KAAK;MACR,CAACC,GAAG,GAAG;QACL,GAAGD,KAAK,CAACC,GAAG,CAAC;QACbO,KAAK;QACLJ,gBAAgB,EAAEC,IAAI,CAACC,GAAG;MAC5B;IACF,CAAC;EACH;EAEA,MAAM,IAAIV,wBAAwB,CAAC,uBAAuB,CAAC;AAC7D,CAAC;;AAED;AACA;AACA,MAAMa,aAAa,GAAG,CACpBT,KAAqB,EACrBU,MAAqD,KAClD;EACH,MAAMC,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AAMW,QAAwB,GAAG,CAAC,CAAC;EAEnC,KAAK,MAAMV,GAAG,IAAID,KAAK,EAAE;IACvB,IAAIA,KAAK,CAACC,GAAG,CAAC,CAACO,KAAK,YAAYV,gBAAgB,EAAE;MAChDa,QAAQ,CAACV,GAAG,CAAC,GAAG;QAAE,GAAGD,KAAK,CAACC,GAAG;MAAE,CAAC;IACnC;EACF;EAEA,OAAOU,QAAQ;AACjB,CAAC;AAED,MAAMU,YAA4B,GAAG,CAAC,CAAC;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,gBAAsD,GAAG,YAGjE;EAAA,IAFHtB,KAAK,uEAAGqB,YAAY;EAAA,IACpBE,MAAM;EAEN,IAAI,CAACA,MAAM,EAAE;IACX,OAAOvB,KAAK;EACd;EAEA,QAAQuB,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOf,aAAa,CAACT,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOL,cAAc,CAACpB,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAOlB,QAAQ,CAACP,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC1B,OAAOT,WAAW,CAAChB,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAON,SAAS,CAACI,MAAM,CAACE,OAAO,EAAEzB,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAAC;AAEnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>\n) => ComponentType<any>;\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>\n) => ComponentType<any>;\n"],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import { goBack } from "../_router/RouterActions";
2
- import { updateModel } from "../_modularui/ModularUIActions";
2
+ import { updateForm } from "../_modularui/ModularUIActions";
3
3
  import { logoutSuccess } from "./SignOut";
4
4
  import { reloadApplication } from "./Application";
5
5
  import { startProgress, finishProgress } from "./ProgressIndicator";
@@ -10,7 +10,7 @@ import Authenticate from "../../modularui/Authenticate";
10
10
  export const previousObject = form => {
11
11
  const newForm = form.clone();
12
12
  newForm.setPreviousObject();
13
- return updateModel(newForm);
13
+ return updateForm(newForm);
14
14
  };
15
15
 
16
16
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Form.js","names":["goBack","updateModel","logoutSuccess","reloadApplication","startProgress","finishProgress","Authenticate","previousObject","form","newForm","clone","setPreviousObject","cancelForm","dispatch","getState","key","auth","mustChangePassword","logout","then"],"sources":["../../../src/redux/actions/Form.js"],"sourcesContent":["// @flow\nimport { goBack } from \"../_router/RouterActions\";\nimport { updateModel } from \"../_modularui/ModularUIActions\";\nimport { logoutSuccess } from \"./SignOut\";\nimport { reloadApplication } from \"./Application\";\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\n\nimport Authenticate from \"../../modularui/Authenticate\";\n\nimport type { Dispatch, GetState, ThunkAction } from \"../types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type { UpdateModelAction } from \"../_modularui/types\";\n\n/**\n * Go back to previous object (back button on form)\n */\nexport const previousObject = (form: FormModel): UpdateModelAction => {\n const newForm = form.clone();\n\n newForm.setPreviousObject();\n\n return updateModel(newForm);\n};\n\n/**\n */\nexport const cancelForm =\n (form: FormModel): ThunkAction =>\n (dispatch: Dispatch, getState: GetState) => {\n if (form.key === \"ChangePassword\" && getState().auth.mustChangePassword) {\n dispatch(startProgress());\n return new Authenticate().logout().then(() => {\n dispatch(logoutSuccess());\n dispatch(reloadApplication());\n dispatch(finishProgress());\n\n return dispatch(goBack());\n });\n }\n\n return dispatch(goBack());\n };\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,0BAA0B;AACjD,SAASC,WAAW,QAAQ,gCAAgC;AAC5D,SAASC,aAAa,QAAQ,WAAW;AACzC,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,aAAa,EAAEC,cAAc,QAAQ,qBAAqB;AAEnE,OAAOC,YAAY,MAAM,8BAA8B;AAMvD;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAIC,IAAe,IAAwB;EACpE,MAAMC,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,iBAAiB,EAAE;EAE3B,OAAOV,WAAW,CAACQ,OAAO,CAAC;AAC7B,CAAC;;AAED;AACA;AACA,OAAO,MAAMG,UAAU,GACpBJ,IAAe,IAChB,CAACK,QAAkB,EAAEC,QAAkB,KAAK;EAC1C,IAAIN,IAAI,CAACO,GAAG,KAAK,gBAAgB,IAAID,QAAQ,EAAE,CAACE,IAAI,CAACC,kBAAkB,EAAE;IACvEJ,QAAQ,CAACT,aAAa,EAAE,CAAC;IACzB,OAAO,IAAIE,YAAY,EAAE,CAACY,MAAM,EAAE,CAACC,IAAI,CAAC,MAAM;MAC5CN,QAAQ,CAACX,aAAa,EAAE,CAAC;MACzBW,QAAQ,CAACV,iBAAiB,EAAE,CAAC;MAC7BU,QAAQ,CAACR,cAAc,EAAE,CAAC;MAE1B,OAAOQ,QAAQ,CAACb,MAAM,EAAE,CAAC;IAC3B,CAAC,CAAC;EACJ;EAEA,OAAOa,QAAQ,CAACb,MAAM,EAAE,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"Form.js","names":["goBack","updateForm","logoutSuccess","reloadApplication","startProgress","finishProgress","Authenticate","previousObject","form","newForm","clone","setPreviousObject","cancelForm","dispatch","getState","key","auth","mustChangePassword","logout","then"],"sources":["../../../src/redux/actions/Form.js"],"sourcesContent":["// @flow\nimport { goBack } from \"../_router/RouterActions\";\nimport { updateForm } from \"../_modularui/ModularUIActions\";\nimport { logoutSuccess } from \"./SignOut\";\nimport { reloadApplication } from \"./Application\";\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\n\nimport Authenticate from \"../../modularui/Authenticate\";\n\nimport type { Dispatch, GetState, ThunkAction } from \"../types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type { UpdateFormAction } from \"../_modularui/types\";\n\n/**\n * Go back to previous object (back button on form)\n */\nexport const previousObject = (form: FormModel): UpdateFormAction => {\n const newForm = form.clone();\n\n newForm.setPreviousObject();\n\n return updateForm(newForm);\n};\n\n/**\n */\nexport const cancelForm =\n (form: FormModel): ThunkAction =>\n (dispatch: Dispatch, getState: GetState) => {\n if (form.key === \"ChangePassword\" && getState().auth.mustChangePassword) {\n dispatch(startProgress());\n return new Authenticate().logout().then(() => {\n dispatch(logoutSuccess());\n dispatch(reloadApplication());\n dispatch(finishProgress());\n\n return dispatch(goBack());\n });\n }\n\n return dispatch(goBack());\n };\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,0BAA0B;AACjD,SAASC,UAAU,QAAQ,gCAAgC;AAC3D,SAASC,aAAa,QAAQ,WAAW;AACzC,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,aAAa,EAAEC,cAAc,QAAQ,qBAAqB;AAEnE,OAAOC,YAAY,MAAM,8BAA8B;AAMvD;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAIC,IAAe,IAAuB;EACnE,MAAMC,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,iBAAiB,EAAE;EAE3B,OAAOV,UAAU,CAACQ,OAAO,CAAC;AAC5B,CAAC;;AAED;AACA;AACA,OAAO,MAAMG,UAAU,GACpBJ,IAAe,IAChB,CAACK,QAAkB,EAAEC,QAAkB,KAAK;EAC1C,IAAIN,IAAI,CAACO,GAAG,KAAK,gBAAgB,IAAID,QAAQ,EAAE,CAACE,IAAI,CAACC,kBAAkB,EAAE;IACvEJ,QAAQ,CAACT,aAAa,EAAE,CAAC;IACzB,OAAO,IAAIE,YAAY,EAAE,CAACY,MAAM,EAAE,CAACC,IAAI,CAAC,MAAM;MAC5CN,QAAQ,CAACX,aAAa,EAAE,CAAC;MACzBW,QAAQ,CAACV,iBAAiB,EAAE,CAAC;MAC7BU,QAAQ,CAACR,cAAc,EAAE,CAAC;MAE1B,OAAOQ,QAAQ,CAACb,MAAM,EAAE,CAAC;IAC3B,CAAC,CAAC;EACJ;EAEA,OAAOa,QAAQ,CAACb,MAAM,EAAE,CAAC;AAC3B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { updateModel } from "../_modularui/ModularUIActions";
1
+ import { updateForm } from "../_modularui/ModularUIActions";
2
2
  import { getSetting } from "../../constants/Settings";
3
3
  import { validateFormObject } from "./FormValidations";
4
4
  import { autosaveFormObject } from "./FormAutosave";
@@ -40,7 +40,7 @@ export const updateFormAttribute = function (form, formObject, attribute, inputv
40
40
  // server form validations happens async, don't wait for the form to return
41
41
  dispatch(validateFormObject(newForm));
42
42
  }
43
- return dispatch(updateModel(newForm));
43
+ return dispatch(updateForm(newForm));
44
44
  };
45
45
  };
46
46
  //# sourceMappingURL=FormAttributeSet.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormAttributeSet.js","names":["updateModel","getSetting","validateFormObject","autosaveFormObject","autosubmitFormObject","updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"],"sources":["../../../src/redux/actions/FormAttributeSet.js"],"sourcesContent":["// @flow\nimport { updateModel } from \"../_modularui/ModularUIActions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\n\nimport type { Dispatch, ThunkAction, UpdateFormOptions } from \"../types\";\nimport type { AttributeType } from \"../../models/types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\n\n/**\n * Update an attribute on a form\n */\nexport const updateFormAttribute =\n (\n form: FormModel,\n formObject: FormObjectModel,\n attribute: AttributeType,\n inputvalue: string,\n options: UpdateFormOptions = {\n autosubmit: false,\n autosave: false,\n forceUpdate: false,\n validate: true,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (options.validate === undefined) {\n options.validate = true;\n }\n\n if (newForm.currentFormObject?.equals(formObject)) {\n newForm.currentFormObject.updateAttribute(attribute, inputvalue);\n } else {\n newForm.completedFormObjects.forEach((completeObject) => {\n if (completeObject.equals(formObject)) {\n completeObject.updateAttribute(attribute, inputvalue);\n }\n });\n }\n\n if (options.autosubmit && newForm.isValid) {\n const autosubmitAction = autosubmitFormObject(\n newForm,\n attribute,\n options.forceUpdate\n );\n if (autosubmitAction) {\n return dispatch(autosubmitAction);\n }\n }\n\n if (options.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n options.validate &&\n newForm.currentFormObject?.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n // server form validations happens async, don't wait for the form to return\n dispatch(validateFormObject(newForm));\n }\n return dispatch(updateModel(newForm));\n };\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,gCAAgC;AAE5D,SAASC,UAAU,QAAQ,0BAA0B;AAErD,SAASC,kBAAkB,QAAQ,mBAAmB;AACtD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,oBAAoB,QAAQ,kBAAkB;AAOvD;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAC9B,UACEC,IAAe,EACfC,UAA2B,EAC3BC,SAAwB,EACxBC,UAAkB;EAAA,IAClBC,OAA0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AAOD,QAAQ,CAACf,WAAW,CAACgB,OAAO,CAAC,CAAC;EACvC,CAAC;AAAA"}
1
+ {"version":3,"file":"FormAttributeSet.js","names":["updateForm","getSetting","validateFormObject","autosaveFormObject","autosubmitFormObject","updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"],"sources":["../../../src/redux/actions/FormAttributeSet.js"],"sourcesContent":["// @flow\nimport { updateForm } from \"../_modularui/ModularUIActions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\n\nimport type { Dispatch, ThunkAction, UpdateFormOptions } from \"../types\";\nimport type { AttributeType } from \"../../models/types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\n\n/**\n * Update an attribute on a form\n */\nexport const updateFormAttribute =\n (\n form: FormModel,\n formObject: FormObjectModel,\n attribute: AttributeType,\n inputvalue: string,\n options: UpdateFormOptions = {\n autosubmit: false,\n autosave: false,\n forceUpdate: false,\n validate: true,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (options.validate === undefined) {\n options.validate = true;\n }\n\n if (newForm.currentFormObject?.equals(formObject)) {\n newForm.currentFormObject.updateAttribute(attribute, inputvalue);\n } else {\n newForm.completedFormObjects.forEach((completeObject) => {\n if (completeObject.equals(formObject)) {\n completeObject.updateAttribute(attribute, inputvalue);\n }\n });\n }\n\n if (options.autosubmit && newForm.isValid) {\n const autosubmitAction = autosubmitFormObject(\n newForm,\n attribute,\n options.forceUpdate\n );\n if (autosubmitAction) {\n return dispatch(autosubmitAction);\n }\n }\n\n if (options.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n options.validate &&\n newForm.currentFormObject?.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n // server form validations happens async, don't wait for the form to return\n dispatch(validateFormObject(newForm));\n }\n\n return dispatch(updateForm(newForm));\n };\n"],"mappings":"AACA,SAASA,UAAU,QAAQ,gCAAgC;AAE3D,SAASC,UAAU,QAAQ,0BAA0B;AAErD,SAASC,kBAAkB,QAAQ,mBAAmB;AACtD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,oBAAoB,QAAQ,kBAAkB;AAOvD;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAC9B,UACEC,IAAe,EACfC,UAA2B,EAC3BC,SAAwB,EACxBC,UAAkB;EAAA,IAClBC,OAA0B,uEAAG;IAC3BC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE,KAAK;IACfC,WAAW,EAAE,KAAK;IAClBC,QAAQ,EAAE;EACZ,CAAC;EAAA,OAEFC,QAAkB,IAAK;IACtB,MAAMC,OAAO,GAAGV,IAAI,CAACW,KAAK,EAAE;IAE5B,IAAIP,OAAO,CAACI,QAAQ,KAAKI,SAAS,EAAE;MAClCR,OAAO,CAACI,QAAQ,GAAG,IAAI;IACzB;IAEA,IAAIE,OAAO,CAACG,iBAAiB,EAAEC,MAAM,CAACb,UAAU,CAAC,EAAE;MACjDS,OAAO,CAACG,iBAAiB,CAACE,eAAe,CAACb,SAAS,EAAEC,UAAU,CAAC;IAClE,CAAC,MAAM;MACLO,OAAO,CAACM,oBAAoB,CAACC,OAAO,CAAEC,cAAc,IAAK;QACvD,IAAIA,cAAc,CAACJ,MAAM,CAACb,UAAU,CAAC,EAAE;UACrCiB,cAAc,CAACH,eAAe,CAACb,SAAS,EAAEC,UAAU,CAAC;QACvD;MACF,CAAC,CAAC;IACJ;IAEA,IAAIC,OAAO,CAACC,UAAU,IAAIK,OAAO,CAACS,OAAO,EAAE;MACzC,MAAMC,gBAAgB,GAAGtB,oBAAoB,CAC3CY,OAAO,EACPR,SAAS,EACTE,OAAO,CAACG,WAAW,CACpB;MACD,IAAIa,gBAAgB,EAAE;QACpB,OAAOX,QAAQ,CAACW,gBAAgB,CAAC;MACnC;IACF;IAEA,IAAIhB,OAAO,CAACE,QAAQ,IAAII,OAAO,CAACS,OAAO,IAAIT,OAAO,CAACW,SAAS,EAAE,EAAE;MAC9DZ,QAAQ,CAACZ,kBAAkB,CAACa,OAAO,CAAC,CAAC;IACvC;IAEA,IACEN,OAAO,CAACI,QAAQ,IAChBE,OAAO,CAACG,iBAAiB,EAAES,qBAAqB,IAChD3B,UAAU,CAAC,+BAA+B,CAAC,EAC3C;MACA;MACAc,QAAQ,CAACb,kBAAkB,CAACc,OAAO,CAAC,CAAC;IACvC;IAEA,OAAOD,QAAQ,CAACf,UAAU,CAACgB,OAAO,CAAC,CAAC;EACtC,CAAC;AAAA"}
@@ -1,10 +1,10 @@
1
- import { updateModel } from "../_modularui/ModularUIActions";
1
+ import { updateForm } from "../_modularui/ModularUIActions";
2
2
  /**
3
3
  */
4
4
  export const addRepeatableAttributeSet = form => {
5
5
  const newForm = form.clone();
6
6
  newForm.addEmptyFormObject();
7
- return updateModel(newForm);
7
+ return updateForm(newForm);
8
8
  };
9
9
 
10
10
  /**
@@ -13,7 +13,7 @@ export const cancelRepeatableAttributeSet = (form, formObject) => {
13
13
  const newForm = form.clone();
14
14
  newForm.addEmptyFormObject();
15
15
  newForm.removeFormObject(formObject);
16
- return updateModel(newForm);
16
+ return updateForm(newForm);
17
17
  };
18
18
 
19
19
  /**
@@ -21,6 +21,6 @@ export const cancelRepeatableAttributeSet = (form, formObject) => {
21
21
  export const removeRepeatableAttributeSet = (form, formObject) => {
22
22
  const newForm = form.clone();
23
23
  newForm.removeFormObject(formObject);
24
- return updateModel(newForm);
24
+ return updateForm(newForm);
25
25
  };
26
26
  //# sourceMappingURL=FormAttributeSetRepeatable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormAttributeSetRepeatable.js","names":["updateModel","addRepeatableAttributeSet","form","newForm","clone","addEmptyFormObject","cancelRepeatableAttributeSet","formObject","removeFormObject","removeRepeatableAttributeSet"],"sources":["../../../src/redux/actions/FormAttributeSetRepeatable.js"],"sourcesContent":["// @flow\nimport { updateModel } from \"../_modularui/ModularUIActions\";\n\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\nimport type { UpdateModelAction } from \"../_modularui/types\";\n\n/**\n */\nexport const addRepeatableAttributeSet = (\n form: FormModel\n): UpdateModelAction => {\n const newForm = form.clone();\n\n newForm.addEmptyFormObject();\n\n return updateModel(newForm);\n};\n\n/**\n */\nexport const cancelRepeatableAttributeSet = (\n form: FormModel,\n formObject: FormObjectModel\n): UpdateModelAction => {\n const newForm = form.clone();\n\n newForm.addEmptyFormObject();\n newForm.removeFormObject(formObject);\n\n return updateModel(newForm);\n};\n\n/**\n */\nexport const removeRepeatableAttributeSet = (\n form: FormModel,\n formObject: FormObjectModel\n): UpdateModelAction => {\n const newForm = form.clone();\n\n newForm.removeFormObject(formObject);\n\n return updateModel(newForm);\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,gCAAgC;AAM5D;AACA;AACA,OAAO,MAAMC,yBAAyB,GACpCC,IAAe,IACO;EACtB,MAAMC,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,kBAAkB,EAAE;EAE5B,OAAOL,WAAW,CAACG,OAAO,CAAC;AAC7B,CAAC;;AAED;AACA;AACA,OAAO,MAAMG,4BAA4B,GAAG,CAC1CJ,IAAe,EACfK,UAA2B,KACL;EACtB,MAAMJ,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,kBAAkB,EAAE;EAC5BF,OAAO,CAACK,gBAAgB,CAACD,UAAU,CAAC;EAEpC,OAAOP,WAAW,CAACG,OAAO,CAAC;AAC7B,CAAC;;AAED;AACA;AACA,OAAO,MAAMM,4BAA4B,GAAG,CAC1CP,IAAe,EACfK,UAA2B,KACL;EACtB,MAAMJ,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACK,gBAAgB,CAACD,UAAU,CAAC;EAEpC,OAAOP,WAAW,CAACG,OAAO,CAAC;AAC7B,CAAC"}
1
+ {"version":3,"file":"FormAttributeSetRepeatable.js","names":["updateForm","addRepeatableAttributeSet","form","newForm","clone","addEmptyFormObject","cancelRepeatableAttributeSet","formObject","removeFormObject","removeRepeatableAttributeSet"],"sources":["../../../src/redux/actions/FormAttributeSetRepeatable.js"],"sourcesContent":["// @flow\nimport { updateForm } from \"../_modularui/ModularUIActions\";\n\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\nimport type { UpdateFormAction } from \"../_modularui/types\";\n\n/**\n */\nexport const addRepeatableAttributeSet = (\n form: FormModel\n): UpdateFormAction => {\n const newForm = form.clone();\n\n newForm.addEmptyFormObject();\n\n return updateForm(newForm);\n};\n\n/**\n */\nexport const cancelRepeatableAttributeSet = (\n form: FormModel,\n formObject: FormObjectModel\n): UpdateFormAction => {\n const newForm = form.clone();\n\n newForm.addEmptyFormObject();\n newForm.removeFormObject(formObject);\n\n return updateForm(newForm);\n};\n\n/**\n */\nexport const removeRepeatableAttributeSet = (\n form: FormModel,\n formObject: FormObjectModel\n): UpdateFormAction => {\n const newForm = form.clone();\n\n newForm.removeFormObject(formObject);\n\n return updateForm(newForm);\n};\n"],"mappings":"AACA,SAASA,UAAU,QAAQ,gCAAgC;AAM3D;AACA;AACA,OAAO,MAAMC,yBAAyB,GACpCC,IAAe,IACM;EACrB,MAAMC,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,kBAAkB,EAAE;EAE5B,OAAOL,UAAU,CAACG,OAAO,CAAC;AAC5B,CAAC;;AAED;AACA;AACA,OAAO,MAAMG,4BAA4B,GAAG,CAC1CJ,IAAe,EACfK,UAA2B,KACN;EACrB,MAAMJ,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,kBAAkB,EAAE;EAC5BF,OAAO,CAACK,gBAAgB,CAACD,UAAU,CAAC;EAEpC,OAAOP,UAAU,CAACG,OAAO,CAAC;AAC5B,CAAC;;AAED;AACA;AACA,OAAO,MAAMM,4BAA4B,GAAG,CAC1CP,IAAe,EACfK,UAA2B,KACN;EACrB,MAAMJ,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACK,gBAAgB,CAACD,UAAU,CAAC;EAEpC,OAAOP,UAAU,CAACG,OAAO,CAAC;AAC5B,CAAC"}
@@ -2,7 +2,7 @@ import debounce from "lodash/debounce";
2
2
  import ModularUIRequest from "../../modularui/ModularUIRequest";
3
3
  import FormModel from "../../models/form/FormModel";
4
4
  import { HTTP_METHODS, VALIDATE_DEBOUNCE_TIMEOUT, AUTOSAVE_STATUS } from "../../constants/Constants";
5
- import { updateModel } from "../_modularui/ModularUIActions";
5
+ import { updateForm } from "../_modularui/ModularUIActions";
6
6
  /**
7
7
  * Update validations of the form currently in the reducer
8
8
  * because of the debounce timeout there might have been an update on the form during validation
@@ -30,7 +30,7 @@ const autosave = (dispatch, form) => {
30
30
  // update last server update to indicate an update has happened
31
31
  // send the existing form to prevent updates in the ui based on autosave results
32
32
  form.lastServerUpdate = savedForm.lastServerUpdate;
33
- dispatch(updateModel(form));
33
+ dispatch(updateForm(form));
34
34
  dispatch(updateAutosave(AUTOSAVE_STATUS.FINISHED, savedForm));
35
35
  }
36
36
  });
@@ -1 +1 @@
1
- {"version":3,"file":"FormAutosave.js","names":["debounce","ModularUIRequest","FormModel","HTTP_METHODS","VALIDATE_DEBOUNCE_TIMEOUT","AUTOSAVE_STATUS","updateModel","updateAutosave","status","model","type","payload","autosave","dispatch","form","START","formdata","getFormData","selfhref","setParameter","method","POST","data","childmodels","locale","fetch","then","savedForm","lastServerUpdate","FINISHED","debouncedAutosave","autosaveFormObject"],"sources":["../../../src/redux/actions/FormAutosave.js"],"sourcesContent":["// @flow\nimport debounce from \"lodash/debounce\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport {\n HTTP_METHODS,\n VALIDATE_DEBOUNCE_TIMEOUT,\n AUTOSAVE_STATUS,\n} from \"../../constants/Constants\";\n\nimport { updateModel } from \"../_modularui/ModularUIActions\";\n\nimport type { UpdateAutosaveAction, ThunkAction, Dispatch } from \"../types\";\n\n/**\n * Update validations of the form currently in the reducer\n * because of the debounce timeout there might have been an update on the form during validation\n */\nconst updateAutosave = (\n status: $Keys<typeof AUTOSAVE_STATUS>,\n model: FormModel\n): UpdateAutosaveAction => ({\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status,\n model,\n },\n});\n\n/**\n */\nconst autosave = (dispatch: Dispatch, form: FormModel) => {\n dispatch(updateAutosave(AUTOSAVE_STATUS.START, form));\n\n const formdata = form.getFormData(true, false);\n\n new ModularUIRequest(form.selfhref.setParameter(\"commit\", \"true\"), {\n method: HTTP_METHODS.POST,\n data: formdata,\n childmodels: false,\n locale: form.locale,\n })\n .fetch()\n .then((savedForm) => {\n if (savedForm instanceof FormModel) {\n // update last server update to indicate an update has happened\n // send the existing form to prevent updates in the ui based on autosave results\n form.lastServerUpdate = savedForm.lastServerUpdate;\n\n dispatch(updateModel(form));\n dispatch(updateAutosave(AUTOSAVE_STATUS.FINISHED, savedForm));\n }\n });\n};\n\n/**\n * Validates form objects debounced to prevent overloading the (form) service\n * When a form with new errors (or complete) arrives, we send the validations\n * to the current form model where the errors are processed\n * A new form with the new constraints is send to the store\n */\nconst debouncedAutosave = debounce((dispatch, form) => {\n autosave(dispatch, form);\n}, VALIDATE_DEBOUNCE_TIMEOUT);\n\n/**\n */\nexport const autosaveFormObject =\n (form: FormModel): ThunkAction =>\n (dispatch) =>\n debouncedAutosave(dispatch, form);\n"],"mappings":"AACA,OA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,IAAI,KAAK;EACrDF,QAAQ,CAACC,QAAQ,EAAEC,IAAI,CAAC;AAC1B,CAAC,EAAEV,yBAAyB,CAAC;;AAE7B;AACA;AACA,OAAO,MAAM2B,kBAAkB,GAC5BjB,IAAe,IACfD,QAAQ,IACPiB,iBAAiB,CAACjB,QAAQ,EAAEC,IAAI,CAAC"}
1
+ {"version":3,"file":"FormAutosave.js","names":["debounce","ModularUIRequest","FormModel","HTTP_METHODS","VALIDATE_DEBOUNCE_TIMEOUT","AUTOSAVE_STATUS","updateForm","updateAutosave","status","model","type","payload","autosave","dispatch","form","START","formdata","getFormData","selfhref","setParameter","method","POST","data","childmodels","locale","fetch","then","savedForm","lastServerUpdate","FINISHED","debouncedAutosave","autosaveFormObject"],"sources":["../../../src/redux/actions/FormAutosave.js"],"sourcesContent":["// @flow\nimport debounce from \"lodash/debounce\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport {\n HTTP_METHODS,\n VALIDATE_DEBOUNCE_TIMEOUT,\n AUTOSAVE_STATUS,\n} from \"../../constants/Constants\";\n\nimport { updateForm } from \"../_modularui/ModularUIActions\";\n\nimport type { UpdateAutosaveAction, ThunkAction, Dispatch } from \"../types\";\n\n/**\n * Update validations of the form currently in the reducer\n * because of the debounce timeout there might have been an update on the form during validation\n */\nconst updateAutosave = (\n status: $Keys<typeof AUTOSAVE_STATUS>,\n model: FormModel\n): UpdateAutosaveAction => ({\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status,\n model,\n },\n});\n\n/**\n */\nconst autosave = (dispatch: Dispatch, form: FormModel) => {\n dispatch(updateAutosave(AUTOSAVE_STATUS.START, form));\n\n const formdata = form.getFormData(true, false);\n\n new ModularUIRequest(form.selfhref.setParameter(\"commit\", \"true\"), {\n method: HTTP_METHODS.POST,\n data: formdata,\n childmodels: false,\n locale: form.locale,\n })\n .fetch()\n .then((savedForm) => {\n if (savedForm instanceof FormModel) {\n // update last server update to indicate an update has happened\n // send the existing form to prevent updates in the ui based on autosave results\n form.lastServerUpdate = savedForm.lastServerUpdate;\n\n dispatch(updateForm(form));\n dispatch(updateAutosave(AUTOSAVE_STATUS.FINISHED, savedForm));\n }\n });\n};\n\n/**\n * Validates form objects debounced to prevent overloading the (form) service\n * When a form with new errors (or complete) arrives, we send the validations\n * to the current form model where the errors are processed\n * A new form with the new constraints is send to the store\n */\nconst debouncedAutosave = debounce((dispatch, form) => {\n autosave(dispatch, form);\n}, VALIDATE_DEBOUNCE_TIMEOUT);\n\n/**\n */\nexport const autosaveFormObject =\n (form: FormModel): ThunkAction =>\n (dispatch) =>\n debouncedAutosave(dispatch, form);\n"],"mappings":"AACA,OAAOA,QAAQ,MAAM,iBAAiB;AAEtC,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,OAAOC,SAAS,MAAM,6BAA6B;AAEnD,SACEC,YAAY,EACZC,yBAAyB,EACzBC,eAAe,QACV,2BAA2B;AAElC,SAASC,UAAU,QAAQ,gCAAgC;AAI3D;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG,CACrBC,MAAqC,EACrCC,KAAgB,MACU;EAC1BC,IAAI,EAAE,wBAAwB;EAC9BC,OAAO,EAAE;IACPH,MAAM;IACNC;EACF;AACF,CAAC,CAAC;;AAEF;AACA;AACA,MAAMG,QAAQ,GAAG,CAACC,QAAkB,EAAEC,IAAe,KAAK;EACxDD,QAAQ,CAACN,cAAc,CAACF,eAAe,CAACU,KAAK,EAAED,IAAI,CAAC,CAAC;EAErD,MAAME,QAAQ,GAAGF,IAAI,CAACG,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC;EAE9C,IAAIhB,gBAAgB,CAACa,IAAI,CAACI,QAAQ,CAACC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;IACjEC,MAAM,EAAEjB,YAAY,CAACkB,IAAI;IACzBC,IAAI,EAAEN,QAAQ;IACdO,WAAW,EAAE,KAAK;IAClBC,MAAM,EAAEV,IAAI,CAACU;EACf,CAAC,CAAC,CACCC,KAAK,EAAE,CACPC,IAAI,CAAEC,SAAS,IAAK;IACnB,IAAIA,SAAS,YAAYzB,SAAS,EAAE;MAClC;MACA;MACAY,IAAI,CAACc,gBAAgB,GAAGD,SAAS,CAACC,gBAAgB;MAElDf,QAAQ,CAACP,UAAU,CAACQ,IAAI,CAAC,CAAC;MAC1BD,QAAQ,CAACN,cAAc,CAACF,eAAe,CAACwB,QAAQ,EAAEF,SAAS,CAAC,CAAC;IAC/D;EACF,CAAC,CAAC;AACN,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,iBAAiB,GAAG9B,QAAQ,CAAC,CAACa,QAAQ,EAAEC,IAAI,KAAK;EACrDF,QAAQ,CAACC,QAAQ,EAAEC,IAAI,CAAC;AAC1B,CAAC,EAAEV,yBAAyB,CAAC;;AAE7B;AACA;AACA,OAAO,MAAM2B,kBAAkB,GAC5BjB,IAAe,IACfD,QAAQ,IACPiB,iBAAiB,CAACjB,QAAQ,EAAEC,IAAI,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import debounce from "lodash/debounce";
2
- import { updateModel } from "../_modularui/ModularUIActions";
2
+ import { updateForm } from "../_modularui/ModularUIActions";
3
3
  import ModularUIRequest from "../../modularui/ModularUIRequest";
4
4
  import { HTTP_METHODS, VALIDATE_DEBOUNCE_TIMEOUT } from "../../constants/Constants";
5
5
  import FormModel from "../../models/form/FormModel";
@@ -14,7 +14,7 @@ const updateValidations = (form, formWithValidations) => (dispatch, getState) =>
14
14
  if (validatedForm instanceof FormModel) {
15
15
  validatedForm.updateValidations(formWithValidations.data);
16
16
  }
17
- dispatch(updateModel(validatedForm));
17
+ dispatch(updateForm(validatedForm));
18
18
  }
19
19
  };
20
20