@beinformed/ui 1.65.5 → 1.65.7
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.
- package/CHANGELOG.md +11 -0
- package/esm/hooks/__tests__/UseModularUIModel.spec.js.flow +1 -0
- package/esm/hooks/useList.js +47 -3
- package/esm/hooks/useList.js.flow +74 -2
- package/esm/hooks/useList.js.map +1 -1
- package/esm/hooks/usePanel.js +6 -1
- package/esm/hooks/usePanel.js.flow +6 -4
- package/esm/hooks/usePanel.js.map +1 -1
- package/esm/models/concepts/ConceptIndexModel.js +17 -3
- package/esm/models/concepts/ConceptIndexModel.js.flow +22 -7
- package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
- package/esm/models/filters/AssignmentFilterModel.js +1 -12
- package/esm/models/filters/AssignmentFilterModel.js.flow +6 -14
- package/esm/models/filters/AssignmentFilterModel.js.map +1 -1
- package/esm/models/filters/BaseFilterModel.js +12 -0
- package/esm/models/filters/BaseFilterModel.js.flow +12 -0
- package/esm/models/filters/BaseFilterModel.js.map +1 -1
- package/esm/models/filters/ConceptIndexFilterModel.js.flow +5 -2
- package/esm/models/filters/ConceptIndexFilterModel.js.map +1 -1
- package/esm/models/filters/FilterCollection.js +26 -8
- package/esm/models/filters/FilterCollection.js.flow +23 -6
- package/esm/models/filters/FilterCollection.js.map +1 -1
- package/esm/models/filters/FilterModel.js.flow +3 -3
- package/esm/models/filters/FilterModel.js.map +1 -1
- package/esm/models/filters/RangeFilterModel.js.flow +2 -2
- package/esm/models/filters/RangeFilterModel.js.map +1 -1
- package/esm/models/filters/StringFilterModel.js.flow +3 -3
- package/esm/models/filters/StringFilterModel.js.map +1 -1
- package/esm/models/list/ListModel.js.flow +2 -2
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/search/CaseSearchModel.js.flow +2 -2
- package/esm/models/search/CaseSearchModel.js.map +1 -1
- package/esm/models/types.js +1 -1
- package/esm/models/types.js.flow +28 -10
- package/esm/models/types.js.map +1 -1
- package/esm/react-server/serverUtil.js +2 -2
- package/esm/react-server/serverUtil.js.flow +2 -2
- package/esm/react-server/serverUtil.js.map +1 -1
- package/lib/hooks/useList.js +47 -3
- package/lib/hooks/useList.js.map +1 -1
- package/lib/hooks/usePanel.js +6 -1
- package/lib/hooks/usePanel.js.map +1 -1
- package/lib/models/concepts/ConceptIndexModel.js +17 -3
- package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
- package/lib/models/filters/AssignmentFilterModel.js +0 -12
- package/lib/models/filters/AssignmentFilterModel.js.map +1 -1
- package/lib/models/filters/BaseFilterModel.js +12 -0
- package/lib/models/filters/BaseFilterModel.js.map +1 -1
- package/lib/models/filters/ConceptIndexFilterModel.js.map +1 -1
- package/lib/models/filters/FilterCollection.js +26 -8
- package/lib/models/filters/FilterCollection.js.map +1 -1
- package/lib/models/filters/FilterModel.js.map +1 -1
- package/lib/models/filters/RangeFilterModel.js.map +1 -1
- package/lib/models/filters/StringFilterModel.js.map +1 -1
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/search/CaseSearchModel.js.map +1 -1
- package/lib/models/types.js +2 -0
- package/lib/models/types.js.map +1 -1
- package/lib/react-server/serverUtil.js +5 -5
- package/lib/react-server/serverUtil.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/__tests__/UseModularUIModel.spec.js +1 -0
- package/src/hooks/useList.js +74 -2
- package/src/hooks/usePanel.js +6 -4
- package/src/models/concepts/ConceptIndexModel.js +22 -7
- package/src/models/filters/AssignmentFilterModel.js +6 -14
- package/src/models/filters/BaseFilterModel.js +12 -0
- package/src/models/filters/ConceptIndexFilterModel.js +5 -2
- package/src/models/filters/FilterCollection.js +23 -6
- package/src/models/filters/FilterModel.js +3 -3
- package/src/models/filters/RangeFilterModel.js +2 -2
- package/src/models/filters/StringFilterModel.js +3 -3
- package/src/models/list/ListModel.js +2 -2
- package/src/models/search/CaseSearchModel.js +2 -2
- package/src/models/types.js +28 -10
- package/src/react-server/serverUtil.js +2 -2
package/src/hooks/useList.js
CHANGED
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import {
|
|
2
|
+
import { useHistory } from "react-router";
|
|
3
3
|
import { useDispatch } from "react-redux";
|
|
4
|
+
|
|
5
|
+
import { useModularUIBasic } from "./useModularUIBasic";
|
|
4
6
|
import { HTTP_METHODS } from "../constants/Constants";
|
|
7
|
+
|
|
5
8
|
import { loadModularUI } from "../redux";
|
|
9
|
+
|
|
6
10
|
import DetailModel from "../models/detail/DetailModel";
|
|
7
11
|
import ListModel from "../models/list/ListModel";
|
|
8
12
|
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
9
13
|
import ListDetailModel from "../models/list/ListDetailModel";
|
|
10
14
|
import Href from "../models/href/Href";
|
|
15
|
+
import FilterCollection from "../models/filters/FilterCollection";
|
|
16
|
+
import AssignmentFilterModel from "../models/filters/AssignmentFilterModel";
|
|
17
|
+
import FilterModel from "../models/filters/FilterModel";
|
|
11
18
|
|
|
12
19
|
import type { HookOptions } from "./useModularUIBasic";
|
|
13
|
-
import {
|
|
20
|
+
import type { AttributeType, IFilter } from "../models/types";
|
|
14
21
|
|
|
15
22
|
type ListNavigationHook = {
|
|
16
23
|
update: (list: ListModel, resetPage?: boolean) => void,
|
|
24
|
+
updateFilters: (list: ListModel, filters: FilterCollection) => void,
|
|
25
|
+
updateFilter: (
|
|
26
|
+
list: ListModel,
|
|
27
|
+
filter: IFilter,
|
|
28
|
+
value: string,
|
|
29
|
+
attribute?: AttributeType,
|
|
30
|
+
) => void,
|
|
31
|
+
updateSort: (list: ListModel, sortOption: string) => void,
|
|
32
|
+
updatePage: (list: ListModel, page: number) => void,
|
|
33
|
+
updatePageSize: (list: ListModel, pagesize: number) => void,
|
|
34
|
+
resetFilters: (list: ListModel) => void,
|
|
35
|
+
removeFilter: (list: ListModel, filter: IFilter) => void,
|
|
17
36
|
};
|
|
18
37
|
|
|
19
38
|
/**
|
|
@@ -85,7 +104,60 @@ export const useListNavigation = (): ListNavigationHook => {
|
|
|
85
104
|
}
|
|
86
105
|
};
|
|
87
106
|
|
|
107
|
+
const updateFilters = (list: ListModel, filters: FilterCollection) => {
|
|
108
|
+
list.filterCollection = filters;
|
|
109
|
+
update(list, true);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const updateFilter = (
|
|
113
|
+
list: ListModel,
|
|
114
|
+
filter: IFilter,
|
|
115
|
+
value: string,
|
|
116
|
+
attribute?: AttributeType,
|
|
117
|
+
) => {
|
|
118
|
+
if (attribute) {
|
|
119
|
+
filter.update(attribute, value);
|
|
120
|
+
} else if (filter instanceof AssignmentFilterModel) {
|
|
121
|
+
throw new Error("Need the attribute to update for AssigmentFilterModel");
|
|
122
|
+
} else if (filter instanceof FilterModel) {
|
|
123
|
+
filter.update(filter.attribute, value);
|
|
124
|
+
}
|
|
125
|
+
update(list, true);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const resetFilters = (list: ListModel) => {
|
|
129
|
+
list.filterCollection.reset();
|
|
130
|
+
update(list, true);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const removeFilter = (list: ListModel, filter: IFilter) => {
|
|
134
|
+
list.filterCollection.getFilterByName(filter.name)?.reset();
|
|
135
|
+
update(list, true);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const updateSort = (list: ListModel, sortOption: string) => {
|
|
139
|
+
list.sorting.value = sortOption;
|
|
140
|
+
update(list, true);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const updatePage = (list: ListModel, page: number) => {
|
|
144
|
+
list.paging.page = page;
|
|
145
|
+
update(list);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const updatePageSize = (list: ListModel, pagesize: number) => {
|
|
149
|
+
list.paging.pagesize.value = pagesize;
|
|
150
|
+
update(list);
|
|
151
|
+
};
|
|
152
|
+
|
|
88
153
|
return {
|
|
89
154
|
update,
|
|
155
|
+
updateFilters,
|
|
156
|
+
updateFilter,
|
|
157
|
+
updateSort,
|
|
158
|
+
updatePage,
|
|
159
|
+
updatePageSize,
|
|
160
|
+
resetFilters,
|
|
161
|
+
removeFilter,
|
|
90
162
|
};
|
|
91
163
|
};
|
package/src/hooks/usePanel.js
CHANGED
|
@@ -5,9 +5,10 @@ import Href from "../models/href/Href";
|
|
|
5
5
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
6
6
|
|
|
7
7
|
import type { HookOptions } from "./useModularUIBasic";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
8
|
+
import GroupingPanelModel from "../models/panels/GroupingPanelModel";
|
|
9
|
+
import ListModel from "../models/list/ListModel";
|
|
10
|
+
import DetailModel from "../models/detail/DetailModel";
|
|
11
|
+
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
11
12
|
|
|
12
13
|
const useUrl = (href?: string | Href, fromRoute: boolean = false) => {
|
|
13
14
|
const [previousUrl, setPreviousUrl] = useState(null);
|
|
@@ -69,7 +70,8 @@ export const usePanel = (
|
|
|
69
70
|
|
|
70
71
|
const url = useUrl(href, fromRoute || false);
|
|
71
72
|
const basicOptions = {
|
|
72
|
-
expectedModels: ["List", "GroupingPanel", "Detail"],
|
|
73
|
+
expectedModels: ["List", "GroupingPanel", "Detail", "CaseSearch"],
|
|
74
|
+
targetModel: [ListModel, GroupingPanelModel, DetailModel, CaseSearchModel],
|
|
73
75
|
...(hookOptions: HookOptions),
|
|
74
76
|
};
|
|
75
77
|
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import ResourceModel from "../base/ResourceModel";
|
|
3
3
|
import ResourceCollection from "../base/ResourceCollection";
|
|
4
4
|
import FilterCollection from "../filters/FilterCollection";
|
|
5
|
+
import ConceptIndexFilterModel from "../filters/ConceptIndexFilterModel";
|
|
6
|
+
import FilterModel from "../filters/FilterModel";
|
|
5
7
|
import ConceptLinkModel from "./ConceptLinkModel";
|
|
6
8
|
|
|
7
9
|
import { TIMEVERSION_FILTER_NAME } from "../../constants/Constants";
|
|
8
10
|
|
|
9
11
|
import type { ModularUIResponse } from "../../modularui";
|
|
10
|
-
import type {
|
|
12
|
+
import type { ModularUIModel } from "../types";
|
|
11
13
|
import type LinkModel from "../links/LinkModel";
|
|
12
14
|
import type Href from "../href/Href";
|
|
13
15
|
import type ErrorResponse from "../error/ErrorResponse";
|
|
@@ -122,8 +124,12 @@ export default class ConceptIndexModel extends ResourceModel {
|
|
|
122
124
|
/**
|
|
123
125
|
* Get index filter
|
|
124
126
|
*/
|
|
125
|
-
get indexfilter():
|
|
126
|
-
|
|
127
|
+
get indexfilter(): ConceptIndexFilterModel | null {
|
|
128
|
+
const indexFilter = this.filterCollection.getFilterByAttributeKey("index");
|
|
129
|
+
if (indexFilter instanceof ConceptIndexFilterModel) {
|
|
130
|
+
return indexFilter;
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
/**
|
|
@@ -144,15 +150,24 @@ export default class ConceptIndexModel extends ResourceModel {
|
|
|
144
150
|
/**
|
|
145
151
|
* get searchterm filter
|
|
146
152
|
*/
|
|
147
|
-
get searchtermfilter():
|
|
148
|
-
|
|
153
|
+
get searchtermfilter(): FilterModel | null {
|
|
154
|
+
const termFilter = this.filterCollection.getFilterByAttributeKey("label");
|
|
155
|
+
if (termFilter instanceof FilterModel) {
|
|
156
|
+
return termFilter;
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
149
159
|
}
|
|
150
160
|
|
|
151
161
|
/**
|
|
152
162
|
* Get model category filter
|
|
153
163
|
*/
|
|
154
|
-
get modelCategoryFilter():
|
|
155
|
-
|
|
164
|
+
get modelCategoryFilter(): FilterModel | null {
|
|
165
|
+
const categoryFilter =
|
|
166
|
+
this.filterCollection.getFilterByAttributeKey("modelCategory");
|
|
167
|
+
if (categoryFilter instanceof FilterModel) {
|
|
168
|
+
return categoryFilter;
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
156
171
|
}
|
|
157
172
|
|
|
158
173
|
/**
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import BaseFilterModel from "../filters/BaseFilterModel";
|
|
3
3
|
|
|
4
|
-
import type { AttributeType, ModelOptions } from "../types";
|
|
4
|
+
import type { IFilter, AttributeType, ModelOptions } from "../types";
|
|
5
5
|
import { IllegalStateException } from "../../exceptions";
|
|
6
6
|
import createAttribute from "../attributes/_createAttribute";
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* Assignment filter consists of two filters: assignment type and user filter
|
|
9
10
|
*/
|
|
10
|
-
export default class AssignmentFilterModel
|
|
11
|
+
export default class AssignmentFilterModel
|
|
12
|
+
extends BaseFilterModel
|
|
13
|
+
implements IFilter
|
|
14
|
+
{
|
|
11
15
|
_listKey: string;
|
|
12
16
|
_assignmenttype: AttributeType;
|
|
13
17
|
_user: AttributeType;
|
|
@@ -26,18 +30,6 @@ export default class AssignmentFilterModel extends BaseFilterModel {
|
|
|
26
30
|
this._user = this.createUserModel();
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
/**
|
|
30
|
-
*/
|
|
31
|
-
get key(): ?string {
|
|
32
|
-
return this.data.name;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
*/
|
|
37
|
-
get contextid(): string {
|
|
38
|
-
return this.getContribution("contextid", "");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
33
|
/**
|
|
42
34
|
* Creates an assignmenttype model when assignmenttype json is present
|
|
43
35
|
*/
|
|
@@ -29,6 +29,12 @@ export default class BaseFilterModel extends BaseModel {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
*/
|
|
34
|
+
get key(): string {
|
|
35
|
+
return this.data.name;
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
/**
|
|
33
39
|
* Get the type of a filter.
|
|
34
40
|
*/
|
|
@@ -72,6 +78,12 @@ export default class BaseFilterModel extends BaseModel {
|
|
|
72
78
|
this._context = context;
|
|
73
79
|
}
|
|
74
80
|
|
|
81
|
+
/**
|
|
82
|
+
*/
|
|
83
|
+
get contextid(): string {
|
|
84
|
+
return this.getContribution("contextid", "");
|
|
85
|
+
}
|
|
86
|
+
|
|
75
87
|
/**
|
|
76
88
|
* Getting the context label
|
|
77
89
|
*/
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
import FilterModel from "../filters/FilterModel";
|
|
3
3
|
import ChoiceAttributeModel from "../attributes/ChoiceAttributeModel";
|
|
4
4
|
|
|
5
|
-
import type { ModelOptions } from "../types";
|
|
5
|
+
import type { IFilter, ModelOptions } from "../types";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The concept index model is a special filter used to index all first concept label letters in de modelcatalog.
|
|
9
9
|
*/
|
|
10
|
-
export default class ConceptIndexFilterModel
|
|
10
|
+
export default class ConceptIndexFilterModel
|
|
11
|
+
extends FilterModel
|
|
12
|
+
implements IFilter
|
|
13
|
+
{
|
|
11
14
|
/**
|
|
12
15
|
* Construct a filter
|
|
13
16
|
*/
|
|
@@ -8,13 +8,13 @@ import ConceptIndexFilterModel from "../filters/ConceptIndexFilterModel";
|
|
|
8
8
|
import CompositeAttributeModel from "../attributes/CompositeAttributeModel";
|
|
9
9
|
import FilterModel from "../filters/FilterModel";
|
|
10
10
|
|
|
11
|
-
import type { AttributeType,
|
|
11
|
+
import type { AttributeType, IFilter, ModelOptions } from "../types";
|
|
12
12
|
import { PARAMETER_TYPES } from "../../constants";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Contains a collection of filters
|
|
16
16
|
*/
|
|
17
|
-
export default class FilterCollection extends BaseCollection<
|
|
17
|
+
export default class FilterCollection extends BaseCollection<IFilter> {
|
|
18
18
|
/**
|
|
19
19
|
* Construct a collection of filters
|
|
20
20
|
*/
|
|
@@ -68,7 +68,7 @@ export default class FilterCollection extends BaseCollection<FilterType> {
|
|
|
68
68
|
data: Object,
|
|
69
69
|
contributions: Object,
|
|
70
70
|
modelOptions?: ModelOptions,
|
|
71
|
-
):
|
|
71
|
+
): IFilter {
|
|
72
72
|
const type = contributions.type || "stringfilter";
|
|
73
73
|
if (type === "choicefilter" && filterKey === "index") {
|
|
74
74
|
return new ConceptIndexFilterModel(data, contributions, modelOptions);
|
|
@@ -92,7 +92,7 @@ export default class FilterCollection extends BaseCollection<FilterType> {
|
|
|
92
92
|
/**
|
|
93
93
|
* Call the reset function on all filters
|
|
94
94
|
*
|
|
95
|
-
* @see {
|
|
95
|
+
* @see {IFilter#reset()}
|
|
96
96
|
*/
|
|
97
97
|
reset(): FilterCollection {
|
|
98
98
|
this.collection = this.collection.map((filter) => filter.reset());
|
|
@@ -134,10 +134,16 @@ export default class FilterCollection extends BaseCollection<FilterType> {
|
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
*/
|
|
139
|
+
getFilterByName(name: string): IFilter | null {
|
|
140
|
+
return this.find((filter) => filter.name === name) || null;
|
|
141
|
+
}
|
|
142
|
+
|
|
137
143
|
/**
|
|
138
144
|
* Getting the filter by name
|
|
139
145
|
*/
|
|
140
|
-
getFilterByAttributeKey(key: string):
|
|
146
|
+
getFilterByAttributeKey(key: string): IFilter | null {
|
|
141
147
|
return (
|
|
142
148
|
this.find((filter) => {
|
|
143
149
|
if (filter instanceof RangeFilterModel) {
|
|
@@ -148,7 +154,11 @@ export default class FilterCollection extends BaseCollection<FilterType> {
|
|
|
148
154
|
return this.checkAssignmentFilterByAttributeKey(filter, key);
|
|
149
155
|
}
|
|
150
156
|
|
|
151
|
-
|
|
157
|
+
if (filter instanceof FilterModel) {
|
|
158
|
+
return filter.attribute.key === key;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return false;
|
|
152
162
|
}) || null
|
|
153
163
|
);
|
|
154
164
|
}
|
|
@@ -191,6 +201,13 @@ export default class FilterCollection extends BaseCollection<FilterType> {
|
|
|
191
201
|
return this.collection.some((filter) => filter.isActive());
|
|
192
202
|
}
|
|
193
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Retrieve all filters with a value
|
|
206
|
+
*/
|
|
207
|
+
getActiveFilters(): Array<IFilter> {
|
|
208
|
+
return this.collection.filter((filter) => filter.isActive());
|
|
209
|
+
}
|
|
210
|
+
|
|
194
211
|
/**
|
|
195
212
|
*/
|
|
196
213
|
get formdata(): { [string]: any } | null {
|
|
@@ -3,11 +3,11 @@ import BaseFilterModel from "../filters/BaseFilterModel";
|
|
|
3
3
|
import createAttribute from "../attributes/_createAttribute";
|
|
4
4
|
import { IllegalStateException } from "../../exceptions";
|
|
5
5
|
|
|
6
|
-
import type { AttributeType,
|
|
6
|
+
import type { AttributeType, IFilter, ModelOptions } from "../types";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
*/
|
|
10
|
-
export default class FilterModel extends BaseFilterModel {
|
|
10
|
+
export default class FilterModel extends BaseFilterModel implements IFilter {
|
|
11
11
|
_attribute: AttributeType | null = null;
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -103,7 +103,7 @@ export default class FilterModel extends BaseFilterModel {
|
|
|
103
103
|
/**
|
|
104
104
|
* Reset the value of this filter to undefined
|
|
105
105
|
*/
|
|
106
|
-
reset():
|
|
106
|
+
reset(): FilterModel {
|
|
107
107
|
if (this.attribute) {
|
|
108
108
|
this.attribute.reset();
|
|
109
109
|
}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import FilterModel from "../filters/FilterModel";
|
|
3
3
|
|
|
4
4
|
import CompositeAttributeModel from "../attributes/CompositeAttributeModel";
|
|
5
|
-
import type { AttributeType } from "../types";
|
|
5
|
+
import type { AttributeType, IFilter } from "../types";
|
|
6
6
|
|
|
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 FilterModel {
|
|
10
|
+
export default class RangeFilterModel extends FilterModel implements IFilter {
|
|
11
11
|
/**
|
|
12
12
|
*/
|
|
13
13
|
update(attribute: AttributeType, value: string) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
|
|
3
|
-
import type { AttributeType,
|
|
3
|
+
import type { AttributeType, IFilter, ModelOptions } from "../types";
|
|
4
4
|
import FilterModel from "./FilterModel";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* StringFilterModel can handle string filters with multiple setting
|
|
8
8
|
*/
|
|
9
|
-
export default class StringFilterModel extends FilterModel {
|
|
9
|
+
export default class StringFilterModel extends FilterModel implements IFilter {
|
|
10
10
|
_isValid: boolean = true;
|
|
11
11
|
_value: string | null;
|
|
12
12
|
_inputvalue: string;
|
|
@@ -58,7 +58,7 @@ export default class StringFilterModel extends FilterModel {
|
|
|
58
58
|
/**
|
|
59
59
|
* Reset the value of this filter to undefined
|
|
60
60
|
*/
|
|
61
|
-
reset():
|
|
61
|
+
reset(): StringFilterModel {
|
|
62
62
|
this._inputvalue = "";
|
|
63
63
|
this._value = null;
|
|
64
64
|
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
SHOW_ONE_RESULT_AS_DETAIL,
|
|
21
21
|
} from "../../constants/LayoutHints";
|
|
22
22
|
|
|
23
|
-
import type { ModularUIModel,
|
|
23
|
+
import type { ModularUIModel, IFilter } from "../types";
|
|
24
24
|
import type LinkModel from "../links/LinkModel";
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -288,7 +288,7 @@ export default class ListModel extends ResourceModel {
|
|
|
288
288
|
/**
|
|
289
289
|
* Set filterCollection
|
|
290
290
|
*/
|
|
291
|
-
set filterCollection(filterCollection: FilterCollection | Array<
|
|
291
|
+
set filterCollection(filterCollection: FilterCollection | Array<IFilter>) {
|
|
292
292
|
if (Array.isArray(filterCollection)) {
|
|
293
293
|
this._filterCollection.collection = filterCollection;
|
|
294
294
|
} else {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import ListModel from "../list/ListModel";
|
|
3
3
|
|
|
4
4
|
import type { ModularUIResponse } from "../../modularui";
|
|
5
|
-
import type {
|
|
5
|
+
import type { IFilter } from "../types";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Case search model
|
|
@@ -32,7 +32,7 @@ export default class CaseSearchModel extends ListModel {
|
|
|
32
32
|
/**
|
|
33
33
|
* Retrieve quick search filters
|
|
34
34
|
*/
|
|
35
|
-
getQuickSearchFilters(): Array<
|
|
35
|
+
getQuickSearchFilters(): Array<IFilter> {
|
|
36
36
|
return this.filterCollection
|
|
37
37
|
? this.filterCollection.filter((filter) => filter.isQuickSearch())
|
|
38
38
|
: [];
|
package/src/models/types.js
CHANGED
|
@@ -25,10 +25,6 @@ import type SectionModel from "./content/SectionModel";
|
|
|
25
25
|
import type ContentTOCModel from "./content/ContentTOCModel";
|
|
26
26
|
import type ContentTypeModel from "./content/ContentTypeModel";
|
|
27
27
|
import type DetailModel from "./detail/DetailModel";
|
|
28
|
-
import type AssignmentFilterModel from "./filters/AssignmentFilterModel";
|
|
29
|
-
import type FilterModel from "./filters/FilterModel";
|
|
30
|
-
import type RangeFilterModel from "./filters/RangeFilterModel";
|
|
31
|
-
import type ConceptIndexFilterModel from "./filters/ConceptIndexFilterModel";
|
|
32
28
|
import type FormModel from "./form/FormModel";
|
|
33
29
|
import type ListDetailModel from "./list/ListDetailModel";
|
|
34
30
|
import type ListModel from "./list/ListModel";
|
|
@@ -45,6 +41,7 @@ import type AttributeCollection from "./attributes/AttributeCollection";
|
|
|
45
41
|
import type AttributeModel from "./attributes/AttributeModel";
|
|
46
42
|
import type LayoutHintCollection from "./layouthint/LayoutHintCollection";
|
|
47
43
|
import type ErrorResponse from "./error/ErrorResponse";
|
|
44
|
+
import { PARAMETER_TYPES } from "../constants";
|
|
48
45
|
|
|
49
46
|
export type ModularUIModel =
|
|
50
47
|
| ApplicationModel
|
|
@@ -90,12 +87,6 @@ export type RangeChildAttributeType =
|
|
|
90
87
|
| NumberAttributeModel
|
|
91
88
|
| DatetimeAttributeModel;
|
|
92
89
|
|
|
93
|
-
export type FilterType =
|
|
94
|
-
| AssignmentFilterModel
|
|
95
|
-
| FilterModel
|
|
96
|
-
| RangeFilterModel
|
|
97
|
-
| ConceptIndexFilterModel;
|
|
98
|
-
|
|
99
90
|
export type FormErrorAnchor = {
|
|
100
91
|
id: string,
|
|
101
92
|
properties?: {
|
|
@@ -135,6 +126,33 @@ export type textfragmentJSON = {
|
|
|
135
126
|
type: string,
|
|
136
127
|
};
|
|
137
128
|
|
|
129
|
+
export interface IFilter {
|
|
130
|
+
+type: string;
|
|
131
|
+
+parameterType: $Values<typeof PARAMETER_TYPES>;
|
|
132
|
+
+isMultiple: boolean;
|
|
133
|
+
context: Object;
|
|
134
|
+
+contextid: string;
|
|
135
|
+
+contextLabel: string;
|
|
136
|
+
listkey: string;
|
|
137
|
+
+label: string;
|
|
138
|
+
+key: string;
|
|
139
|
+
+name: string;
|
|
140
|
+
+param: string;
|
|
141
|
+
+params: Array<{ name: string, value: ?string }>;
|
|
142
|
+
isQuickSearch(): boolean;
|
|
143
|
+
+assistantMessage: string | null;
|
|
144
|
+
+value: string | { [string]: string } | null;
|
|
145
|
+
+inputvalue: string | { [string]: string };
|
|
146
|
+
hasValue(): boolean;
|
|
147
|
+
reset(): IFilter;
|
|
148
|
+
update(attribute: AttributeType, value: string): void;
|
|
149
|
+
isActive(): boolean;
|
|
150
|
+
+isValid: boolean;
|
|
151
|
+
+readonlyvalue: string | { [string]: string };
|
|
152
|
+
+formdata: { [string]: any } | null;
|
|
153
|
+
clone(): IFilter;
|
|
154
|
+
}
|
|
155
|
+
|
|
138
156
|
export interface IConstraintModel {
|
|
139
157
|
+id: string;
|
|
140
158
|
+defaultMessage: string;
|
|
@@ -22,9 +22,9 @@ import {
|
|
|
22
22
|
|
|
23
23
|
import { getEnabledLocales } from "../constants/Settings";
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import IllegalArgumentException from "../exceptions/IllegalArgumentException";
|
|
26
26
|
|
|
27
|
-
import { initModels } from "../redux";
|
|
27
|
+
import { initModels } from "../redux/_modularui/ModularUIActions";
|
|
28
28
|
import { getLocale } from "../redux/selectors/i18n";
|
|
29
29
|
|
|
30
30
|
import ModularUIRequest from "../modularui/ModularUIRequest";
|