@beinformed/ui 1.29.0 → 1.30.1

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 (224) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/esm/models/attributes/BooleanAttributeModel.js +1 -1
  3. package/esm/models/attributes/BooleanAttributeModel.js.map +1 -1
  4. package/esm/models/attributes/layouthint-rules/BaseLayoutHintRule.js +5 -6
  5. package/esm/models/attributes/layouthint-rules/BaseLayoutHintRule.js.map +1 -1
  6. package/esm/models/attributes/layouthint-rules/DependentAttribute.js +2 -0
  7. package/esm/models/attributes/layouthint-rules/DependentAttribute.js.map +1 -1
  8. package/esm/models/error/ErrorResponse.js +6 -0
  9. package/esm/models/error/ErrorResponse.js.map +1 -1
  10. package/esm/models/form/FormModel.js +45 -3
  11. package/esm/models/form/FormModel.js.map +1 -1
  12. package/esm/utils/number/DecimalFormat.js +4 -8
  13. package/esm/utils/number/DecimalFormat.js.map +1 -1
  14. package/lib/models/attributes/BooleanAttributeModel.js +1 -1
  15. package/lib/models/attributes/BooleanAttributeModel.js.flow +1 -1
  16. package/lib/models/attributes/BooleanAttributeModel.js.map +1 -1
  17. package/lib/models/attributes/__tests__/BooleanAttributeModel.spec.js.flow +14 -0
  18. package/lib/models/attributes/layouthint-rules/BaseLayoutHintRule.js +5 -6
  19. package/lib/models/attributes/layouthint-rules/BaseLayoutHintRule.js.map +1 -1
  20. package/lib/models/attributes/layouthint-rules/DependentAttribute.js +2 -0
  21. package/lib/models/attributes/layouthint-rules/DependentAttribute.js.map +1 -1
  22. package/lib/models/error/ErrorResponse.js +6 -0
  23. package/lib/models/error/ErrorResponse.js.map +1 -1
  24. package/lib/models/form/FormModel.js +45 -3
  25. package/lib/models/form/FormModel.js.flow +58 -4
  26. package/lib/models/form/FormModel.js.map +1 -1
  27. package/lib/models/form/__tests__/FormModel.spec.js.flow +4 -0
  28. package/lib/models/form/__tests__/FormResultData.spec.js.flow +86 -0
  29. package/lib/utils/number/DecimalFormat.js +4 -8
  30. package/lib/utils/number/DecimalFormat.js.map +1 -1
  31. package/package.json +17 -17
  32. package/src/models/attributes/BooleanAttributeModel.js +1 -1
  33. package/src/models/attributes/__tests__/BooleanAttributeModel.spec.js +14 -0
  34. package/src/models/form/FormModel.js +58 -4
  35. package/src/models/form/__tests__/FormModel.spec.js +4 -0
  36. package/src/models/form/__tests__/FormResultData.spec.js +86 -0
  37. package/types/constants/Constants.d.ts +145 -145
  38. package/types/constants/LayoutHintConfig.d.ts +226 -226
  39. package/types/constants/LayoutHints.d.ts +74 -74
  40. package/types/constants/Settings.d.ts +29 -29
  41. package/types/constants/index.d.ts +3 -3
  42. package/types/exceptions/ConfigurationException.d.ts +6 -6
  43. package/types/exceptions/FetchException.d.ts +31 -31
  44. package/types/exceptions/IllegalArgumentException.d.ts +6 -6
  45. package/types/exceptions/IllegalReturnException.d.ts +5 -5
  46. package/types/exceptions/IllegalStateException.d.ts +6 -6
  47. package/types/exceptions/JsonParseException.d.ts +6 -6
  48. package/types/exceptions/MissingPropertyException.d.ts +6 -6
  49. package/types/exceptions/NetworkException.d.ts +9 -9
  50. package/types/exceptions/NotAllowedUriException.d.ts +6 -6
  51. package/types/exceptions/NotFoundException.d.ts +10 -10
  52. package/types/exceptions/ServerRequestException.d.ts +6 -6
  53. package/types/exceptions/ThemePropertyException.d.ts +6 -6
  54. package/types/exceptions/TimeoutException.d.ts +7 -7
  55. package/types/exceptions/UnauthorizedException.d.ts +11 -11
  56. package/types/exceptions/UnsupportedOperationException.d.ts +6 -6
  57. package/types/exceptions/index.d.ts +15 -15
  58. package/types/hooks/useI18n.d.ts +9 -9
  59. package/types/i18n/Locale.d.ts +53 -53
  60. package/types/i18n/Locales.d.ts +55 -55
  61. package/types/i18n/Message.d.ts +6 -6
  62. package/types/i18n/index.d.ts +5 -5
  63. package/types/i18n/languages.d.ts +215 -215
  64. package/types/i18n/translations/beinformed_error_messages_en.nl.d.ts +97 -97
  65. package/types/i18n/translations/beinformed_error_messages_nl.nl.d.ts +97 -97
  66. package/types/i18n/types.d.ts +11 -11
  67. package/types/i18n/withMessage.d.ts +3 -3
  68. package/types/index.d.ts +6 -6
  69. package/types/models/actions/ActionCollection.d.ts +29 -29
  70. package/types/models/actions/ActionModel.d.ts +84 -84
  71. package/types/models/application/ApplicationModel.d.ts +41 -41
  72. package/types/models/attributes/AttributeCollection.d.ts +96 -96
  73. package/types/models/attributes/AttributeContent.d.ts +64 -64
  74. package/types/models/attributes/AttributeDataHelper.d.ts +67 -67
  75. package/types/models/attributes/AttributeModel.d.ts +395 -395
  76. package/types/models/attributes/AttributeSetModel.d.ts +28 -28
  77. package/types/models/attributes/BooleanAttributeModel.d.ts +65 -65
  78. package/types/models/attributes/CaptchaAttributeModel.d.ts +19 -19
  79. package/types/models/attributes/ChoiceAttributeModel.d.ts +76 -76
  80. package/types/models/attributes/ChoiceAttributeOptionCollection.d.ts +79 -79
  81. package/types/models/attributes/ChoiceAttributeOptionModel.d.ts +133 -133
  82. package/types/models/attributes/CompositeAttributeChildCollection.d.ts +56 -56
  83. package/types/models/attributes/CompositeAttributeModel.d.ts +44 -44
  84. package/types/models/attributes/DatetimeAttributeModel.d.ts +117 -117
  85. package/types/models/attributes/HelptextAttributeModel.d.ts +16 -16
  86. package/types/models/attributes/LabelAttributeModel.d.ts +12 -12
  87. package/types/models/attributes/MemoAttributeModel.d.ts +14 -14
  88. package/types/models/attributes/MoneyAttributeModel.d.ts +14 -14
  89. package/types/models/attributes/NumberAttributeModel.d.ts +49 -49
  90. package/types/models/attributes/PasswordAttributeModel.d.ts +62 -62
  91. package/types/models/attributes/StringAttributeModel.d.ts +62 -62
  92. package/types/models/attributes/UploadAttributeModel.d.ts +60 -60
  93. package/types/models/attributes/XMLAttributeModel.d.ts +10 -10
  94. package/types/models/attributes/_createAttribute.d.ts +6 -6
  95. package/types/models/attributes/input-constraints/BSNConstraint.d.ts +26 -26
  96. package/types/models/attributes/input-constraints/ConstraintCollection.d.ts +24 -24
  97. package/types/models/attributes/input-constraints/ConstraintModel.d.ts +34 -34
  98. package/types/models/attributes/input-constraints/DateBoundaryConstraint.d.ts +109 -109
  99. package/types/models/attributes/input-constraints/DateTimeDateFormatConstraint.d.ts +36 -36
  100. package/types/models/attributes/input-constraints/DateTimeTimeFormatConstraint.d.ts +36 -36
  101. package/types/models/attributes/input-constraints/DatetimeFormatConstraint.d.ts +92 -92
  102. package/types/models/attributes/input-constraints/FileExtensionConstraint.d.ts +33 -33
  103. package/types/models/attributes/input-constraints/FileSizeConstraint.d.ts +42 -42
  104. package/types/models/attributes/input-constraints/IBANConstraint.d.ts +23 -23
  105. package/types/models/attributes/input-constraints/MandatoryConstraint.d.ts +23 -23
  106. package/types/models/attributes/input-constraints/MandatoryRangeConstraint.d.ts +36 -36
  107. package/types/models/attributes/input-constraints/NumberBoundaryConstraint.d.ts +61 -61
  108. package/types/models/attributes/input-constraints/NumberFormatConstraint.d.ts +52 -52
  109. package/types/models/attributes/input-constraints/NumberGroupingConstraint.d.ts +46 -46
  110. package/types/models/attributes/input-constraints/PasswordConfirmConstraint.d.ts +36 -36
  111. package/types/models/attributes/input-constraints/PasswordLowerAndUpperCaseConstraint.d.ts +23 -23
  112. package/types/models/attributes/input-constraints/PasswordMinNumericCharactersConstraint.d.ts +32 -32
  113. package/types/models/attributes/input-constraints/PasswordMinSpecialCharactersConstraint.d.ts +32 -32
  114. package/types/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.d.ts +35 -35
  115. package/types/models/attributes/input-constraints/RangeConstraint.d.ts +97 -97
  116. package/types/models/attributes/input-constraints/RegexConstraint.d.ts +37 -37
  117. package/types/models/attributes/input-constraints/StringLengthConstraint.d.ts +46 -46
  118. package/types/models/attributes/input-constraints/XMLConstraint.d.ts +26 -26
  119. package/types/models/attributes/layouthint-rules/BaseLayoutHintRule.d.ts +46 -46
  120. package/types/models/attributes/layouthint-rules/DependentAttribute.d.ts +57 -57
  121. package/types/models/attributes/layouthint-rules/LayoutHintRuleCollection.d.ts +27 -27
  122. package/types/models/attributes/layouthint-rules/RemainingTotalUploadSize.d.ts +17 -17
  123. package/types/models/base/BaseCollection.d.ts +89 -89
  124. package/types/models/base/BaseModel.d.ts +67 -67
  125. package/types/models/base/ResourceCollection.d.ts +19 -19
  126. package/types/models/base/ResourceModel.d.ts +97 -97
  127. package/types/models/caseview/CaseViewModel.d.ts +45 -45
  128. package/types/models/concepts/BusinessScenarioModel.d.ts +20 -20
  129. package/types/models/concepts/ConceptDetailModel.d.ts +69 -69
  130. package/types/models/concepts/ConceptIndexModel.d.ts +36 -36
  131. package/types/models/concepts/ConceptLinkModel.d.ts +65 -65
  132. package/types/models/concepts/ConceptRelationCollection.d.ts +34 -34
  133. package/types/models/concepts/ConceptRelationModel.d.ts +44 -44
  134. package/types/models/concepts/ConceptTypeDetailModel.d.ts +39 -39
  135. package/types/models/concepts/SourceReferenceCollection.d.ts +13 -13
  136. package/types/models/concepts/SourceReferenceModel.d.ts +30 -30
  137. package/types/models/content/ContentIndexModel.d.ts +34 -34
  138. package/types/models/content/ContentLinkModel.d.ts +81 -81
  139. package/types/models/content/ContentModel.d.ts +74 -74
  140. package/types/models/content/ContentTOCModel.d.ts +37 -37
  141. package/types/models/content/ContentTypeModel.d.ts +26 -26
  142. package/types/models/content/SectionModel.d.ts +75 -75
  143. package/types/models/content/SubSectionModel.d.ts +64 -64
  144. package/types/models/contentconfiguration/ContentConfiguration.d.ts +28 -28
  145. package/types/models/contentconfiguration/ContentConfigurationElements.d.ts +47 -47
  146. package/types/models/contentconfiguration/ContentConfigurationEndResults.d.ts +16 -16
  147. package/types/models/contentconfiguration/ContentConfigurationQuestions.d.ts +22 -22
  148. package/types/models/contentconfiguration/ContentConfigurationResults.d.ts +39 -39
  149. package/types/models/detail/DetailModel.d.ts +72 -72
  150. package/types/models/error/ErrorCollection.d.ts +51 -51
  151. package/types/models/error/ErrorModel.d.ts +41 -41
  152. package/types/models/error/ErrorResponse.d.ts +148 -148
  153. package/types/models/filters/AssignmentFilterModel.d.ts +35 -35
  154. package/types/models/filters/BaseFilterModel.d.ts +85 -85
  155. package/types/models/filters/ConceptIndexFilterModel.d.ts +6 -6
  156. package/types/models/filters/FilterCollection.d.ts +48 -48
  157. package/types/models/filters/FilterModel.d.ts +5 -5
  158. package/types/models/filters/RangeFilterModel.d.ts +6 -6
  159. package/types/models/form/FormModel.d.ts +343 -312
  160. package/types/models/form/FormObjectModel.d.ts +196 -196
  161. package/types/models/grouping/GroupingModel.d.ts +85 -85
  162. package/types/models/href/Href.d.ts +196 -196
  163. package/types/models/href/ListHref.d.ts +64 -64
  164. package/types/models/index.d.ts +95 -94
  165. package/types/models/layouthint/LayoutHintCollection.d.ts +43 -43
  166. package/types/models/links/LinkCollection.d.ts +62 -62
  167. package/types/models/links/LinkModel.d.ts +92 -92
  168. package/types/models/links/normalizeLinkJSON.d.ts +9 -9
  169. package/types/models/list/ListDetailModel.d.ts +69 -69
  170. package/types/models/list/ListHeaderModel.d.ts +64 -64
  171. package/types/models/list/ListItemCollection.d.ts +21 -21
  172. package/types/models/list/ListItemModel.d.ts +34 -34
  173. package/types/models/list/ListModel.d.ts +135 -135
  174. package/types/models/lookup/LookupOptionCollection.d.ts +11 -11
  175. package/types/models/lookup/LookupOptionsModel.d.ts +19 -19
  176. package/types/models/modelcatalog/ModelCatalogModel.d.ts +18 -18
  177. package/types/models/paging/PagesizeModel.d.ts +25 -25
  178. package/types/models/paging/PagingModel.d.ts +49 -49
  179. package/types/models/panels/GroupingPanelModel.d.ts +39 -39
  180. package/types/models/parameter/Parameter.d.ts +40 -40
  181. package/types/models/process/ProcessStatusSettingsModel.d.ts +38 -38
  182. package/types/models/resolveModel.d.ts +7 -7
  183. package/types/models/search/CaseSearchModel.d.ts +14 -14
  184. package/types/models/sorting/SortOptionModel.d.ts +48 -48
  185. package/types/models/sorting/SortingModel.d.ts +42 -42
  186. package/types/models/tab/TabModel.d.ts +44 -44
  187. package/types/models/taskgroup/TaskGroupCollection.d.ts +12 -12
  188. package/types/models/taskgroup/TaskGroupModel.d.ts +15 -15
  189. package/types/models/types.d.ts +161 -161
  190. package/types/models/user/UserModel.d.ts +14 -14
  191. package/types/models/user/UserProfileModel.d.ts +12 -12
  192. package/types/models/user/UserServicesModel.d.ts +28 -28
  193. package/types/modularui/Authenticate.d.ts +49 -49
  194. package/types/modularui/CaptchaRequest.d.ts +45 -45
  195. package/types/modularui/ModularUIError.d.ts +10 -10
  196. package/types/modularui/ModularUIRequest.d.ts +198 -198
  197. package/types/modularui/ModularUIResponse.d.ts +56 -56
  198. package/types/modularui/UploadRequest.d.ts +35 -35
  199. package/types/modularui/index.d.ts +5 -5
  200. package/types/modularui/types.d.ts +2 -2
  201. package/types/redux/_i18n/types.d.ts +13 -13
  202. package/types/redux/_modularui/types.d.ts +61 -61
  203. package/types/redux/_router/types.d.ts +35 -35
  204. package/types/redux/selectors/i18n.d.ts +4 -4
  205. package/types/redux/types.d.ts +105 -105
  206. package/types/utils/browser/Cache.d.ts +45 -45
  207. package/types/utils/browser/Cookies.d.ts +9 -9
  208. package/types/utils/datetime/DateTimeUtil.d.ts +164 -164
  209. package/types/utils/fetch/serverFetch.d.ts +5 -5
  210. package/types/utils/fetch/types.d.ts +40 -40
  211. package/types/utils/fetch/universalFetch.d.ts +7 -7
  212. package/types/utils/fetch/xhr.d.ts +5 -5
  213. package/types/utils/helpers/checkResource.d.ts +3 -3
  214. package/types/utils/helpers/createHash.d.ts +8 -8
  215. package/types/utils/helpers/createUUID.d.ts +4 -4
  216. package/types/utils/helpers/index.d.ts +7 -7
  217. package/types/utils/helpers/objects.d.ts +11 -11
  218. package/types/utils/helpers/repositoryResource.d.ts +1 -1
  219. package/types/utils/helpers/sanitizeHtml.d.ts +9 -9
  220. package/types/utils/helpers/text.d.ts +7 -7
  221. package/types/utils/index.d.ts +11 -11
  222. package/types/utils/number/DecimalFormat.d.ts +90 -90
  223. package/types/utils/number/formatValue.d.ts +4 -4
  224. package/types/utils/number/parseNumbers.d.ts +9 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.29.0",
3
+ "version": "1.30.1",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -85,7 +85,7 @@
85
85
  "@babel/runtime-corejs3": "^7.21.0",
86
86
  "big.js": "^6.2.1",
87
87
  "date-fns": "^2.29.3",
88
- "deepmerge": "^4.3.0",
88
+ "deepmerge": "^4.3.1",
89
89
  "dequal": "^2.0.3",
90
90
  "file-size": "^1.0.0",
91
91
  "format-message": "^6.2.4",
@@ -99,39 +99,39 @@
99
99
  },
100
100
  "devDependencies": {
101
101
  "@babel/cli": "^7.21.0",
102
- "@babel/core": "^7.21.0",
103
- "@babel/eslint-parser": "^7.19.1",
102
+ "@babel/core": "^7.21.4",
103
+ "@babel/eslint-parser": "^7.21.3",
104
104
  "@babel/eslint-plugin": "^7.19.1",
105
105
  "@babel/plugin-proposal-class-properties": "^7.18.6",
106
106
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
107
- "@babel/plugin-transform-runtime": "^7.21.0",
108
- "@babel/preset-env": "^7.20.2",
109
- "@babel/preset-flow": "^7.18.6",
107
+ "@babel/plugin-transform-runtime": "^7.21.4",
108
+ "@babel/preset-env": "^7.21.4",
109
+ "@babel/preset-flow": "^7.21.4",
110
110
  "@babel/preset-react": "^7.18.6",
111
- "@commitlint/cli": "^17.4.4",
111
+ "@commitlint/cli": "^17.5.1",
112
112
  "@commitlint/config-conventional": "^17.4.4",
113
113
  "@testing-library/react": "^14.0.0",
114
114
  "auditjs": "^4.0.39",
115
115
  "babel-jest": "^29.5.0",
116
116
  "babel-plugin-styled-components": "^2.0.7",
117
117
  "cherry-pick": "^0.5.0",
118
- "commit-and-tag-version": "^11.1.0",
118
+ "commit-and-tag-version": "^11.2.0",
119
119
  "cross-env": "^7.0.3",
120
120
  "documentation": "^14.0.1",
121
- "eslint": "^8.35.0",
122
- "eslint-config-prettier": "^8.7.0",
121
+ "eslint": "^8.37.0",
122
+ "eslint-config-prettier": "^8.8.0",
123
123
  "eslint-plugin-babel": "^5.3.1",
124
124
  "eslint-plugin-ft-flow": "^2.0.3",
125
125
  "eslint-plugin-import": "^2.27.5",
126
126
  "eslint-plugin-jest": "^27.2.1",
127
- "eslint-plugin-jsdoc": "^40.0.1",
127
+ "eslint-plugin-jsdoc": "^40.1.0",
128
128
  "eslint-plugin-react": "^7.32.2",
129
129
  "eslint-plugin-react-hooks": "^4.5.0",
130
130
  "eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0",
131
131
  "flow-bin": "^0.200.1",
132
132
  "flow-copy-source": "^2.0.9",
133
133
  "flow-typed": "^3.8.0",
134
- "glob": "^8.1.0",
134
+ "glob": "^9.3.2",
135
135
  "history": "^4.0.0",
136
136
  "husky": "^8.0.3",
137
137
  "jest": "^29.5.0",
@@ -139,9 +139,9 @@
139
139
  "jest-junit": "^15.0.0",
140
140
  "jest-sonar-reporter": "^2.0.0",
141
141
  "jscodeshift": "^0.14.0",
142
- "lint-staged": "^13.1.2",
142
+ "lint-staged": "^13.2.0",
143
143
  "polished": "^4.0.0",
144
- "prettier": "^2.8.4",
144
+ "prettier": "^2.8.7",
145
145
  "react": "^18.0.0",
146
146
  "react-dom": "^18.0.0",
147
147
  "react-helmet-async": "^1.0.0",
@@ -151,8 +151,8 @@
151
151
  "redux": "^4.2.1",
152
152
  "redux-mock-store": "^1.5.4",
153
153
  "redux-thunk": "^2.4.2",
154
- "rimraf": "^4.4.0",
155
- "styled-components": "^5.3.8",
154
+ "rimraf": "^4.4.1",
155
+ "styled-components": "^5.3.9",
156
156
  "xhr-mock": "^2.5.1"
157
157
  },
158
158
  "scarfSettings": {
@@ -253,7 +253,7 @@ export default class BooleanAttributeModel extends AttributeModel {
253
253
  } else if (typeof value === "string" && this.isMultiple) {
254
254
  values = value.split(",");
255
255
  } else {
256
- values = [value];
256
+ values = [value.toString()];
257
257
  }
258
258
 
259
259
  values.forEach((val) => {
@@ -61,6 +61,20 @@ describe("booleanAttributeModel", () => {
61
61
  expect(attribute.getFormData()).toStrictEqual({ boolean: false });
62
62
  });
63
63
 
64
+ it("handles update empty string", () => {
65
+ const data = { key: "boolean", value: null };
66
+ const contributions = { label: "Boolean", type: "boolean" };
67
+
68
+ const attribute = new BooleanAttributeModel(data, contributions);
69
+
70
+ attribute.update(false);
71
+ expect(attribute.value).toBe("false");
72
+ attribute.reset();
73
+ expect(attribute.value).toBe(null);
74
+
75
+ expect(attribute.getFormData()).toStrictEqual({ boolean: null });
76
+ });
77
+
64
78
  it("should return proper AttributeWidth for attribute with alternative label", () => {
65
79
  const attribute = new BooleanAttributeModel(
66
80
  {},
@@ -27,6 +27,7 @@ import type { ModularUIResponse } from "../../modularui";
27
27
  import type ErrorResponse from "../error/ErrorResponse";
28
28
  import type LinkModel from "../links/LinkModel";
29
29
  import LayoutHintCollection from "../layouthint/LayoutHintCollection";
30
+ import AttributeSetModel from "../attributes/AttributeSetModel";
30
31
 
31
32
  /**
32
33
  */
@@ -50,6 +51,7 @@ class FormModel extends ResourceModel {
50
51
  _commit: boolean;
51
52
  _isFinished: boolean;
52
53
  _isComplete: boolean;
54
+ _success: { redirect: string, data: Object } | null;
53
55
 
54
56
  _parameters: Array<Parameter>;
55
57
  _tokens: Array<string>;
@@ -71,6 +73,8 @@ class FormModel extends ResourceModel {
71
73
  if (this.data.errors) {
72
74
  this.handleRootErrors(this.data.errors);
73
75
  }
76
+
77
+ this.createSuccess();
74
78
  }
75
79
 
76
80
  /**
@@ -573,7 +577,7 @@ class FormModel extends ResourceModel {
573
577
  * Inidicates if form is finished: Form is completely entered and committed
574
578
  */
575
579
  get isFinished(): boolean {
576
- return this._isFinished || "success" in this.data;
580
+ return this._isFinished || this.success != undefined;
577
581
  }
578
582
 
579
583
  /**
@@ -599,8 +603,8 @@ class FormModel extends ResourceModel {
599
603
  * Handle success redirects
600
604
  */
601
605
  get successRedirect(): Href | null {
602
- return this.isFinished && this.data.success
603
- ? new Href(this.data.success.redirect)
606
+ return this.isFinished && this.success
607
+ ? new Href(this.success.redirect)
604
608
  : null;
605
609
  }
606
610
 
@@ -611,9 +615,34 @@ class FormModel extends ResourceModel {
611
615
  }
612
616
 
613
617
  /**
618
+ * Get the result data as plain json object
614
619
  */
615
620
  getSuccessData(): ?Object {
616
- return this.data.success?.data;
621
+ return this.success?.data;
622
+ }
623
+
624
+ /**
625
+ * Retrieve an object where each property is a result data attribute set
626
+ */
627
+ getResultData(): ?{
628
+ [key: string]: AttributeSetModel,
629
+ } {
630
+ const resultDataKeys = Object.keys(this.contributions.resultdata) ?? [];
631
+ const successData = this.getSuccessData() ?? {};
632
+
633
+ const resultdata: {
634
+ [key: string]: AttributeSetModel,
635
+ } = {};
636
+
637
+ for (const resultDataKey of resultDataKeys) {
638
+ resultdata[resultDataKey] = new AttributeSetModel(
639
+ resultDataKey,
640
+ successData[resultDataKey],
641
+ this.contributions.resultdata[resultDataKey]
642
+ );
643
+ }
644
+
645
+ return resultdata;
617
646
  }
618
647
 
619
648
  /**
@@ -862,6 +891,8 @@ class FormModel extends ResourceModel {
862
891
  */
863
892
  setPreviousObject() {
864
893
  this.isComplete = false;
894
+ this.isFinished = false;
895
+ this.success = null;
865
896
 
866
897
  const oldCurrentFormObject = this.currentFormObject;
867
898
 
@@ -959,6 +990,7 @@ class FormModel extends ResourceModel {
959
990
 
960
991
  this.isComplete = receivedForm.isComplete;
961
992
  this.isFinished = receivedForm.isFinished;
993
+ this.success = receivedForm.success;
962
994
 
963
995
  const receivedFormData = receivedForm.data ?? {};
964
996
  const hasMissing = has(receivedFormData, "missing");
@@ -990,6 +1022,28 @@ class FormModel extends ResourceModel {
990
1022
  return this;
991
1023
  }
992
1024
 
1025
+ /**
1026
+ * Retrieve success information from response
1027
+ * @returns {{redirect: string, data: object}}
1028
+ */
1029
+ get success(): { redirect: string, data: Object } | null {
1030
+ return this._success;
1031
+ }
1032
+
1033
+ /**
1034
+ * Set success information, contains redirect and event data
1035
+ * @param success
1036
+ */
1037
+ set success(success: { redirect: string, data: Object } | null) {
1038
+ this._success = success;
1039
+ }
1040
+
1041
+ /**
1042
+ */
1043
+ createSuccess() {
1044
+ this._success = this.data.success;
1045
+ }
1046
+
993
1047
  /**
994
1048
  * Process finished form
995
1049
  */
@@ -458,11 +458,15 @@ describe("formModel", () => {
458
458
  expect(form.completedFormObjects).toHaveLength(2);
459
459
  expect(form.allObjects).toHaveLength(2);
460
460
  expect(form.currentFormObject).toBeNull();
461
+ expect(form.success).toStrictEqual({ redirect: "/endredirect" });
462
+ expect(form.isFinished).toBe(true);
461
463
 
462
464
  form.setPreviousObject();
463
465
  expect(form.completedFormObjects).toHaveLength(1);
464
466
  expect(form.currentFormObject).toBeInstanceOf(FormObjectModel);
465
467
  expect(form.hasNextStep).toBeFalsy();
468
+ expect(form.success).toBeNull();
469
+ expect(form.isFinished).toBe(false);
466
470
  });
467
471
 
468
472
  it("is able to get formdata for request", () => {
@@ -0,0 +1,86 @@
1
+ import ModularUIResponse from "../../../modularui/ModularUIResponse";
2
+ import FormModel from "../FormModel";
3
+
4
+ describe("formModel with result data", () => {
5
+ it("should be able to create a FormModel with result data", () => {
6
+ const data = ModularUIResponse.create({
7
+ data: {
8
+ formresponse: {
9
+ _links: {
10
+ self: { href: "/rebuild-db/database-actions/rebuild-db-server" },
11
+ api_doc: {
12
+ href: "/api-docs/v3/rebuild-db/database-actions/rebuild-db-server",
13
+ },
14
+ contributions: {
15
+ href: "/contributions/rebuild-db/database-actions/rebuild-db-server",
16
+ },
17
+ },
18
+ success: { redirect: "/", data: { out: { money: 10 } } },
19
+ },
20
+ },
21
+ contributions: {
22
+ RebuildDBServer: {
23
+ label: "Rebuild DB server",
24
+ resourcetype: "Form",
25
+ actiontype: "form",
26
+ objects: {
27
+ AttributeSet: {
28
+ dynamicObject: false,
29
+ repeatable: false,
30
+ dynamicValidations: false,
31
+ label: "Rebuild DB",
32
+ mandatory: false,
33
+ attributes: [
34
+ {
35
+ Dummy: {
36
+ type: "string",
37
+ label: "Dummy (not visible)",
38
+ mandatory: false,
39
+ readonly: true,
40
+ layouthint: ["label"],
41
+ },
42
+ },
43
+ ],
44
+ },
45
+ },
46
+ resultdata: {
47
+ out: {
48
+ repeatable: false,
49
+ label: "Result data",
50
+ introText: {
51
+ id: "out.Introtext",
52
+ message: "<p>uit</p>",
53
+ },
54
+ attributes: [
55
+ {
56
+ money: {
57
+ type: "number",
58
+ label: "Money",
59
+ mandatory: false,
60
+ decimalSeparator: ",",
61
+ layouthint: ["money"],
62
+ format: "#,##0.00",
63
+ groupingSeparator: ".",
64
+ currencySymbol: "€",
65
+ },
66
+ },
67
+ ],
68
+ },
69
+ },
70
+ },
71
+ },
72
+ });
73
+
74
+ const form = new FormModel(data);
75
+
76
+ const resultData = form.getResultData();
77
+ expect(resultData.out.key).toBe("out");
78
+ expect(resultData.out.label).toBe("Result data");
79
+ expect(resultData.out.attributeCollection.size).toBe(1);
80
+ expect(resultData.out.attributeCollection.first.label).toBe("Money");
81
+ expect(resultData.out.attributeCollection.first.readonlyvalue).toBe(
82
+ "10,00"
83
+ );
84
+ expect(resultData.out.attributeCollection.first.currencySymbol).toBe("€");
85
+ });
86
+ });
@@ -1,145 +1,145 @@
1
- /**
2
- * path to content service
3
- */
4
- export const CONTENT_PATH: "/content";
5
- /**
6
- * Upload Path
7
- */
8
- export const UPLOAD_PATH: "/uploadFile";
9
- /**
10
- * Captcha Path
11
- */
12
- export const CAPTCHA_PATH: "/captchaServices";
13
- /**
14
- * Path to change password page / component
15
- */
16
- export const CHANGEPASSWORD_PATH: "/change-password";
17
- /**
18
- * Path to user profile page / component
19
- */
20
- export const USERPROFILE_PATH: "/user";
21
- /**
22
- * Path to resources in the Be Informed repository
23
- */
24
- export const RESOURCE_PATH: "/resource";
25
- /**
26
- * Separator for parameters of a list, makes it possible to render multiple lists on a page in a non-js environment
27
- */
28
- export const PARAMETER_SEPARATOR: "~";
29
- /**
30
- * Timeversion filter name
31
- */
32
- export const TIMEVERSION_FILTER_NAME: "entryDate";
33
- /**
34
- * Parameter name for the viewtype toggle
35
- */
36
- export const DEFAULT_UI_PARAMETERS: Array<string>;
37
- /**
38
- */
39
- export const ISO_DATE_FORMAT: "yyyy-MM-dd";
40
- /**
41
- */
42
- export const ISO_DATETIME_FORMAT: "yyyy-MM-dd'T'HH:mm:ss";
43
- /**
44
- */
45
- export const ISO_TIME_FORMAT: "HH:mm:ss";
46
- /**
47
- */
48
- export const ISO_TIMESTAMP_FORMAT: "yyyy-MM-dd'T'HH:mm:ss.SSS";
49
- /**
50
- * week starts on monday by default
51
- */
52
- export const DEFAULT_WEEK_STARTS_ON: 1;
53
- /**
54
- * first week indicated by the 1st of january
55
- */
56
- export const DEFAULT_FIRST_WEEK_CONTAINS_DATE: 1;
57
- /**
58
- * Key codes
59
- * @type {{SPACE: number, PAGE_DOWN: number, TAB: number, ARROW_RIGHT: number, ARROW_DOWN: number, ENTER: number, ARROW_UP: number, ARROW_LEFT: number, PAGE_UP: number, ESCAPE: number}}
60
- */
61
- export const KEYCODES: {
62
- SPACE: number;
63
- PAGE_DOWN: number;
64
- TAB: number;
65
- ARROW_RIGHT: number;
66
- ARROW_DOWN: number;
67
- ENTER: number;
68
- ARROW_UP: number;
69
- ARROW_LEFT: number;
70
- PAGE_UP: number;
71
- ESCAPE: number;
72
- };
73
- /**
74
- * @type {boolean}
75
- */
76
- export const IS_SYNC: boolean;
77
- /**
78
- * @type {boolean}
79
- */
80
- export const IS_SERVER: boolean;
81
- /**
82
- * @type {{SUCCESS: string, ERROR: string, INFO: string, WARNING: string}}
83
- */
84
- export const NOTIFICATION_TYPES: {
85
- SUCCESS: string;
86
- ERROR: string;
87
- INFO: string;
88
- WARNING: string;
89
- };
90
- /**
91
- * SUPPORTED HTTP METHODS
92
- * @type {{POST: string, GET: string}}
93
- */
94
- export const HTTP_METHODS: {
95
- POST: string;
96
- GET: string;
97
- };
98
- /**
99
- * POSSIBLE MODULARUI STATUSSES
100
- * @type {{LOADING: string, ERROR: string, FINISHED: string}}
101
- */
102
- export const MODULARUI_STATUS: {
103
- LOADING: string;
104
- ERROR: string;
105
- FINISHED: string;
106
- };
107
- /**
108
- * POSSIBLE AUTOSAVE STATUSSES
109
- * @type {{START: string, FINISHED: string}}
110
- */
111
- export const AUTOSAVE_STATUS: {
112
- START: string;
113
- FINISHED: string;
114
- };
115
- /**
116
- * DEBOUNCE INPUT TIMEOUT
117
- */
118
- export const INPUT_DEBOUNCE_TIMEOUT: 100;
119
- /**
120
- * DEBOUNCE VALIDATION TIMEOUT
121
- */
122
- export const VALIDATE_DEBOUNCE_TIMEOUT: 500;
123
- export namespace ATTRIBUTE_WIDTH {
124
- const EXTRA_SMALL: string;
125
- const SMALL: string;
126
- const MEDIUM: string;
127
- const LARGE: string;
128
- const EXTRA_LARGE: string;
129
- }
130
- export const ALL_CONTENT_IN_DATA_SETTING: "hasAllContentInData";
131
- export namespace INTERNAL_LOGIN_TYPE {
132
- const JAAS: string;
133
- const PAC4J_FORM: string;
134
- const PAC4J_BASIC: string;
135
- }
136
- export const LOGIN_TYPE: "security.clients";
137
- export const LOGIN_PATH_SETTING: "FormClient.login_url";
138
- export const LOGIN_USERNAME_SETTING: "FormClient.username_field_name";
139
- export const LOGIN_PASSWORD_SETTING: "FormClient.password_field_name";
140
- export const LOGOUT_PATH_SETTING: "FormClient.logout_url";
141
- export namespace DEFAULT_AUTHENTICATION_TYPE {
142
- const name: string;
143
- const authentication: string;
144
- const isPrimary: boolean;
145
- }
1
+ /**
2
+ * path to content service
3
+ */
4
+ export const CONTENT_PATH: "/content";
5
+ /**
6
+ * Upload Path
7
+ */
8
+ export const UPLOAD_PATH: "/uploadFile";
9
+ /**
10
+ * Captcha Path
11
+ */
12
+ export const CAPTCHA_PATH: "/captchaServices";
13
+ /**
14
+ * Path to change password page / component
15
+ */
16
+ export const CHANGEPASSWORD_PATH: "/change-password";
17
+ /**
18
+ * Path to user profile page / component
19
+ */
20
+ export const USERPROFILE_PATH: "/user";
21
+ /**
22
+ * Path to resources in the Be Informed repository
23
+ */
24
+ export const RESOURCE_PATH: "/resource";
25
+ /**
26
+ * Separator for parameters of a list, makes it possible to render multiple lists on a page in a non-js environment
27
+ */
28
+ export const PARAMETER_SEPARATOR: "~";
29
+ /**
30
+ * Timeversion filter name
31
+ */
32
+ export const TIMEVERSION_FILTER_NAME: "entryDate";
33
+ /**
34
+ * Parameter name for the viewtype toggle
35
+ */
36
+ export const DEFAULT_UI_PARAMETERS: Array<string>;
37
+ /**
38
+ */
39
+ export const ISO_DATE_FORMAT: "yyyy-MM-dd";
40
+ /**
41
+ */
42
+ export const ISO_DATETIME_FORMAT: "yyyy-MM-dd'T'HH:mm:ss";
43
+ /**
44
+ */
45
+ export const ISO_TIME_FORMAT: "HH:mm:ss";
46
+ /**
47
+ */
48
+ export const ISO_TIMESTAMP_FORMAT: "yyyy-MM-dd'T'HH:mm:ss.SSS";
49
+ /**
50
+ * week starts on monday by default
51
+ */
52
+ export const DEFAULT_WEEK_STARTS_ON: 1;
53
+ /**
54
+ * first week indicated by the 1st of january
55
+ */
56
+ export const DEFAULT_FIRST_WEEK_CONTAINS_DATE: 1;
57
+ /**
58
+ * Key codes
59
+ * @type {{SPACE: number, PAGE_DOWN: number, TAB: number, ARROW_RIGHT: number, ARROW_DOWN: number, ENTER: number, ARROW_UP: number, ARROW_LEFT: number, PAGE_UP: number, ESCAPE: number}}
60
+ */
61
+ export const KEYCODES: {
62
+ SPACE: number;
63
+ PAGE_DOWN: number;
64
+ TAB: number;
65
+ ARROW_RIGHT: number;
66
+ ARROW_DOWN: number;
67
+ ENTER: number;
68
+ ARROW_UP: number;
69
+ ARROW_LEFT: number;
70
+ PAGE_UP: number;
71
+ ESCAPE: number;
72
+ };
73
+ /**
74
+ * @type {boolean}
75
+ */
76
+ export const IS_SYNC: boolean;
77
+ /**
78
+ * @type {boolean}
79
+ */
80
+ export const IS_SERVER: boolean;
81
+ /**
82
+ * @type {{SUCCESS: string, ERROR: string, INFO: string, WARNING: string}}
83
+ */
84
+ export const NOTIFICATION_TYPES: {
85
+ SUCCESS: string;
86
+ ERROR: string;
87
+ INFO: string;
88
+ WARNING: string;
89
+ };
90
+ /**
91
+ * SUPPORTED HTTP METHODS
92
+ * @type {{POST: string, GET: string}}
93
+ */
94
+ export const HTTP_METHODS: {
95
+ POST: string;
96
+ GET: string;
97
+ };
98
+ /**
99
+ * POSSIBLE MODULARUI STATUSSES
100
+ * @type {{LOADING: string, ERROR: string, FINISHED: string}}
101
+ */
102
+ export const MODULARUI_STATUS: {
103
+ LOADING: string;
104
+ ERROR: string;
105
+ FINISHED: string;
106
+ };
107
+ /**
108
+ * POSSIBLE AUTOSAVE STATUSSES
109
+ * @type {{START: string, FINISHED: string}}
110
+ */
111
+ export const AUTOSAVE_STATUS: {
112
+ START: string;
113
+ FINISHED: string;
114
+ };
115
+ /**
116
+ * DEBOUNCE INPUT TIMEOUT
117
+ */
118
+ export const INPUT_DEBOUNCE_TIMEOUT: 100;
119
+ /**
120
+ * DEBOUNCE VALIDATION TIMEOUT
121
+ */
122
+ export const VALIDATE_DEBOUNCE_TIMEOUT: 500;
123
+ export namespace ATTRIBUTE_WIDTH {
124
+ const EXTRA_SMALL: string;
125
+ const SMALL: string;
126
+ const MEDIUM: string;
127
+ const LARGE: string;
128
+ const EXTRA_LARGE: string;
129
+ }
130
+ export const ALL_CONTENT_IN_DATA_SETTING: "hasAllContentInData";
131
+ export namespace INTERNAL_LOGIN_TYPE {
132
+ const JAAS: string;
133
+ const PAC4J_FORM: string;
134
+ const PAC4J_BASIC: string;
135
+ }
136
+ export const LOGIN_TYPE: "security.clients";
137
+ export const LOGIN_PATH_SETTING: "FormClient.login_url";
138
+ export const LOGIN_USERNAME_SETTING: "FormClient.username_field_name";
139
+ export const LOGIN_PASSWORD_SETTING: "FormClient.password_field_name";
140
+ export const LOGOUT_PATH_SETTING: "FormClient.logout_url";
141
+ export namespace DEFAULT_AUTHENTICATION_TYPE {
142
+ const name: string;
143
+ const authentication: string;
144
+ const isPrimary: boolean;
145
+ }