@beinformed/ui 1.63.13 → 1.64.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 (88) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/esm/constants/Constants.js +4 -0
  3. package/esm/constants/Constants.js.flow +5 -0
  4. package/esm/constants/Constants.js.map +1 -1
  5. package/esm/hooks/__tests__/UseModularUIModel.spec.js.flow +7 -5
  6. package/esm/hooks/index.js +2 -0
  7. package/esm/hooks/index.js.flow +2 -0
  8. package/esm/hooks/index.js.map +1 -1
  9. package/esm/hooks/useList.js +69 -0
  10. package/esm/hooks/useList.js.flow +90 -0
  11. package/esm/hooks/useList.js.map +1 -0
  12. package/esm/hooks/useModularUIBasic.js +1 -1
  13. package/esm/hooks/useModularUIBasic.js.flow +6 -2
  14. package/esm/hooks/useModularUIBasic.js.map +1 -1
  15. package/esm/hooks/useModularUIModel.js +0 -34
  16. package/esm/hooks/useModularUIModel.js.flow +1 -55
  17. package/esm/hooks/useModularUIModel.js.map +1 -1
  18. package/esm/hooks/usePanel.js +51 -0
  19. package/esm/hooks/usePanel.js.flow +76 -0
  20. package/esm/hooks/usePanel.js.map +1 -0
  21. package/esm/models/filters/BaseFilterModel.js +27 -1
  22. package/esm/models/filters/BaseFilterModel.js.flow +30 -1
  23. package/esm/models/filters/BaseFilterModel.js.map +1 -1
  24. package/esm/models/filters/FilterCollection.js +16 -0
  25. package/esm/models/filters/FilterCollection.js.flow +16 -0
  26. package/esm/models/filters/FilterCollection.js.map +1 -1
  27. package/esm/models/filters/StringFilterModel.js +8 -0
  28. package/esm/models/filters/StringFilterModel.js.flow +8 -0
  29. package/esm/models/filters/StringFilterModel.js.map +1 -1
  30. package/esm/models/href/ListHref.js +3 -1
  31. package/esm/models/href/ListHref.js.flow +11 -8
  32. package/esm/models/href/ListHref.js.map +1 -1
  33. package/esm/models/list/ListModel.js +17 -7
  34. package/esm/models/list/ListModel.js.flow +20 -8
  35. package/esm/models/list/ListModel.js.map +1 -1
  36. package/esm/models/paging/PagesizeModel.js +6 -0
  37. package/esm/models/paging/PagesizeModel.js.flow +6 -0
  38. package/esm/models/paging/PagesizeModel.js.map +1 -1
  39. package/esm/models/paging/PagingModel.js +11 -0
  40. package/esm/models/paging/PagingModel.js.flow +11 -0
  41. package/esm/models/paging/PagingModel.js.map +1 -1
  42. package/esm/redux/actions/SignIn.js +2 -1
  43. package/esm/redux/actions/SignIn.js.flow +3 -2
  44. package/esm/redux/actions/SignIn.js.map +1 -1
  45. package/lib/constants/Constants.js +5 -1
  46. package/lib/constants/Constants.js.map +1 -1
  47. package/lib/hooks/index.js +22 -0
  48. package/lib/hooks/index.js.map +1 -1
  49. package/lib/hooks/useList.js +80 -0
  50. package/lib/hooks/useList.js.map +1 -0
  51. package/lib/hooks/useModularUIBasic.js +2 -2
  52. package/lib/hooks/useModularUIBasic.js.map +1 -1
  53. package/lib/hooks/useModularUIModel.js +1 -39
  54. package/lib/hooks/useModularUIModel.js.map +1 -1
  55. package/lib/hooks/usePanel.js +59 -0
  56. package/lib/hooks/usePanel.js.map +1 -0
  57. package/lib/models/filters/BaseFilterModel.js +26 -0
  58. package/lib/models/filters/BaseFilterModel.js.map +1 -1
  59. package/lib/models/filters/FilterCollection.js +15 -0
  60. package/lib/models/filters/FilterCollection.js.map +1 -1
  61. package/lib/models/filters/StringFilterModel.js +8 -0
  62. package/lib/models/filters/StringFilterModel.js.map +1 -1
  63. package/lib/models/href/ListHref.js +3 -1
  64. package/lib/models/href/ListHref.js.map +1 -1
  65. package/lib/models/list/ListModel.js +17 -7
  66. package/lib/models/list/ListModel.js.map +1 -1
  67. package/lib/models/paging/PagesizeModel.js +6 -0
  68. package/lib/models/paging/PagesizeModel.js.map +1 -1
  69. package/lib/models/paging/PagingModel.js +11 -0
  70. package/lib/models/paging/PagingModel.js.map +1 -1
  71. package/lib/redux/actions/SignIn.js +2 -1
  72. package/lib/redux/actions/SignIn.js.map +1 -1
  73. package/package.json +8 -8
  74. package/src/constants/Constants.js +5 -0
  75. package/src/hooks/__tests__/UseModularUIModel.spec.js +7 -5
  76. package/src/hooks/index.js +2 -0
  77. package/src/hooks/useList.js +90 -0
  78. package/src/hooks/useModularUIBasic.js +6 -2
  79. package/src/hooks/useModularUIModel.js +1 -55
  80. package/src/hooks/usePanel.js +76 -0
  81. package/src/models/filters/BaseFilterModel.js +30 -1
  82. package/src/models/filters/FilterCollection.js +16 -0
  83. package/src/models/filters/StringFilterModel.js +8 -0
  84. package/src/models/href/ListHref.js +11 -8
  85. package/src/models/list/ListModel.js +20 -8
  86. package/src/models/paging/PagesizeModel.js +6 -0
  87. package/src/models/paging/PagingModel.js +11 -0
  88. package/src/redux/actions/SignIn.js +3 -2
@@ -1,7 +1,10 @@
1
1
  // @flow
2
2
  import BaseModel from "../base/BaseModel";
3
3
  import createAttribute from "../attributes/_createAttribute";
4
- import { PARAMETER_SEPARATOR } from "../../constants/Constants";
4
+ import {
5
+ PARAMETER_SEPARATOR,
6
+ PARAMETER_TYPES,
7
+ } from "../../constants/Constants";
5
8
 
6
9
  import type { AttributeType, FilterType, ModelOptions } from "../types";
7
10
  import { IllegalStateException } from "../../exceptions";
@@ -44,6 +47,19 @@ export default class BaseFilterModel extends BaseModel {
44
47
  : "string";
45
48
  }
46
49
 
50
+ /**
51
+ * Returns the parameter type, when the filter can only be used in a POST request the type is 'bodyParameter', else 'queryParameter'.
52
+ */
53
+ get parameterType(): $Values<typeof PARAMETER_TYPES> {
54
+ const parameterType = this.getContribution("parameterType");
55
+ switch (parameterType) {
56
+ case "bodyParameter":
57
+ return PARAMETER_TYPES.BODY;
58
+ default:
59
+ return PARAMETER_TYPES.QUERY;
60
+ }
61
+ }
62
+
47
63
  /**
48
64
  * Create attribute through the attribute factory. Create type based on filter key without the filter suffix
49
65
  */
@@ -177,6 +193,13 @@ export default class BaseFilterModel extends BaseModel {
177
193
  return this.attribute?.inputvalue;
178
194
  }
179
195
 
196
+ /**
197
+ * Indicates if the filter has a value.
198
+ */
199
+ hasValue(): boolean {
200
+ return this.value !== null && this.value !== "";
201
+ }
202
+
180
203
  /**
181
204
  * Reset the value of this filter to undefined
182
205
  */
@@ -233,4 +256,10 @@ export default class BaseFilterModel extends BaseModel {
233
256
  get assistantMessage(): string | null {
234
257
  return this.getContribution("assistant");
235
258
  }
259
+
260
+ /**
261
+ */
262
+ get formdata(): { [string]: any } | null {
263
+ return this.attribute.formdata ?? null;
264
+ }
236
265
  }
@@ -9,6 +9,7 @@ import CompositeAttributeModel from "../attributes/CompositeAttributeModel";
9
9
  import FilterModel from "../filters/FilterModel";
10
10
 
11
11
  import type { AttributeType, FilterType, ModelOptions } from "../types";
12
+ import { PARAMETER_TYPES } from "../../constants";
12
13
 
13
14
  /**
14
15
  * Contains a collection of filters
@@ -189,4 +190,19 @@ export default class FilterCollection extends BaseCollection<FilterType> {
189
190
  hasActiveFilters(): boolean {
190
191
  return this.collection.some((filter) => filter.isActive());
191
192
  }
193
+
194
+ /**
195
+ */
196
+ get formdata(): { [string]: any } | null {
197
+ let data = {};
198
+ this.filter(
199
+ (f) => f.parameterType === PARAMETER_TYPES.BODY && f.hasValue(),
200
+ ).forEach((f) => {
201
+ data = {
202
+ ...data,
203
+ ...f.formdata,
204
+ };
205
+ });
206
+ return data;
207
+ }
192
208
  }
@@ -156,4 +156,12 @@ export default class StringFilterModel extends FilterModel {
156
156
  (this.isIBAN() || this.isZipcode() || this.isBSN())
157
157
  );
158
158
  }
159
+
160
+ /**
161
+ */
162
+ get formdata(): { [string]: any } | null {
163
+ return {
164
+ [this.param]: this.value,
165
+ };
166
+ }
159
167
  }
@@ -1,5 +1,6 @@
1
1
  // @flow
2
2
  import Href from "./Href";
3
+ import { PARAMETER_TYPES } from "../../constants/Constants";
3
4
 
4
5
  import type FilterCollection from "../filters/FilterCollection";
5
6
  import type ListModel from "../list/ListModel";
@@ -133,14 +134,16 @@ export default class ListHref extends Href {
133
134
  return;
134
135
  }
135
136
 
136
- filters.forEach((filter) => {
137
- filter.params.forEach((param) => {
138
- if (param.value != null) {
139
- this.setParameter(param.name, param.value, this.prefix);
140
- } else {
141
- this.removeParameter(param.name, this.prefix);
142
- }
137
+ filters
138
+ .filter((filter) => filter.parameterType === PARAMETER_TYPES.QUERY)
139
+ .forEach((filter) => {
140
+ filter.params.forEach((param) => {
141
+ if (param.value != null) {
142
+ this.setParameter(param.name, param.value, this.prefix);
143
+ } else {
144
+ this.removeParameter(param.name, this.prefix);
145
+ }
146
+ });
143
147
  });
144
- });
145
148
  }
146
149
  }
@@ -12,6 +12,8 @@ import ListItemModel from "../list/ListItemModel";
12
12
  import PagingModel from "../paging/PagingModel";
13
13
  import ResourceModel from "../base/ResourceModel";
14
14
  import SortingModel from "../sorting/SortingModel";
15
+ import { HTTP_METHODS, PARAMETER_TYPES } from "../../constants";
16
+
15
17
  import {
16
18
  CASEVIEW_LINK,
17
19
  HIDE_WHEN_EMPTY,
@@ -33,7 +35,6 @@ export default class ListModel extends ResourceModel {
33
35
  _actionCollection: ActionCollection;
34
36
  _listItemCollection: ListItemCollection;
35
37
  _grouping: GroupingModel;
36
- _selfhref: ListHref;
37
38
 
38
39
  /**
39
40
  */
@@ -91,6 +92,16 @@ export default class ListModel extends ResourceModel {
91
92
  this.detail = models.find((childModel) => childModel.type === "ListDetail");
92
93
  }
93
94
 
95
+ /**
96
+ */
97
+ get requestMethod(): $Keys<typeof HTTP_METHODS> {
98
+ const mustPost = this.filterCollection.some(
99
+ (filter) =>
100
+ filter.parameterType === PARAMETER_TYPES.BODY && filter.hasValue(),
101
+ );
102
+ return mustPost ? HTTP_METHODS.POST : HTTP_METHODS.GET;
103
+ }
104
+
94
105
  /**
95
106
  * Getting the label of the list
96
107
  */
@@ -159,8 +170,6 @@ export default class ListModel extends ResourceModel {
159
170
 
160
171
  this._detail = detail;
161
172
  }
162
-
163
- this.setSelfHref();
164
173
  }
165
174
 
166
175
  /**
@@ -335,7 +344,7 @@ export default class ListModel extends ResourceModel {
335
344
  /**
336
345
  * Sets self href from links collection
337
346
  */
338
- setSelfHref(): ListHref {
347
+ getSelfHref(): ListHref {
339
348
  const selfLink = this.links ? this.links.getLinkByKey("self") : null;
340
349
 
341
350
  if (selfLink !== null) {
@@ -349,10 +358,7 @@ export default class ListModel extends ResourceModel {
349
358
  * Getting the self link of this list
350
359
  */
351
360
  get selfhref(): ListHref {
352
- if (!this._selfhref) {
353
- this._selfhref = this.setSelfHref();
354
- }
355
- return this._selfhref;
361
+ return this.getSelfHref();
356
362
  }
357
363
 
358
364
  /**
@@ -435,4 +441,10 @@ export default class ListModel extends ResourceModel {
435
441
 
436
442
  return null;
437
443
  }
444
+
445
+ /**
446
+ */
447
+ get formdata(): string {
448
+ return JSON.stringify(this.filterCollection.formdata);
449
+ }
438
450
  }
@@ -41,4 +41,10 @@ export default class PagesizeModel {
41
41
  get options(): Array<number> {
42
42
  return this._options;
43
43
  }
44
+
45
+ /**
46
+ */
47
+ get querystring(): string {
48
+ return `${this.name}=${this.value}`;
49
+ }
44
50
  }
@@ -91,4 +91,15 @@ export default class PagingModel {
91
91
  get pagesize(): PagesizeModel {
92
92
  return this._pagesize;
93
93
  }
94
+
95
+ /**
96
+ */
97
+ get querystring(): string {
98
+ const qs = [];
99
+ if (this.pagesize) {
100
+ qs.push(this.pagesize.querystring);
101
+ }
102
+ qs.push(`${this.name}=${this.page}`);
103
+ return qs.join("&");
104
+ }
94
105
  }
@@ -3,9 +3,10 @@ import Cache from "../../utils/browser/Cache";
3
3
  import Authenticate from "../../modularui/Authenticate";
4
4
  import { getApplication } from "../_modularui/ModularUISelectors";
5
5
 
6
+ import { handleError } from "./Error";
6
7
  import { reloadApplication } from "./Application";
7
-
8
8
  import { startProgress, finishProgress } from "./ProgressIndicator";
9
+
9
10
  import { push } from "../_router/RouterActions";
10
11
  import { CHANGEPASSWORD_PATH } from "../../constants/Constants";
11
12
 
@@ -97,6 +98,6 @@ export const login =
97
98
  }
98
99
 
99
100
  dispatch(loginFailed(error.id));
100
- return dispatch(finishProgress());
101
+ return dispatch(handleError(error));
101
102
  });
102
103
  };