@gisce/react-ooui 1.0.19 → 1.1.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.
- package/dist/actionbar/ChangeViewButton.d.ts +3 -2
- package/dist/actionbar/ChangeViewButton.d.ts.map +1 -1
- package/dist/actionbar/FormActionBar.d.ts +3 -1
- package/dist/actionbar/FormActionBar.d.ts.map +1 -1
- package/dist/actionbar/GraphActionBar.d.ts +6 -0
- package/dist/actionbar/GraphActionBar.d.ts.map +1 -0
- package/dist/actionbar/TreeActionBar.d.ts +2 -1
- package/dist/actionbar/TreeActionBar.d.ts.map +1 -1
- package/dist/context/ActionViewContext.d.ts +7 -3
- package/dist/context/ActionViewContext.d.ts.map +1 -1
- package/dist/context/One2manyContext.d.ts +4 -4
- package/dist/context/One2manyContext.d.ts.map +1 -1
- package/dist/context/TabManagerContext.d.ts +2 -3
- package/dist/context/TabManagerContext.d.ts.map +1 -1
- package/dist/helpers/searchHelper.d.ts +6 -0
- package/dist/helpers/searchHelper.d.ts.map +1 -0
- package/dist/hooks/useSearch.d.ts +52 -0
- package/dist/hooks/useSearch.d.ts.map +1 -0
- package/dist/locales/ca_ES.d.ts +1 -0
- package/dist/locales/ca_ES.d.ts.map +1 -1
- package/dist/locales/en_US.d.ts +1 -0
- package/dist/locales/en_US.d.ts.map +1 -1
- package/dist/locales/es_ES.d.ts +1 -0
- package/dist/locales/es_ES.d.ts.map +1 -1
- package/dist/react-ooui.es.js +4867 -4416
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +14 -14
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/types/index.d.ts +29 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/TitleHeader.d.ts +1 -0
- package/dist/ui/TitleHeader.d.ts.map +1 -1
- package/dist/views/ActionView.d.ts +3 -7
- package/dist/views/ActionView.d.ts.map +1 -1
- package/dist/views/RootView.d.ts.map +1 -1
- package/dist/views/actionViews/DashboardActionView.d.ts +7 -0
- package/dist/views/actionViews/DashboardActionView.d.ts.map +1 -0
- package/dist/views/actionViews/FormActionView.d.ts +18 -0
- package/dist/views/actionViews/FormActionView.d.ts.map +1 -0
- package/dist/views/actionViews/GraphActionView.d.ts +13 -0
- package/dist/views/actionViews/GraphActionView.d.ts.map +1 -0
- package/dist/views/actionViews/TreeActionView.d.ts +19 -0
- package/dist/views/actionViews/TreeActionView.d.ts.map +1 -0
- package/dist/widgets/base/one2many/One2many.d.ts +0 -1
- package/dist/widgets/base/one2many/One2many.d.ts.map +1 -1
- package/dist/widgets/base/one2many/One2manyInput.d.ts.map +1 -1
- package/dist/widgets/base/one2many/One2manyTopBar.d.ts +2 -2
- package/dist/widgets/base/one2many/One2manyTopBar.d.ts.map +1 -1
- package/dist/widgets/custom/ButtonGroup.d.ts.map +1 -1
- package/dist/widgets/views/Dashboard/Dashboard.d.ts +1 -1
- package/dist/widgets/views/Dashboard/Dashboard.d.ts.map +1 -1
- package/dist/widgets/views/Dashboard/DashboardTree.d.ts.map +1 -1
- package/dist/widgets/views/Graph/Graph.d.ts +3 -3
- package/dist/widgets/views/Graph/Graph.d.ts.map +1 -1
- package/dist/widgets/views/Graph/GraphChart.d.ts +1 -1
- package/dist/widgets/views/Graph/GraphChart.d.ts.map +1 -1
- package/dist/widgets/views/Graph/useGraphData.d.ts +1 -1
- package/dist/widgets/views/Graph/useGraphData.d.ts.map +1 -1
- package/dist/widgets/views/SearchTree.d.ts.map +1 -1
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts +4 -0
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/actionbar/ChangeViewButton.tsx +34 -39
- package/src/actionbar/FormActionBar.tsx +6 -6
- package/src/actionbar/GraphActionBar.tsx +67 -0
- package/src/actionbar/TreeActionBar.tsx +10 -11
- package/src/context/ActionViewContext.tsx +27 -8
- package/src/context/One2manyContext.tsx +5 -5
- package/src/context/TabManagerContext.tsx +2 -3
- package/src/helpers/{searchFilterHelper.ts → searchHelper.ts} +32 -7
- package/src/hooks/useFetchViews.ts +0 -0
- package/src/hooks/useSearch.ts +404 -0
- package/src/locales/ca_ES.tsx +1 -0
- package/src/locales/en_US.tsx +1 -0
- package/src/locales/es_ES.tsx +1 -0
- package/src/types/index.ts +37 -3
- package/src/ui/FavouriteButton.tsx +2 -2
- package/src/ui/TitleHeader.tsx +4 -3
- package/src/views/ActionView.tsx +185 -171
- package/src/views/RootView.tsx +5 -6
- package/src/views/actionViews/DashboardActionView.tsx +47 -0
- package/src/views/actionViews/FormActionView.tsx +70 -0
- package/src/views/actionViews/GraphActionView.tsx +136 -0
- package/src/views/actionViews/TreeActionView.tsx +77 -0
- package/src/widgets/base/Button.tsx +1 -1
- package/src/widgets/base/Image.tsx +1 -1
- package/src/widgets/base/many2one/Many2oneSuffix.tsx +1 -1
- package/src/widgets/base/one2many/One2many.tsx +5 -7
- package/src/widgets/base/one2many/One2manyInput.tsx +5 -7
- package/src/widgets/base/one2many/One2manyTopBar.tsx +5 -5
- package/src/widgets/containers/Notebook.tsx +1 -1
- package/src/widgets/custom/ButtonGroup.tsx +15 -14
- package/src/widgets/custom/Indicator.tsx +2 -2
- package/src/widgets/views/Dashboard/Dashboard.tsx +4 -5
- package/src/widgets/views/Dashboard/DashboardTree.tsx +15 -18
- package/src/widgets/views/Graph/Graph.tsx +40 -6
- package/src/widgets/views/Graph/GraphChart.tsx +1 -1
- package/src/widgets/views/Graph/useGraphData.tsx +2 -2
- package/src/widgets/views/SearchTree.tsx +81 -331
- package/src/widgets/views/searchFilter/SearchFilter.tsx +58 -23
- package/dist/helpers/searchFilterHelper.d.ts +0 -5
- package/dist/helpers/searchFilterHelper.d.ts.map +0 -1
- package/dist/widgets/views/Dashboard/Dashboard.types.d.ts +0 -8
- package/dist/widgets/views/Dashboard/Dashboard.types.d.ts.map +0 -1
- package/src/widgets/views/Dashboard/Dashboard.types.ts +0 -8
|
@@ -16,7 +16,7 @@ export type GraphDataQueryOpts = {
|
|
|
16
16
|
model: string;
|
|
17
17
|
domain?: any;
|
|
18
18
|
context?: any;
|
|
19
|
-
limit
|
|
19
|
+
limit?: number;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export type GraphDataOpts = GraphDataQueryOpts & {
|
|
@@ -126,7 +126,7 @@ async function retrieveData({
|
|
|
126
126
|
domain: any;
|
|
127
127
|
context: any;
|
|
128
128
|
order: string | null;
|
|
129
|
-
limit
|
|
129
|
+
limit?: number;
|
|
130
130
|
}) {
|
|
131
131
|
const values: any[] = (await ConnectionProvider.getHandler().search({
|
|
132
132
|
model,
|
|
@@ -5,7 +5,6 @@ import React, {
|
|
|
5
5
|
useContext,
|
|
6
6
|
forwardRef,
|
|
7
7
|
useImperativeHandle,
|
|
8
|
-
useCallback,
|
|
9
8
|
} from "react";
|
|
10
9
|
import { Alert, Spin } from "antd";
|
|
11
10
|
|
|
@@ -18,22 +17,14 @@ import {
|
|
|
18
17
|
ActionViewContext,
|
|
19
18
|
ActionViewContextType,
|
|
20
19
|
} from "@/context/ActionViewContext";
|
|
21
|
-
import {
|
|
22
|
-
getColorMap,
|
|
23
|
-
getTableItems,
|
|
24
|
-
getTree,
|
|
25
|
-
sortResults,
|
|
26
|
-
} from "@/helpers/treeHelper";
|
|
27
20
|
import useWindowDimensions from "@/hooks/useWindowDimensions";
|
|
28
|
-
import Measure from "react-measure";
|
|
29
21
|
import { mergeSearchFields } from "@/helpers/formHelper";
|
|
30
22
|
import {
|
|
31
23
|
ContentRootContext,
|
|
32
24
|
ContentRootContextType,
|
|
33
25
|
} from "@/context/ContentRootContext";
|
|
34
26
|
import showErrorDialog from "@/ui/ActionErrorDialog";
|
|
35
|
-
|
|
36
|
-
const DEFAULT_SEARCH_LIMIT = 80;
|
|
27
|
+
import { DEFAULT_SEARCH_LIMIT, useSearch } from "@/hooks/useSearch";
|
|
37
28
|
|
|
38
29
|
type OnRowClickedData = {
|
|
39
30
|
id: number;
|
|
@@ -83,33 +74,23 @@ function SearchTree(props: Props, ref: any) {
|
|
|
83
74
|
const [treeView, setTreeView] = useState<TreeView>();
|
|
84
75
|
const [formView, setFormView] = useState<FormView>();
|
|
85
76
|
|
|
86
|
-
const [page, setPage] = useState<number>(1);
|
|
87
|
-
const [offset, setOffset] = useState<number>(0);
|
|
88
|
-
const [limit, setLimit] = useState<number>(DEFAULT_SEARCH_LIMIT);
|
|
89
77
|
const [limitFromAction, setLimitFromAction] = useState<number>();
|
|
78
|
+
const [limit, setLimit] = useState<number>(DEFAULT_SEARCH_LIMIT);
|
|
90
79
|
|
|
91
|
-
const paramsRef = useRef<Array<any>>([]);
|
|
92
|
-
|
|
93
|
-
const [totalItems, setTotalItems] = useState<number>();
|
|
94
|
-
const [resultsInternal, setResultsInternal] = useState<any>([]);
|
|
95
|
-
const [colorsForResults, setColorsForResults] = useState<any>(undefined);
|
|
96
|
-
|
|
97
|
-
const [searchFilterLoading, setSearchFilterLoading] = useState<boolean>(
|
|
98
|
-
false
|
|
99
|
-
);
|
|
100
|
-
const [searchError, setSearchError] = useState<string>();
|
|
101
80
|
const [initialError, setInitialError] = useState<string>();
|
|
102
81
|
|
|
103
|
-
const [tableRefreshing, setTableRefreshing] = useState<boolean>(false);
|
|
104
|
-
|
|
105
82
|
const actionDomain = useRef<any>([]);
|
|
106
83
|
const [searchFilterHeight, setSearchFilterHeight] = useState<number>(200);
|
|
107
84
|
|
|
108
|
-
const originalResults = useRef<any[]>([]);
|
|
109
85
|
const expandableClickActionData = useRef<any>();
|
|
110
86
|
|
|
111
87
|
const { height } = useWindowDimensions();
|
|
112
88
|
|
|
89
|
+
const contentRootContext = useContext(
|
|
90
|
+
ContentRootContext
|
|
91
|
+
) as ContentRootContextType;
|
|
92
|
+
const { processAction } = contentRootContext || {};
|
|
93
|
+
|
|
113
94
|
const actionViewContext = useContext(
|
|
114
95
|
ActionViewContext
|
|
115
96
|
) as ActionViewContextType;
|
|
@@ -120,6 +101,7 @@ function SearchTree(props: Props, ref: any) {
|
|
|
120
101
|
results: resultsActionView = undefined,
|
|
121
102
|
selectedRowItems = undefined,
|
|
122
103
|
setSelectedRowItems = undefined,
|
|
104
|
+
searchParams = [],
|
|
123
105
|
setSearchParams = undefined,
|
|
124
106
|
searchVisible = true,
|
|
125
107
|
setSearchVisible = undefined,
|
|
@@ -128,12 +110,51 @@ function SearchTree(props: Props, ref: any) {
|
|
|
128
110
|
setTotalItems: setActionViewTotalItems = undefined,
|
|
129
111
|
setSearchTreeNameSearch = undefined,
|
|
130
112
|
setTreeIsLoading = undefined,
|
|
113
|
+
searchValues = {},
|
|
114
|
+
setSearchValues = undefined,
|
|
131
115
|
} = (rootTree ? actionViewContext : {}) || {};
|
|
132
116
|
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
117
|
+
const {
|
|
118
|
+
submit,
|
|
119
|
+
clear,
|
|
120
|
+
fetchResults,
|
|
121
|
+
tableRefreshing,
|
|
122
|
+
searchFilterLoading,
|
|
123
|
+
searchError,
|
|
124
|
+
page,
|
|
125
|
+
offset,
|
|
126
|
+
getResults,
|
|
127
|
+
requestPageChange,
|
|
128
|
+
changeSort,
|
|
129
|
+
fetchChildrenForRecord,
|
|
130
|
+
colorsForResults,
|
|
131
|
+
totalItems,
|
|
132
|
+
} = useSearch({
|
|
133
|
+
model: currentModel!,
|
|
134
|
+
setSearchTreeNameSearch,
|
|
135
|
+
setSelectedRowItems,
|
|
136
|
+
setSearchParams,
|
|
137
|
+
setSearchValues,
|
|
138
|
+
searchParams,
|
|
139
|
+
setSearchVisible,
|
|
140
|
+
setTreeIsLoading,
|
|
141
|
+
nameSearch,
|
|
142
|
+
searchNameGetDoneRef,
|
|
143
|
+
context: parentContext,
|
|
144
|
+
formView: formView!,
|
|
145
|
+
treeView: treeView!,
|
|
146
|
+
sorter,
|
|
147
|
+
setSorter,
|
|
148
|
+
setCurrentItemIndex,
|
|
149
|
+
setResultsActionView,
|
|
150
|
+
resultsActionView,
|
|
151
|
+
domain,
|
|
152
|
+
currentId,
|
|
153
|
+
setActionViewTotalItems,
|
|
154
|
+
limitFromAction,
|
|
155
|
+
setLimit,
|
|
156
|
+
limit,
|
|
157
|
+
});
|
|
137
158
|
|
|
138
159
|
useImperativeHandle(ref, () => ({
|
|
139
160
|
refreshResults: () => {
|
|
@@ -142,212 +163,6 @@ function SearchTree(props: Props, ref: any) {
|
|
|
142
163
|
},
|
|
143
164
|
}));
|
|
144
165
|
|
|
145
|
-
const onRequestPageChange = (page: number) => {
|
|
146
|
-
setTableRefreshing(true);
|
|
147
|
-
setPage(page);
|
|
148
|
-
setOffset((page - 1) * limit!);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
function setResults(results: any) {
|
|
152
|
-
setResultsActionView?.([...results]);
|
|
153
|
-
setResultsInternal([...results]);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const getResults = useCallback(() => {
|
|
157
|
-
if (!resultsActionView) {
|
|
158
|
-
return resultsInternal;
|
|
159
|
-
}
|
|
160
|
-
return resultsActionView;
|
|
161
|
-
}, [resultsActionView, resultsInternal]);
|
|
162
|
-
|
|
163
|
-
const searchByNameSearch = async () => {
|
|
164
|
-
const searchResults = await ConnectionProvider.getHandler().nameSearch({
|
|
165
|
-
model: currentModel!,
|
|
166
|
-
payload: nameSearch,
|
|
167
|
-
limit: internalLimit.current,
|
|
168
|
-
attrs: actionDomain.current.length > 0 ? actionDomain.current : domain,
|
|
169
|
-
context: parentContext,
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
setTotalItems(searchResults.length);
|
|
173
|
-
setActionViewTotalItems?.(searchResults.length);
|
|
174
|
-
|
|
175
|
-
if (searchResults.length > 0) {
|
|
176
|
-
const resultsIds = searchResults.map((item: any) => {
|
|
177
|
-
return item?.[0];
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const { colors } = getTree(treeView!);
|
|
181
|
-
|
|
182
|
-
const resultsWithData = await ConnectionProvider.getHandler().readEvalUiObjects(
|
|
183
|
-
{
|
|
184
|
-
model: currentModel!,
|
|
185
|
-
ids: resultsIds,
|
|
186
|
-
arch: treeView?.arch!,
|
|
187
|
-
fields: treeView!.field_parent
|
|
188
|
-
? { ...treeView!.fields, [treeView!.field_parent]: {} }
|
|
189
|
-
: treeView!.fields,
|
|
190
|
-
context: parentContext,
|
|
191
|
-
attrs: colors && {
|
|
192
|
-
colors,
|
|
193
|
-
},
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
const resultsData = resultsWithData[0];
|
|
197
|
-
|
|
198
|
-
originalResults.current = [...resultsData];
|
|
199
|
-
|
|
200
|
-
setColorsForResults(getColorMap(resultsWithData[1]));
|
|
201
|
-
|
|
202
|
-
const newResultIds = resultsData.map((item: any) => item.id);
|
|
203
|
-
|
|
204
|
-
const resultsSorted =
|
|
205
|
-
sorter !== undefined
|
|
206
|
-
? sortResults({
|
|
207
|
-
resultsToSort: resultsData,
|
|
208
|
-
sorter,
|
|
209
|
-
fields: { ...treeView!.fields, ...formView!.fields },
|
|
210
|
-
})
|
|
211
|
-
: [...originalResults.current];
|
|
212
|
-
|
|
213
|
-
setResults(resultsSorted);
|
|
214
|
-
|
|
215
|
-
if (newResultIds.length > 0) {
|
|
216
|
-
setCurrentItemIndex?.(0);
|
|
217
|
-
} else {
|
|
218
|
-
setCurrentItemIndex?.(undefined);
|
|
219
|
-
}
|
|
220
|
-
} else {
|
|
221
|
-
setResults([]);
|
|
222
|
-
setCurrentItemIndex?.(undefined);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
searchNameGetDoneRef.current = true;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
const getUniqueFieldsForParams = (params: any[]) => {
|
|
229
|
-
const uniqueFields: any = {};
|
|
230
|
-
|
|
231
|
-
params.forEach((param) => {
|
|
232
|
-
if (Array.isArray(param) && param[0]) {
|
|
233
|
-
uniqueFields[param[0]] = true;
|
|
234
|
-
} else {
|
|
235
|
-
uniqueFields[param] = true;
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
return Object.keys(uniqueFields);
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const mergeParams = (searchParams: any[], domainParams: any[]) => {
|
|
243
|
-
const finalParams = searchParams;
|
|
244
|
-
const uniqueParams = getUniqueFieldsForParams(searchParams);
|
|
245
|
-
|
|
246
|
-
domainParams.forEach((element) => {
|
|
247
|
-
if (Array.isArray(element) && element[0]) {
|
|
248
|
-
if (!uniqueParams.includes(element[0])) {
|
|
249
|
-
finalParams.push(element);
|
|
250
|
-
}
|
|
251
|
-
} else if (!uniqueParams.includes(element)) {
|
|
252
|
-
finalParams.push(element);
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
return finalParams;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
const searchResults = async () => {
|
|
260
|
-
const domainParams =
|
|
261
|
-
actionDomain.current.length > 0 ? actionDomain.current : domain;
|
|
262
|
-
|
|
263
|
-
const searchParams = mergeParams(paramsRef.current, domainParams);
|
|
264
|
-
const { colors } = getTree(treeView!);
|
|
265
|
-
|
|
266
|
-
const {
|
|
267
|
-
totalItems,
|
|
268
|
-
results,
|
|
269
|
-
attrsEvaluated,
|
|
270
|
-
} = await ConnectionProvider.getHandler().searchForTree({
|
|
271
|
-
params: searchParams,
|
|
272
|
-
limit,
|
|
273
|
-
offset,
|
|
274
|
-
model: currentModel!,
|
|
275
|
-
fields: treeView!.field_parent
|
|
276
|
-
? { ...treeView!.fields, [treeView!.field_parent]: {} }
|
|
277
|
-
: treeView!.fields,
|
|
278
|
-
context: parentContext,
|
|
279
|
-
attrs: colors && { colors },
|
|
280
|
-
});
|
|
281
|
-
setColorsForResults(getColorMap(attrsEvaluated));
|
|
282
|
-
|
|
283
|
-
originalResults.current = [...results];
|
|
284
|
-
|
|
285
|
-
const resultsSorted =
|
|
286
|
-
sorter !== undefined
|
|
287
|
-
? sortResults({
|
|
288
|
-
resultsToSort: results,
|
|
289
|
-
sorter: sorter,
|
|
290
|
-
fields: { ...treeView!.fields, ...formView!.fields },
|
|
291
|
-
})
|
|
292
|
-
: [...originalResults.current];
|
|
293
|
-
|
|
294
|
-
totalItems.then((value) => {
|
|
295
|
-
setTotalItems(value);
|
|
296
|
-
setActionViewTotalItems?.(value);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
setResults(resultsSorted);
|
|
300
|
-
|
|
301
|
-
if (resultsActionView && resultsSorted.length > 0) {
|
|
302
|
-
const newCurrentItemIndex = resultsSorted.findIndex(
|
|
303
|
-
(item) => currentId === item.id
|
|
304
|
-
);
|
|
305
|
-
|
|
306
|
-
if (newCurrentItemIndex === -1) {
|
|
307
|
-
setCurrentItemIndex?.(0);
|
|
308
|
-
} else {
|
|
309
|
-
setCurrentItemIndex?.(newCurrentItemIndex);
|
|
310
|
-
}
|
|
311
|
-
} else {
|
|
312
|
-
setCurrentItemIndex?.(undefined);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
const fetchResults = async () => {
|
|
317
|
-
try {
|
|
318
|
-
setTableRefreshing(true);
|
|
319
|
-
setTreeIsLoading?.(true);
|
|
320
|
-
if (nameSearch && !searchNameGetDoneRef.current) {
|
|
321
|
-
await searchByNameSearch();
|
|
322
|
-
} else {
|
|
323
|
-
await searchResults();
|
|
324
|
-
}
|
|
325
|
-
} catch (error) {
|
|
326
|
-
setSearchError(error);
|
|
327
|
-
} finally {
|
|
328
|
-
setTableRefreshing(false);
|
|
329
|
-
setSearchFilterLoading(false);
|
|
330
|
-
setTreeIsLoading?.(false);
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
async function onFetchChildrenForRecord(record: any) {
|
|
335
|
-
const child_id = record[treeView?.field_parent || "child_id"];
|
|
336
|
-
|
|
337
|
-
const children = await ConnectionProvider.getHandler().readObjects({
|
|
338
|
-
model: currentModel!,
|
|
339
|
-
ids: child_id,
|
|
340
|
-
fields: treeView!.field_parent
|
|
341
|
-
? { ...treeView!.fields, [treeView!.field_parent]: {} }
|
|
342
|
-
: treeView!.fields,
|
|
343
|
-
context: parentContext,
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
setResults([...getResults(), ...children]);
|
|
347
|
-
|
|
348
|
-
return getTableItems(getTree(treeView!), children);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
166
|
useEffect(() => {
|
|
352
167
|
if (!initialFetchDone) {
|
|
353
168
|
return;
|
|
@@ -381,12 +196,11 @@ function SearchTree(props: Props, ref: any) {
|
|
|
381
196
|
};
|
|
382
197
|
|
|
383
198
|
const fetchActionData = async () => {
|
|
384
|
-
const dataForAction =
|
|
385
|
-
{
|
|
199
|
+
const dataForAction =
|
|
200
|
+
await ConnectionProvider.getHandler().getViewsForAction({
|
|
386
201
|
action: action!,
|
|
387
202
|
context: parentContext,
|
|
388
|
-
}
|
|
389
|
-
);
|
|
203
|
+
});
|
|
390
204
|
actionDomain.current = dataForAction.domain;
|
|
391
205
|
setFormView(dataForAction.views.get("form"));
|
|
392
206
|
setTreeView(dataForAction.views.get("tree"));
|
|
@@ -432,40 +246,6 @@ function SearchTree(props: Props, ref: any) {
|
|
|
432
246
|
}
|
|
433
247
|
}, [action, model]);
|
|
434
248
|
|
|
435
|
-
const onClear = () => {
|
|
436
|
-
if (tableRefreshing) return;
|
|
437
|
-
setSearchTreeNameSearch?.(undefined);
|
|
438
|
-
paramsRef.current = [];
|
|
439
|
-
setSearchParams?.([]);
|
|
440
|
-
setSearchError(undefined);
|
|
441
|
-
setOffset(0);
|
|
442
|
-
setPage(1);
|
|
443
|
-
setLimit(limitFromAction || DEFAULT_SEARCH_LIMIT);
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
const onSubmit = ({
|
|
447
|
-
params: newParams,
|
|
448
|
-
limit: newLimit,
|
|
449
|
-
offset: newOffset,
|
|
450
|
-
}: {
|
|
451
|
-
params: any;
|
|
452
|
-
limit: number;
|
|
453
|
-
offset: number;
|
|
454
|
-
}) => {
|
|
455
|
-
if (tableRefreshing) return;
|
|
456
|
-
paramsRef.current = newParams;
|
|
457
|
-
setSearchTreeNameSearch?.(undefined);
|
|
458
|
-
setSelectedRowItems?.([]);
|
|
459
|
-
setSearchParams?.(newParams);
|
|
460
|
-
setSearchVisible?.(false);
|
|
461
|
-
setSearchFilterLoading(true);
|
|
462
|
-
setSearchError(undefined);
|
|
463
|
-
setPage(1);
|
|
464
|
-
if (newLimit) setLimit(newLimit);
|
|
465
|
-
if (newOffset) setOffset(newOffset);
|
|
466
|
-
fetchResults();
|
|
467
|
-
};
|
|
468
|
-
|
|
469
249
|
const onSearchTreeLimitChange = (newLimit: number) => {
|
|
470
250
|
internalLimit.current = newLimit;
|
|
471
251
|
};
|
|
@@ -474,13 +254,12 @@ function SearchTree(props: Props, ref: any) {
|
|
|
474
254
|
const { id } = record;
|
|
475
255
|
|
|
476
256
|
if (!expandableClickActionData.current) {
|
|
477
|
-
expandableClickActionData.current =
|
|
478
|
-
{
|
|
257
|
+
expandableClickActionData.current =
|
|
258
|
+
await ConnectionProvider.getHandler().treeButOpen({
|
|
479
259
|
id: treeView!.view_id,
|
|
480
260
|
model: currentModel!,
|
|
481
261
|
context: parentContext,
|
|
482
|
-
}
|
|
483
|
-
);
|
|
262
|
+
});
|
|
484
263
|
}
|
|
485
264
|
|
|
486
265
|
const actionData: any = expandableClickActionData.current[0][2];
|
|
@@ -538,48 +317,30 @@ function SearchTree(props: Props, ref: any) {
|
|
|
538
317
|
|
|
539
318
|
return (
|
|
540
319
|
<>
|
|
541
|
-
<
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
{
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
offset={offset}
|
|
559
|
-
isSearching={searchFilterLoading}
|
|
560
|
-
onSubmit={onSubmit}
|
|
561
|
-
onLimitChange={onSearchTreeLimitChange}
|
|
562
|
-
/>
|
|
563
|
-
{searchError && (
|
|
564
|
-
<Alert
|
|
565
|
-
className="mt-10"
|
|
566
|
-
message={searchError}
|
|
567
|
-
type="error"
|
|
568
|
-
banner
|
|
569
|
-
/>
|
|
570
|
-
)}
|
|
571
|
-
<div className="pb-5" />
|
|
572
|
-
</div>
|
|
573
|
-
</div>
|
|
574
|
-
)}
|
|
575
|
-
</Measure>
|
|
320
|
+
<SearchFilter
|
|
321
|
+
fields={{ ...treeView.fields, ...formView.fields }}
|
|
322
|
+
searchFields={mergeSearchFields([
|
|
323
|
+
formView.search_fields,
|
|
324
|
+
treeView.search_fields,
|
|
325
|
+
])}
|
|
326
|
+
onClear={clear}
|
|
327
|
+
limit={limit}
|
|
328
|
+
offset={offset}
|
|
329
|
+
isSearching={searchFilterLoading}
|
|
330
|
+
onSubmit={submit}
|
|
331
|
+
onLimitChange={onSearchTreeLimitChange}
|
|
332
|
+
setSearchFilterHeight={setSearchFilterHeight}
|
|
333
|
+
searchError={searchError}
|
|
334
|
+
searchVisible={searchVisible}
|
|
335
|
+
searchValues={searchValues}
|
|
336
|
+
/>
|
|
576
337
|
<Tree
|
|
577
338
|
total={totalItems}
|
|
578
339
|
limit={limit}
|
|
579
340
|
page={page}
|
|
580
341
|
treeView={treeView}
|
|
581
342
|
results={getResults()}
|
|
582
|
-
onRequestPageChange={
|
|
343
|
+
onRequestPageChange={requestPageChange}
|
|
583
344
|
loading={tableRefreshing}
|
|
584
345
|
onRowClicked={onRowClickedHandler}
|
|
585
346
|
scrollY={treeScrollY || calculateTableHeight()}
|
|
@@ -589,20 +350,9 @@ function SearchTree(props: Props, ref: any) {
|
|
|
589
350
|
onChange: changeSelectedRowKeys,
|
|
590
351
|
}}
|
|
591
352
|
sorter={sorter}
|
|
592
|
-
onChangeSort={
|
|
593
|
-
setSorter?.(newSorter);
|
|
594
|
-
const sortedResults =
|
|
595
|
-
newSorter !== undefined
|
|
596
|
-
? sortResults({
|
|
597
|
-
resultsToSort: getResults(),
|
|
598
|
-
sorter: newSorter,
|
|
599
|
-
fields: { ...treeView.fields, ...formView.fields },
|
|
600
|
-
})
|
|
601
|
-
: [...originalResults.current];
|
|
602
|
-
setResults(sortedResults);
|
|
603
|
-
}}
|
|
353
|
+
onChangeSort={changeSort}
|
|
604
354
|
onFetchChildrenForRecord={
|
|
605
|
-
treeView.isExpandable ?
|
|
355
|
+
treeView.isExpandable ? fetchChildrenForRecord : undefined
|
|
606
356
|
}
|
|
607
357
|
childField={treeView.field_parent}
|
|
608
358
|
/>
|
|
@@ -610,10 +360,10 @@ function SearchTree(props: Props, ref: any) {
|
|
|
610
360
|
);
|
|
611
361
|
};
|
|
612
362
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
363
|
+
const error = initialError || searchError;
|
|
364
|
+
|
|
365
|
+
if (error) {
|
|
366
|
+
return <Alert className="mt-10" message={error} type="error" banner />;
|
|
617
367
|
}
|
|
618
368
|
|
|
619
369
|
return (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { Form, Row, Col } from "antd";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import { Form, Row, Col, Alert } from "antd";
|
|
3
3
|
import useDeepCompareEffect from "use-deep-compare-effect";
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -13,7 +13,8 @@ import { SearchBottomBar } from "./SearchBottomBar";
|
|
|
13
13
|
import { SearchFields } from "@/types";
|
|
14
14
|
import { SearchParams } from "./SearchParams";
|
|
15
15
|
|
|
16
|
-
import { getParamsForFields } from "@/helpers/
|
|
16
|
+
import { getParamsForFields } from "@/helpers/searchHelper";
|
|
17
|
+
import Measure from "react-measure";
|
|
17
18
|
|
|
18
19
|
type Props = {
|
|
19
20
|
fields: any;
|
|
@@ -24,6 +25,10 @@ type Props = {
|
|
|
24
25
|
limit: number;
|
|
25
26
|
offset: number;
|
|
26
27
|
onLimitChange?: (limit: number) => void;
|
|
28
|
+
searchVisible?: boolean;
|
|
29
|
+
setSearchFilterHeight?: (height: number) => void;
|
|
30
|
+
searchError?: string;
|
|
31
|
+
searchValues?: any;
|
|
27
32
|
};
|
|
28
33
|
|
|
29
34
|
function SearchFilter(props: Props) {
|
|
@@ -36,6 +41,10 @@ function SearchFilter(props: Props) {
|
|
|
36
41
|
offset,
|
|
37
42
|
limit,
|
|
38
43
|
onLimitChange,
|
|
44
|
+
searchVisible,
|
|
45
|
+
setSearchFilterHeight,
|
|
46
|
+
searchError,
|
|
47
|
+
searchValues,
|
|
39
48
|
} = props;
|
|
40
49
|
|
|
41
50
|
const [simpleSearchFields, setSimpleSearchFields] = useState<Container>();
|
|
@@ -44,6 +53,10 @@ function SearchFilter(props: Props) {
|
|
|
44
53
|
|
|
45
54
|
const [form] = Form.useForm();
|
|
46
55
|
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
form.setFieldsValue(searchValues);
|
|
58
|
+
}, [searchValues]);
|
|
59
|
+
|
|
47
60
|
const getRowsAndCols = () => {
|
|
48
61
|
if (!advancedSearchFields) {
|
|
49
62
|
return;
|
|
@@ -83,30 +96,52 @@ function SearchFilter(props: Props) {
|
|
|
83
96
|
delete values.limit;
|
|
84
97
|
const newParams = getParamsForFields(values, fields);
|
|
85
98
|
|
|
86
|
-
onSubmit({ params: newParams, offset, limit });
|
|
99
|
+
onSubmit({ params: newParams, offset, limit, searchValues: values });
|
|
87
100
|
};
|
|
88
101
|
|
|
89
102
|
return (
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
103
|
+
<Measure
|
|
104
|
+
bounds
|
|
105
|
+
onResize={(contentRect) => {
|
|
106
|
+
setSearchFilterHeight?.(contentRect.bounds?.height!);
|
|
107
|
+
}}
|
|
95
108
|
>
|
|
96
|
-
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
{({ measureRef }) => (
|
|
110
|
+
<div ref={measureRef}>
|
|
111
|
+
<div style={{ display: searchVisible ? "block" : "none" }}>
|
|
112
|
+
<Form
|
|
113
|
+
className="p-3 rounded shadow-md bg-gray-50"
|
|
114
|
+
form={form}
|
|
115
|
+
onFinish={onFinish}
|
|
116
|
+
initialValues={{ offset, limit }}
|
|
117
|
+
>
|
|
118
|
+
{rows}
|
|
119
|
+
{advancedFilter && <SearchParams onLimitChange={onLimitChange} />}
|
|
120
|
+
<SearchBottomBar
|
|
121
|
+
advancedFilter={advancedFilter}
|
|
122
|
+
onAdvancedFilterToggle={() => {
|
|
123
|
+
setAdvancedFilter(!advancedFilter);
|
|
124
|
+
}}
|
|
125
|
+
onClear={() => {
|
|
126
|
+
form.resetFields();
|
|
127
|
+
onClear();
|
|
128
|
+
}}
|
|
129
|
+
isSearching={isSearching}
|
|
130
|
+
/>
|
|
131
|
+
</Form>
|
|
132
|
+
{searchError && (
|
|
133
|
+
<Alert
|
|
134
|
+
className="mt-10"
|
|
135
|
+
message={searchError}
|
|
136
|
+
type="error"
|
|
137
|
+
banner
|
|
138
|
+
/>
|
|
139
|
+
)}
|
|
140
|
+
<div className="pb-5" />
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
)}
|
|
144
|
+
</Measure>
|
|
110
145
|
);
|
|
111
146
|
}
|
|
112
147
|
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
declare const getParamsForFields: (values: any, fields: any) => any[];
|
|
2
|
-
declare const groupDateTimeValuesIfNeeded: (values: any) => any;
|
|
3
|
-
declare const removeUndefinedFields: (values: any) => any;
|
|
4
|
-
export { removeUndefinedFields, groupDateTimeValuesIfNeeded, getParamsForFields, };
|
|
5
|
-
//# sourceMappingURL=searchFilterHelper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchFilterHelper.d.ts","sourceRoot":"","sources":["searchFilterHelper.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,kBAAkB,WAAY,GAAG,UAAU,GAAG,UAoBnD,CAAC;AA+DF,QAAA,MAAM,2BAA2B,WAAY,GAAG,QAqC/C,CAAC;AAuBF,QAAA,MAAM,qBAAqB,WAAY,GAAG,QAUzC,CAAC;AAEF,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,kBAAkB,GACnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Dashboard.types.d.ts","sourceRoot":"","sources":["Dashboard.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,oBAAY,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,YAAY,CAAC,EAAE,WAAW,CAAC;CAC5B,CAAC"}
|