@beinformed/ui 1.27.4 → 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 (88) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/esm/hooks/useForm.js.map +1 -1
  3. package/esm/models/actions/ActionCollection.js +10 -16
  4. package/esm/models/actions/ActionCollection.js.map +1 -1
  5. package/esm/models/attributes/ChoiceAttributeModel.js +1 -0
  6. package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
  7. package/esm/models/attributes/ChoiceAttributeOptionModel.js +2 -2
  8. package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  9. package/esm/redux/_modularui/ModularUIActions.js +7 -0
  10. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  11. package/esm/redux/_modularui/ModularUIReducer.js +1 -0
  12. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  13. package/esm/redux/_modularui/types.js.map +1 -1
  14. package/esm/redux/actions/Form.js +2 -2
  15. package/esm/redux/actions/Form.js.map +1 -1
  16. package/esm/redux/actions/FormAttributeSet.js +2 -2
  17. package/esm/redux/actions/FormAttributeSet.js.map +1 -1
  18. package/esm/redux/actions/FormAttributeSetRepeatable.js +4 -4
  19. package/esm/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
  20. package/esm/redux/actions/FormAutosave.js +2 -2
  21. package/esm/redux/actions/FormAutosave.js.map +1 -1
  22. package/esm/redux/actions/FormValidations.js +2 -2
  23. package/esm/redux/actions/FormValidations.js.map +1 -1
  24. package/esm/redux/connectors/Form.js.map +1 -1
  25. package/esm/redux/connectors/FormAttributeSet.js.map +1 -1
  26. package/esm/redux/types.js.map +1 -1
  27. package/lib/hooks/__tests__/useForm.spec.js.flow +4 -4
  28. package/lib/hooks/useForm.js.flow +5 -5
  29. package/lib/hooks/useForm.js.map +1 -1
  30. package/lib/models/actions/ActionCollection.js +10 -16
  31. package/lib/models/actions/ActionCollection.js.flow +12 -20
  32. package/lib/models/actions/ActionCollection.js.map +1 -1
  33. package/lib/models/actions/__tests__/ActionCollection.spec.js.flow +16 -4
  34. package/lib/models/attributes/ChoiceAttributeModel.js +1 -0
  35. package/lib/models/attributes/ChoiceAttributeModel.js.flow +1 -0
  36. package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
  37. package/lib/models/attributes/ChoiceAttributeOptionModel.js +2 -2
  38. package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +2 -2
  39. package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  40. package/lib/redux/_modularui/ModularUIActions.js +9 -1
  41. package/lib/redux/_modularui/ModularUIActions.js.flow +8 -0
  42. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  43. package/lib/redux/_modularui/ModularUIReducer.js +1 -0
  44. package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
  45. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  46. package/lib/redux/_modularui/types.js.flow +5 -0
  47. package/lib/redux/_modularui/types.js.map +1 -1
  48. package/lib/redux/actions/Form.js +1 -1
  49. package/lib/redux/actions/Form.js.flow +4 -4
  50. package/lib/redux/actions/Form.js.map +1 -1
  51. package/lib/redux/actions/FormAttributeSet.js +1 -1
  52. package/lib/redux/actions/FormAttributeSet.js.flow +3 -2
  53. package/lib/redux/actions/FormAttributeSet.js.map +1 -1
  54. package/lib/redux/actions/FormAttributeSetRepeatable.js +3 -3
  55. package/lib/redux/actions/FormAttributeSetRepeatable.js.flow +8 -8
  56. package/lib/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
  57. package/lib/redux/actions/FormAutosave.js +1 -1
  58. package/lib/redux/actions/FormAutosave.js.flow +2 -2
  59. package/lib/redux/actions/FormAutosave.js.map +1 -1
  60. package/lib/redux/actions/FormValidations.js +1 -1
  61. package/lib/redux/actions/FormValidations.js.flow +2 -2
  62. package/lib/redux/actions/FormValidations.js.map +1 -1
  63. package/lib/redux/actions/__tests__/Form.spec.js.flow +1 -1
  64. package/lib/redux/connectors/Form.js.flow +2 -5
  65. package/lib/redux/connectors/Form.js.map +1 -1
  66. package/lib/redux/connectors/FormAttributeSet.js.flow +5 -5
  67. package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
  68. package/lib/redux/types.js.flow +2 -0
  69. package/lib/redux/types.js.map +1 -1
  70. package/package.json +1 -1
  71. package/src/hooks/__tests__/useForm.spec.js +4 -4
  72. package/src/hooks/useForm.js +5 -5
  73. package/src/models/actions/ActionCollection.js +12 -20
  74. package/src/models/actions/__tests__/ActionCollection.spec.js +16 -4
  75. package/src/models/attributes/ChoiceAttributeModel.js +1 -0
  76. package/src/models/attributes/ChoiceAttributeOptionModel.js +2 -2
  77. package/src/redux/_modularui/ModularUIActions.js +8 -0
  78. package/src/redux/_modularui/ModularUIReducer.js +1 -0
  79. package/src/redux/_modularui/types.js +5 -0
  80. package/src/redux/actions/Form.js +4 -4
  81. package/src/redux/actions/FormAttributeSet.js +3 -2
  82. package/src/redux/actions/FormAttributeSetRepeatable.js +8 -8
  83. package/src/redux/actions/FormAutosave.js +2 -2
  84. package/src/redux/actions/FormValidations.js +2 -2
  85. package/src/redux/actions/__tests__/Form.spec.js +1 -1
  86. package/src/redux/connectors/Form.js +2 -5
  87. package/src/redux/connectors/FormAttributeSet.js +5 -5
  88. package/src/redux/types.js +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceAttributeOptionModel.js","names":["ChoiceAttributeOptionModel","BaseModel","constructor","selectedValues","option","referenceDate","DateUtil","now","code","contributions","key","_isSelected","_referenceDate","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","LinkCollection","_content","AttributeContent","content","createFromListItemModel","listitem","id","toString","attributeCollection","links","getInitialChildModelLinks","initialLinks","hasContentFromData","conceptLink","push","children","setChildModels","models","conceptHref","href","concept","model","selfhref","equalsWithParameters","_code","equals","getContribution","has","data","AttributeCollection","label","hasItems","title","getAttributeByLayoutHint","TITLE","readonlyvalue","first","getContentConfiguredLabel","contentConfiguration","configuredLabelProperties","labelConfig","types","length","configuredLabels","getLabelElementByIds","configuredLabel","value","configuredLabelProperty","some","_id","selected","count","ChoiceAttributeOptionCollection","create","options","date","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","_concept","ConceptDetailModel","level","isBooleanType","hasAlternativeLabel","mergeOption","withOption","mergeOptions","hasAllContentInData"],"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;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA,MAAMA,0BAA0B,SACtBC,kBAAS,CAEnB;EAWE;AACF;EACEC,WAAW,GAIT;IAAA,IAHAC,cAA6B,uEAAG,EAAE;IAAA,IAClCC,MAAc,uEAAG,CAAC,CAAC;IAAA,IACnBC,aAAuB,uEAAGC,sBAAQ,CAACC,GAAG,EAAE;IAExC,KAAK,CAAC,CAAC,CAAC,EAA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AE;IAClD,IAAI,CAAC9C,OAAO,GAAG8C,UAAU,CAAC9C,OAAO;IAEjC,IAAI,IAAI,CAACL,QAAQ,IAAI,IAAI,IAAImD,UAAU,CAACnD,QAAQ,IAAI,IAAI,EAAE;MACxD,IAAI,CAACA,QAAQ,CAACoD,YAAY,CAACD,UAAU,CAACnD,QAAQ,CAAC;IACjD;EACF;;EAEA;AACF;AACA;EACE,IAAIH,kBAAkB,GAAY;IAChC,OAAO,IAAAwD,6BAAmB,GAAE;EAC9B;;EAEA;AACF;EACE,IAAIjE,OAAO,GAAqB;IAC9B,OAAO,IAAI,CAACF,QAAQ;EACtB;AACF;AAAC,eAEcpB,0BAA0B;AAAA"}
1
+ {"version":3,"file":"ChoiceAttributeOptionModel.js","names":["ChoiceAttributeOptionModel","BaseModel","constructor","selectedValues","option","referenceDate","DateUtil","now","code","contributions","key","_isSelected","_referenceDate","_level","_attributeCollection","createAttributeCollection","_children","addChildren","_links","LinkCollection","_content","AttributeContent","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","has","data","AttributeCollection","label","hasItems","title","getAttributeByLayoutHint","TITLE","readonlyvalue","first","getContentConfiguredLabel","contentConfiguration","configuredLabelProperties","labelConfig","types","length","configuredLabels","getLabelElementByIds","configuredLabel","value","configuredLabelProperty","some","_id","selected","count","ChoiceAttributeOptionCollection","create","options","date","getLinkByKey","addParameter","TIMEVERSION_FILTER_NAME","isCacheable","_concept","ConceptDetailModel","level","isBooleanType","hasAlternativeLabel","mergeOption","withOption","mergeOptions","hasAllContentInData"],"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;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAMA;AACA;AACA,MAAMA,0BAA0B,SACtBC,kBAAS,CAEnB;EAWE;AACF;EACEC,WAAW,GAIT;IAAA,IAHAC,cAA6B,uEAAG,EAAE;IAAA,IAClCC,MAAc,uEAAG,CAAC,CAAC;IAAA,IACnBC,aAAuB,uEAAGC,sBAAQ,CAACC,GAAG,EAAE;IAExC,KAAK,CAAC,CAAC,CAAC,EAAEH,MAAM,CAAC;IAAC;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAElB,IAAI,CAACI,IAAI,GAAG,IAAI,CAACC,aAAa,CAACD,IAAI,IAAI,IAAI,CAACC,aAAa,CAACC,GAAG,IAAI,EAAE;IAEnE,IAAI,CAACC,WAAW,GAAG,uBAAAR,cAAc,OAAdA,cAAc,EAAU,IAAI,CAACK,IAAI,CAAC;IAErD,IAAI,CAACI,cAAc,GAAGP,aAAa;IAEnC,IAAI,CAACQ,MAAM,GAAG,CAAC;IAEf,IAAI,CAACC,oBAAoB,GAAG,IAAI,CAACC,yBAAyB,EAAE;IAC5D,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I,CAACF,QAAQ;EACtB;AACF;AAAC,eAEcpB,0BAA0B;AAAA"}
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.updateStatus = exports.updateModel = exports.setModel = exports.resetModularUI = exports.removeModelByKey = exports.reloadModel = exports.loadModularUI = exports.loadModel = exports.initModels = void 0;
7
+ exports.updateStatus = exports.updateModel = exports.updateForm = exports.setModel = exports.resetModularUI = exports.removeModelByKey = exports.reloadModel = exports.loadModularUI = exports.loadModel = exports.initModels = void 0;
8
8
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
9
9
  var _Constants = require("../../constants/Constants");
10
10
  var _Href = _interopRequireDefault(require("../../models/href/Href"));
@@ -44,6 +44,14 @@ const updateModel = model => ({
44
44
  /**
45
45
  */
46
46
  exports.updateModel = updateModel;
47
+ const updateForm = model => ({
48
+ type: "MODULARUI/UPDATE_FORM",
49
+ payload: model
50
+ });
51
+
52
+ /**
53
+ */
54
+ exports.updateForm = updateForm;
47
55
  const removeModelByKey = key => ({
48
56
  type: "MODULARUI/REMOVE_KEY",
49
57
  payload: key
@@ -12,6 +12,7 @@ import type {
12
12
  SetModelAction,
13
13
  InitModelAction,
14
14
  UpdateModelAction,
15
+ UpdateFormAction,
15
16
  RemoveModelByKeyAction,
16
17
  ResetModularUIAction,
17
18
  UpdateStatusAction,
@@ -51,6 +52,13 @@ export const updateModel = (model: ModularUIModel): UpdateModelAction => ({
51
52
  payload: model,
52
53
  });
53
54
 
55
+ /**
56
+ */
57
+ export const updateForm = (model: ModularUIModel): UpdateFormAction => ({
58
+ type: "MODULARUI/UPDATE_FORM",
59
+ payload: model,
60
+ });
61
+
54
62
  /**
55
63
  */
56
64
  export const removeModelByKey = (key: string): RemoveModelByKeyAction => ({
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIActions.js","names":["setModel","key","model","connectKey","type","payload","initModels","models","updateModel","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","modelToUpdate","clonedModel","clone","update","Error","loadModel","href","options","Href","method","HTTP_METHODS","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","LOADING","startProgress","loadModelPromise","resolve","then","response","FINISHED","finishProgress","catch","handleError","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 isReload: true,\n });\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AACA;AACA;AAeA;AACA;AACO,MAAMA,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;AADA;AAEO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AADA;AAEO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AADA;AAEO,MAAMO,gBAAgB,GAAIR,GAAW,KAA8B;EACxEG,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AAFA;AAGO,MAAMS,cAAc,GAAG,OAA6B;EACzDN,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AADA;AAEO,MAAMO,YAAY,GAAG,CAC1BV,GAAW,EACXW,MAAsC,MACd;EACxBR,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAE;IAAEJ,GAAG;IAAEW;EAAO;AACzB,CAAC,CAAC;;AAEF;AACA;AADA;AAEA,MAAMC,sBAAsB,GAAG,CAC7BZ,GAAW,EACXC,KAAqB,EACrBY,aAA8B,KACS;EACvC,IAAIA,aAAa,EAAE;IACjB;IACA,IAAI,OAAOA,a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AC9B;MAEA,OAAOU,YAAY,CAACV,GAAG,EAAEqC,2BAAgB,CAACC,KAAK,CAAC;IAClD;EACF;AACF,CAAC,CAAC;;AAEF;AACA;AADA;AAEO,MAAMC,aAAa,GACxB,CACEvC,GAAW,EACXmB,IAAmB,EACnBC,OAAiC,KAElCoB,QAAkB,IAAK;EACtBA,QAAQ,CAAC9B,YAAY,CAACV,GAAG,EAAEqC,2BAAgB,CAACI,OAAO,CAAC,CAAC;EACrDD,QAAQ,CAAC,IAAAE,gCAAa,GAAE,CAAC;EAEzB,MAAMC,gBAAgB,GAAGH,QAAQ,CAACtB,SAAS,CAAClB,GAAG,EAAEmB,IAAI,EAAEC,OAAO,CAAC,CAAC;EAEhE,OAAO,iBAAQwB,OAAO,CAACD,gBAAgB,CAAC,CACrCE,IAAI,CAAEC,QAAQ,IAAK;IAClB,IAAIA,QAAQ,EAAE3C,IAAI,KAAK,iBAAiB,EAAE;MACxCqC,QAAQ,CAAC9B,YAAY,CAACV,GAAG,EAAEqC,2BAAgB,CAACU,QAAQ,CAAC,CAAC;IACxD;IAEA,OAAOP,QAAQ,CAAC,IAAAQ,iCAAc,GAAE,CAAC;EACnC,CAAC,CAAC,CACDC,KAAK,CAAEjB,KAAK,IAAKQ,QAAQ,CAAC,IAAAU,kBAAW,EAAClB,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AADA;AAEO,MAAMmB,WAAW,GAAG,CACzBlD,KAAqB,EACrBmB,OAAiC,KAEjCmB,aAAa,CAACtC,KAAK,CAACC,UAAU,EAAED,KAAK,CAACmD,QAAQ,EAAE;EAC9C,GAAGhC,OAAO;EACViC,QAAQ,EAAE;AACZ,CAAC,CAAC;AAAC"}
1
+ {"version":3,"file":"ModularUIActions.js","names":["setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","modelToUpdate","clonedModel","clone","update","Error","loadModel","href","options","Href","method","HTTP_METHODS","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","LOADING","startProgress","loadModelPromise","resolve","then","response","FINISHED","finishProgress","catch","handleError","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;AACA;AACA;AACA;AACA;AAgBA;AACA;AACO,MAAMA,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;AADA;AAEO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AADA;AAEO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AADA;AAEO,MAAMO,UAAU,GAAIP,KAAqB,KAAwB;EACtEE,IAAI,EAAE,uBAAuB;EAC7BC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AADA;AAEO,MAAMQ,gBAAgB,GAAIT,GAAW,KAA8B;EACxEG,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AAFA;AAGO,MAAMU,cAAc,GAAG,OAA6B;EACzDP,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AADA;AAEO,MAAMQ,YAAY,GAAG,CAC1BX,GAAW,EACXY,MAAsC,MACd;EACxBT,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAE;IAAEJ,GAAG;IAAEY;EAAO;AACzB,CAAC,CAAC;;AAEF;AACA;AADA;AAEA,MAAMC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
140
140
  return setModel(state, action.payload);
141
141
  case "MODULARUI/UPDATE":
142
+ case "MODULARUI/UPDATE_FORM":
142
143
  return updateModel(state, action.payload);
143
144
  case "MODULARUI/REMOVE_KEY":
144
145
  return removeKey(action.payload, state);
@@ -144,6 +144,7 @@ export const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (
144
144
  return setModel(state, action.payload);
145
145
 
146
146
  case "MODULARUI/UPDATE":
147
+ case "MODULARUI/UPDATE_FORM":
147
148
  return updateModel(state, action.payload);
148
149
 
149
150
  case "MODULARUI/REMOVE_KEY":
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIReducer.js","names":["updateStatus","state","key","status","MODULARUI_STATUS","LOADING","lastModification","Date","now","setModel","model","IllegalArgumentException","initModularUI","models","newState","forEach","FINISHED","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","ApplicationModel","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;AACA;AACA;AAOA;AACA;AACA,MAAMA,YAAY,GAAG,CACnBC,KAAqB,WAElB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uEAAGwB,YAAY;EAAA,IACpBE,MAAM;EAEN,IAAI,CAACA,MAAM,EAAE;IACX,OAAO1B,KAAK;EACd;EAEA,QAAQ0B,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOhB,aAAa,CAACX,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAON,cAAc,CAACtB,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAOpB,QAAQ,CAACR,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;MACrB,OAAOV,WAAW,CAAClB,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOP,SAAS,CAACK,MAAM,CAACE,OAAO,EAAE5B,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAAC;AAEnB,CAAC;AAAC"}
1
+ {"version":3,"file":"ModularUIReducer.js","names":["updateStatus","state","key","status","MODULARUI_STATUS","LOADING","lastModification","Date","now","setModel","model","IllegalArgumentException","initModularUI","models","newState","forEach","FINISHED","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","ApplicationModel","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;AACA;AACA;AAOA;AACA;AACA,MAAMA,YAAY,GAAG,CACnBC,KAAqB,WAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC;EAExE;EACA,IAAIA,MAAM,KAAKC,2BAAgB,CAACC,OAAO,IAAI,CAACJ,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;MACNG,gBAAgB,EAAEC,IAAI,CAACC,GAAG;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,MAAMC,QAAQ,GAAG,CACfR,KAAqB,YAElB;EAAA,IADH;IAAEC,GAAG;IAAEQ;EAA+C,CAAC;EAEvD,IAAI,CAACT,KAAK,CAACC,GAAG,CAAC,EAAE;IACf,OAAOD,KAAK;EACd;EAEA,IAAIS,KAAK,EAAE;IACT,OAAO;MACL,GAAGT,KAAK;MACR,CAACC,GAAG,GAAG;QACL,GAAGD,KAAK,CAACC,GAAG,CAAC;QACbQ,KAAK;QACLJ,gBAAgB,EAAEC,IAAI,CAACC,GAAG;MAC5B;IACF,CAAC;EACH;EAEA,MAAM,IAAIG,oCAAwB,CAAC,uBAAuB,CAAC;AAC7D,CAAC;;AAED;AACA;AACA,MAAMC,aAAa,GAAG,CACpBX,KAAqB,EACrBY,MAAqD,KAClD;EACH,MAAMC,QAAQ,GAAG,qBAAc,CAAC,CAAC,EAAEb,KAAK,CAAC;EAEzCY,MAAM,CAAC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,KAAK,EAAE;IACvB,IAAIA,KAAK,CAACC,GAAG,CAAC,CAACQ,KAAK,YAAYc,wBAAgB,EAAE;MAChDV,QAAQ,CAACZ,GAAG,CAAC,GAAG;QAAE,GAAGD,KAAK,CAACC,GAAG;MAAE,CAAC;IACnC;EACF;EAEA,OAAOY,QAAQ;AACjB,CAAC;AAED,MAAMW,YAA4B,GAAG,CAAC,CAAC;;AAEvC;AACA;AACA;AACO,MAAMC,gBAAsD,GAAG,YAGjE;EAAA,IAFHzB,KAAK,uEAAGwB,YAAY;EAAA,IACpBE,MAAM;EAEN,IAAI,CAACA,MAAM,EAAE;IACX,OAAO1B,KAAK;EACd;EAEA,QAAQ0B,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOhB,aAAa,CAACX,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAON,cAAc,CAACtB,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAOpB,QAAQ,CAACR,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC1B,OAAOV,WAAW,CAAClB,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOP,SAAS,CAACK,MAAM,CAACE,OAAO,EAAE5B,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAAC;AAEnB,CAAC;AAAC"}
@@ -49,6 +49,11 @@ export type UpdateModelAction = {
49
49
  payload: ModularUIModel,
50
50
  };
51
51
 
52
+ export type UpdateFormAction = {
53
+ type: "MODULARUI/UPDATE_FORM",
54
+ payload: ModularUIModel,
55
+ };
56
+
52
57
  export type SuccessAction = (
53
58
  model: ModularUIModel
54
59
  ) => UpdateModelAction | SetModelAction;
@@ -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":""}
@@ -17,7 +17,7 @@ var _Authenticate = _interopRequireDefault(require("../../modularui/Authenticate
17
17
  const previousObject = form => {
18
18
  const newForm = form.clone();
19
19
  newForm.setPreviousObject();
20
- return (0, _ModularUIActions.updateModel)(newForm);
20
+ return (0, _ModularUIActions.updateForm)(newForm);
21
21
  };
22
22
 
23
23
  /**
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
  import { goBack } from "../_router/RouterActions";
3
- import { updateModel } from "../_modularui/ModularUIActions";
3
+ import { updateForm } from "../_modularui/ModularUIActions";
4
4
  import { logoutSuccess } from "./SignOut";
5
5
  import { reloadApplication } from "./Application";
6
6
  import { startProgress, finishProgress } from "./ProgressIndicator";
@@ -9,17 +9,17 @@ import Authenticate from "../../modularui/Authenticate";
9
9
 
10
10
  import type { Dispatch, GetState, ThunkAction } from "../types";
11
11
  import type FormModel from "../../models/form/FormModel";
12
- import type { UpdateModelAction } from "../_modularui/types";
12
+ import type { UpdateFormAction } from "../_modularui/types";
13
13
 
14
14
  /**
15
15
  * Go back to previous object (back button on form)
16
16
  */
17
- export const previousObject = (form: FormModel): UpdateModelAction => {
17
+ export const previousObject = (form: FormModel): UpdateFormAction => {
18
18
  const newForm = form.clone();
19
19
 
20
20
  newForm.setPreviousObject();
21
21
 
22
- return updateModel(newForm);
22
+ return updateForm(newForm);
23
23
  };
24
24
 
25
25
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Form.js","names":["previousObject","form","newForm","clone","setPreviousObject","updateModel","cancelForm","dispatch","getState","key","auth","mustChangePassword","startProgress","Authenticate","logout","then","logoutSuccess","reloadApplication","finishProgress","goBack"],"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;AACA;AACA;AACA;AACA;AAEA;AAMA;AACA;AACA;AACO,MAAMA,cAAc,GAAIC,IAAe,IAAwB;EACpE,MAAMC,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,iBAAiB,EAAE;EAE3B,OAAO,IAAAC,6BAAW,EAACH,OAAO,CAAC;AAC7B,CAAC;;AAED;AACA;AADA;AAEO,MAAMI,UAAU,GACpBL,IAAe,IAChB,CAACM,QAAkB,EAAEC,QAAkB,KAAK;EAC1C,IAAIP,IAAI,CAACQ,GAAG,KAAK,gBAAgB,IAAID,QAAQ,EAAE,CAACE,IAAI,CAACC,kBAAkB,EAAE;IACvEJ,QAAQ,CAAC,IAAAK,gCAAa,GAAE,CAAC;IACzB,OAAO,IAAIC,qBAAY,EAAE,CAACC,MAAM,EAAE,CAACC,IAAI,CAAC,MAAM;MAC5CR,QAAQ,CAAC,IAAAS,sBAAa,GAAE,CAAC;MACzBT,QAAQ,CAAC,IAAAU,8BAAiB,GAAE,CAAC;MAC7BV,QAAQ,CAAC,IAAAW,iCAAc,GAAE,CAAC;MAE1B,OAAOX,QAAQ,CAAC,IAAAY,qBAAM,GAAE,CAAC;IAC3B,CAAC,CAAC;EACJ;EAEA,OAAOZ,QAAQ,CAAC,IAAAY,qBAAM,GAAE,CAAC;AAC3B,CAAC;AAAC"}
1
+ {"version":3,"file":"Form.js","names":["previousObject","form","newForm","clone","setPreviousObject","updateForm","cancelForm","dispatch","getState","key","auth","mustChangePassword","startProgress","Authenticate","logout","then","logoutSuccess","reloadApplication","finishProgress","goBack"],"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;AACA;AACA;AACA;AACA;AAEA;AAMA;AACA;AACA;AACO,MAAMA,cAAc,GAAIC,IAAe,IAAuB;EACnE,MAAMC,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,iBAAiB,EAAE;EAE3B,OAAO,IAAAC,4BAAU,EAACH,OAAO,CAAC;AAC5B,CAAC;;AAED;AACA;AADA;AAEO,MAAMI,UAAU,GACpBL,IAAe,IAChB,CAACM,QAAkB,EAAEC,QAAkB,KAAK;EAC1C,IAAIP,IAAI,CAACQ,GAAG,KAAK,gBAAgB,IAAID,QAAQ,EAAE,CAACE,IAAI,CAACC,kBAAkB,EAAE;IACvEJ,QAAQ,CAAC,IAAAK,gCAAa,GAAE,CAAC;IACzB,OAAO,IAAIC,qBAAY,EAAE,CAACC,MAAM,EAAE,CAACC,IAAI,CAAC,MAAM;MAC5CR,QAAQ,CAAC,IAAAS,sBAAa,GAAE,CAAC;MACzBT,QAAQ,CAAC,IAAAU,8BAAiB,GAAE,CAAC;MAC7BV,QAAQ,CAAC,IAAAW,iCAAc,GAAE,CAAC;MAE1B,OAAOX,QAAQ,CAAC,IAAAY,qBAAM,GAAE,CAAC;IAC3B,CAAC,CAAC;EACJ;EAEA,OAAOZ,QAAQ,CAAC,IAAAY,qBAAM,GAAE,CAAC;AAC3B,CAAC;AAAC"}
@@ -46,7 +46,7 @@ const updateFormAttribute = function (form, formObject, attribute, inputvalue) {
46
46
  // server form validations happens async, don't wait for the form to return
47
47
  dispatch((0, _FormValidations.validateFormObject)(newForm));
48
48
  }
49
- return dispatch((0, _ModularUIActions.updateModel)(newForm));
49
+ return dispatch((0, _ModularUIActions.updateForm)(newForm));
50
50
  };
51
51
  };
52
52
  exports.updateFormAttribute = updateFormAttribute;
@@ -1,5 +1,5 @@
1
1
  // @flow
2
- import { updateModel } from "../_modularui/ModularUIActions";
2
+ import { updateForm } from "../_modularui/ModularUIActions";
3
3
 
4
4
  import { getSetting } from "../../constants/Settings";
5
5
 
@@ -68,5 +68,6 @@ export const updateFormAttribute =
68
68
  // server form validations happens async, don't wait for the form to return
69
69
  dispatch(validateFormObject(newForm));
70
70
  }
71
- return dispatch(updateModel(newForm));
71
+
72
+ return dispatch(updateForm(newForm));
72
73
  };
@@ -1 +1 @@
1
- {"version":3,"file":"FormAttributeSet.js","names":["updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","autosubmitFormObject","isChanged","autosaveFormObject","hasDynamicValidations","getSetting","validateFormObject","updateModel"],"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;AAEA;AAEA;AACA;AACA;AAOA;AACA;AACA;AACO,MAAMA,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,GAAG,IAAAC,oCAAoB,EAC3CX,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,CAACY,SAAS,EAAE,EAAE;MAC9Db,QAAQ,CAAC,IAAAc,gCAAkB,EAACb,OAAO,CAAC,CAAC;IACvC;IAEA,IACEN,OAAO,CAACI,QAAQ,IAChBE,OAAO,CAACG,iBAAiB,EAAEW,qBAAqB,IAChD,IAAAC,oBAAU,EAAC,+BAA+B,CAAC,EAC3C;MACA;MACAhB,QAAQ,CAAC,IAAAiB,mCAAkB,EAAChB,OAAO,CAAC,CAAC;IACvC;IACA,OAAOD,QAAQ,CAAC,IAAAkB,6BAAW,EAACjB,OAAO,CAAC,CAAC;EACvC,CAAC;AAAA;AAAC"}
1
+ {"version":3,"file":"FormAttributeSet.js","names":["updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","autosubmitFormObject","isChanged","autosaveFormObject","hasDynamicValidations","getSetting","validateFormObject","updateForm"],"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;AAEA;AAEA;AACA;AACA;AAOA;AACA;AACA;AACO,MAAMA,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,GAAG,IAAAC,oCAAoB,EAC3CX,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,CAACY,SAAS,EAAE,EAAE;MAC9Db,QAAQ,CAAC,IAAAc,gCAAkB,EAACb,OAAO,CAAC,CAAC;IACvC;IAEA,IACEN,OAAO,CAACI,QAAQ,IAChBE,OAAO,CAACG,iBAAiB,EAAEW,qBAAqB,IAChD,IAAAC,oBAAU,EAAC,+BAA+B,CAAC,EAC3C;MACA;MACAhB,QAAQ,CAAC,IAAAiB,mCAAkB,EAAChB,OAAO,CAAC,CAAC;IACvC;IAEA,OAAOD,QAAQ,CAAC,IAAAkB,4BAAU,EAACjB,OAAO,CAAC,CAAC;EACtC,CAAC;AAAA;AAAC"}
@@ -10,7 +10,7 @@ var _ModularUIActions = require("../_modularui/ModularUIActions");
10
10
  const addRepeatableAttributeSet = form => {
11
11
  const newForm = form.clone();
12
12
  newForm.addEmptyFormObject();
13
- return (0, _ModularUIActions.updateModel)(newForm);
13
+ return (0, _ModularUIActions.updateForm)(newForm);
14
14
  };
15
15
 
16
16
  /**
@@ -20,7 +20,7 @@ const cancelRepeatableAttributeSet = (form, formObject) => {
20
20
  const newForm = form.clone();
21
21
  newForm.addEmptyFormObject();
22
22
  newForm.removeFormObject(formObject);
23
- return (0, _ModularUIActions.updateModel)(newForm);
23
+ return (0, _ModularUIActions.updateForm)(newForm);
24
24
  };
25
25
 
26
26
  /**
@@ -29,7 +29,7 @@ exports.cancelRepeatableAttributeSet = cancelRepeatableAttributeSet;
29
29
  const removeRepeatableAttributeSet = (form, formObject) => {
30
30
  const newForm = form.clone();
31
31
  newForm.removeFormObject(formObject);
32
- return (0, _ModularUIActions.updateModel)(newForm);
32
+ return (0, _ModularUIActions.updateForm)(newForm);
33
33
  };
34
34
  exports.removeRepeatableAttributeSet = removeRepeatableAttributeSet;
35
35
  //# sourceMappingURL=FormAttributeSetRepeatable.js.map
@@ -1,20 +1,20 @@
1
1
  // @flow
2
- import { updateModel } from "../_modularui/ModularUIActions";
2
+ import { updateForm } from "../_modularui/ModularUIActions";
3
3
 
4
4
  import type FormModel from "../../models/form/FormModel";
5
5
  import type FormObjectModel from "../../models/form/FormObjectModel";
6
- import type { UpdateModelAction } from "../_modularui/types";
6
+ import type { UpdateFormAction } from "../_modularui/types";
7
7
 
8
8
  /**
9
9
  */
10
10
  export const addRepeatableAttributeSet = (
11
11
  form: FormModel
12
- ): UpdateModelAction => {
12
+ ): UpdateFormAction => {
13
13
  const newForm = form.clone();
14
14
 
15
15
  newForm.addEmptyFormObject();
16
16
 
17
- return updateModel(newForm);
17
+ return updateForm(newForm);
18
18
  };
19
19
 
20
20
  /**
@@ -22,13 +22,13 @@ export const addRepeatableAttributeSet = (
22
22
  export const cancelRepeatableAttributeSet = (
23
23
  form: FormModel,
24
24
  formObject: FormObjectModel
25
- ): UpdateModelAction => {
25
+ ): UpdateFormAction => {
26
26
  const newForm = form.clone();
27
27
 
28
28
  newForm.addEmptyFormObject();
29
29
  newForm.removeFormObject(formObject);
30
30
 
31
- return updateModel(newForm);
31
+ return updateForm(newForm);
32
32
  };
33
33
 
34
34
  /**
@@ -36,10 +36,10 @@ export const cancelRepeatableAttributeSet = (
36
36
  export const removeRepeatableAttributeSet = (
37
37
  form: FormModel,
38
38
  formObject: FormObjectModel
39
- ): UpdateModelAction => {
39
+ ): UpdateFormAction => {
40
40
  const newForm = form.clone();
41
41
 
42
42
  newForm.removeFormObject(formObject);
43
43
 
44
- return updateModel(newForm);
44
+ return updateForm(newForm);
45
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"FormAttributeSetRepeatable.js","names":["addRepeatableAttributeSet","form","newForm","clone","addEmptyFormObject","updateModel","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;AAMA;AACA;AACO,MAAMA,yBAAyB,GACpCC,IAAe,IACO;EACtB,MAAMC,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,kBAAkB,EAAE;EAE5B,OAAO,IAAAC,6BAAW,EAACH,OAAO,CAAC;AAC7B,CAAC;;AAED;AACA;AADA;AAEO,MAAMI,4BAA4B,GAAG,CAC1CL,IAAe,EACfM,UAA2B,KACL;EACtB,MAAML,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,kBAAkB,EAAE;EAC5BF,OAAO,CAACM,gBAAgB,CAACD,UAAU,CAAC;EAEpC,OAAO,IAAAF,6BAAW,EAACH,OAAO,CAAC;AAC7B,CAAC;;AAED;AACA;AADA;AAEO,MAAMO,4BAA4B,GAAG,CAC1CR,IAAe,EACfM,UAA2B,KACL;EACtB,MAAML,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACM,gBAAgB,CAACD,UAAU,CAAC;EAEpC,OAAO,IAAAF,6BAAW,EAACH,OAAO,CAAC;AAC7B,CAAC;AAAC"}
1
+ {"version":3,"file":"FormAttributeSetRepeatable.js","names":["addRepeatableAttributeSet","form","newForm","clone","addEmptyFormObject","updateForm","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;AAMA;AACA;AACO,MAAMA,yBAAyB,GACpCC,IAAe,IACM;EACrB,MAAMC,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,kBAAkB,EAAE;EAE5B,OAAO,IAAAC,4BAAU,EAACH,OAAO,CAAC;AAC5B,CAAC;;AAED;AACA;AADA;AAEO,MAAMI,4BAA4B,GAAG,CAC1CL,IAAe,EACfM,UAA2B,KACN;EACrB,MAAML,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,kBAAkB,EAAE;EAC5BF,OAAO,CAACM,gBAAgB,CAACD,UAAU,CAAC;EAEpC,OAAO,IAAAF,4BAAU,EAACH,OAAO,CAAC;AAC5B,CAAC;;AAED;AACA;AADA;AAEO,MAAMO,4BAA4B,GAAG,CAC1CR,IAAe,EACfM,UAA2B,KACN;EACrB,MAAML,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACM,gBAAgB,CAACD,UAAU,CAAC;EAEpC,OAAO,IAAAF,4BAAU,EAACH,OAAO,CAAC;AAC5B,CAAC;AAAC"}
@@ -37,7 +37,7 @@ const autosave = (dispatch, form) => {
37
37
  // update last server update to indicate an update has happened
38
38
  // send the existing form to prevent updates in the ui based on autosave results
39
39
  form.lastServerUpdate = savedForm.lastServerUpdate;
40
- dispatch((0, _ModularUIActions.updateModel)(form));
40
+ dispatch((0, _ModularUIActions.updateForm)(form));
41
41
  dispatch(updateAutosave(_Constants.AUTOSAVE_STATUS.FINISHED, savedForm));
42
42
  }
43
43
  });
@@ -10,7 +10,7 @@ import {
10
10
  AUTOSAVE_STATUS,
11
11
  } from "../../constants/Constants";
12
12
 
13
- import { updateModel } from "../_modularui/ModularUIActions";
13
+ import { updateForm } from "../_modularui/ModularUIActions";
14
14
 
15
15
  import type { UpdateAutosaveAction, ThunkAction, Dispatch } from "../types";
16
16
 
@@ -49,7 +49,7 @@ const autosave = (dispatch: Dispatch, form: FormModel) => {
49
49
  // send the existing form to prevent updates in the ui based on autosave results
50
50
  form.lastServerUpdate = savedForm.lastServerUpdate;
51
51
 
52
- dispatch(updateModel(form));
52
+ dispatch(updateForm(form));
53
53
  dispatch(updateAutosave(AUTOSAVE_STATUS.FINISHED, savedForm));
54
54
  }
55
55
  });
@@ -1 +1 @@
1
- {"version":3,"file":"FormAutosave.js","names":["updateAutosave","status","model","type","payload","autosave","dispatch","form","AUTOSAVE_STATUS","START","formdata","getFormData","ModularUIRequest","selfhref","setParameter","method","HTTP_METHODS","POST","data","childmodels","locale","fetch","then","savedForm","FormModel","lastServerUpdate","updateModel","FINISHED","debouncedAutosave","debounce","VALIDATE_DEBOUNCE_TIMEOUT","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;AAEA;AACA;AAEA;AAMA;AAIA;AACA;AACA;AACA;AACA,MAAMA,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,CAACQ,0BAAe,CAACC,KAAK,EAAEF,IAAI,CAAC,CAAC;EAErD,MAAMG,QAAQ,GAAGH,IAAI,CAACI,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC;EAE9C,IAAIC,yBAAgB,CAACL,IAAI,CAACM,QAAQ,CAACC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;IACjEC,MAAM,EAAEC,uBAAY,CAACC,IAAI;IACzBC,IAAI,EAAER,QAAQ;IACdS,WAAW,EAAE,KAAK;IAClBC,MAAM,EAAEb,IAAI,CAACa;EACf,CAAC,CAAC,CACCC,KAAK,EAAE,CACPC,IAAI,CAAEC,SAAS,IAAK;IACnB,IAAIA,SAAS,YAAYC,kBAAS,EAAE;MAClC;MACA;MACAjB,IAAI,CAACkB,gBAAgB,GAAGF,SAAS,CAACE,gBAAgB;MAElDnB,QAAQ,CAAC,IAAAoB,6BAAW,EAACnB,IAAI,CAAC,CAAC;MAC3BD,QAAQ,CAACN,cAAc,CAACQ,0BAAe,CAACmB,QAAQ,EAAEJ,SAAS,CAAC,CAAC;IAC/D;EACF,CAAC,CAAC;AACN,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,iBAAiB,GAAG,IAAAC,iBAAQ,EAAC,CAACvB,QAAQ,EAAEC,IAAI,KAAK;EACrDF,QAAQ,CAACC,QAAQ,EAAEC,IAAI,CAAC;AAC1B,CAAC,EAAEuB,oCAAyB,CAAC;;AAE7B;AACA;AACO,MAAMC,kBAAkB,GAC5BxB,IAAe,IACfD,QAAQ,IACPsB,iBAAiB,CAACtB,QAAQ,EAAEC,IAAI,CAAC;AAAC"}
1
+ {"version":3,"file":"FormAutosave.js","names":["updateAutosave","status","model","type","payload","autosave","dispatch","form","AUTOSAVE_STATUS","START","formdata","getFormData","ModularUIRequest","selfhref","setParameter","method","HTTP_METHODS","POST","data","childmodels","locale","fetch","then","savedForm","FormModel","lastServerUpdate","updateForm","FINISHED","debouncedAutosave","debounce","VALIDATE_DEBOUNCE_TIMEOUT","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;AAEA;AACA;AAEA;AAMA;AAIA;AACA;AACA;AACA;AACA,MAAMA,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,CAACQ,0BAAe,CAACC,KAAK,EAAEF,IAAI,CAAC,CAAC;EAErD,MAAMG,QAAQ,GAAGH,IAAI,CAACI,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC;EAE9C,IAAIC,yBAAgB,CAACL,IAAI,CAACM,QAAQ,CAACC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;IACjEC,MAAM,EAAEC,uBAAY,CAACC,IAAI;IACzBC,IAAI,EAAER,QAAQ;IACdS,WAAW,EAAE,KAAK;IAClBC,MAAM,EAAEb,IAAI,CAACa;EACf,CAAC,CAAC,CACCC,KAAK,EAAE,CACPC,IAAI,CAAEC,SAAS,IAAK;IACnB,IAAIA,SAAS,YAAYC,kBAAS,EAAE;MAClC;MACA;MACAjB,IAAI,CAACkB,gBAAgB,GAAGF,SAAS,CAACE,gBAAgB;MAElDnB,QAAQ,CAAC,IAAAoB,4BAAU,EAACnB,IAAI,CAAC,CAAC;MAC1BD,QAAQ,CAACN,cAAc,CAACQ,0BAAe,CAACmB,QAAQ,EAAEJ,SAAS,CAAC,CAAC;IAC/D;EACF,CAAC,CAAC;AACN,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,iBAAiB,GAAG,IAAAC,iBAAQ,EAAC,CAACvB,QAAQ,EAAEC,IAAI,KAAK;EACrDF,QAAQ,CAACC,QAAQ,EAAEC,IAAI,CAAC;AAC1B,CAAC,EAAEuB,oCAAyB,CAAC;;AAE7B;AACA;AACO,MAAMC,kBAAkB,GAC5BxB,IAAe,IACfD,QAAQ,IACPsB,iBAAiB,CAACtB,QAAQ,EAAEC,IAAI,CAAC;AAAC"}
@@ -21,7 +21,7 @@ const updateValidations = (form, formWithValidations) => (dispatch, getState) =>
21
21
  if (validatedForm instanceof _FormModel.default) {
22
22
  validatedForm.updateValidations(formWithValidations.data);
23
23
  }
24
- dispatch((0, _ModularUIActions.updateModel)(validatedForm));
24
+ dispatch((0, _ModularUIActions.updateForm)(validatedForm));
25
25
  }
26
26
  };
27
27
 
@@ -1,7 +1,7 @@
1
1
  // @flow
2
2
  import debounce from "lodash/debounce";
3
3
 
4
- import { updateModel } from "../_modularui/ModularUIActions";
4
+ import { updateForm } from "../_modularui/ModularUIActions";
5
5
 
6
6
  import ModularUIRequest from "../../modularui/ModularUIRequest";
7
7
 
@@ -30,7 +30,7 @@ const updateValidations =
30
30
  validatedForm.updateValidations(formWithValidations.data);
31
31
  }
32
32
 
33
- dispatch(updateModel(validatedForm));
33
+ dispatch(updateForm(validatedForm));
34
34
  }
35
35
  };
36
36
 
@@ -1 +1 @@
1
- {"version":3,"file":"FormValidations.js","names":["updateValidations","form","formWithValidations","dispatch","getState","currentForm","modularui","connectKey","validatedForm","model","clone","FormModel","data","updateModel","debouncedValidateFormObject","debounce","ModularUIRequest","selfhref","setParameter","method","HTTP_METHODS","POST","validationData","childmodels","isValidationRequest","locale","fetch","then","VALIDATE_DEBOUNCE_TIMEOUT","leading","trailing","validateFormObject"],"sources":["../../../src/redux/actions/FormValidations.js"],"sourcesContent":["// @flow\nimport debounce from \"lodash/debounce\";\n\nimport { updateModel } from \"../_modularui/ModularUIActions\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\n\nimport {\n HTTP_METHODS,\n VALIDATE_DEBOUNCE_TIMEOUT,\n} from \"../../constants/Constants\";\n\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { Dispatch, GetState, ThunkAction } from \"../types\";\nimport type { ModularUIModel } from \"../../models\";\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 updateValidations =\n (form: FormModel, formWithValidations: ModularUIModel) =>\n (dispatch: Dispatch, getState: GetState) => {\n const currentForm = getState().modularui[form.connectKey];\n\n if (currentForm) {\n const validatedForm = currentForm.model.clone();\n if (validatedForm instanceof FormModel) {\n validatedForm.updateValidations(formWithValidations.data);\n }\n\n dispatch(updateModel(validatedForm));\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 debouncedValidateFormObject = debounce<\n (dispatch: Dispatch, form: FormModel) => void\n>(\n (dispatch, form: FormModel) => {\n new ModularUIRequest(form.selfhref.setParameter(\"commit\", \"false\"), {\n method: HTTP_METHODS.POST,\n data: form.validationData,\n childmodels: false,\n isValidationRequest: true,\n locale: form.locale,\n })\n .fetch()\n .then((formWithValidations) =>\n dispatch(updateValidations(form, formWithValidations))\n );\n },\n VALIDATE_DEBOUNCE_TIMEOUT,\n {\n leading: true,\n trailing: true,\n }\n);\n\n/**\n */\nexport const validateFormObject =\n (form: FormModel): ThunkAction =>\n (dispatch) =>\n debouncedValidateFormObject(dispatch, form);\n"],"mappings":";;;;;;;AACA;AAEA;AAEA;AAEA;AAKA;AAKA;AACA;AACA;AACA;AACA,MAAMA,iBAAiB,GACrB,CAACC,IAAe,EAAEC,mBAAmC,KACrD,CAACC,QAAkB,EAAEC,QAAkB,KAAK;EAC1C,MAAMC,WAAW,GAAGD,QAAQ,EAAE,CAACE,SAAS,CAACL,IAAI,CAACM,UAAU,CAAC;EAEzD,IAAIF,WAAW,EAAE;IACf,MAAMG,aAAa,GAAGH,WAAW,CAACI,KAAK,CAACC,KAAK,EAAE;IAC/C,IAAIF,aAAa,YAAYG,kBAAS,EAAE;MACtCH,aAAa,CAACR,iBAAiB,CAACE,mBAAmB,CAACU,IAAI,CAAC;IAC3D;IAEAT,QAAQ,CAAC,IAAAU,6BAAW,EAACL,aAAa,CAAC,CAAC;EACtC;AACF,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,2BAA2B,GAAG,IAAAC,iBAAQ,EAG1C,CAACZ,QAAQ,EAAEF,IAAe,KAAK;EAC7B,IAAIe,yBAAgB,CAACf,IAAI,CAACgB,QAAQ,CAACC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE;IAClEC,MAAM,EAAEC,uBAAY,CAACC,IAAI;IACzBT,IAAI,EAAEX,IAAI,CAACqB,cAAc;IACzBC,WAAW,EAAE,KAAK;IAClBC,mBAAmB,EAAE,IAAI;IACzBC,MAAM,EAAExB,IAAI,CAACwB;EACf,CAAC,CAAC,CACCC,KAAK,EAAE,CACPC,IAAI,CAAEzB,mBAAmB,IACxBC,QAAQ,CAACH,iBAAiB,CAACC,IAAI,EAAEC,mBAAmB,CAAC,CAAC,CACvD;AACL,CAAC,EACD0B,oCAAyB,EACzB;EACEC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;AACZ,CAAC,CACF;;AAED;AACA;AACO,MAAMC,kBAAkB,GAC5B9B,IAAe,IACfE,QAAQ,IACPW,2BAA2B,CAACX,QAAQ,EAAEF,IAAI,CAAC;AAAC"}
1
+ {"version":3,"file":"FormValidations.js","names":["updateValidations","form","formWithValidations","dispatch","getState","currentForm","modularui","connectKey","validatedForm","model","clone","FormModel","data","updateForm","debouncedValidateFormObject","debounce","ModularUIRequest","selfhref","setParameter","method","HTTP_METHODS","POST","validationData","childmodels","isValidationRequest","locale","fetch","then","VALIDATE_DEBOUNCE_TIMEOUT","leading","trailing","validateFormObject"],"sources":["../../../src/redux/actions/FormValidations.js"],"sourcesContent":["// @flow\nimport debounce from \"lodash/debounce\";\n\nimport { updateForm } from \"../_modularui/ModularUIActions\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\n\nimport {\n HTTP_METHODS,\n VALIDATE_DEBOUNCE_TIMEOUT,\n} from \"../../constants/Constants\";\n\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { Dispatch, GetState, ThunkAction } from \"../types\";\nimport type { ModularUIModel } from \"../../models\";\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 updateValidations =\n (form: FormModel, formWithValidations: ModularUIModel) =>\n (dispatch: Dispatch, getState: GetState) => {\n const currentForm = getState().modularui[form.connectKey];\n\n if (currentForm) {\n const validatedForm = currentForm.model.clone();\n if (validatedForm instanceof FormModel) {\n validatedForm.updateValidations(formWithValidations.data);\n }\n\n dispatch(updateForm(validatedForm));\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 debouncedValidateFormObject = debounce<\n (dispatch: Dispatch, form: FormModel) => void\n>(\n (dispatch, form: FormModel) => {\n new ModularUIRequest(form.selfhref.setParameter(\"commit\", \"false\"), {\n method: HTTP_METHODS.POST,\n data: form.validationData,\n childmodels: false,\n isValidationRequest: true,\n locale: form.locale,\n })\n .fetch()\n .then((formWithValidations) =>\n dispatch(updateValidations(form, formWithValidations))\n );\n },\n VALIDATE_DEBOUNCE_TIMEOUT,\n {\n leading: true,\n trailing: true,\n }\n);\n\n/**\n */\nexport const validateFormObject =\n (form: FormModel): ThunkAction =>\n (dispatch) =>\n debouncedValidateFormObject(dispatch, form);\n"],"mappings":";;;;;;;AACA;AAEA;AAEA;AAEA;AAKA;AAKA;AACA;AACA;AACA;AACA,MAAMA,iBAAiB,GACrB,CAACC,IAAe,EAAEC,mBAAmC,KACrD,CAACC,QAAkB,EAAEC,QAAkB,KAAK;EAC1C,MAAMC,WAAW,GAAGD,QAAQ,EAAE,CAACE,SAAS,CAACL,IAAI,CAACM,UAAU,CAAC;EAEzD,IAAIF,WAAW,EAAE;IACf,MAAMG,aAAa,GAAGH,WAAW,CAACI,KAAK,CAACC,KAAK,EAAE;IAC/C,IAAIF,aAAa,YAAYG,kBAAS,EAAE;MACtCH,aAAa,CAACR,iBAAiB,CAACE,mBAAmB,CAACU,IAAI,CAAC;IAC3D;IAEAT,QAAQ,CAAC,IAAAU,4BAAU,EAACL,aAAa,CAAC,CAAC;EACrC;AACF,CAAC;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA,MAAMM,2BAA2B,GAAG,IAAAC,iBAAQ,EAG1C,CAACZ,QAAQ,EAAEF,IAAe,KAAK;EAC7B,IAAIe,yBAAgB,CAACf,IAAI,CAACgB,QAAQ,CAACC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE;IAClEC,MAAM,EAAEC,uBAAY,CAACC,IAAI;IACzBT,IAAI,EAAEX,IAAI,CAACqB,cAAc;IACzBC,WAAW,EAAE,KAAK;IAClBC,mBAAmB,EAAE,IAAI;IACzBC,MAAM,EAAExB,IAAI,CAACwB;EACf,CAAC,CAAC,CACCC,KAAK,EAAE,CACPC,IAAI,CAAEzB,mBAAmB,IACxBC,QAAQ,CAACH,iBAAiB,CAACC,IAAI,EAAEC,mBAAmB,CAAC,CAAC,CACvD;AACL,CAAC,EACD0B,oCAAyB,EACzB;EACEC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE;AACZ,CAAC,CACF;;AAED;AACA;AACO,MAAMC,kBAAkB,GAC5B9B,IAAe,IACfE,QAAQ,IACPW,2BAA2B,CAACX,QAAQ,EAAEF,IAAI,CAAC;AAAC"}
@@ -15,7 +15,7 @@ describe("form actions", () => {
15
15
 
16
16
  expect(store.getActions()).toStrictEqual([
17
17
  {
18
- type: "MODULARUI/UPDATE",
18
+ type: "MODULARUI/UPDATE_FORM",
19
19
  payload: expect.objectContaining({
20
20
  _contributions: expect.objectContaining({
21
21
  label: "Create person",
@@ -16,10 +16,7 @@ import type { AbstractComponent } from "react";
16
16
  import type FormModel from "../../models/form/FormModel";
17
17
  import type { ContextRouter } from "react-router";
18
18
  import type { ReduxState, ThunkAction } from "../types";
19
- import type {
20
- ModularUIConnector,
21
- UpdateModelAction,
22
- } from "../_modularui/types";
19
+ import type { ModularUIConnector, UpdateFormAction } from "../_modularui/types";
23
20
 
24
21
  type OwnProps = {
25
22
  ...?ContextRouter,
@@ -33,7 +30,7 @@ type StateProps = {
33
30
  };
34
31
 
35
32
  type DispatchProps = {
36
- onPrevious: (form: FormModel) => UpdateModelAction,
33
+ onPrevious: (form: FormModel) => UpdateFormAction,
37
34
  onCancel: (form: FormModel) => ThunkAction,
38
35
  showFormNotification: (form: FormModel) => ThunkAction,
39
36
  };