@beinformed/ui 1.21.0 → 1.21.3

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 (54) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/esm/models/attributes/AttributeModel.js +2 -2
  3. package/esm/models/attributes/AttributeModel.js.map +1 -1
  4. package/esm/models/attributes/ChoiceAttributeModel.js +2 -1
  5. package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
  6. package/esm/models/attributes/DatetimeAttributeModel.js +2 -1
  7. package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
  8. package/esm/models/error/ErrorCollection.js +7 -6
  9. package/esm/models/error/ErrorCollection.js.map +1 -1
  10. package/esm/models/error/ErrorModel.js +2 -1
  11. package/esm/models/error/ErrorModel.js.map +1 -1
  12. package/esm/models/error/ErrorResponse.js +46 -32
  13. package/esm/models/error/ErrorResponse.js.map +1 -1
  14. package/esm/models/form/FormModel.js +5 -4
  15. package/esm/models/form/FormModel.js.map +1 -1
  16. package/esm/models/form/FormObjectModel.js +1 -1
  17. package/esm/models/form/FormObjectModel.js.map +1 -1
  18. package/esm/models/types.js.map +1 -1
  19. package/lib/models/attributes/AttributeModel.js +2 -2
  20. package/lib/models/attributes/AttributeModel.js.flow +2 -0
  21. package/lib/models/attributes/AttributeModel.js.map +1 -1
  22. package/lib/models/attributes/ChoiceAttributeModel.js +2 -1
  23. package/lib/models/attributes/ChoiceAttributeModel.js.flow +2 -2
  24. package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
  25. package/lib/models/attributes/DatetimeAttributeModel.js +2 -1
  26. package/lib/models/attributes/DatetimeAttributeModel.js.flow +2 -2
  27. package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
  28. package/lib/models/error/ErrorCollection.js +7 -5
  29. package/lib/models/error/ErrorCollection.js.flow +6 -3
  30. package/lib/models/error/ErrorCollection.js.map +1 -1
  31. package/lib/models/error/ErrorModel.js +2 -1
  32. package/lib/models/error/ErrorModel.js.flow +6 -3
  33. package/lib/models/error/ErrorModel.js.map +1 -1
  34. package/lib/models/error/ErrorResponse.js +46 -32
  35. package/lib/models/error/ErrorResponse.js.flow +31 -24
  36. package/lib/models/error/ErrorResponse.js.map +1 -1
  37. package/lib/models/form/FormModel.js +5 -3
  38. package/lib/models/form/FormModel.js.flow +8 -1
  39. package/lib/models/form/FormModel.js.map +1 -1
  40. package/lib/models/form/FormObjectModel.js +1 -1
  41. package/lib/models/form/FormObjectModel.js.flow +1 -0
  42. package/lib/models/form/FormObjectModel.js.map +1 -1
  43. package/lib/models/types.js.flow +1 -1
  44. package/lib/models/types.js.map +1 -1
  45. package/package.json +1 -1
  46. package/src/models/attributes/AttributeModel.js +2 -0
  47. package/src/models/attributes/ChoiceAttributeModel.js +2 -2
  48. package/src/models/attributes/DatetimeAttributeModel.js +2 -2
  49. package/src/models/error/ErrorCollection.js +6 -3
  50. package/src/models/error/ErrorModel.js +6 -3
  51. package/src/models/error/ErrorResponse.js +31 -24
  52. package/src/models/form/FormModel.js +8 -1
  53. package/src/models/form/FormObjectModel.js +1 -0
  54. package/src/models/types.js +1 -1
@@ -710,6 +710,7 @@ export default class AttributeModel
710
710
  addServerError(error: FormErrorAnchor) {
711
711
  this._errorCollection.addServerError(
712
712
  error.id,
713
+ error.layouthint,
713
714
  error.message,
714
715
  error.properties
715
716
  );
@@ -812,6 +813,7 @@ export default class AttributeModel
812
813
  if (this.hasValue()) {
813
814
  this._errorCollection.addServerError(
814
815
  error.id,
816
+ error.layouthint,
815
817
  error.message,
816
818
  this.formatParameters(error.properties)
817
819
  );
@@ -396,7 +396,7 @@ export default class ChoiceAttributeModel extends AttributeModel {
396
396
  * Registers an error that was received from a server response
397
397
  */
398
398
  addServerError(error: FormErrorAnchor) {
399
- const { id, message, properties } = error;
399
+ const { id, layouthint, message, properties } = error;
400
400
 
401
401
  const ANSWER_OPTION_KEY = "answer-option-key";
402
402
 
@@ -412,7 +412,7 @@ export default class ChoiceAttributeModel extends AttributeModel {
412
412
  }
413
413
  }
414
414
 
415
- this._errorCollection.addServerError(id, message, properties);
415
+ this._errorCollection.addServerError(id, layouthint, message, properties);
416
416
  }
417
417
 
418
418
  /**
@@ -425,12 +425,12 @@ class DatetimeAttributeModel extends StringAttributeModel {
425
425
  * Registers an error that was received from a server response
426
426
  */
427
427
  addServerError(error: FormErrorAnchor) {
428
- const { id, message, properties } = error;
428
+ const { id, layouthint, message, properties } = error;
429
429
  if (properties && has(properties, "format") && this.formatLabel) {
430
430
  properties.format = this.formatLabel;
431
431
  }
432
432
 
433
- this._errorCollection.addServerError(id, message, properties);
433
+ this._errorCollection.addServerError(id, layouthint, message, properties);
434
434
  }
435
435
 
436
436
  /**
@@ -4,6 +4,7 @@ import ErrorModel from "./ErrorModel";
4
4
 
5
5
  import type { MessageParameters } from "../../i18n/types";
6
6
  import type { IConstraintModel } from "../types";
7
+ import LayoutHintCollection from "../layouthint/LayoutHintCollection";
7
8
 
8
9
  /**
9
10
  * Form Objects
@@ -42,6 +43,7 @@ export default class ErrorCollection extends BaseCollection<ErrorModel> {
42
43
  */
43
44
  addError(
44
45
  id: string,
46
+ layouthint?: LayoutHintCollection,
45
47
  defaultMessage?: string,
46
48
  parameters?: MessageParameters
47
49
  ) {
@@ -51,7 +53,7 @@ export default class ErrorCollection extends BaseCollection<ErrorModel> {
51
53
  this.removeByIndex(itemIdx);
52
54
  }
53
55
 
54
- this.add(new ErrorModel(id, defaultMessage, parameters));
56
+ this.add(new ErrorModel(id, defaultMessage, parameters, false, layouthint));
55
57
  }
56
58
 
57
59
  /**
@@ -66,13 +68,14 @@ export default class ErrorCollection extends BaseCollection<ErrorModel> {
66
68
  */
67
69
  addServerError(
68
70
  id: string,
71
+ layouthint?: LayoutHintCollection,
69
72
  defaultMessage?: string,
70
73
  parameters?: MessageParameters
71
74
  ) {
72
75
  if (parameters) {
73
- this.addError(id, defaultMessage, parameters);
76
+ this.addError(id, layouthint, defaultMessage, parameters);
74
77
  } else {
75
- this.addError(id, defaultMessage);
78
+ this.addError(id, layouthint, defaultMessage);
76
79
  }
77
80
  }
78
81
 
@@ -19,13 +19,16 @@ class ErrorModel {
19
19
  id: string,
20
20
  defaultMessage: ?string,
21
21
  parameters: ?MessageParameters,
22
- isClientConstraint: boolean = false
22
+ isClientConstraint: boolean = false,
23
+ layouthint: LayoutHintCollection = new LayoutHintCollection()
23
24
  ) {
24
25
  this._id = id;
25
26
  this._parameters = parameters;
26
27
  this._defaultMessage = defaultMessage;
27
28
  this._isClientConstraint = isClientConstraint;
28
- this._layouthint = new LayoutHintCollection();
29
+ this._layouthint = Array.isArray(layouthint)
30
+ ? new LayoutHintCollection(layouthint)
31
+ : layouthint;
29
32
  }
30
33
 
31
34
  /**
@@ -55,7 +58,7 @@ class ErrorModel {
55
58
 
56
59
  /**
57
60
  */
58
- get layouthint(): ?LayoutHintCollection {
61
+ get layouthint(): LayoutHintCollection {
59
62
  return this._layouthint;
60
63
  }
61
64
 
@@ -89,88 +89,95 @@ export default class ErrorResponse {
89
89
  }
90
90
 
91
91
  /**
92
- * Return error title
92
+ * Return response error message
93
+ */
94
+ get responseMessage(): string {
95
+ return this.response.message || this.id;
96
+ }
97
+
98
+ /**
99
+ * Return response error title
93
100
  */
94
101
  get title(): TitleObject {
95
- return this.error.title || null;
102
+ return this.response.title || null;
96
103
  }
97
104
 
98
105
  /**
99
- * Return error title message
106
+ * Return response error title message
100
107
  */
101
108
  get titleMessage(): string {
102
- return this.error.title?.message || undefined;
109
+ return this.response.title?.message || undefined;
103
110
  }
104
111
 
105
112
  /**
106
- * Return error title Id
113
+ * Return response error title Id
107
114
  */
108
115
  get titleId(): string {
109
- return this.error.title?.id || undefined;
116
+ return this.response.title?.id || undefined;
110
117
  }
111
118
 
112
119
  /**
113
- * Return error title properties
120
+ * Return response error title properties
114
121
  */
115
122
  get titleProperties(): Object {
116
- return this.error.title?.properties || null;
123
+ return this.response.title?.properties || null;
117
124
  }
118
125
 
119
126
  /**
120
- * Return error redirect
127
+ * Return response error redirect
121
128
  */
122
129
  get redirect(): RedirectObject {
123
- return this.error.redirect || null;
130
+ return this.response.redirect || null;
124
131
  }
125
132
  /**
126
- * Return error redirect text
133
+ * Return response error redirect text
127
134
  */
128
135
  get redirectText(): RedirectTextObject {
129
- return this.error.redirect?.text || null;
136
+ return this.response?.redirect?.text || null;
130
137
  }
131
138
 
132
139
  /**
133
- * Return error redirect text id
140
+ * Return response error redirect text id
134
141
  */
135
142
  get redirectTextID(): string {
136
- return this.error.redirect?.text?.id || undefined;
143
+ return this.response.redirect?.text?.id || undefined;
137
144
  }
138
145
 
139
146
  /**
140
- * Return error redirect text properties
147
+ * Return response error redirect text properties
141
148
  */
142
149
  get redirectTextProperties(): Object {
143
- return this.error.redirect?.text?.properties || null;
150
+ return this.response.redirect?.text?.properties || null;
144
151
  }
145
152
 
146
153
  /**
147
- * Return error redirect text message
154
+ * Return response error redirect text message
148
155
  */
149
156
  get redirectMessage(): string {
150
- return this.error.redirect?.text?.message || undefined;
157
+ return this.response.redirect?.text?.message || undefined;
151
158
  }
152
159
 
153
160
  /**
154
- * Return error redirect href
161
+ * Return response error redirect href
155
162
  */
156
163
  get redirectHref(): Href {
157
- if (this.error.redirect?.href) {
158
- return new Href(this.error.redirect.href);
164
+ if (this.response.redirect?.href) {
165
+ return new Href(this.response.redirect?.href);
159
166
  }
160
167
  return new Href();
161
168
  }
162
169
 
163
170
  /**
164
- * Return error layouthint
171
+ * Return error response layouthint
165
172
  */
166
173
  get layouthint(): LayoutHintCollection {
167
- return new LayoutHintCollection(this.error.layouthint);
174
+ return new LayoutHintCollection(this.response?.layouthint);
168
175
  }
169
176
 
170
177
  /**
171
178
  */
172
179
  get response(): Object {
173
- return this.error.response || {};
180
+ return this.error?.response?.error || {};
174
181
  }
175
182
 
176
183
  /**
@@ -26,6 +26,7 @@ import type { AttributeType, ModularUIModel } from "../types";
26
26
  import type { ModularUIResponse } from "../../modularui";
27
27
  import type ErrorResponse from "../error/ErrorResponse";
28
28
  import type LinkModel from "../links/LinkModel";
29
+ import LayoutHintCollection from "../layouthint/LayoutHintCollection";
29
30
 
30
31
  /**
31
32
  */
@@ -512,11 +513,16 @@ class FormModel extends ResourceModel {
512
513
  if (error.parameters) {
513
514
  this.errorCollection.addServerError(
514
515
  error.id,
516
+ error.layouthint,
515
517
  error.message,
516
518
  error.parameters
517
519
  );
518
520
  } else {
519
- this.errorCollection.addServerError(error.id, error.message);
521
+ this.errorCollection.addServerError(
522
+ error.id,
523
+ error.layouthint,
524
+ error.message
525
+ );
520
526
  }
521
527
  }
522
528
 
@@ -1018,6 +1024,7 @@ class FormModel extends ResourceModel {
1018
1024
  } else {
1019
1025
  this.errorCollection.addServerError(
1020
1026
  error.id,
1027
+ new LayoutHintCollection(error.layouthint),
1021
1028
  error.message,
1022
1029
  error.properties
1023
1030
  );
@@ -401,6 +401,7 @@ export default class FormObjectModel extends BaseModel {
401
401
  } else {
402
402
  this._errorCollection.addServerError(
403
403
  error.id,
404
+ error.layouthint,
404
405
  error.message,
405
406
  error.properties
406
407
  );
@@ -109,7 +109,7 @@ export type FormErrorAnchor = {
109
109
  index?: number,
110
110
  "index-identifier"?: string,
111
111
  },
112
- layouthint?: LayoutHintCollection,
112
+ layouthint: LayoutHintCollection,
113
113
  message: string,
114
114
  param?: {
115
115
  name: string,