@beinformed/ui 1.65.7 → 1.65.9
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 +18 -0
- package/esm/hooks/__tests__/UseModularUIModel.spec.js.flow +1 -1
- package/esm/hooks/index.js +3 -1
- package/esm/hooks/index.js.flow +3 -1
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/useForm.js +3 -3
- package/esm/hooks/useForm.js.flow +7 -4
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useList.js +37 -26
- package/esm/hooks/useList.js.flow +140 -83
- package/esm/hooks/useList.js.map +1 -1
- package/esm/hooks/useLookup.js +62 -0
- package/esm/hooks/useLookup.js.flow +82 -0
- package/esm/hooks/useLookup.js.map +1 -0
- package/esm/hooks/useModularUIModel.js +0 -17
- package/esm/hooks/useModularUIModel.js.flow +0 -25
- package/esm/hooks/useModularUIModel.js.map +1 -1
- package/esm/hooks/useProgressIndicator.js +21 -6
- package/esm/hooks/useProgressIndicator.js.flow +27 -10
- package/esm/hooks/useProgressIndicator.js.map +1 -1
- package/esm/hooks/useSearch.js +19 -0
- package/esm/hooks/useSearch.js.flow +31 -0
- package/esm/hooks/useSearch.js.map +1 -0
- package/esm/models/attributes/AttributeSetModel.js +1 -1
- package/esm/models/attributes/AttributeSetModel.js.flow +1 -1
- package/esm/models/attributes/AttributeSetModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +19 -2
- package/esm/models/attributes/ChoiceAttributeModel.js.flow +23 -2
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/links/LinkModel.js +17 -1
- package/esm/models/links/LinkModel.js.flow +18 -1
- package/esm/models/links/LinkModel.js.map +1 -1
- package/lib/hooks/index.js +26 -4
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useForm.js +5 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useList.js +37 -26
- package/lib/hooks/useList.js.map +1 -1
- package/lib/hooks/useLookup.js +70 -0
- package/lib/hooks/useLookup.js.map +1 -0
- package/lib/hooks/useModularUIModel.js +1 -20
- package/lib/hooks/useModularUIModel.js.map +1 -1
- package/lib/hooks/useProgressIndicator.js +23 -7
- package/lib/hooks/useProgressIndicator.js.map +1 -1
- package/lib/hooks/useSearch.js +28 -0
- package/lib/hooks/useSearch.js.map +1 -0
- package/lib/models/attributes/AttributeSetModel.js +1 -1
- package/lib/models/attributes/AttributeSetModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +18 -1
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/links/LinkModel.js +17 -0
- package/lib/models/links/LinkModel.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/__tests__/UseModularUIModel.spec.js +1 -1
- package/src/hooks/index.js +3 -1
- package/src/hooks/useForm.js +7 -4
- package/src/hooks/useList.js +140 -83
- package/src/hooks/useLookup.js +82 -0
- package/src/hooks/useModularUIModel.js +0 -25
- package/src/hooks/useProgressIndicator.js +27 -10
- package/src/hooks/useSearch.js +31 -0
- package/src/models/attributes/AttributeSetModel.js +1 -1
- package/src/models/attributes/ChoiceAttributeModel.js +23 -2
- package/src/models/links/LinkModel.js +18 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.65.
|
|
3
|
+
"version": "1.65.9",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "https://support.beinformed.com",
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
"eslint-config-prettier": "^10.1.8",
|
|
115
115
|
"eslint-plugin-babel": "^5.3.1",
|
|
116
116
|
"eslint-plugin-ft-flow": "^3.0.11",
|
|
117
|
-
"eslint-plugin-jest": "^29.
|
|
118
|
-
"eslint-plugin-jsdoc": "^
|
|
117
|
+
"eslint-plugin-jest": "^29.12.1",
|
|
118
|
+
"eslint-plugin-jsdoc": "^61.5.0",
|
|
119
119
|
"eslint-plugin-react": "^7.37.5",
|
|
120
120
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
121
121
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
|
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
useCaseView,
|
|
13
13
|
useGroupingPanel,
|
|
14
14
|
useDetailPanel,
|
|
15
|
-
useQuicksearch,
|
|
16
15
|
useUserProfile,
|
|
17
16
|
} from "../useModularUIModel";
|
|
18
17
|
import { useList, useListDetail } from "../useList";
|
|
19
18
|
import { usePanel } from "../usePanel";
|
|
19
|
+
import { useQuicksearch } from "../useSearch";
|
|
20
20
|
import {
|
|
21
21
|
ApplicationModel,
|
|
22
22
|
CaseSearchModel,
|
package/src/hooks/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// @flow
|
|
2
|
+
export * from "./useAllFormsOnModel";
|
|
2
3
|
export * from "./useAuthentication";
|
|
3
4
|
export * from "./useContent";
|
|
4
5
|
export * from "./useForm";
|
|
5
6
|
export * from "./useI18n";
|
|
6
7
|
export * from "./useList";
|
|
8
|
+
export * from "./useLookup";
|
|
7
9
|
export * from "./useModal";
|
|
8
10
|
export * from "./useModelCatalog";
|
|
9
11
|
export * from "./useModels";
|
|
@@ -16,4 +18,4 @@ export * from "./usePanel";
|
|
|
16
18
|
export * from "./usePreference";
|
|
17
19
|
export * from "./useProgressIndicator";
|
|
18
20
|
export * from "./useRouter";
|
|
19
|
-
export * from "./
|
|
21
|
+
export * from "./useSearch";
|
package/src/hooks/useForm.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { useDispatch } from "react-redux";
|
|
3
3
|
|
|
4
|
-
import Href from "../models/href/Href";
|
|
5
|
-
|
|
6
4
|
import { getSetting, HTTP_METHODS } from "../constants";
|
|
7
5
|
|
|
8
6
|
import type {
|
|
9
7
|
RemoveModelByKeyAction,
|
|
10
8
|
UpdateFormAction,
|
|
11
9
|
} from "../redux/_modularui";
|
|
12
|
-
import {
|
|
13
|
-
|
|
10
|
+
import {
|
|
11
|
+
loadModularUI,
|
|
12
|
+
removeModelByKey,
|
|
13
|
+
} from "../redux/_modularui/ModularUIActions";
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
addRepeatableAttributeSet,
|
|
@@ -22,8 +22,11 @@ import {
|
|
|
22
22
|
updateFormAttribute,
|
|
23
23
|
} from "../redux/actions";
|
|
24
24
|
|
|
25
|
+
import Href from "../models/href/Href";
|
|
25
26
|
import FormModel from "../models/form/FormModel";
|
|
26
27
|
|
|
28
|
+
import { useModularUI } from "./useModularUI";
|
|
29
|
+
|
|
27
30
|
import type { AttributeType, FormObjectModel, ModularUIModel } from "../models";
|
|
28
31
|
import type { UpdateFormOptions } from "../redux/types";
|
|
29
32
|
|
package/src/hooks/useList.js
CHANGED
|
@@ -18,6 +18,7 @@ import FilterModel from "../models/filters/FilterModel";
|
|
|
18
18
|
|
|
19
19
|
import type { HookOptions } from "./useModularUIBasic";
|
|
20
20
|
import type { AttributeType, IFilter } from "../models/types";
|
|
21
|
+
import { useCallback, useMemo } from "react";
|
|
21
22
|
|
|
22
23
|
type ListNavigationHook = {
|
|
23
24
|
update: (list: ListModel, resetPage?: boolean) => void,
|
|
@@ -35,6 +36,11 @@ type ListNavigationHook = {
|
|
|
35
36
|
removeFilter: (list: ListModel, filter: IFilter) => void,
|
|
36
37
|
};
|
|
37
38
|
|
|
39
|
+
type ListNavigationOptions = {
|
|
40
|
+
syncLocation: boolean,
|
|
41
|
+
historyAction: "push" | "replace",
|
|
42
|
+
};
|
|
43
|
+
|
|
38
44
|
/**
|
|
39
45
|
*/
|
|
40
46
|
export const useList = (
|
|
@@ -74,90 +80,141 @@ export const useListDetail = (
|
|
|
74
80
|
|
|
75
81
|
/**
|
|
76
82
|
*/
|
|
77
|
-
export const useListNavigation = (
|
|
83
|
+
export const useListNavigation = (
|
|
84
|
+
{ syncLocation, historyAction }: ListNavigationOptions = {
|
|
85
|
+
syncLocation: true,
|
|
86
|
+
historyAction: "push",
|
|
87
|
+
},
|
|
88
|
+
): ListNavigationHook => {
|
|
78
89
|
const history = useHistory();
|
|
79
90
|
const dispatch = useDispatch();
|
|
80
91
|
|
|
81
|
-
const update = (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
92
|
+
const update = useCallback(
|
|
93
|
+
(list: ListModel, resetPage: boolean = false) => {
|
|
94
|
+
const listHref = list.selfhref;
|
|
95
|
+
if (resetPage) {
|
|
96
|
+
listHref.page = null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (list.requestMethod === HTTP_METHODS.POST) {
|
|
100
|
+
if (syncLocation) {
|
|
101
|
+
history[historyAction]({
|
|
102
|
+
search: listHref.querystring,
|
|
103
|
+
state: list.formdata,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
dispatch(
|
|
108
|
+
loadModularUI(list.connectKey, listHref, {
|
|
109
|
+
method: HTTP_METHODS.POST,
|
|
110
|
+
data: list.formdata,
|
|
111
|
+
targetModel: [ListModel, CaseSearchModel],
|
|
112
|
+
}),
|
|
113
|
+
);
|
|
114
|
+
} else {
|
|
115
|
+
if (syncLocation) {
|
|
116
|
+
history[historyAction]({ search: listHref.querystring });
|
|
117
|
+
}
|
|
118
|
+
dispatch(
|
|
119
|
+
loadModularUI(list.connectKey, listHref, {
|
|
120
|
+
method: HTTP_METHODS.GET,
|
|
121
|
+
targetModel: [ListModel, CaseSearchModel],
|
|
122
|
+
}),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
[dispatch, history, historyAction, syncLocation],
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const updateFilters = useCallback(
|
|
130
|
+
(list: ListModel, filters: FilterCollection) => {
|
|
131
|
+
list.filterCollection = filters;
|
|
132
|
+
update(list, true);
|
|
133
|
+
},
|
|
134
|
+
[update],
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
const updateFilter = useCallback(
|
|
138
|
+
(
|
|
139
|
+
list: ListModel,
|
|
140
|
+
filter: IFilter,
|
|
141
|
+
value: string,
|
|
142
|
+
attribute?: AttributeType,
|
|
143
|
+
) => {
|
|
144
|
+
if (attribute) {
|
|
145
|
+
filter.update(attribute, value);
|
|
146
|
+
} else if (filter instanceof AssignmentFilterModel) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
"Need the attribute to update for AssigmentFilterModel",
|
|
149
|
+
);
|
|
150
|
+
} else if (filter instanceof FilterModel) {
|
|
151
|
+
filter.update(filter.attribute, value);
|
|
152
|
+
}
|
|
153
|
+
update(list, true);
|
|
154
|
+
},
|
|
155
|
+
[update],
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const resetFilters = useCallback(
|
|
159
|
+
(list: ListModel) => {
|
|
160
|
+
list.filterCollection.reset();
|
|
161
|
+
update(list, true);
|
|
162
|
+
},
|
|
163
|
+
[update],
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const removeFilter = useCallback(
|
|
167
|
+
(list: ListModel, filter: IFilter) => {
|
|
168
|
+
list.filterCollection.getFilterByName(filter.name)?.reset();
|
|
169
|
+
update(list, true);
|
|
170
|
+
},
|
|
171
|
+
[update],
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const updateSort = useCallback(
|
|
175
|
+
(list: ListModel, sortOption: string) => {
|
|
176
|
+
list.sorting.value = sortOption;
|
|
177
|
+
update(list, true);
|
|
178
|
+
},
|
|
179
|
+
[update],
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const updatePage = useCallback(
|
|
183
|
+
(list: ListModel, page: number) => {
|
|
184
|
+
list.paging.page = page;
|
|
185
|
+
update(list);
|
|
186
|
+
},
|
|
187
|
+
[update],
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
const updatePageSize = useCallback(
|
|
191
|
+
(list: ListModel, pagesize: number) => {
|
|
192
|
+
list.paging.pagesize.value = pagesize;
|
|
193
|
+
update(list);
|
|
194
|
+
},
|
|
195
|
+
[update],
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
return useMemo(
|
|
199
|
+
() => ({
|
|
200
|
+
update,
|
|
201
|
+
updateFilters,
|
|
202
|
+
updateFilter,
|
|
203
|
+
updateSort,
|
|
204
|
+
updatePage,
|
|
205
|
+
updatePageSize,
|
|
206
|
+
resetFilters,
|
|
207
|
+
removeFilter,
|
|
208
|
+
}),
|
|
209
|
+
[
|
|
210
|
+
removeFilter,
|
|
211
|
+
resetFilters,
|
|
212
|
+
update,
|
|
213
|
+
updateFilter,
|
|
214
|
+
updateFilters,
|
|
215
|
+
updatePage,
|
|
216
|
+
updatePageSize,
|
|
217
|
+
updateSort,
|
|
218
|
+
],
|
|
219
|
+
);
|
|
163
220
|
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { HTTP_METHODS } from "../constants";
|
|
5
|
+
|
|
6
|
+
import Href from "../models/href/Href";
|
|
7
|
+
import LinkModel from "../models/links/LinkModel";
|
|
8
|
+
import LookupOptionsModel from "../models/lookup/LookupOptionsModel";
|
|
9
|
+
|
|
10
|
+
import { useModularUIRequest } from "./useModularUIRequest";
|
|
11
|
+
import { useProgressIndicator } from "./useProgressIndicator";
|
|
12
|
+
|
|
13
|
+
type UseLookupHook = {
|
|
14
|
+
lookupOptions: LookupOptionsModel | null,
|
|
15
|
+
lookupLoading: boolean,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Lookup options call
|
|
20
|
+
*/
|
|
21
|
+
export const useLookup = (
|
|
22
|
+
lookupLink: LinkModel,
|
|
23
|
+
filterInput: string = "",
|
|
24
|
+
minLength: number = 2,
|
|
25
|
+
debounceMs: number = 300,
|
|
26
|
+
): UseLookupHook => {
|
|
27
|
+
const { start, finish } = useProgressIndicator();
|
|
28
|
+
const modularuiRequest = useModularUIRequest();
|
|
29
|
+
|
|
30
|
+
const [lookupOptions, setLookupOptions] = useState(null);
|
|
31
|
+
const [lookupLoading, setLookupLoading] = useState(false);
|
|
32
|
+
|
|
33
|
+
const { href, filterName, method } = lookupLink;
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (filterInput.length < minLength) {
|
|
37
|
+
setLookupOptions(null);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const timeoutId = setTimeout(async () => {
|
|
42
|
+
setLookupLoading(true);
|
|
43
|
+
start();
|
|
44
|
+
|
|
45
|
+
const lookupHref = new Href(href);
|
|
46
|
+
const requestOptions = { method, data: undefined };
|
|
47
|
+
if (method === HTTP_METHODS.POST) {
|
|
48
|
+
requestOptions.data = { [filterName]: filterInput };
|
|
49
|
+
} else {
|
|
50
|
+
lookupHref.addParameter(filterName, filterInput);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
modularuiRequest(lookupHref, requestOptions)
|
|
54
|
+
.fetch()
|
|
55
|
+
.then((lookupResponse) => {
|
|
56
|
+
if (lookupResponse instanceof LookupOptionsModel) {
|
|
57
|
+
setLookupOptions(lookupResponse);
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
.finally(() => {
|
|
61
|
+
finish();
|
|
62
|
+
setLookupLoading(false);
|
|
63
|
+
});
|
|
64
|
+
}, debounceMs);
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
clearTimeout(timeoutId);
|
|
68
|
+
};
|
|
69
|
+
}, [
|
|
70
|
+
debounceMs,
|
|
71
|
+
filterInput,
|
|
72
|
+
filterName,
|
|
73
|
+
finish,
|
|
74
|
+
href,
|
|
75
|
+
method,
|
|
76
|
+
minLength,
|
|
77
|
+
modularuiRequest,
|
|
78
|
+
start,
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
return { lookupOptions, lookupLoading };
|
|
82
|
+
};
|
|
@@ -4,7 +4,6 @@ import CaseViewModel from "../models/caseview/CaseViewModel";
|
|
|
4
4
|
import TabModel from "../models/tab/TabModel";
|
|
5
5
|
import GroupingPanelModel from "../models/panels/GroupingPanelModel";
|
|
6
6
|
import DetailModel from "../models/detail/DetailModel";
|
|
7
|
-
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
8
7
|
import UserProfileModel from "../models/user/UserProfileModel";
|
|
9
8
|
|
|
10
9
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
@@ -74,30 +73,6 @@ export const useDetailPanel = (
|
|
|
74
73
|
...options,
|
|
75
74
|
});
|
|
76
75
|
|
|
77
|
-
/**
|
|
78
|
-
*/
|
|
79
|
-
export const useQuicksearch = (
|
|
80
|
-
href: string | Href,
|
|
81
|
-
options?: HookOptions,
|
|
82
|
-
): CaseSearchModel | null =>
|
|
83
|
-
useModularUIBasic("quicksearch", href, {
|
|
84
|
-
expectedModels: ["CaseSearch"],
|
|
85
|
-
targetModel: CaseSearchModel,
|
|
86
|
-
...options,
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
*/
|
|
91
|
-
export const useSearch = (
|
|
92
|
-
href: string | Href,
|
|
93
|
-
options?: HookOptions,
|
|
94
|
-
): CaseSearchModel | null =>
|
|
95
|
-
useModularUIBasic("search", href, {
|
|
96
|
-
expectedModels: ["CaseSearch"],
|
|
97
|
-
targetModel: CaseSearchModel,
|
|
98
|
-
...options,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
76
|
/**
|
|
102
77
|
*/
|
|
103
78
|
export const useUserProfile = (
|
|
@@ -7,27 +7,44 @@ import {
|
|
|
7
7
|
updateProgress,
|
|
8
8
|
} from "../redux/actions/ProgressIndicator";
|
|
9
9
|
import type { ProgressIndicatorState } from "../redux/types";
|
|
10
|
+
import { useCallback } from "react";
|
|
10
11
|
|
|
11
12
|
type ProgressIndicatorHook = {
|
|
12
|
-
...ProgressIndicatorState,
|
|
13
13
|
start: () => void,
|
|
14
14
|
finish: () => void,
|
|
15
15
|
reset: () => void,
|
|
16
16
|
update: (percentComplete: number) => void,
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
type ProgressIndicatorStateHook = {
|
|
20
|
+
...ProgressIndicatorState,
|
|
21
|
+
};
|
|
22
|
+
|
|
19
23
|
/**
|
|
20
24
|
*/
|
|
21
25
|
export const useProgressIndicator = (): ProgressIndicatorHook => {
|
|
22
26
|
const dispatch = useDispatch();
|
|
23
|
-
const progress = useSelector((state) => state.progressindicator);
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const start = useCallback(() => {
|
|
29
|
+
dispatch(startProgress());
|
|
30
|
+
}, [dispatch]);
|
|
31
|
+
const finish = useCallback(() => {
|
|
32
|
+
dispatch(finishProgress());
|
|
33
|
+
}, [dispatch]);
|
|
34
|
+
const reset = useCallback(() => {
|
|
35
|
+
dispatch(resetProgress());
|
|
36
|
+
}, [dispatch]);
|
|
37
|
+
const update = useCallback(
|
|
38
|
+
(percentComplete: number) => {
|
|
39
|
+
dispatch(updateProgress(percentComplete));
|
|
40
|
+
},
|
|
41
|
+
[dispatch],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return { start, finish, reset, update };
|
|
33
45
|
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*/
|
|
49
|
+
export const useProgressIndicatorState = (): ProgressIndicatorStateHook =>
|
|
50
|
+
useSelector((state) => state.progressindicator);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import Href from "../models/href/Href";
|
|
3
|
+
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
4
|
+
|
|
5
|
+
import { useModularUIBasic } from "./useModularUIBasic";
|
|
6
|
+
|
|
7
|
+
import type { HookOptions } from "./useModularUIBasic";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*/
|
|
11
|
+
export const useQuicksearch = (
|
|
12
|
+
href: string | Href,
|
|
13
|
+
options?: HookOptions,
|
|
14
|
+
): CaseSearchModel | null =>
|
|
15
|
+
useModularUIBasic("quicksearch", href, {
|
|
16
|
+
expectedModels: ["CaseSearch"],
|
|
17
|
+
targetModel: CaseSearchModel,
|
|
18
|
+
...options,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*/
|
|
23
|
+
export const useSearch = (
|
|
24
|
+
href: string | Href,
|
|
25
|
+
options?: HookOptions,
|
|
26
|
+
): CaseSearchModel | null =>
|
|
27
|
+
useModularUIBasic("search", href, {
|
|
28
|
+
expectedModels: ["CaseSearch"],
|
|
29
|
+
targetModel: CaseSearchModel,
|
|
30
|
+
...options,
|
|
31
|
+
});
|
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
RENDER_SECTION_LABEL,
|
|
14
14
|
SORT_OPTIONS,
|
|
15
15
|
} from "../../constants/LayoutHints";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
ATTRIBUTE_WIDTH,
|
|
18
|
+
PARAMETER_TYPES,
|
|
19
|
+
HTTP_METHODS,
|
|
20
|
+
} from "../../constants";
|
|
17
21
|
|
|
18
22
|
import type {
|
|
19
23
|
ModularUIModel,
|
|
@@ -133,7 +137,24 @@ export default class ChoiceAttributeModel extends AttributeModel {
|
|
|
133
137
|
* Retrieve lookup service link
|
|
134
138
|
*/
|
|
135
139
|
get lookupLink(): LinkModel | null {
|
|
136
|
-
|
|
140
|
+
const link = this.links.getLinkByKey("lookupOptions");
|
|
141
|
+
if (link && this.lookupParameterType === PARAMETER_TYPES.BODY) {
|
|
142
|
+
link.method = HTTP_METHODS.POST;
|
|
143
|
+
}
|
|
144
|
+
return link;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Indicate if the lookup must be done with POST or GET
|
|
149
|
+
*/
|
|
150
|
+
get lookupParameterType(): $Values<typeof PARAMETER_TYPES> {
|
|
151
|
+
const parameterType = this.getContribution("parameterType");
|
|
152
|
+
switch (parameterType) {
|
|
153
|
+
case "bodyParameter":
|
|
154
|
+
return PARAMETER_TYPES.BODY;
|
|
155
|
+
default:
|
|
156
|
+
return PARAMETER_TYPES.QUERY;
|
|
157
|
+
}
|
|
137
158
|
}
|
|
138
159
|
|
|
139
160
|
/**
|
|
@@ -6,9 +6,10 @@ import BaseModel from "../base/BaseModel";
|
|
|
6
6
|
import Href from "../href/Href";
|
|
7
7
|
import LinkCollection from "../links/LinkCollection";
|
|
8
8
|
import { INITIAL_FILTER } from "../../constants/LayoutHints";
|
|
9
|
+
import Parameter from "../parameter/Parameter";
|
|
10
|
+
import { HTTP_METHODS } from "../../constants";
|
|
9
11
|
|
|
10
12
|
import type { ModelOptions, ModularUIModel } from "../types";
|
|
11
|
-
import Parameter from "../parameter/Parameter";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Defines a Link. For instance below example of a link to the tab 'books'
|
|
@@ -23,6 +24,7 @@ class LinkModel extends BaseModel {
|
|
|
23
24
|
_isCacheable: boolean;
|
|
24
25
|
_icon: string;
|
|
25
26
|
_targetModel: ?Class<ModularUIModel>;
|
|
27
|
+
_method: $Keys<typeof HTTP_METHODS>;
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* Create a Link
|
|
@@ -36,6 +38,7 @@ class LinkModel extends BaseModel {
|
|
|
36
38
|
|
|
37
39
|
this.createHref(modelOptions);
|
|
38
40
|
|
|
41
|
+
this._method = HTTP_METHODS.GET;
|
|
39
42
|
this._isCacheable = false;
|
|
40
43
|
}
|
|
41
44
|
|
|
@@ -121,6 +124,20 @@ class LinkModel extends BaseModel {
|
|
|
121
124
|
this._href = href;
|
|
122
125
|
}
|
|
123
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Indicate how this link must be called, GET by default
|
|
129
|
+
*/
|
|
130
|
+
get method(): $Keys<typeof HTTP_METHODS> {
|
|
131
|
+
return this._method;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Set http method for this link
|
|
136
|
+
*/
|
|
137
|
+
set method(method: $Keys<typeof HTTP_METHODS>) {
|
|
138
|
+
this._method = method;
|
|
139
|
+
}
|
|
140
|
+
|
|
124
141
|
/**
|
|
125
142
|
* Getting the label of the link
|
|
126
143
|
*/
|