@beinformed/ui 1.60.5 → 1.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/esm/hooks/__tests__/useForm.spec.js.flow +1 -1
  3. package/esm/hooks/useForm.js +15 -20
  4. package/esm/hooks/useForm.js.flow +5 -14
  5. package/esm/hooks/useForm.js.map +1 -1
  6. package/esm/hooks/useModularUI.d.ts +0 -1
  7. package/esm/hooks/useModularUI.js +3 -11
  8. package/esm/hooks/useModularUI.js.flow +4 -23
  9. package/esm/hooks/useModularUI.js.map +1 -1
  10. package/esm/models/attributes/AttributeCollection.js +2 -2
  11. package/esm/models/attributes/AttributeCollection.js.map +1 -1
  12. package/esm/models/attributes/AttributeContent.js +1 -1
  13. package/esm/models/attributes/AttributeContent.js.flow +1 -1
  14. package/esm/models/attributes/AttributeContent.js.map +1 -1
  15. package/esm/models/attributes/CompositeAttributeChildCollection.js +4 -4
  16. package/esm/models/attributes/CompositeAttributeChildCollection.js.map +1 -1
  17. package/esm/models/concepts/ConceptDetailModel.js +9 -9
  18. package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
  19. package/esm/models/content/ContentTOCModel.d.ts +7 -0
  20. package/esm/models/content/ContentTOCModel.js +35 -8
  21. package/esm/models/content/ContentTOCModel.js.flow +36 -9
  22. package/esm/models/content/ContentTOCModel.js.map +1 -1
  23. package/esm/models/content/SectionModel.d.ts +3 -0
  24. package/esm/models/content/SectionModel.js +11 -2
  25. package/esm/models/content/SectionModel.js.flow +11 -0
  26. package/esm/models/content/SectionModel.js.map +1 -1
  27. package/esm/models/content/SubSectionModel.d.ts +1 -1
  28. package/esm/models/content/SubSectionModel.js.flow +1 -1
  29. package/esm/models/content/SubSectionModel.js.map +1 -1
  30. package/esm/models/content/__tests__/Formalsource.spec.js.flow +91 -0
  31. package/esm/models/form/FormModel.js +33 -33
  32. package/esm/models/form/FormModel.js.map +1 -1
  33. package/esm/models/form/FormObjectModel.d.ts +13 -12
  34. package/esm/models/form/FormObjectModel.js +10 -9
  35. package/esm/models/form/FormObjectModel.js.flow +41 -27
  36. package/esm/models/form/FormObjectModel.js.map +1 -1
  37. package/esm/models/form/__tests__/FormValidation.spec.js.flow +79 -0
  38. package/esm/models/href/Href.js +6 -6
  39. package/esm/models/href/Href.js.map +1 -1
  40. package/esm/models/links/LinkCollection.js +4 -4
  41. package/esm/models/links/LinkCollection.js.map +1 -1
  42. package/esm/redux/_modularui/ModularUIActions.d.ts +2 -2
  43. package/esm/redux/_modularui/ModularUIActions.js +27 -10
  44. package/esm/redux/_modularui/ModularUIActions.js.flow +24 -5
  45. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  46. package/esm/redux/_modularui/ModularUIMiddleware.js +1 -1
  47. package/esm/redux/_modularui/ModularUIMiddleware.js.flow +1 -1
  48. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  49. package/esm/redux/_modularui/ModularUIReducer.js +4 -2
  50. package/esm/redux/_modularui/ModularUIReducer.js.flow +10 -1
  51. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  52. package/esm/redux/_modularui/ModularUISelectors.js +2 -2
  53. package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
  54. package/esm/redux/_modularui/__tests__/actions.spec.js.flow +5 -1
  55. package/esm/redux/_modularui/types.d.ts +1 -0
  56. package/esm/redux/_modularui/types.js.flow +2 -0
  57. package/esm/redux/_modularui/types.js.map +1 -1
  58. package/esm/utils/helpers/text.d.ts +1 -1
  59. package/esm/utils/helpers/text.js +1 -1
  60. package/esm/utils/helpers/text.js.flow +2 -2
  61. package/esm/utils/helpers/text.js.map +1 -1
  62. package/lib/hooks/useDeepCompareEffect.js +1 -2
  63. package/lib/hooks/useDeepCompareEffect.js.map +1 -1
  64. package/lib/hooks/useForm.js +14 -19
  65. package/lib/hooks/useForm.js.map +1 -1
  66. package/lib/hooks/useModularUI.d.ts +0 -1
  67. package/lib/hooks/useModularUI.js +4 -13
  68. package/lib/hooks/useModularUI.js.map +1 -1
  69. package/lib/i18n/index.js +1 -2
  70. package/lib/i18n/index.js.map +1 -1
  71. package/lib/models/attributes/AttributeCollection.js +2 -2
  72. package/lib/models/attributes/AttributeCollection.js.map +1 -1
  73. package/lib/models/attributes/AttributeContent.js +1 -1
  74. package/lib/models/attributes/AttributeContent.js.map +1 -1
  75. package/lib/models/attributes/CompositeAttributeChildCollection.js +4 -4
  76. package/lib/models/attributes/CompositeAttributeChildCollection.js.map +1 -1
  77. package/lib/models/concepts/ConceptDetailModel.js +9 -9
  78. package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
  79. package/lib/models/content/ContentTOCModel.d.ts +7 -0
  80. package/lib/models/content/ContentTOCModel.js +35 -8
  81. package/lib/models/content/ContentTOCModel.js.map +1 -1
  82. package/lib/models/content/SectionModel.d.ts +3 -0
  83. package/lib/models/content/SectionModel.js +11 -2
  84. package/lib/models/content/SectionModel.js.map +1 -1
  85. package/lib/models/content/SubSectionModel.d.ts +1 -1
  86. package/lib/models/content/SubSectionModel.js.map +1 -1
  87. package/lib/models/form/FormModel.js +33 -33
  88. package/lib/models/form/FormModel.js.map +1 -1
  89. package/lib/models/form/FormObjectModel.d.ts +13 -12
  90. package/lib/models/form/FormObjectModel.js +10 -9
  91. package/lib/models/form/FormObjectModel.js.map +1 -1
  92. package/lib/models/href/Href.js +6 -6
  93. package/lib/models/href/Href.js.map +1 -1
  94. package/lib/models/index.js +1 -2
  95. package/lib/models/index.js.map +1 -1
  96. package/lib/models/links/LinkCollection.js +4 -4
  97. package/lib/models/links/LinkCollection.js.map +1 -1
  98. package/lib/react-server/serverUtil.js +1 -2
  99. package/lib/react-server/serverUtil.js.map +1 -1
  100. package/lib/redux/_modularui/ModularUIActions.d.ts +2 -2
  101. package/lib/redux/_modularui/ModularUIActions.js +27 -10
  102. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  103. package/lib/redux/_modularui/ModularUIMiddleware.js +1 -1
  104. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  105. package/lib/redux/_modularui/ModularUIReducer.js +4 -2
  106. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  107. package/lib/redux/_modularui/ModularUISelectors.js +2 -2
  108. package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
  109. package/lib/redux/_modularui/types.d.ts +1 -0
  110. package/lib/redux/_modularui/types.js.map +1 -1
  111. package/lib/utils/helpers/text.d.ts +1 -1
  112. package/lib/utils/helpers/text.js +1 -1
  113. package/lib/utils/helpers/text.js.map +1 -1
  114. package/package.json +17 -17
  115. package/src/hooks/__tests__/useForm.spec.js +1 -1
  116. package/src/hooks/useForm.js +5 -14
  117. package/src/hooks/useModularUI.js +4 -23
  118. package/src/models/attributes/AttributeContent.js +1 -1
  119. package/src/models/content/ContentTOCModel.js +36 -9
  120. package/src/models/content/SectionModel.js +11 -0
  121. package/src/models/content/SubSectionModel.js +1 -1
  122. package/src/models/content/__tests__/Formalsource.spec.js +91 -0
  123. package/src/models/content/__tests__/formalsource-complete.json +234 -0
  124. package/src/models/content/__tests__/formalsource-contributions.json +110 -0
  125. package/src/models/content/__tests__/formalsource-section-contributions.json +84 -0
  126. package/src/models/content/__tests__/formalsource-section.json +60 -0
  127. package/src/models/content/__tests__/formalsource-toc.json +119 -0
  128. package/src/models/form/FormObjectModel.js +41 -27
  129. package/src/models/form/__tests__/FormValidation.spec.js +79 -0
  130. package/src/models/form/__tests__/FormValidationContributions.json +45 -0
  131. package/src/models/form/__tests__/FormValidationDataInitial.json +33 -0
  132. package/src/models/form/__tests__/FormValidationDataUpdate1.json +25 -0
  133. package/src/models/form/__tests__/FormValidationDataUpdate2.json +33 -0
  134. package/src/redux/_modularui/ModularUIActions.js +24 -5
  135. package/src/redux/_modularui/ModularUIMiddleware.js +1 -1
  136. package/src/redux/_modularui/ModularUIReducer.js +10 -1
  137. package/src/redux/_modularui/__tests__/actions.spec.js +5 -1
  138. package/src/redux/_modularui/types.js +2 -0
  139. package/src/utils/helpers/text.js +2 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.61.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.60.6...v1.61.0) (2025-06-02)
6
+
7
+
8
+ ### Features
9
+
10
+ * **formalsource:** allow loading of complete formal source into model ([d6a287f](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d6a287fb09f9b9245584ba586ce93eeaf2b607fd))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **form-validation:** handle combination of missing and error ([dad649a](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/dad649aba14e567ea0168a512297f45d5da0f720))
16
+
17
+ ## [1.60.6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.60.5...v1.60.6) (2025-04-15)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **modularui:** retry req when qs is changed but original req still loading ([1ffa2ee](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/1ffa2eeccf7520b941f346fc2583afd028118e23))
23
+
5
24
  ## [1.60.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.60.4...v1.60.5) (2025-04-14)
6
25
 
7
26
 
@@ -73,7 +73,7 @@ describe("form hooks", () => {
73
73
  {
74
74
  type: "MODULARUI/FETCH",
75
75
  payload: expect.objectContaining({
76
- key: "form(/form?commit=false)(en)",
76
+ key: "form(/form)(en)",
77
77
  href: new Href("/form?commit=false"),
78
78
  locale: "en",
79
79
  targetModel: FormModel,
@@ -2,11 +2,9 @@ import { useDispatch } from "react-redux";
2
2
  import Href from "../models/href/Href";
3
3
  import { getSetting, HTTP_METHODS } from "../constants";
4
4
  import { loadModularUI, removeModelByKey } from "../redux/_modularui";
5
- import { createKeyForModularUIStore, useModularUI } from "./useModularUI";
5
+ import { useModularUI } from "./useModularUI";
6
6
  import { addRepeatableAttributeSet, cancelForm, cancelRepeatableAttributeSet, previousObject, removeRepeatableAttributeSet, showFormNotification, updateFormAttribute } from "../redux/actions";
7
7
  import FormModel from "../models/form/FormModel";
8
- const FORM_MODEL_KEY = "form";
9
-
10
8
  /**
11
9
  * Load a form by href
12
10
  */
@@ -15,7 +13,7 @@ export const useForm = (href, data) => {
15
13
  if (!getSetting("ALWAYS_COMMIT_FORM")) {
16
14
  formHref.addParameter("commit", "false");
17
15
  }
18
- const form = useModularUI(FORM_MODEL_KEY, formHref, {
16
+ const form = useModularUI("form", formHref, {
19
17
  method: HTTP_METHODS.POST,
20
18
  targetModel: FormModel,
21
19
  removeOnUnmount: true,
@@ -35,22 +33,19 @@ export const useFormNavigation = () => {
35
33
  const dispatch = useDispatch();
36
34
  const previous = form => dispatch(previousObject(form));
37
35
  const cancel = form => dispatch(cancelForm(form));
38
- const submit = form => {
39
- const connectKey = createKeyForModularUIStore(FORM_MODEL_KEY, form.selfhref.toString(), form.locale);
40
- return dispatch(loadModularUI(connectKey, form.selfhref, {
41
- method: HTTP_METHODS.POST,
42
- data: form.formdata,
43
- updateHandler: newModel => {
44
- if (newModel instanceof FormModel) {
45
- const clonedModel = form.clone();
46
- clonedModel.update(newModel);
47
- return clonedModel;
48
- }
49
- return newModel;
50
- },
51
- targetModel: FormModel
52
- }));
53
- };
36
+ const submit = form => dispatch(loadModularUI(form.connectKey, form.selfhref, {
37
+ method: HTTP_METHODS.POST,
38
+ data: form.formdata,
39
+ updateHandler: newModel => {
40
+ if (newModel instanceof FormModel) {
41
+ const clonedModel = form.clone();
42
+ clonedModel.update(newModel);
43
+ return clonedModel;
44
+ }
45
+ return newModel;
46
+ },
47
+ targetModel: FormModel
48
+ }));
54
49
  const remove = form => dispatch(removeModelByKey(form.connectKey));
55
50
  const showFormNotificationAction = form => dispatch(showFormNotification(form));
56
51
  return {
@@ -10,7 +10,7 @@ import type {
10
10
  UpdateFormAction,
11
11
  } from "../redux/_modularui";
12
12
  import { loadModularUI, removeModelByKey } from "../redux/_modularui";
13
- import { createKeyForModularUIStore, useModularUI } from "./useModularUI";
13
+ import { useModularUI } from "./useModularUI";
14
14
 
15
15
  import {
16
16
  addRepeatableAttributeSet,
@@ -47,8 +47,6 @@ type AttributeUpdateHook = (
47
47
  options: UpdateFormOptions,
48
48
  ) => void;
49
49
 
50
- const FORM_MODEL_KEY = "form";
51
-
52
50
  /**
53
51
  * Load a form by href
54
52
  */
@@ -59,7 +57,7 @@ export const useForm = (href: string | Href, data?: Object): ?FormModel => {
59
57
  formHref.addParameter("commit", "false");
60
58
  }
61
59
 
62
- const form = useModularUI(FORM_MODEL_KEY, formHref, {
60
+ const form = useModularUI("form", formHref, {
63
61
  method: HTTP_METHODS.POST,
64
62
  targetModel: FormModel,
65
63
  removeOnUnmount: true,
@@ -83,15 +81,9 @@ export const useFormNavigation = (): FormNavigationHook => {
83
81
 
84
82
  const cancel = (form: FormModel) => dispatch(cancelForm(form));
85
83
 
86
- const submit = (form: FormModel) => {
87
- const connectKey = createKeyForModularUIStore(
88
- FORM_MODEL_KEY,
89
- form.selfhref.toString(),
90
- form.locale,
91
- );
92
-
93
- return dispatch(
94
- loadModularUI(connectKey, form.selfhref, {
84
+ const submit = (form: FormModel) =>
85
+ dispatch(
86
+ loadModularUI(form.connectKey, form.selfhref, {
95
87
  method: HTTP_METHODS.POST,
96
88
  data: form.formdata,
97
89
  updateHandler: (newModel: ModularUIModel): ModularUIModel => {
@@ -105,7 +97,6 @@ export const useFormNavigation = (): FormNavigationHook => {
105
97
  targetModel: FormModel,
106
98
  }),
107
99
  );
108
- };
109
100
 
110
101
  const remove = (form: FormModel) =>
111
102
  dispatch(removeModelByKey(form.connectKey));
@@ -1 +1 @@
1
- {"version":3,"file":"useForm.js","names":["useDispatch","Href","getSetting","HTTP_METHODS","loadModularUI","removeModelByKey","createKeyForModularUIStore","useModularUI","addRepeatableAttributeSet","cancelForm","cancelRepeatableAttributeSet","previousObject","removeRepeatableAttributeSet","showFormNotification","updateFormAttribute","FormModel","FORM_MODEL_KEY","useForm","href","data","formHref","addParameter","form","method","POST","targetModel","removeOnUnmount","origin","contextPath","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","toString","locale","formdata","updateHandler","newModel","clonedModel","clone","update","remove","showFormNotificationAction","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport type {\n RemoveModelByKeyAction,\n UpdateFormAction,\n} from \"../redux/_modularui\";\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { createKeyForModularUIStore, useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { AttributeType, FormObjectModel, ModularUIModel } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateFormAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateFormAction,\n cancel: (object: FormObjectModel) => UpdateFormAction,\n remove: (object: FormObjectModel) => UpdateFormAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n) => void;\n\nconst FORM_MODEL_KEY = \"form\";\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href, data?: Object): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(FORM_MODEL_KEY, formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n data,\n origin: formHref.origin,\n contextPath: formHref.contextPath,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) => {\n const connectKey = createKeyForModularUIStore(\n FORM_MODEL_KEY,\n form.selfhref.toString(),\n form.locale,\n );\n\n return dispatch(\n loadModularUI(connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n const clonedModel: FormModel = form.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n targetModel: FormModel,\n }),\n );\n };\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Hook that returns a function to update attributes of a form object.\n * <br >\n * The returned function accepts the following options:\n *\n * - autosubmit: Automatically submit the form after a change\n * - autosav: Automatically save the form (in the background) after a change\n * - autoupdate: Automatically update the current form object after a change\n * - forceUpdate: Force the update even if conditions are not met.\n * - validate: Activate/deactivate the form object validation by an update.\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel,\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,OAAOC,IAAI,MAAM,qBAAqB;AAEtC,SAASC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AAMvD,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,qBAAqB;AACrE,SAASC,0BAA0B,EAAEC,YAAY,QAAQ,gBAAgB;AAEzE,SACEC,yBAAyB,EACzBC,UAAU,EACVC,4BAA4B,EAC5BC,cAAc,EACdC,4BAA4B,EAC5BC,oBAAoB,EACpBC,mBAAmB,QACd,kBAAkB;AAEzB,OAAOC,SAAS,MAAM,0BAA0B;AAyBhD,MAAMC,cAAc,GAAG,MAAM;;AAE7B;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAGA,CAACC,IAAmB,EAAEC,IAAa,KAAiB;EACzE,MAAMC,QAAQ,GAAG,IAAInB,IAAI,CAACiB,IAAI,CAAC;EAE/B,IAAI,CAAChB,UAAU,CAAC,oBAAoB,CAAC,EAAE;IACrCkB,QAAQ,CAACC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;EAC1C;EAEA,MAAMC,IAAI,GAAGf,YAAY,CAACS,cAAc,EAAEI,QAAQ,EAAE;IAClDG,MAAM,EAAEpB,YAAY,CAACqB,IAAI;IACzBC,WAAW,EAAEV,SAAS;IACtBW,eAAe,EAAE,IAAI;IACrBP,IAAI;IACJQ,MAAM,EAAEP,QAAQ,CAACO,MAAM;IACvBC,WAAW,EAAER,QAAQ,CAACQ;EACxB,CAAC,CAAC;EAEF,IAAIN,IAAI,EAAEO,KAAK,EAAE;IACf,OAAOP,IAAI,CAACO,KAAK;EACnB;AACF,CAAC;;AAED;AACA;AACA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AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAGA,CAChCzB,IAAe,EACf0B,MAAuB,KACC;EACxB,MAAMjB,QAAQ,GAAG/B,WAAW,CAAC,CAAC;EAE9B,OAAO,CACLiD,SAAwB,EACxBC,KAAa,EACbC,OAA0B,KACvBpB,QAAQ,CAACjB,mBAAmB,CAACQ,IAAI,EAAE0B,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAAC;AAC7E,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAI9B,IAAe,IAAuB;EACpE,MAAMS,QAAQ,GAAG/B,WAAW,CAAC,CAAC;EAE9B,OAAO;IACLqD,IAAI,EAAEA,CAAA,KAAMtB,QAAQ,CAACvB,yBAAyB,CAACc,IAAI,CAAC,CAAC;IACrDW,MAAM,EAAGe,MAAuB,IAC9BjB,QAAQ,CAACrB,4BAA4B,CAACY,IAAI,EAAE0B,MAAM,CAAC,CAAC;IACtDH,MAAM,EAAGG,MAAuB,IAC9BjB,QAAQ,CAACnB,4BAA4B,CAACU,IAAI,EAAE0B,MAAM,CAAC;EACvD,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useForm.js","names":["useDispatch","Href","getSetting","HTTP_METHODS","loadModularUI","removeModelByKey","useModularUI","addRepeatableAttributeSet","cancelForm","cancelRepeatableAttributeSet","previousObject","removeRepeatableAttributeSet","showFormNotification","updateFormAttribute","FormModel","useForm","href","data","formHref","addParameter","form","method","POST","targetModel","removeOnUnmount","origin","contextPath","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","formdata","updateHandler","newModel","clonedModel","clone","update","remove","showFormNotificationAction","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport type {\n RemoveModelByKeyAction,\n UpdateFormAction,\n} from \"../redux/_modularui\";\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { AttributeType, FormObjectModel, ModularUIModel } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateFormAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateFormAction,\n cancel: (object: FormObjectModel) => UpdateFormAction,\n remove: (object: FormObjectModel) => UpdateFormAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href, data?: Object): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n data,\n origin: formHref.origin,\n contextPath: formHref.contextPath,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n const clonedModel: FormModel = form.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n targetModel: FormModel,\n }),\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Hook that returns a function to update attributes of a form object.\n * <br >\n * The returned function accepts the following options:\n *\n * - autosubmit: Automatically submit the form after a change\n * - autosav: Automatically save the form (in the background) after a change\n * - autoupdate: Automatically update the current form object after a change\n * - forceUpdate: Force the update even if conditions are not met.\n * - validate: Activate/deactivate the form object validation by an update.\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel,\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,OAAOC,IAAI,MAAM,qBAAqB;AAEtC,SAASC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AAMvD,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,qBAAqB;AACrE,SAASC,YAAY,QAAQ,gBAAgB;AAE7C,SACEC,yBAAyB,EACzBC,UAAU,EACVC,4BAA4B,EAC5BC,cAAc,EACdC,4BAA4B,EAC5BC,oBAAoB,EACpBC,mBAAmB,QACd,kBAAkB;AAEzB,OAAOC,SAAS,MAAM,0BAA0B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1,3 @@
1
- export function createKeyForModularUIStore(modelKey: string, url: string, locale: string): string;
2
1
  export function useModularUI(modelKey: string, url: string | Href, options?: RequestModularUIOptions): any;
3
2
  import Href from "../models/href/Href";
4
3
  import { RequestModularUIOptions } from "../utils";
@@ -8,17 +8,9 @@ import { useLocale } from "./useI18n";
8
8
  import Href from "../models/href/Href";
9
9
  /**
10
10
  */
11
- export const createKeyForModularUIStore = (modelKey, url, locale) => {
12
- return `${modelKey}(${url})(${locale})`;
13
- };
14
-
15
- /**
16
- */
17
- const useKeyForHook = function (modelKey, url) {
18
- let removeQuerystringFromKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
11
+ const useKeyForHook = (modelKey, url) => {
19
12
  const locale = useLocale();
20
- const href = removeQuerystringFromKey ? url.split("?")[0] : url;
21
- return useMemo(() => createKeyForModularUIStore(modelKey, href, locale), [modelKey, href, locale]);
13
+ return useMemo(() => `${modelKey}(${url.split("?")[0]})(${locale})`, [modelKey, url, locale]);
22
14
  };
23
15
 
24
16
  /**
@@ -31,7 +23,7 @@ export const useModularUI = function (modelKey, url) {
31
23
  };
32
24
  const dispatch = useDispatch();
33
25
  const href = useMemo(() => url?.toString() || "", [url]);
34
- const key = useKeyForHook(modelKey, href, !options.method || options.method === HTTP_METHODS.GET);
26
+ const key = useKeyForHook(modelKey, href);
35
27
  const modelSelector = useMemo(() => state => state.modularui[key], [key]);
36
28
  const model = useSelector(modelSelector);
37
29
  if (url instanceof Href) {
@@ -18,26 +18,11 @@ import type { RequestModularUIOptions } from "../utils";
18
18
 
19
19
  /**
20
20
  */
21
- export const createKeyForModularUIStore = (
22
- modelKey: string,
23
- url: string,
24
- locale: string,
25
- ): string => {
26
- return `${modelKey}(${url})(${locale})`;
27
- };
28
-
29
- /**
30
- */
31
- const useKeyForHook = (
32
- modelKey: string,
33
- url: string,
34
- removeQuerystringFromKey: boolean = true,
35
- ): string => {
21
+ const useKeyForHook = (modelKey: string, url: string) => {
36
22
  const locale = useLocale();
37
- const href = removeQuerystringFromKey ? url.split("?")[0] : url;
38
23
  return useMemo(
39
- () => createKeyForModularUIStore(modelKey, href, locale),
40
- [modelKey, href, locale],
24
+ () => `${modelKey}(${url.split("?")[0]})(${locale})`,
25
+ [modelKey, url, locale],
41
26
  );
42
27
  };
43
28
 
@@ -54,11 +39,7 @@ export const useModularUI = (
54
39
  ): any => {
55
40
  const dispatch = useDispatch();
56
41
  const href = useMemo(() => url?.toString() || "", [url]);
57
- const key = useKeyForHook(
58
- modelKey,
59
- href,
60
- !options.method || options.method === HTTP_METHODS.GET,
61
- );
42
+ const key = useKeyForHook(modelKey, href);
62
43
 
63
44
  const modelSelector = useMemo(() => (state) => state.modularui[key], [key]);
64
45
  const model = useSelector(modelSelector);
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useMemo","useDispatch","useSelector","useLocation","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useLocale","Href","createKeyForModularUIStore","modelKey","url","locale","useKeyForHook","removeQuerystringFromKey","arguments","length","undefined","href","split","useModularUI","options","method","GET","removeOnUnmount","dispatch","toString","key","modelSelector","state","modularui","model","origin","contextPath","location","redirectLocation","forceLoad","equals","prevOptions","prevHref","prevForceLoad","isOldReload","current","isReload","doForceLoad"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef, useMemo } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\nimport Href from \"../models/href/Href\";\n\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n */\nexport const createKeyForModularUIStore = (\n modelKey: string,\n url: string,\n locale: string,\n): string => {\n return `${modelKey}(${url})(${locale})`;\n};\n\n/**\n */\nconst useKeyForHook = (\n modelKey: string,\n url: string,\n removeQuerystringFromKey: boolean = true,\n): string => {\n const locale = useLocale();\n const href = removeQuerystringFromKey ? url.split(\"?\")[0] : url;\n return useMemo(\n () => createKeyForModularUIStore(modelKey, href, locale),\n [modelKey, href, locale],\n );\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n },\n): any => {\n const dispatch = useDispatch();\n const href = useMemo(() => url?.toString() || \"\", [url]);\n const key = useKeyForHook(\n modelKey,\n href,\n !options.method || options.method === HTTP_METHODS.GET,\n );\n\n const modelSelector = useMemo(() => (state) => state.modularui[key], [key]);\n const model = useSelector(modelSelector);\n\n if (url instanceof Href) {\n options.origin = options.origin ?? url.origin;\n options.contextPath = options.contextPath ?? url.contextPath;\n }\n\n const location = useLocation();\n const redirectLocation = location.state?.redirectLocation;\n const forceLoad =\n model == null ||\n (redirectLocation instanceof Href ? redirectLocation?.equals(href) : false);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n const prevForceLoad = useRef(forceLoad);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n const doForceLoad = forceLoad && !prevForceLoad.current;\n\n if (href !== \"\" && (doForceLoad || !isOldReload)) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n prevForceLoad.current = forceLoad;\n }, [key, href, options, forceLoad]);\n\n useEffect(() => {\n if (options.removeOnUnmount) {\n return () => {\n dispatch(removeModelByKey(key));\n };\n }\n }, [dispatch, key, options.removeOnUnmount]);\n\n return model;\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AAClD,SAASC,WAAW,EAAEC,W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,SAAS,IAAI,CAACI,aAAa,CAACE,OAAO;IAEvD,IAAIxB,IAAI,KAAK,EAAE,KAAK0B,WAAW,IAAI,CAACH,WAAW,CAAC,EAAE;MAChDhB,QAAQ,CAACrB,aAAa,CAACuB,GAAG,EAAET,IAAI,EAAEG,OAAO,CAAC,CAAC;IAC7C;IAEAiB,WAAW,CAACI,OAAO,GAAGrB,OAAO;IAC7BkB,QAAQ,CAACG,OAAO,GAAGxB,IAAI;IACvBsB,aAAa,CAACE,OAAO,GAAGN,SAAS;EACnC,CAAC,EAAE,CAACT,GAAG,EAAET,IAAI,EAAEG,OAAO,EAAEe,SAAS,CAAC,CAAC;EAEnCvC,SAAS,CAAC,MAAM;IACd,IAAIwB,OAAO,CAACG,eAAe,EAAE;MAC3B,OAAO,MAAM;QACXC,QAAQ,CAACpB,gBAAgB,CAACsB,GAAG,CAAC,CAAC;MACjC,CAAC;IACH;EACF,CAAC,EAAE,CAACF,QAAQ,EAAEE,GAAG,EAAEN,OAAO,CAACG,eAAe,CAAC,CAAC;EAE5C,OAAOO,KAAK;AACd,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useMemo","useDispatch","useSelector","useLocation","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useLocale","Href","useKeyForHook","modelKey","url","locale","split","useModularUI","options","arguments","length","undefined","method","GET","removeOnUnmount","dispatch","href","toString","key","modelSelector","state","modularui","model","origin","contextPath","location","redirectLocation","forceLoad","equals","prevOptions","prevHref","prevForceLoad","isOldReload","current","isReload","doForceLoad"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef, useMemo } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\nimport Href from \"../models/href/Href\";\n\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return useMemo(\n () => `${modelKey}(${url.split(\"?\")[0]})(${locale})`,\n [modelKey, url, locale],\n );\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n },\n): any => {\n const dispatch = useDispatch();\n const href = useMemo(() => url?.toString() || \"\", [url]);\n const key = useKeyForHook(modelKey, href);\n\n const modelSelector = useMemo(() => (state) => state.modularui[key], [key]);\n const model = useSelector(modelSelector);\n\n if (url instanceof Href) {\n options.origin = options.origin ?? url.origin;\n options.contextPath = options.contextPath ?? url.contextPath;\n }\n\n const location = useLocation();\n const redirectLocation = location.state?.redirectLocation;\n const forceLoad =\n model == null ||\n (redirectLocation instanceof Href ? redirectLocation?.equals(href) : false);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n const prevForceLoad = useRef(forceLoad);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n const doForceLoad = forceLoad && !prevForceLoad.current;\n\n if (href !== \"\" && (doForceLoad || !isOldReload)) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n prevForceLoad.current = forceLoad;\n }, [key, href, options, forceLoad]);\n\n useEffect(() => {\n if (options.removeOnUnmount) {\n return () => {\n dispatch(removeModelByKey(key));\n };\n }\n }, [dispatch, key, options.removeOnUnmount]);\n\n return model;\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AAClD,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa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AAIkB,OAAO,CAACM,eAAe,EAAE;MAC3B,OAAO,MAAM;QACXC,QAAQ,CAACjB,gBAAgB,CAACoB,GAAG,CAAC,CAAC;MACjC,CAAC;IACH;EACF,CAAC,EAAE,CAACH,QAAQ,EAAEG,GAAG,EAAEV,OAAO,CAACM,eAAe,CAAC,CAAC;EAE5C,OAAOQ,KAAK;AACd,CAAC","ignoreList":[]}
@@ -250,9 +250,9 @@ class AttributeCollection extends ResourceCollection {
250
250
  /**
251
251
  */
252
252
  getFormData() {
253
- var _context9, _context10;
253
+ var _context9, _context0;
254
254
  let validationData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
255
- const attributesFormData = _mapInstanceProperty(_context9 = _filterInstanceProperty(_context10 = this.attributes).call(_context10, attribute => attribute.formdata !== null && !attribute.readonly && (!validationData || attribute.hasDynamicValidationData))).call(_context9, attribute => {
255
+ const attributesFormData = _mapInstanceProperty(_context9 = _filterInstanceProperty(_context0 = this.attributes).call(_context0, attribute => attribute.formdata !== null && !attribute.readonly && (!validationData || attribute.hasDynamicValidationData))).call(_context9, attribute => {
256
256
  // make attribute empty when it is not (or no longer) visible
257
257
  if (attribute.isVisible) {
258
258
  return attribute.formdata;
@@ -1 +1 @@
1
- {"version":3,"file":"AttributeCollection.js","names":["has","ResourceCollection","createAttribute","ChoiceAttributeModel","CompositeAttributeModel","ContentConfiguration","ConfigurationException","AttributeCollection","constructor","data","arguments","length","undefined","contributions","modelOptions","forEach","contribution","key","_Object$keys","attribute","origin","contextPath","isReadonly","readonly","collection","push","processLayoutHintRules","attributes","all","visible","_context","_filterInstanceProperty","call","isHidden","questions","_context2","isResult","results","_context3","getAttributeByAttribute","_context4","_findInstanceProperty","attr","equals","getChildByAttribute","getAttributeByKey","_context5","getChildByKey","hasAttributeByKey","getAttributeByLayoutHint","_context6","_len","hints","Array","_key","layouthint","getChoiceAttributeByLayoutHint","layoutHint","getAttributesByLayoutHint","_context7","_len2","_key2","replace","oldAttribute","newAttribute","replaceByKey","index","setReferenceDate","date","clone","referenceDate","hasServerErrors","some","addServerError","error","elementid","anchor","hasErrors","updateValidations","errors","_context8","hasDynamicValidationData","attributeErrors","compositeChildErrors","elementId","_startsWithInstanceProperty","children","indicateContentConfiguration","contentConfiguration","formdata","getFormData","_context9","_context10","validationData","attributesFormData","_mapInstanceProperty","isVisible","getEmptyFormData","attributeFormData"],"sources":["../../../src/models/attributes/AttributeCollection.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceCollection from \"../base/ResourceCollection\";\n\nimport createAttribute from \"./_createAttribute\";\nimport ChoiceAttributeModel from \"./ChoiceAttributeModel\";\nimport CompositeAttributeModel from \"./CompositeAttributeModel\";\n\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\n\nimport { ConfigurationException } from \"../../exceptions\";\n\nimport type { AttributeType, FormErrorAnchor, ModelOptions } from \"../types\";\n\ntype AttributeCollectionOptions = {\n ...ModelOptions,\n isReadonly: boolean,\n};\n\n/**\n * Collection of attributes\n */\nclass AttributeCollection extends ResourceCollection<AttributeType> {\n constructor(\n data: Object | Array<Object> = {},\n contributions: Array<Object> = [],\n modelOptions?: AttributeCollectionOptions,\n ) {\n super();\n\n if (contributions) {\n contributions.forEach((contribution) => {\n const [key] = Object.keys(contribution);\n\n const attribute = createAttribute(key, data, contribution[key], {\n origin: modelOptions?.origin,\n contextPath: modelOptions?.contextPath,\n });\n\n if (attribute !== null) {\n // when readonly is not explicitly set in the contributions, follow argument\n if (modelOptions?.isReadonly && !has(contribution[key], \"readonly\")) {\n attribute.readonly = true;\n }\n\n this.collection.push(attribute);\n }\n });\n\n this.processLayoutHintRules();\n }\n }\n\n /**\n * Retrieve all attributes in this collection<br>\n * This getter processes layout hints, this is different from the standard {@link BaseCollection#all} property\n * @returns {Array<AttributeType>}\n */\n get attributes(): Array<AttributeType> {\n this.processLayoutHintRules();\n return this.all;\n }\n\n /**\n * Replace attributes with a new array of attributes\n */\n set attributes(attributes: Array<AttributeType>) {\n this.collection = attributes;\n }\n\n /**\n */\n processLayoutHintRules(): void {\n this.all.forEach((attribute) => {\n attribute.processLayoutHintRules(this);\n });\n }\n\n /**\n * Retrieve only visible attributes from the collection\n */\n get visible(): Array<AttributeType> {\n // Let flow know that this is a AttributeCollection\n if (this instanceof AttributeCollection) {\n return this.attributes.filter((attribute) => !attribute.isHidden);\n }\n\n return [];\n }\n\n /**\n */\n get questions(): Array<AttributeType> {\n return this.visible.filter((attribute) => !attribute.isResult);\n }\n\n /**\n */\n get results(): Array<AttributeType> {\n return this.visible.filter((attribute) => attribute.isResult);\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.find((attr) => {\n if (attr.equals(attribute)) {\n return true;\n } else if (attribute instanceof CompositeAttributeModel) {\n return attribute.getChildByAttribute(attribute);\n }\n\n return false;\n });\n }\n\n /**\n * Get a single attribute by it's key\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.find((attribute) => {\n if (attribute.key === key) {\n return true;\n } else if (attribute instanceof CompositeAttributeModel) {\n return attribute.getChildByKey(key);\n }\n\n return false;\n });\n }\n\n /**\n * Indicates if attribute with key exists in collection\n */\n hasAttributeByKey(key: string): boolean {\n return this.getAttributeByKey(key) !== null;\n }\n\n /**\n * Getting the first attribute having the supplied layout hint\n */\n getAttributeByLayoutHint(...hints: Array<string>): AttributeType | null {\n return this.find((attribute) => attribute.layouthint.has(...hints)) || null;\n }\n\n /**\n * Getting a choice attribute by layouthint, returns null when not found or not a choice attribute\n */\n getChoiceAttributeByLayoutHint(\n layoutHint: string,\n ): ChoiceAttributeModel | null {\n const attribute = this.getAttributeByLayoutHint(layoutHint);\n\n return attribute instanceof ChoiceAttributeModel ? attribute : null;\n }\n\n /**\n * Getting all attributes having the supplied layout hint\n */\n getAttributesByLayoutHint(...hints: Array<string>): Array<AttributeType> {\n return this.filter((attribute) => attribute.layouthint.has(...hints));\n }\n\n /**\n * Replace an attribute instance in the collection with a new attribute instance\n */\n replace(oldAttribute: AttributeType, newAttribute: AttributeType): void {\n this.replaceByKey(oldAttribute.key, newAttribute);\n }\n\n /**\n * Replace an attribute by the key of the attribute\n */\n replaceByKey(key: string, newAttribute: AttributeType): void {\n this.forEach((attribute, index) => {\n if (attribute.key === key) {\n this.collection[index] = newAttribute;\n }\n });\n }\n\n /**\n * Set reference date by replacing an old attribute with a new attribute with a reference Date\n * Date is a string in ISO format yyyy-MM-dd\n */\n setReferenceDate(date: string): void {\n this.forEach((attribute) => {\n const newAttribute = attribute.clone();\n\n newAttribute.referenceDate = date;\n\n this.replace(attribute, newAttribute);\n });\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return this.collection.some((attribute) => attribute.hasServerErrors());\n }\n\n /**\n */\n addServerError(error: FormErrorAnchor): void {\n const elementid = error?.anchor?.elementid;\n\n if (elementid) {\n const attribute = this.getAttributeByKey(elementid);\n if (attribute) {\n attribute.addServerError(error);\n } else {\n throw new ConfigurationException(\n `Could not add error to missing attribute with id ${elementid}`,\n );\n }\n }\n }\n\n /**\n */\n hasErrors(): boolean {\n return this.visible.some((attribute) => attribute.hasErrors());\n }\n\n /**\n */\n updateValidations(errors: Array<Object>): AttributeCollection {\n this.all\n .filter((attribute) => attribute.hasDynamicValidationData)\n .forEach((attribute) => {\n const attributeErrors = errors.filter(\n (error) => error.anchor?.elementid === attribute.key,\n );\n attribute.updateValidations(attributeErrors);\n\n if (attribute instanceof CompositeAttributeModel) {\n const compositeChildErrors = errors.filter((error) => {\n const elementId = error.anchor?.elementid;\n return elementId && elementId.startsWith(`${attribute.key}.`);\n });\n\n attribute.children.updateValidations(\n `${attribute.key}.`,\n compositeChildErrors,\n );\n }\n });\n\n return this;\n }\n\n /**\n */\n indicateContentConfiguration(\n contentConfiguration: ContentConfiguration,\n ): void {\n if (contentConfiguration) {\n this.all.forEach((attribute) => {\n attribute.indicateContentConfiguration(contentConfiguration);\n });\n }\n }\n\n /**\n * Generate formdata object for current collection based on formdata of attributes\n * Skip attributes that are readonly, the confirmation password or null\n */\n get formdata(): { [string]: any } | null {\n return this.getFormData(false);\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n const attributesFormData = this.attributes\n .filter(\n (attribute) =>\n attribute.formdata !== null &&\n !attribute.readonly &&\n (!validationData || attribute.hasDynamicValidationData),\n )\n .map((attribute) => {\n // make attribute empty when it is not (or no longer) visible\n if (attribute.isVisible) {\n return attribute.formdata;\n }\n\n return attribute.getEmptyFormData();\n });\n\n let data = {};\n attributesFormData.forEach((attributeFormData) => {\n // $FlowIgnore[cannot-spread-indexer]\n // $FlowIgnore[exponential-spread]\n data = {\n ...data,\n ...attributeFormData,\n };\n });\n\n return data;\n }\n}\n\nexport default AttributeCollection;\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,kBAAkB,MAAM,4BAA4B;AAE3D,OAAOC,eAAe,MAAM,oBAAoB;AAChD,OAAOC,oBAAoB,MAAM,wBAAwB;AACzD,OAAOC,uBAAuB,MAAM,2BAA2B;AAE/D,OAAOC,oBAAoB,MAAM,8CAA8C;AAE/E,SAASC,sBAAsB,QAAQ,kBAAkB;AASzD;AACA;AACA;AACA,MAAMC,mBAAmB,SAASN,kBAAkB,CAAgB;EAClEO,WAAWA,CAAA,EAIT;IAAA,IAHAC,IAA4B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IACjCG,aAA4B,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IACjCI,YAAyC,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAEzC,KAAK,CAAC,CAAC;IAEP,IAAIC,aAAa,EAAE;MACjBA,aAAa,CAACE,OAAO,CAAEC,YAAY,IAAK;QACtC,MAAM,CAACC,GAAG,CAAC,GAAGC,YAAA,CAAYF,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;EAChC;;EAEA;AACF;EACEA,WAAWA,CAAA,EAA4D;IAAA,IAAAC,SAAA,EAAAC,UAAA;IAAA,IAA3DC,cAAuB,GAAAnF,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;IACzC,MAAMoF,kBAAkB,GAAGC,oBAAA,CAAAJ,SAAA,GAAA5D,uBAAA,CAAA6D,UAAA,OAAI,CAACjE,UAAU,EAAAK,IAAA,CAAA4D,UAAA,EAErCzE,SAAS,IACRA,SAAS,CAACsE,QAAQ,KAAK,IAAI,IAC3B,CAACtE,SAAS,CAACI,QAAQ,KAClB,CAACsE,cAAc,IAAI1E,SAAS,CAAC8D,wBAAwB,CAC1D,CAAC,EAAAjD,IAAA,CAAA2D,SAAA,EACKxE,SAAS,IAAK;MAClB;MACA,IAAIA,SAAS,CAAC6E,SAAS,EAAE;QACvB,OAAO7E,SAAS,CAACsE,QAAQ;MAC3B;MAEA,OAAOtE,SAAS,CAAC8E,gBAAgB,CAAC,CAAC;IACrC,CAAC,CAAC;IAEJ,IAAIxF,IAAI,GAAG,CAAC,CAAC;IACbqF,kBAAkB,CAAC/E,OAAO,CAAEmF,iBAAiB,IAAK;MAChD;MACA;MACAzF,IAAI,GAAG;QACL,GAAGA,IAAI;QACP,GAAGyF;MACL,CAAC;IACH,CAAC,CAAC;IAEF,OAAOzF,IAAI;EACb;AACF;AAEA,eAAeF,mBAAmB","ignoreList":[]}
1
+ {"version":3,"file":"AttributeCollection.js","names":["has","ResourceCollection","createAttribute","ChoiceAttributeModel","CompositeAttributeModel","ContentConfiguration","ConfigurationException","AttributeCollection","constructor","data","arguments","length","undefined","contributions","modelOptions","forEach","contribution","key","_Object$keys","attribute","origin","contextPath","isReadonly","readonly","collection","push","processLayoutHintRules","attributes","all","visible","_context","_filterInstanceProperty","call","isHidden","questions","_context2","isResult","results","_context3","getAttributeByAttribute","_context4","_findInstanceProperty","attr","equals","getChildByAttribute","getAttributeByKey","_context5","getChildByKey","hasAttributeByKey","getAttributeByLayoutHint","_context6","_len","hints","Array","_key","layouthint","getChoiceAttributeByLayoutHint","layoutHint","getAttributesByLayoutHint","_context7","_len2","_key2","replace","oldAttribute","newAttribute","replaceByKey","index","setReferenceDate","date","clone","referenceDate","hasServerErrors","some","addServerError","error","elementid","anchor","hasErrors","updateValidations","errors","_context8","hasDynamicValidationData","attributeErrors","compositeChildErrors","elementId","_startsWithInstanceProperty","children","indicateContentConfiguration","contentConfiguration","formdata","getFormData","_context9","_context0","validationData","attributesFormData","_mapInstanceProperty","isVisible","getEmptyFormData","attributeFormData"],"sources":["../../../src/models/attributes/AttributeCollection.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceCollection from \"../base/ResourceCollection\";\n\nimport createAttribute from \"./_createAttribute\";\nimport ChoiceAttributeModel from \"./ChoiceAttributeModel\";\nimport CompositeAttributeModel from \"./CompositeAttributeModel\";\n\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\n\nimport { ConfigurationException } from \"../../exceptions\";\n\nimport type { AttributeType, FormErrorAnchor, ModelOptions } from \"../types\";\n\ntype AttributeCollectionOptions = {\n ...ModelOptions,\n isReadonly: boolean,\n};\n\n/**\n * Collection of attributes\n */\nclass AttributeCollection extends ResourceCollection<AttributeType> {\n constructor(\n data: Object | Array<Object> = {},\n contributions: Array<Object> = [],\n modelOptions?: AttributeCollectionOptions,\n ) {\n super();\n\n if (contributions) {\n contributions.forEach((contribution) => {\n const [key] = Object.keys(contribution);\n\n const attribute = createAttribute(key, data, contribution[key], {\n origin: modelOptions?.origin,\n contextPath: modelOptions?.contextPath,\n });\n\n if (attribute !== null) {\n // when readonly is not explicitly set in the contributions, follow argument\n if (modelOptions?.isReadonly && !has(contribution[key], \"readonly\")) {\n attribute.readonly = true;\n }\n\n this.collection.push(attribute);\n }\n });\n\n this.processLayoutHintRules();\n }\n }\n\n /**\n * Retrieve all attributes in this collection<br>\n * This getter processes layout hints, this is different from the standard {@link BaseCollection#all} property\n * @returns {Array<AttributeType>}\n */\n get attributes(): Array<AttributeType> {\n this.processLayoutHintRules();\n return this.all;\n }\n\n /**\n * Replace attributes with a new array of attributes\n */\n set attributes(attributes: Array<AttributeType>) {\n this.collection = attributes;\n }\n\n /**\n */\n processLayoutHintRules(): void {\n this.all.forEach((attribute) => {\n attribute.processLayoutHintRules(this);\n });\n }\n\n /**\n * Retrieve only visible attributes from the collection\n */\n get visible(): Array<AttributeType> {\n // Let flow know that this is a AttributeCollection\n if (this instanceof AttributeCollection) {\n return this.attributes.filter((attribute) => !attribute.isHidden);\n }\n\n return [];\n }\n\n /**\n */\n get questions(): Array<AttributeType> {\n return this.visible.filter((attribute) => !attribute.isResult);\n }\n\n /**\n */\n get results(): Array<AttributeType> {\n return this.visible.filter((attribute) => attribute.isResult);\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.find((attr) => {\n if (attr.equals(attribute)) {\n return true;\n } else if (attribute instanceof CompositeAttributeModel) {\n return attribute.getChildByAttribute(attribute);\n }\n\n return false;\n });\n }\n\n /**\n * Get a single attribute by it's key\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.find((attribute) => {\n if (attribute.key === key) {\n return true;\n } else if (attribute instanceof CompositeAttributeModel) {\n return attribute.getChildByKey(key);\n }\n\n return false;\n });\n }\n\n /**\n * Indicates if attribute with key exists in collection\n */\n hasAttributeByKey(key: string): boolean {\n return this.getAttributeByKey(key) !== null;\n }\n\n /**\n * Getting the first attribute having the supplied layout hint\n */\n getAttributeByLayoutHint(...hints: Array<string>): AttributeType | null {\n return this.find((attribute) => attribute.layouthint.has(...hints)) || null;\n }\n\n /**\n * Getting a choice attribute by layouthint, returns null when not found or not a choice attribute\n */\n getChoiceAttributeByLayoutHint(\n layoutHint: string,\n ): ChoiceAttributeModel | null {\n const attribute = this.getAttributeByLayoutHint(layoutHint);\n\n return attribute instanceof ChoiceAttributeModel ? attribute : null;\n }\n\n /**\n * Getting all attributes having the supplied layout hint\n */\n getAttributesByLayoutHint(...hints: Array<string>): Array<AttributeType> {\n return this.filter((attribute) => attribute.layouthint.has(...hints));\n }\n\n /**\n * Replace an attribute instance in the collection with a new attribute instance\n */\n replace(oldAttribute: AttributeType, newAttribute: AttributeType): void {\n this.replaceByKey(oldAttribute.key, newAttribute);\n }\n\n /**\n * Replace an attribute by the key of the attribute\n */\n replaceByKey(key: string, newAttribute: AttributeType): void {\n this.forEach((attribute, index) => {\n if (attribute.key === key) {\n this.collection[index] = newAttribute;\n }\n });\n }\n\n /**\n * Set reference date by replacing an old attribute with a new attribute with a reference Date\n * Date is a string in ISO format yyyy-MM-dd\n */\n setReferenceDate(date: string): void {\n this.forEach((attribute) => {\n const newAttribute = attribute.clone();\n\n newAttribute.referenceDate = date;\n\n this.replace(attribute, newAttribute);\n });\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return this.collection.some((attribute) => attribute.hasServerErrors());\n }\n\n /**\n */\n addServerError(error: FormErrorAnchor): void {\n const elementid = error?.anchor?.elementid;\n\n if (elementid) {\n const attribute = this.getAttributeByKey(elementid);\n if (attribute) {\n attribute.addServerError(error);\n } else {\n throw new ConfigurationException(\n `Could not add error to missing attribute with id ${elementid}`,\n );\n }\n }\n }\n\n /**\n */\n hasErrors(): boolean {\n return this.visible.some((attribute) => attribute.hasErrors());\n }\n\n /**\n */\n updateValidations(errors: Array<Object>): AttributeCollection {\n this.all\n .filter((attribute) => attribute.hasDynamicValidationData)\n .forEach((attribute) => {\n const attributeErrors = errors.filter(\n (error) => error.anchor?.elementid === attribute.key,\n );\n attribute.updateValidations(attributeErrors);\n\n if (attribute instanceof CompositeAttributeModel) {\n const compositeChildErrors = errors.filter((error) => {\n const elementId = error.anchor?.elementid;\n return elementId && elementId.startsWith(`${attribute.key}.`);\n });\n\n attribute.children.updateValidations(\n `${attribute.key}.`,\n compositeChildErrors,\n );\n }\n });\n\n return this;\n }\n\n /**\n */\n indicateContentConfiguration(\n contentConfiguration: ContentConfiguration,\n ): void {\n if (contentConfiguration) {\n this.all.forEach((attribute) => {\n attribute.indicateContentConfiguration(contentConfiguration);\n });\n }\n }\n\n /**\n * Generate formdata object for current collection based on formdata of attributes\n * Skip attributes that are readonly, the confirmation password or null\n */\n get formdata(): { [string]: any } | null {\n return this.getFormData(false);\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n const attributesFormData = this.attributes\n .filter(\n (attribute) =>\n attribute.formdata !== null &&\n !attribute.readonly &&\n (!validationData || attribute.hasDynamicValidationData),\n )\n .map((attribute) => {\n // make attribute empty when it is not (or no longer) visible\n if (attribute.isVisible) {\n return attribute.formdata;\n }\n\n return attribute.getEmptyFormData();\n });\n\n let data = {};\n attributesFormData.forEach((attributeFormData) => {\n // $FlowIgnore[cannot-spread-indexer]\n // $FlowIgnore[exponential-spread]\n data = {\n ...data,\n ...attributeFormData,\n };\n });\n\n return data;\n }\n}\n\nexport default AttributeCollection;\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,kBAAkB,MAAM,4BAA4B;AAE3D,OAAOC,eAAe,MAAM,oBAAoB;AAChD,OAAOC,oBAAoB,MAAM,wBAAwB;AACzD,OAAOC,uBAAuB,MAAM,2BAA2B;AAE/D,OAAOC,oBAAoB,MAAM,8CAA8C;AAE/E,SAASC,sBAAsB,QAAQ,kBAAkB;AASzD;AACA;AACA;AACA,MAAMC,mBAAmB,SAASN,kBAAkB,CAAgB;EAClEO,WAAWA,CAAA,EAIT;IAAA,IAHAC,IAA4B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IACjCG,aAA4B,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IACjCI,YAAyC,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;I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BAAoB,CAAC;MAC9D,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;AACA;AACA;EACE,IAAIC,QAAQA,CAAA,EAA6B;IACvC,OAAO,IAAI,CAACC,WAAW,CAAC,KAAK,CAAC;EAChC;;EAEA;AACF;EACEA,WAAWA,CAAA,EAA4D;IAAA,IAAAC,SAAA,EAAAC,SAAA;IAAA,IAA3DC,cAAuB,GAAAnF,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;IACzC,MAAMoF,kBAAkB,GAAGC,oBAAA,CAAAJ,SAAA,GAAA5D,uBAAA,CAAA6D,SAAA,OAAI,CAACjE,UAAU,EAAAK,IAAA,CAAA4D,SAAA,EAErCzE,SAAS,IACRA,SAAS,CAACsE,QAAQ,KAAK,IAAI,IAC3B,CAACtE,SAAS,CAACI,QAAQ,KAClB,CAACsE,cAAc,IAAI1E,SAAS,CAAC8D,wBAAwB,CAC1D,CAAC,EAAAjD,IAAA,CAAA2D,SAAA,EACKxE,SAAS,IAAK;MAClB;MACA,IAAIA,SAAS,CAAC6E,SAAS,EAAE;QACvB,OAAO7E,SAAS,CAACsE,QAAQ;MAC3B;MAEA,OAAOtE,SAAS,CAAC8E,gBAAgB,CAAC,CAAC;IACrC,CAAC,CAAC;IAEJ,IAAIxF,IAAI,GAAG,CAAC,CAAC;IACbqF,kBAAkB,CAAC/E,OAAO,CAAEmF,iBAAiB,IAAK;MAChD;MACA;MACAzF,IAAI,GAAG;QACL,GAAGA,IAAI;QACP,GAAGyF;MACL,CAAC;IACH,CAAC,CAAC;IAEF,OAAOzF,IAAI;EACb;AACF;AAEA,eAAeF,mBAAmB","ignoreList":[]}
@@ -77,7 +77,7 @@ class AttributeContent {
77
77
  layouthint: new LayoutHintCollection(layouthint),
78
78
  textfragments: _mapInstanceProperty(textfragments).call(textfragments, textfragment => ({
79
79
  ...textfragment,
80
- text: retrieveText(textfragment.text)
80
+ text: retrieveText(textfragment.text) || ""
81
81
  }))
82
82
  }
83
83
  };
@@ -86,7 +86,7 @@ class AttributeContent {
86
86
  layouthint: new LayoutHintCollection(layouthint),
87
87
  textfragments: textfragments.map((textfragment) => ({
88
88
  ...textfragment,
89
- text: retrieveText(textfragment.text),
89
+ text: retrieveText(textfragment.text) || "",
90
90
  })),
91
91
  },
92
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"AttributeContent.js","names":["retrieveText","hasAllContentInData","SectionModel","LayoutHintCollection","isPlainObject","AttributeContent","constructor","content","_defineProperty","_content","fromData","header","headerLabel","headerDescription","label","description","message","elements","_context","_context2","_mapInstanceProperty","_filterInstanceProperty","call","element","propertyElement","layouthint","properties","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","getContentElements","elementName","_context3","getContentElementCollections","collectionName","_context4","_context5","_flatInstanceProperty","getContentElementCollectionByLabels","labels","_context6","_context7","_context8","_includesInstanceProperty","getConceptPropertiesByLabels","getTextFragmentsByLabels","getSectionsByType","types","_context9","type","getSectionsByLabels","getReferredSections","referredSections","push"],"sources":["../../../src/models/attributes/AttributeContent.js"],"sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nimport type {\n ContentData,\n ContentElementMapped,\n PropertyData,\n PropertyElementMapped,\n TextFragmentData,\n TextFragmentElementMapped,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\n\n/**\n */\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements\n .filter((element) => element !== null)\n .map((element) => {\n if (element.propertyElement) {\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (element.textFragmentElement) {\n const { label, layouthint, textfragments } =\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (element.contentElement) {\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null),\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string): Array<T> {\n // $FlowIssue incompatible-return\n return this.elements.filter((element) => elementName in element);\n }\n\n /**\n */\n getContentElementCollections<T>(\n elementName: string,\n collectionName: string,\n ): Array<T> {\n return this.getContentElements(elementName)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n getContentElementCollectionByLabels<T, U>(\n elementName: string,\n collectionName: string,\n labels: Array<string>,\n ): Array<U> {\n return (\n this.getContentElements<T>(elementName)\n // $FlowIssue incompatible-use\n .filter((element) => labels.includes(element[elementName].label))\n // $FlowIssue incompatible-use\n .map((element) => element[elementName][collectionName])\n .flat()\n );\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElementCollections<PropertyData>(\n \"propertyElement\",\n \"properties\",\n );\n }\n\n /**\n * Get concept properties by property element label\n */\n getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {\n return this.getContentElementCollectionByLabels<\n PropertyElementMapped,\n PropertyData,\n >(\"propertyElement\", \"properties\", labels);\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElementCollections<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\",\n );\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {\n return this.getContentElementCollectionByLabels<\n TextFragmentElementMapped,\n TextFragmentData,\n >(\"textFragmentElement\", \"textfragments\", labels);\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElementCollections<SectionModel>(\n \"contentElement\",\n \"sections\",\n );\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getSectionsByLabels(labels: Array<string>): Array<SectionModel> {\n return this.getContentElementCollectionByLabels<\n ContentElementMapped,\n SectionModel,\n >(\"contentElement\", \"sections\", labels);\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"mappings":";;;;;AACA,SAASA,YAAY,QAAQ,0BAA0B;AACvD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,OAAOC,YAAY,MAAM,yBAAyB;AAElD,OAAOC,oBAAoB,MAAM,oCAAoC;AACrE,SAASC,aAAa,QAAQ,aAAa;AAa3C;AACA;AACA,MAAMC,gBAAgB,CAAC;EAGrBC,WAAWA,CAACC,OAAqB,EAAE;IAAAC,eAAA;IACjC,IAAI,CAACC,QAAQ,GAAGF,OAAO;EACzB;;EAEA;AACF;EACE,IAAIG,QAAQA,CAAA,EAAY;IACtB,OAAOT,mBAAmB,CAAC,CAAC;EAC9B;;EAEA;A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,OAAO,IAAI,CAACD,mCAAmC,CAG7C,qBAAqB,EAAE,eAAe,EAAEC,MAAM,CAAC;EACnD;;EAEA;AACF;EACE,IAAIX,QAAQA,CAAA,EAAwB;IAClC,OAAO,IAAI,CAACK,4BAA4B,CACtC,gBAAgB,EAChB,UACF,CAAC;EACH;;EAEA;AACF;EACEa,iBAAiBA,CAACC,KAAoB,EAAuB;IAAA,IAAAC,SAAA;IAC3D,OAAO/B,uBAAA,CAAA+B,SAAA,OAAI,CAACpB,QAAQ,EAAAV,IAAA,CAAA8B,SAAA,EAASnB,OAAO,IAAKc,yBAAA,CAAAI,KAAK,EAAA7B,IAAA,CAAL6B,KAAK,EAAUlB,OAAO,CAACoB,IAAI,CAAC,CAAC;EACxE;;EAEA;AACF;AACA;EACEC,mBAAmBA,CAACX,MAAqB,EAAuB;IAC9D,OAAO,IAAI,CAACD,mCAAmC,CAG7C,gBAAgB,EAAE,UAAU,EAAEC,MAAM,CAAC;EACzC;;EAEA;AACF;EACEY,mBAAmBA,CAAA,EAA0C;IAC3D,MAAMC,gBAAgB,GAAG,EAAE;IAE3B,KAAK,MAAMvB,OAAO,IAAI,IAAI,CAACD,QAAQ,EAAE;MACnCwB,gBAAgB,CAACC,IAAI,CAAC,GAAGxB,OAAO,CAACsB,mBAAmB,CAAC,CAAC,CAAC;IACzD;IAEA,OAAOC,gBAAgB;EACzB;AACF;AAEA,eAAenD,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"AttributeContent.js","names":["retrieveText","hasAllContentInData","SectionModel","LayoutHintCollection","isPlainObject","AttributeContent","constructor","content","_defineProperty","_content","fromData","header","headerLabel","headerDescription","label","description","message","elements","_context","_context2","_mapInstanceProperty","_filterInstanceProperty","call","element","propertyElement","layouthint","properties","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","getContentElements","elementName","_context3","getContentElementCollections","collectionName","_context4","_context5","_flatInstanceProperty","getContentElementCollectionByLabels","labels","_context6","_context7","_context8","_includesInstanceProperty","getConceptPropertiesByLabels","getTextFragmentsByLabels","getSectionsByType","types","_context9","type","getSectionsByLabels","getReferredSections","referredSections","push"],"sources":["../../../src/models/attributes/AttributeContent.js"],"sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nimport type {\n ContentData,\n ContentElementMapped,\n PropertyData,\n PropertyElementMapped,\n TextFragmentData,\n TextFragmentElementMapped,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\n\n/**\n */\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements\n .filter((element) => element !== null)\n .map((element) => {\n if (element.propertyElement) {\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (element.textFragmentElement) {\n const { label, layouthint, textfragments } =\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text) || \"\",\n })),\n },\n };\n }\n\n if (element.contentElement) {\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null),\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string): Array<T> {\n // $FlowIssue incompatible-return\n return this.elements.filter((element) => elementName in element);\n }\n\n /**\n */\n getContentElementCollections<T>(\n elementName: string,\n collectionName: string,\n ): Array<T> {\n return this.getContentElements(elementName)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n getContentElementCollectionByLabels<T, U>(\n elementName: string,\n collectionName: string,\n labels: Array<string>,\n ): Array<U> {\n return (\n this.getContentElements<T>(elementName)\n // $FlowIssue incompatible-use\n .filter((element) => labels.includes(element[elementName].label))\n // $FlowIssue incompatible-use\n .map((element) => element[elementName][collectionName])\n .flat()\n );\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElementCollections<PropertyData>(\n \"propertyElement\",\n \"properties\",\n );\n }\n\n /**\n * Get concept properties by property element label\n */\n getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {\n return this.getContentElementCollectionByLabels<\n PropertyElementMapped,\n PropertyData,\n >(\"propertyElement\", \"properties\", labels);\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElementCollections<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\",\n );\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {\n return this.getContentElementCollectionByLabels<\n TextFragmentElementMapped,\n TextFragmentData,\n >(\"textFragmentElement\", \"textfragments\", labels);\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElementCollections<SectionModel>(\n \"contentElement\",\n \"sections\",\n );\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getSectionsByLabels(labels: Array<string>): Array<SectionModel> {\n return this.getContentElementCollectionByLabels<\n ContentElementMapped,\n SectionModel,\n >(\"contentElement\", \"sections\", labels);\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"mappings":";;;;;AACA,SAASA,YAAY,QAAQ,0BAA0B;AACvD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,OAAOC,YAAY,MAAM,yBAAyB;AAElD,OAAOC,oBAAoB,MAAM,oCAAoC;AACrE,SAASC,aAAa,QAAQ,aAAa;AAa3C;AACA;AACA,MAAMC,gBAAgB,CAAC;EAGrBC,WAAWA,CAACC,OAAqB,EAAE;IAAAC,eAAA;IACjC,IAAI,CAACC,QAAQ,GAAGF,OAAO;EACzB;;EAEA;AACF;EACE,IAAIG,QAAQA,CAAA,EAAY;IACtB,OAAOT,mBAAmB,CAAC,CAAC;EAC9B;;EAEA;AACF;EACE,IAAIU,MAAMA,CAAA,EAGR;IACA,IAAIC,WAAW,GAAG,IAAI;IACtB,IAAIC,iBAAiB,GAAG,IAAI;IAE5B,MAAMC,KAAK,GAAG,IAAI,CAACL,QAAQ,EAAEE,MAAM,EAAEG,KAAK;IAC1C,IAAIA,KAAK,EAAE;MACTF,WAAW,GAAGE,KAAK;IACrB;IAEA,MAAMC,WAAW,GAAG,IAAI,CAACN,QAAQ,EAAEE,MAAM,EAAEI,WAAW;IACtD,IAAIA,WAAW,EAAE;MACf,IAAIX,aAAa,CAACW,WAAW,CAAC,IAAI,SAAS,IAAIA,WAAW,EAAE;QAC1DF,iBAAiB,GAAGE,WAAW,CAACC,OAAO;MACzC,CAAC,MAAM,IAAI,OAAOD,WAAW,KAAK,QAAQ,EAAE;QAC1CF,iBAAiB,GAAGE,WAAW;MACjC;IACF;IAEA,OAAO;MAAED,KAAK,E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AmC,CAG7C,gBAAgB,EAAE,UAAU,EAAEC,MAAM,CAAC;EACzC;;EAEA;AACF;EACEY,mBAAmBA,CAAA,EAA0C;IAC3D,MAAMC,gBAAgB,GAAG,EAAE;IAE3B,KAAK,MAAMvB,OAAO,IAAI,IAAI,CAACD,QAAQ,EAAE;MACnCwB,gBAAgB,CAACC,IAAI,CAAC,GAAGxB,OAAO,CAACsB,mBAAmB,CAAC,CAAC,CAAC;IACzD;IAEA,OAAOC,gBAAgB;EACzB;AACF;AAEA,eAAenD,gBAAgB","ignoreList":[]}
@@ -155,12 +155,12 @@ class CompositeAttributeChildCollection extends ResourceCollection {
155
155
  /**
156
156
  */
157
157
  get readonlyvalue() {
158
- var _context11, _context12;
158
+ var _context1, _context10;
159
159
  if (this.first instanceof CompositeAttributeChildCollection) {
160
- var _context10;
161
- return _mapInstanceProperty(_context10 = this.collection).call(_context10, collection => collection.readonlyvalue).join(" | ");
160
+ var _context0;
161
+ return _mapInstanceProperty(_context0 = this.collection).call(_context0, collection => collection.readonlyvalue).join(" | ");
162
162
  }
163
- return _mapInstanceProperty(_context11 = _filterInstanceProperty(_context12 = this.collection).call(_context12, child => child.value !== null)).call(_context11, child => child.readonlyvalue).join(", ");
163
+ return _mapInstanceProperty(_context1 = _filterInstanceProperty(_context10 = this.collection).call(_context10, child => child.value !== null)).call(_context1, child => child.readonlyvalue).join(", ");
164
164
  }
165
165
 
166
166
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"CompositeAttributeChildCollection.js","names":["ResourceCollection","ErrorCollection","createAttribute","CompositeAttributeChildCollection","create","data","contributions","modelOptions","Array","isArray","children","isMultipleTableRows","createMultiData","createStandard","_context","_context2","compositeChildCollection","collection","_filterInstanceProperty","_mapInstanceProperty","call","contribution","_context3","_context4","key","_Object$keys","attributeData","_findInstanceProperty","attr","attributeContribution","_includesInstanceProperty","type","replace","attribute","dynamicschema","readonly","parentKey","_context5","childData","getInputValue","_context6","child","inputvalue","join","validate","every","isValid","errorCollection","hasServerErrors","serverErrors","length","some","hasErrors","hasItems","reset","forEach","initvalue","_context8","first","_context7","value","_context9","formdata","readonlyvalue","_context11","_context12","_context10","updateValidations","prefix","errors","attributeErrors","error","anchor","elementid","hasValue"],"sources":["../../../src/models/attributes/CompositeAttributeChildCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ErrorCollection from \"../error/ErrorCollection\";\n\nimport createAttribute from \"./_createAttribute\";\n\nimport type { AttributeType, ModelOptions } from \"../types\";\n\n/**\n * Collection of choice attribute options\n */\nclass CompositeAttributeChildCollection extends ResourceCollection<AttributeType> {\n /**\n */\n static create(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n if (\n data &&\n contributions &&\n Array.isArray(contributions.children) &&\n Array.isArray(data.children)\n ) {\n // a composite with multiple data elements and one contributions element\n // multiple 'composites' are returned\n const isMultipleTableRows = Array.isArray(data.children[0]);\n if (isMultipleTableRows) {\n return CompositeAttributeChildCollection.createMultiData(\n data,\n contributions,\n modelOptions,\n );\n }\n\n return CompositeAttributeChildCollection.createStandard(\n data,\n contributions,\n modelOptions,\n );\n }\n\n return new CompositeAttributeChildCollection();\n }\n\n /**\n */\n static createStandard(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n const compositeChildCollection = new CompositeAttributeChildCollection();\n\n compositeChildCollection.collection = contributions.children\n .map((contribution) => {\n const [key] = Object.keys(contribution);\n\n const attributeData = Array.isArray(data.children)\n ? data.children.find((attr) => attr.key === key)\n : {};\n\n const attributeContribution = contribution[key];\n\n if (\n contributions.type.includes(\"range\") &&\n !attributeContribution.type\n ) {\n attributeContribution.type = contributions.type.replace(\"range\", \"\");\n }\n\n const attribute = createAttribute(\n key,\n {\n ...attributeData,\n dynamicschema: attributeData?.dynamicschema,\n },\n {\n ...attributeContribution,\n readonly: attributeContribution.readonly || contributions.readonly,\n },\n modelOptions,\n );\n\n if (attribute) {\n attribute.parentKey = data.key;\n }\n\n return attribute;\n })\n .filter((attribute) => attribute !== null);\n\n return compositeChildCollection;\n }\n\n /*\n * Creates a composite for each child data element using the same contributions\n */\n /**\n */\n static createMultiData(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n const compositeChildCollection = new CompositeAttributeChildCollection();\n\n compositeChildCollection.collection = data.children.map((childData) =>\n CompositeAttributeChildCollection.create(\n {\n ...data,\n children: childData,\n },\n contributions,\n modelOptions,\n ),\n );\n\n return compositeChildCollection;\n }\n\n /**\n * Get input value of contributions\n */\n getInputValue(): string {\n return this.collection.map((child) => child.inputvalue).join(\",\");\n }\n\n /**\n * Validate input\n */\n validate(): boolean {\n return this.collection.every((child) => child.isValid);\n }\n\n /**\n * Retrieve error messages of this attribute\n */\n get errorCollection(): ErrorCollection {\n return new ErrorCollection(\"compositechildren\");\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.serverErrors.length > 0 ||\n this.collection.some((child) => child.hasServerErrors())\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.collection.some((child) => child.hasErrors())\n );\n }\n\n /**\n * Reset attribute to empty string\n */\n reset() {\n this.collection.forEach((child) => {\n child.reset();\n });\n }\n\n /**\n */\n get initvalue(): any {\n if (this.first instanceof CompositeAttributeChildCollection) {\n // $FlowFixMe[missing-type-arg]\n return this.collection.map<Array<Object>>(\n (collection) => collection.initvalue,\n );\n }\n\n const children: { [string]: any } = {};\n this.collection\n .filter((child) => child.initvalue !== null)\n .forEach((child) => {\n children[child.key] = child.initvalue;\n });\n\n if (Object.keys(children).length === 0) {\n return null;\n }\n\n return children;\n }\n\n /**\n */\n get value(): any {\n if (this.first instanceof CompositeAttributeChildCollection) {\n return this.collection.map((collection) => collection.value);\n }\n\n let children: { [string]: any } = {};\n\n this.collection.forEach((attribute) => {\n if (attribute.formdata !== null && !attribute.readonly) {\n children = {\n ...children,\n ...attribute.formdata,\n };\n }\n });\n\n if (Object.keys(children).length === 0) {\n return null;\n }\n\n return children;\n }\n\n /**\n */\n get readonlyvalue(): string {\n if (this.first instanceof CompositeAttributeChildCollection) {\n return this.collection\n .map((collection) => collection.readonlyvalue)\n .join(\" | \");\n }\n\n return this.collection\n .filter((child) => child.value !== null)\n .map((child) => child.readonlyvalue)\n .join(\", \");\n }\n\n /**\n */\n updateValidations(prefix: string, errors: Object) {\n this.collection.forEach((child) => {\n const attributeErrors = errors.filter(\n (error) => error.anchor?.elementid === `${prefix}${child.key}`,\n );\n\n child.updateValidations(attributeErrors);\n });\n }\n\n /**\n */\n hasValue(): boolean {\n return this.collection.some((child) => child.hasValue());\n }\n}\n\nexport default CompositeAttributeChildCollection;\n"],"mappings":";;;;;AACA,OAAOA,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,eAAe,MAAM,0BAA0B;AAEtD,OAAOC,eAAe,MAAM,oBAAoB;AAIhD;AACA;AACA;AACA,MAAMC,iCAAiC,SAASH,kBAAkB,CAAgB;EAChF;AACF;EACE,OAAOI,MAAMA,CACXC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EACQ;IACnC,IACEF,IAAI,IACJC,aAAa,IACbE,KAAK,CAACC,OAAO,CAACH,aAAa,CAACI,QAAQ,CAAC,IACrCF,KAAK,CAACC,OAAO,CAACJ,IAAI,CAACK,QAAQ,CAAC,EAC5B;MACA;MACA;MACA,MAAMC,mBAAmB,GAAGH,KAAK,CAACC,OAAO,CAACJ,IAAI,CAACK,QAAQ,CAAC,CAAC,CAAC,CAAC;MAC3D,IAAIC,mBAAmB,EAAE;QACvB,OAAOR,iCAAiC,CAACS,eAAe,CACtDP,IAAI,EACJC,aAAa,EACbC,YACF,CAAC;MACH;MAEA,OAAOJ,iCAAiC,CAACU,cAAc,CACrDR,IAAI,EACJC,aAAa,EACbC,YACF,CAAC;IACH;IAEA,OAAO,IAAIJ,iCAAiC,CAAC,CAAC;EAChD;;EAEA;AACF;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pD,UAAU,CAACsC,OAAO,CAAEd,KAAK,IAAK;MACjC,MAAM6B,eAAe,GAAGpD,uBAAA,CAAAmD,MAAM,EAAAjD,IAAA,CAANiD,MAAM,EAC3BE,KAAK,IAAKA,KAAK,CAACC,MAAM,EAAEC,SAAS,KAAK,GAAGL,MAAM,GAAG3B,KAAK,CAACjB,GAAG,EAC9D,CAAC;MAEDiB,KAAK,CAAC0B,iBAAiB,CAACG,eAAe,CAAC;IAC1C,CAAC,CAAC;EACJ;;EAEA;AACF;EACEI,QAAQA,CAAA,EAAY;IAClB,OAAO,IAAI,CAACzD,UAAU,CAACkC,IAAI,CAAEV,KAAK,IAAKA,KAAK,CAACiC,QAAQ,CAAC,CAAC,CAAC;EAC1D;AACF;AAEA,eAAevE,iCAAiC","ignoreList":[]}
1
+ {"version":3,"file":"CompositeAttributeChildCollection.js","names":["ResourceCollection","ErrorCollection","createAttribute","CompositeAttributeChildCollection","create","data","contributions","modelOptions","Array","isArray","children","isMultipleTableRows","createMultiData","createStandard","_context","_context2","compositeChildCollection","collection","_filterInstanceProperty","_mapInstanceProperty","call","contribution","_context3","_context4","key","_Object$keys","attributeData","_findInstanceProperty","attr","attributeContribution","_includesInstanceProperty","type","replace","attribute","dynamicschema","readonly","parentKey","_context5","childData","getInputValue","_context6","child","inputvalue","join","validate","every","isValid","errorCollection","hasServerErrors","serverErrors","length","some","hasErrors","hasItems","reset","forEach","initvalue","_context8","first","_context7","value","_context9","formdata","readonlyvalue","_context1","_context10","_context0","updateValidations","prefix","errors","attributeErrors","error","anchor","elementid","hasValue"],"sources":["../../../src/models/attributes/CompositeAttributeChildCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ErrorCollection from \"../error/ErrorCollection\";\n\nimport createAttribute from \"./_createAttribute\";\n\nimport type { AttributeType, ModelOptions } from \"../types\";\n\n/**\n * Collection of choice attribute options\n */\nclass CompositeAttributeChildCollection extends ResourceCollection<AttributeType> {\n /**\n */\n static create(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n if (\n data &&\n contributions &&\n Array.isArray(contributions.children) &&\n Array.isArray(data.children)\n ) {\n // a composite with multiple data elements and one contributions element\n // multiple 'composites' are returned\n const isMultipleTableRows = Array.isArray(data.children[0]);\n if (isMultipleTableRows) {\n return CompositeAttributeChildCollection.createMultiData(\n data,\n contributions,\n modelOptions,\n );\n }\n\n return CompositeAttributeChildCollection.createStandard(\n data,\n contributions,\n modelOptions,\n );\n }\n\n return new CompositeAttributeChildCollection();\n }\n\n /**\n */\n static createStandard(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n const compositeChildCollection = new CompositeAttributeChildCollection();\n\n compositeChildCollection.collection = contributions.children\n .map((contribution) => {\n const [key] = Object.keys(contribution);\n\n const attributeData = Array.isArray(data.children)\n ? data.children.find((attr) => attr.key === key)\n : {};\n\n const attributeContribution = contribution[key];\n\n if (\n contributions.type.includes(\"range\") &&\n !attributeContribution.type\n ) {\n attributeContribution.type = contributions.type.replace(\"range\", \"\");\n }\n\n const attribute = createAttribute(\n key,\n {\n ...attributeData,\n dynamicschema: attributeData?.dynamicschema,\n },\n {\n ...attributeContribution,\n readonly: attributeContribution.readonly || contributions.readonly,\n },\n modelOptions,\n );\n\n if (attribute) {\n attribute.parentKey = data.key;\n }\n\n return attribute;\n })\n .filter((attribute) => attribute !== null);\n\n return compositeChildCollection;\n }\n\n /*\n * Creates a composite for each child data element using the same contributions\n */\n /**\n */\n static createMultiData(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n const compositeChildCollection = new CompositeAttributeChildCollection();\n\n compositeChildCollection.collection = data.children.map((childData) =>\n CompositeAttributeChildCollection.create(\n {\n ...data,\n children: childData,\n },\n contributions,\n modelOptions,\n ),\n );\n\n return compositeChildCollection;\n }\n\n /**\n * Get input value of contributions\n */\n getInputValue(): string {\n return this.collection.map((child) => child.inputvalue).join(\",\");\n }\n\n /**\n * Validate input\n */\n validate(): boolean {\n return this.collection.every((child) => child.isValid);\n }\n\n /**\n * Retrieve error messages of this attribute\n */\n get errorCollection(): ErrorCollection {\n return new ErrorCollection(\"compositechildren\");\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.serverErrors.length > 0 ||\n this.collection.some((child) => child.hasServerErrors())\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.collection.some((child) => child.hasErrors())\n );\n }\n\n /**\n * Reset attribute to empty string\n */\n reset() {\n this.collection.forEach((child) => {\n child.reset();\n });\n }\n\n /**\n */\n get initvalue(): any {\n if (this.first instanceof CompositeAttributeChildCollection) {\n // $FlowFixMe[missing-type-arg]\n return this.collection.map<Array<Object>>(\n (collection) => collection.initvalue,\n );\n }\n\n const children: { [string]: any } = {};\n this.collection\n .filter((child) => child.initvalue !== null)\n .forEach((child) => {\n children[child.key] = child.initvalue;\n });\n\n if (Object.keys(children).length === 0) {\n return null;\n }\n\n return children;\n }\n\n /**\n */\n get value(): any {\n if (this.first instanceof CompositeAttributeChildCollection) {\n return this.collection.map((collection) => collection.value);\n }\n\n let children: { [string]: any } = {};\n\n this.collection.forEach((attribute) => {\n if (attribute.formdata !== null && !attribute.readonly) {\n children = {\n ...children,\n ...attribute.formdata,\n };\n }\n });\n\n if (Object.keys(children).length === 0) {\n return null;\n }\n\n return children;\n }\n\n /**\n */\n get readonlyvalue(): string {\n if (this.first instanceof CompositeAttributeChildCollection) {\n return this.collection\n .map((collection) => collection.readonlyvalue)\n .join(\" | \");\n }\n\n return this.collection\n .filter((child) => child.value !== null)\n .map((child) => child.readonlyvalue)\n .join(\", \");\n }\n\n /**\n */\n updateValidations(prefix: string, errors: Object) {\n this.collection.forEach((child) => {\n const attributeErrors = errors.filter(\n (error) => error.anchor?.elementid === `${prefix}${child.key}`,\n );\n\n child.updateValidations(attributeErrors);\n });\n }\n\n /**\n */\n hasValue(): boolean {\n return this.collection.some((child) => child.hasValue());\n }\n}\n\nexport default CompositeAttributeChildCollection;\n"],"mappings":";;;;;AACA,OAAOA,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,eAAe,MAAM,0BAA0B;AAEtD,OAAOC,eAAe,MAAM,oBAAoB;AAIhD;AACA;AACA;AACA,MAAMC,iCAAiC,SAASH,kBAAkB,CAAgB;EAChF;AACF;EACE,OAAOI,MAAMA,CACXC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EACQ;IACnC,IACEF,IAAI,IACJC,aAAa,IACbE,KAAK,CAACC,OAAO,CAACH,aAAa,CAACI,QAAQ,CAAC,IACrCF,KAAK,CAACC,OAAO,CAACJ,IAAI,CAACK,QAAQ,CAAC,EAC5B;MACA;MACA;MACA,MAAMC,mBAAmB,GAAGH,KAAK,CAACC,OAAO,CAACJ,IAAI,CAACK,QAAQ,CAAC,CAAC,CAAC,CAAC;MAC3D,IAAIC,mBAAmB,EAAE;QACvB,OAAOR,iCAAiC,CAACS,eAAe,CACtDP,IAAI,EACJC,aAAa,EACbC,YACF,CAAC;MACH;MAEA,OAAOJ,iCAAiC,CAACU,cAAc,CACrDR,IAAI,EACJC,aAAa,EACbC,YACF,CAAC;IACH;IAEA,OAAO,IAAIJ,iCAAiC,CAAC,CAAC;EAChD;;EAEA;AACF;EACE,OAAOU,cAAcA,CACnBR,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EACQ;IAAA,IAAAO,QAAA,EAAAC,SAAA;IACnC,MAAMC,wBAAwB,GAAG,IAAIb,iCAAiC,CAAC,CAAC;IAExEa,wBAAwB,CAACC,UAAU,GAAGC,uBAAA,CAAAJ,QAAA,GAAAK,oBAAA,CAAAJ,SAAA,GAAAT,aAAa,CAACI,QAAQ,EAAAU,IAAA,CAAAL,SAAA,EACpDM,YAAY,IAAK;MAAA,IAAAC,SAAA,EAAAC,SAAA;MACrB,MAAM,CAACC,GAAG,CAAC,GAAGC,YAAA,CAAYJ,YAAY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