@beinformed/ui 1.65.2 → 1.65.4

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 (96) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/esm/hooks/useList.js +4 -4
  3. package/esm/hooks/useList.js.flow +5 -5
  4. package/esm/hooks/useList.js.map +1 -1
  5. package/esm/models/concepts/ConceptIndexModel.js +3 -2
  6. package/esm/models/concepts/ConceptIndexModel.js.flow +5 -4
  7. package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
  8. package/esm/models/content/ContentIndexModel.js +7 -1
  9. package/esm/models/content/ContentIndexModel.js.flow +8 -3
  10. package/esm/models/content/ContentIndexModel.js.map +1 -1
  11. package/esm/models/content/ContentModel.js +3 -2
  12. package/esm/models/content/ContentModel.js.flow +4 -3
  13. package/esm/models/content/ContentModel.js.map +1 -1
  14. package/esm/models/content/ContentTOCModel.js +6 -2
  15. package/esm/models/content/ContentTOCModel.js.flow +6 -2
  16. package/esm/models/content/ContentTOCModel.js.map +1 -1
  17. package/esm/models/filters/AssignmentFilterModel.js +54 -26
  18. package/esm/models/filters/AssignmentFilterModel.js.flow +68 -37
  19. package/esm/models/filters/AssignmentFilterModel.js.map +1 -1
  20. package/esm/models/filters/BaseFilterModel.js +0 -110
  21. package/esm/models/filters/BaseFilterModel.js.flow +2 -133
  22. package/esm/models/filters/BaseFilterModel.js.map +1 -1
  23. package/esm/models/filters/ConceptIndexFilterModel.js +2 -2
  24. package/esm/models/filters/ConceptIndexFilterModel.js.flow +2 -2
  25. package/esm/models/filters/ConceptIndexFilterModel.js.map +1 -1
  26. package/esm/models/filters/FilterModel.js +117 -2
  27. package/esm/models/filters/FilterModel.js.flow +146 -1
  28. package/esm/models/filters/FilterModel.js.map +1 -1
  29. package/esm/models/filters/RangeFilterModel.js +2 -2
  30. package/esm/models/filters/RangeFilterModel.js.flow +2 -2
  31. package/esm/models/filters/RangeFilterModel.js.map +1 -1
  32. package/esm/models/href/Href.js +1 -1
  33. package/esm/models/href/Href.js.flow +1 -1
  34. package/esm/models/href/Href.js.map +1 -1
  35. package/esm/models/list/ListModel.js +5 -1
  36. package/esm/models/list/ListModel.js.flow +7 -3
  37. package/esm/models/list/ListModel.js.map +1 -1
  38. package/esm/models/sorting/SortOptionModel.js +7 -0
  39. package/esm/models/sorting/SortOptionModel.js.flow +7 -0
  40. package/esm/models/sorting/SortOptionModel.js.map +1 -1
  41. package/esm/models/sorting/SortingModel.js +14 -2
  42. package/esm/models/sorting/SortingModel.js.flow +14 -2
  43. package/esm/models/sorting/SortingModel.js.map +1 -1
  44. package/esm/models/types.js.flow +1 -3
  45. package/esm/models/types.js.map +1 -1
  46. package/esm/redux/_modularui/ModularUIConnector.js +7 -6
  47. package/esm/redux/_modularui/ModularUIConnector.js.flow +6 -4
  48. package/esm/redux/_modularui/ModularUIConnector.js.map +1 -1
  49. package/lib/hooks/useList.js +4 -4
  50. package/lib/hooks/useList.js.map +1 -1
  51. package/lib/models/concepts/ConceptIndexModel.js +3 -2
  52. package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
  53. package/lib/models/content/ContentIndexModel.js +6 -1
  54. package/lib/models/content/ContentIndexModel.js.map +1 -1
  55. package/lib/models/content/ContentModel.js +3 -2
  56. package/lib/models/content/ContentModel.js.map +1 -1
  57. package/lib/models/content/ContentTOCModel.js +6 -2
  58. package/lib/models/content/ContentTOCModel.js.map +1 -1
  59. package/lib/models/filters/AssignmentFilterModel.js +54 -26
  60. package/lib/models/filters/AssignmentFilterModel.js.map +1 -1
  61. package/lib/models/filters/BaseFilterModel.js +0 -109
  62. package/lib/models/filters/BaseFilterModel.js.map +1 -1
  63. package/lib/models/filters/ConceptIndexFilterModel.js +2 -2
  64. package/lib/models/filters/ConceptIndexFilterModel.js.map +1 -1
  65. package/lib/models/filters/FilterModel.js +117 -1
  66. package/lib/models/filters/FilterModel.js.map +1 -1
  67. package/lib/models/filters/RangeFilterModel.js +2 -2
  68. package/lib/models/filters/RangeFilterModel.js.map +1 -1
  69. package/lib/models/href/Href.js +1 -1
  70. package/lib/models/href/Href.js.map +1 -1
  71. package/lib/models/list/ListModel.js +5 -1
  72. package/lib/models/list/ListModel.js.map +1 -1
  73. package/lib/models/sorting/SortOptionModel.js +7 -0
  74. package/lib/models/sorting/SortOptionModel.js.map +1 -1
  75. package/lib/models/sorting/SortingModel.js +14 -2
  76. package/lib/models/sorting/SortingModel.js.map +1 -1
  77. package/lib/models/types.js.map +1 -1
  78. package/lib/redux/_modularui/ModularUIConnector.js +7 -6
  79. package/lib/redux/_modularui/ModularUIConnector.js.map +1 -1
  80. package/package.json +6 -6
  81. package/src/hooks/useList.js +5 -5
  82. package/src/models/concepts/ConceptIndexModel.js +5 -4
  83. package/src/models/content/ContentIndexModel.js +8 -3
  84. package/src/models/content/ContentModel.js +4 -3
  85. package/src/models/content/ContentTOCModel.js +6 -2
  86. package/src/models/filters/AssignmentFilterModel.js +68 -37
  87. package/src/models/filters/BaseFilterModel.js +2 -133
  88. package/src/models/filters/ConceptIndexFilterModel.js +2 -2
  89. package/src/models/filters/FilterModel.js +146 -1
  90. package/src/models/filters/RangeFilterModel.js +2 -2
  91. package/src/models/href/Href.js +1 -1
  92. package/src/models/list/ListModel.js +7 -3
  93. package/src/models/sorting/SortOptionModel.js +7 -0
  94. package/src/models/sorting/SortingModel.js +14 -2
  95. package/src/models/types.js +1 -3
  96. package/src/redux/_modularui/ModularUIConnector.js +6 -4
@@ -1,6 +1,151 @@
1
1
  // @flow
2
2
  import BaseFilterModel from "../filters/BaseFilterModel";
3
+ import createAttribute from "../attributes/_createAttribute";
4
+ import { IllegalStateException } from "../../exceptions";
5
+
6
+ import type { AttributeType, FilterType, ModelOptions } from "../types";
3
7
 
4
8
  /**
5
9
  */
6
- export default class FilterModel extends BaseFilterModel {}
10
+ export default class FilterModel extends BaseFilterModel {
11
+ _attribute: AttributeType | null = null;
12
+
13
+ /**
14
+ */
15
+ constructor(
16
+ data: Object,
17
+ contributions: Object,
18
+ modelOptions?: ModelOptions,
19
+ ) {
20
+ super(data, contributions, modelOptions);
21
+
22
+ this._attribute = this.createAttribute(
23
+ this.type,
24
+ this.param,
25
+ this.data,
26
+ this.contributions,
27
+ );
28
+ }
29
+
30
+ /**
31
+ * Create attribute through the attribute factory. Create type based on filter key without the filter suffix
32
+ */
33
+ createAttribute(
34
+ type: string,
35
+ param: string,
36
+ data: Object,
37
+ contributions: Object,
38
+ ): AttributeType | null {
39
+ if (type === "assignment") {
40
+ return null;
41
+ }
42
+
43
+ return createAttribute(
44
+ param,
45
+ data,
46
+ {
47
+ ...contributions,
48
+ type: type,
49
+ },
50
+ this.modelOptions,
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Get attribute of filter
56
+ */
57
+ get attribute(): AttributeType {
58
+ if (!this._attribute) {
59
+ throw new IllegalStateException(
60
+ `Missing filter attribute on filter model: ${this.label}`,
61
+ );
62
+ }
63
+ return this._attribute;
64
+ }
65
+
66
+ /**
67
+ * Retrieve the parameters with it's value for this filter
68
+ */
69
+ get params(): Array<{ name: string, value: ?string }> {
70
+ if (!this.param) {
71
+ return [];
72
+ }
73
+
74
+ return [
75
+ {
76
+ name: this.param,
77
+ value: this.attribute?.value,
78
+ },
79
+ ];
80
+ }
81
+
82
+ /**
83
+ * Getting the value of the filter
84
+ */
85
+ get value(): string | null {
86
+ return this.attribute?.value;
87
+ }
88
+
89
+ /**
90
+ * Getting the inputvalue of the filter
91
+ */
92
+ get inputvalue(): string {
93
+ return this.attribute?.inputvalue;
94
+ }
95
+
96
+ /**
97
+ * Indicates if the filter has a value.
98
+ */
99
+ hasValue(): boolean {
100
+ return this.value !== null && this.value !== "";
101
+ }
102
+
103
+ /**
104
+ * Reset the value of this filter to undefined
105
+ */
106
+ reset(): FilterType {
107
+ if (this.attribute) {
108
+ this.attribute.reset();
109
+ }
110
+
111
+ return this;
112
+ }
113
+
114
+ /**
115
+ * Update this filter with input name and value
116
+ */
117
+ update(attribute: AttributeType, value: string) {
118
+ if (this.attribute) {
119
+ this.attribute.update(value);
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Inidiates if filter is active
125
+ */
126
+ isActive(): boolean {
127
+ return this.attribute?.initvalue !== null;
128
+ }
129
+
130
+ /**
131
+ * Inidiates if filter is valid
132
+ */
133
+ get isValid(): boolean {
134
+ return this.attribute?.isValid || true;
135
+ }
136
+
137
+ /**
138
+ */
139
+ get readonlyvalue(): string {
140
+ if (this.attribute) {
141
+ return this.attribute.readonlyvalue;
142
+ }
143
+ return "";
144
+ }
145
+
146
+ /**
147
+ */
148
+ get formdata(): { [string]: any } | null {
149
+ return this.attribute.formdata ?? null;
150
+ }
151
+ }
@@ -1,5 +1,5 @@
1
1
  // @flow
2
- import BaseFilterModel from "../filters/BaseFilterModel";
2
+ import FilterModel from "../filters/FilterModel";
3
3
 
4
4
  import CompositeAttributeModel from "../attributes/CompositeAttributeModel";
5
5
  import type { AttributeType } from "../types";
@@ -7,7 +7,7 @@ import type { AttributeType } from "../types";
7
7
  /**
8
8
  * Range filter, for instance a date range filter or a number range filter
9
9
  */
10
- export default class RangeFilterModel extends BaseFilterModel {
10
+ export default class RangeFilterModel extends FilterModel {
11
11
  /**
12
12
  */
13
13
  update(attribute: AttributeType, value: string) {
@@ -281,7 +281,7 @@ class Href {
281
281
  * Remove a parameter from the parameter collection
282
282
  */
283
283
  removeParameter(name: string, prefix: ?string, value: ?string): Href {
284
- if (value !== undefined) {
284
+ if (value != undefined) {
285
285
  const valueToRemove = value;
286
286
 
287
287
  this._parameters = this._parameters.map((param) => {
@@ -20,7 +20,7 @@ import {
20
20
  SHOW_ONE_RESULT_AS_DETAIL,
21
21
  } from "../../constants/LayoutHints";
22
22
 
23
- import type { ModularUIModel } from "../types";
23
+ import type { ModularUIModel, FilterType } from "../types";
24
24
  import type LinkModel from "../links/LinkModel";
25
25
 
26
26
  /**
@@ -288,8 +288,12 @@ export default class ListModel extends ResourceModel {
288
288
  /**
289
289
  * Set filterCollection
290
290
  */
291
- set filterCollection(filterCollection: FilterCollection) {
292
- this._filterCollection = filterCollection;
291
+ set filterCollection(filterCollection: FilterCollection | Array<FilterType>) {
292
+ if (Array.isArray(filterCollection)) {
293
+ this._filterCollection.collection = filterCollection;
294
+ } else {
295
+ this._filterCollection = filterCollection;
296
+ }
293
297
  }
294
298
 
295
299
  /**
@@ -28,6 +28,13 @@ class SortOptionModel {
28
28
  }
29
29
  }
30
30
 
31
+ /**
32
+ */
33
+ reset() {
34
+ this.selected = false;
35
+ this.sortorder = "desc";
36
+ }
37
+
31
38
  /**
32
39
  */
33
40
  get selected(): boolean {
@@ -47,6 +47,13 @@ class SortingModel extends BaseCollection<SortOptionModel> {
47
47
  .join(",");
48
48
  }
49
49
 
50
+ /**
51
+ */
52
+ set value(value: string) {
53
+ this.reset();
54
+ this.setSelected(value);
55
+ }
56
+
50
57
  /**
51
58
  */
52
59
  get param(): string {
@@ -61,8 +68,13 @@ class SortingModel extends BaseCollection<SortOptionModel> {
61
68
 
62
69
  /**
63
70
  */
64
- setSelected(currentSort: string = "") {
65
- currentSort.split(",").forEach((sortItem) => {
71
+ reset() {
72
+ this.collection.forEach((option) => option.reset());
73
+ }
74
+ /**
75
+ */
76
+ setSelected(value: string = "") {
77
+ value.split(",").forEach((sortItem) => {
66
78
  const [key, direction] = sortItem.split(" ");
67
79
 
68
80
  this.collection.forEach((option) => {
@@ -41,7 +41,6 @@ import type UserModel from "./user/UserModel";
41
41
  import type UserServicesModel from "./user/UserServicesModel";
42
42
  import type LinkModel from "./links/LinkModel";
43
43
  import type LookupOptionsModel from "./lookup/LookupOptionsModel";
44
- import type BaseFilterModel from "./filters/BaseFilterModel";
45
44
  import type AttributeCollection from "./attributes/AttributeCollection";
46
45
  import type AttributeModel from "./attributes/AttributeModel";
47
46
  import type LayoutHintCollection from "./layouthint/LayoutHintCollection";
@@ -92,9 +91,8 @@ export type RangeChildAttributeType =
92
91
  | DatetimeAttributeModel;
93
92
 
94
93
  export type FilterType =
95
- | BaseFilterModel
96
- | FilterModel
97
94
  | AssignmentFilterModel
95
+ | FilterModel
98
96
  | RangeFilterModel
99
97
  | ConceptIndexFilterModel;
100
98
 
@@ -118,13 +118,15 @@ const modularUIConnector = (
118
118
  }, [dispatch, doReload, url, modelKey]);
119
119
 
120
120
  // Remove model when hoc unloads
121
- useEffect(() => {
122
- return () => {
121
+ useEffect(
122
+ // prettier-ignore
123
+ () => () => { //NOSONAR
123
124
  if (finalRemoveOnUnmount) {
124
125
  dispatch(removeModelByKey(modelKey));
125
126
  }
126
- };
127
- }, [dispatch, modelKey, finalRemoveOnUnmount]);
127
+ },
128
+ [dispatch, modelKey, finalRemoveOnUnmount],
129
+ );
128
130
 
129
131
  // Create new properties object to inject modularui properties to own props
130
132
  const locale = useLocale();