@gisce/react-ooui 1.1.2-rc.3 → 1.1.2-rc.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.
@@ -1 +1 @@
1
- {"version":3,"file":"GraphActionView.d.ts","sourceRoot":"","sources":["GraphActionView.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAO7C,oBAAY,oBAAoB,GAAG;IACjC,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,UAAW,oBAAoB,uBAiH1D,CAAC"}
1
+ {"version":3,"file":"GraphActionView.d.ts","sourceRoot":"","sources":["GraphActionView.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAO7C,oBAAY,oBAAoB,GAAG;IACjC,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,GAAG,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;IACZ,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,UAAW,oBAAoB,uBA2H1D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"TreeActionView.d.ts","sourceRoot":"","sources":["TreeActionView.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAKnD,oBAAY,mBAAmB,GAAG;IAChC,QA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AAE,IAAI,KAAK,IAAI,CAAC;IACrC,cAAc,EAAE,IAAI,EAAE,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,mBAAmB,uBAsDxD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardTree.d.ts","sourceRoot":"","sources":["DashboardTree.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOnD,aAAK,gBAAgB,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,aAAK,KAAK,GAAG;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC/C,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,GAAG,CAAC;CACrB,CAAC;AAEF,iBAAS,aAAa,CAAC,KAAK,EAAE,KAAK,sBAwOlC;AAED,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"DashboardTree.d.ts","sourceRoot":"","sources":["DashboardTree.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAY,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQnD,aAAK,gBAAgB,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,aAAK,KAAK,GAAG;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC/C,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,GAAG,CAAC;CACrB,CAAC;AAEF,iBAAS,aAAa,CAAC,KAAK,EAAE,KAAK,sBA6MlC;AAED,eAAe,aAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GraphChart.d.ts","sourceRoot":"","sources":["GraphChart.tsx"],"names":[],"mappings":";AAaA,oBAAY,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,eAAe,gBA6ChD,CAAC"}
1
+ {"version":3,"file":"GraphChart.d.ts","sourceRoot":"","sources":["GraphChart.tsx"],"names":[],"mappings":";AAaA,oBAAY,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,UAAU,UAAW,eAAe,gBAgDhD,CAAC"}
@@ -14,5 +14,6 @@ export declare const useGraphData: (opts: GraphDataOpts) => {
14
14
  error: any;
15
15
  type: GraphType;
16
16
  values: any;
17
+ evaluatedEntries: any[] | undefined;
17
18
  };
18
19
  //# sourceMappingURL=useGraphData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useGraphData.d.ts","sourceRoot":"","sources":["useGraphData.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,SAAS,EACV,MAAM,aAAa,CAAC;AAOrB,oBAAY,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,aAAa,GAAG,kBAAkB,GAAG;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,aAAa;;;;;CAsE/C,CAAC"}
1
+ {"version":3,"file":"useGraphData.d.ts","sourceRoot":"","sources":["useGraphData.tsx"],"names":[],"mappings":"AACA,OAAO,EAKL,SAAS,EACV,MAAM,aAAa,CAAC;AAOrB,oBAAY,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,aAAa,GAAG,kBAAkB,GAAG;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,aAAa;;;;;;CA8E/C,CAAC"}
@@ -13,6 +13,7 @@ declare type Props = {
13
13
  setSearchFilterHeight?: (height: number) => void;
14
14
  searchError?: string;
15
15
  searchValues?: any;
16
+ showLimitOptions?: boolean;
16
17
  };
17
18
  declare function SearchFilter(props: Props): JSX.Element;
18
19
  export default SearchFilter;
@@ -1 +1 @@
1
- {"version":3,"file":"SearchFilter.d.ts","sourceRoot":"","sources":["SearchFilter.tsx"],"names":[],"mappings":";AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC,aAAK,KAAK,GAAG;IACX,MAAM,EAAE,GAAG,CAAC;IACZ,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,MAAM,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;AAED,eAAe,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "1.1.2-rc.3",
3
+ "version": "1.1.2-rc.4",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
@@ -175,7 +175,7 @@ export const getUniqueFieldsForParams = (params: any[]) => {
175
175
  };
176
176
 
177
177
  export const mergeParams = (searchParams: any[], domainParams: any[]) => {
178
- const finalParams = searchParams;
178
+ const finalParams = [...searchParams];
179
179
  const uniqueParams = getUniqueFieldsForParams(searchParams);
180
180
 
181
181
  domainParams.forEach((element) => {
@@ -75,7 +75,6 @@ export const useSearch = (opts: UseSearchOpts) => {
75
75
  const internalLimit = useRef(limit || DEFAULT_SEARCH_LIMIT);
76
76
 
77
77
  const originalResults = useRef<any[]>([]);
78
- const actionDomain = useRef<any>([]);
79
78
 
80
79
  const setResults = useCallback((results: any) => {
81
80
  setResultsActionView?.([...results]);
@@ -94,7 +93,7 @@ export const useSearch = (opts: UseSearchOpts) => {
94
93
  model,
95
94
  payload: nameSearch,
96
95
  limit: internalLimit.current,
97
- attrs: actionDomain.current.length > 0 ? actionDomain.current : domain,
96
+ attrs: domain,
98
97
  context,
99
98
  });
100
99
 
@@ -163,117 +162,119 @@ export const useSearch = (opts: UseSearchOpts) => {
163
162
  sorter,
164
163
  setCurrentItemIndex,
165
164
  setActionViewTotalItems,
166
- actionDomain,
167
165
  ]);
168
166
 
169
- const searchResults = useCallback(async () => {
170
- const domainParams =
171
- actionDomain.current.length > 0 ? actionDomain.current : domain;
167
+ const searchResults = useCallback(
168
+ async (opts?: { params: any; newOffset: number }) => {
169
+ const { params, newOffset } = opts || {};
172
170
 
173
- const mergedParams = mergeParams(searchParams, domainParams);
174
- const { colors } = getTree(treeView!);
171
+ const mergedParams = mergeParams(params || searchParams, domain);
172
+ const { colors } = getTree(treeView!);
175
173
 
176
- const { totalItems, results, attrsEvaluated } =
177
- await ConnectionProvider.getHandler().searchForTree({
178
- params: mergedParams,
179
- limit: internalLimit.current,
180
- offset,
181
- model,
182
- fields: treeView!.field_parent
183
- ? { ...treeView!.fields, [treeView!.field_parent]: {} }
184
- : treeView!.fields,
185
- context,
186
- attrs: colors && { colors },
187
- });
188
- setColorsForResults(getColorMap(attrsEvaluated));
174
+ const { totalItems, results, attrsEvaluated } =
175
+ await ConnectionProvider.getHandler().searchForTree({
176
+ params: mergedParams,
177
+ limit: internalLimit.current,
178
+ offset: newOffset || offset,
179
+ model,
180
+ fields: treeView!.field_parent
181
+ ? { ...treeView!.fields, [treeView!.field_parent]: {} }
182
+ : treeView!.fields,
183
+ context,
184
+ attrs: colors && { colors },
185
+ });
186
+ setColorsForResults(getColorMap(attrsEvaluated));
189
187
 
190
- originalResults.current = [...results];
188
+ originalResults.current = [...results];
191
189
 
192
- const resultsSorted =
193
- sorter !== undefined
194
- ? sortResults({
195
- resultsToSort: results,
196
- sorter: sorter,
197
- fields: { ...treeView!.fields, ...formView!.fields },
198
- })
199
- : [...originalResults.current];
190
+ const resultsSorted =
191
+ sorter !== undefined
192
+ ? sortResults({
193
+ resultsToSort: results,
194
+ sorter: sorter,
195
+ fields: { ...treeView!.fields, ...formView!.fields },
196
+ })
197
+ : [...originalResults.current];
200
198
 
201
- setResults(resultsSorted);
199
+ setResults(resultsSorted);
202
200
 
203
- if (resultsActionView && resultsSorted.length > 0) {
204
- const newCurrentItemIndex = resultsSorted.findIndex(
205
- (item) => currentId === item.id
206
- );
201
+ if (resultsActionView && resultsSorted.length > 0) {
202
+ const newCurrentItemIndex = resultsSorted.findIndex(
203
+ (item) => currentId === item.id
204
+ );
207
205
 
208
- if (newCurrentItemIndex === -1) {
209
- setCurrentItemIndex?.(0);
206
+ if (newCurrentItemIndex === -1) {
207
+ setCurrentItemIndex?.(0);
208
+ } else {
209
+ setCurrentItemIndex?.(newCurrentItemIndex);
210
+ }
210
211
  } else {
211
- setCurrentItemIndex?.(newCurrentItemIndex);
212
+ setCurrentItemIndex?.(undefined);
212
213
  }
213
- } else {
214
- setCurrentItemIndex?.(undefined);
215
- }
216
214
 
217
- const totalItemsValue = await totalItems;
215
+ const totalItemsValue = await totalItems;
218
216
 
219
- setTotalItems(totalItemsValue);
220
- setActionViewTotalItems?.(totalItemsValue);
221
- }, [
222
- setCurrentItemIndex,
223
- resultsActionView,
224
- setResults,
225
- currentId,
226
- model,
227
- context,
228
- domain,
229
- treeView,
230
- formView,
231
- sorter,
232
- setActionViewTotalItems,
233
- limit,
234
- offset,
235
- actionDomain,
236
- searchParams,
237
- ]);
217
+ setTotalItems(totalItemsValue);
218
+ setActionViewTotalItems?.(totalItemsValue);
219
+ },
220
+ [
221
+ setCurrentItemIndex,
222
+ resultsActionView,
223
+ setResults,
224
+ currentId,
225
+ model,
226
+ context,
227
+ domain,
228
+ treeView,
229
+ formView,
230
+ sorter,
231
+ setActionViewTotalItems,
232
+ limit,
233
+ offset,
234
+ searchParams,
235
+ ]
236
+ );
238
237
 
239
- const fetchResults = useCallback(async () => {
240
- try {
241
- setTableRefreshing(true);
242
- setTreeIsLoading?.(true);
243
- if (nameSearch && !searchNameGetDoneRef.current) {
244
- await searchByNameSearch();
245
- } else {
246
- await searchResults();
238
+ const fetchResults = useCallback(
239
+ async (opts?: { params: any; newOffset: number }) => {
240
+ try {
241
+ setTableRefreshing(true);
242
+ setTreeIsLoading?.(true);
243
+ if (nameSearch && !searchNameGetDoneRef.current) {
244
+ await searchByNameSearch();
245
+ } else {
246
+ await searchResults(opts);
247
+ }
248
+ } catch (error) {
249
+ setSearchError(error.message);
250
+ } finally {
251
+ setTableRefreshing(false);
252
+ setSearchFilterLoading(false);
253
+ setTreeIsLoading?.(false);
247
254
  }
248
- } catch (error) {
249
- setSearchError(error.message);
250
- } finally {
251
- setTableRefreshing(false);
252
- setSearchFilterLoading(false);
253
- setTreeIsLoading?.(false);
254
- }
255
- }, [
256
- actionDomain,
257
- context,
258
- currentId,
259
- domain,
260
- formView,
261
- limit,
262
- model,
263
- nameSearch,
264
- offset,
265
- resultsActionView,
266
- searchNameGetDoneRef,
267
- setActionViewTotalItems,
268
- setCurrentItemIndex,
269
- setResults,
270
- setSearchError,
271
- setSearchFilterLoading,
272
- setTableRefreshing,
273
- setTreeIsLoading,
274
- sorter,
275
- treeView,
276
- ]);
255
+ },
256
+ [
257
+ context,
258
+ currentId,
259
+ domain,
260
+ formView,
261
+ limit,
262
+ model,
263
+ nameSearch,
264
+ offset,
265
+ resultsActionView,
266
+ searchNameGetDoneRef,
267
+ setActionViewTotalItems,
268
+ setCurrentItemIndex,
269
+ setResults,
270
+ setSearchError,
271
+ setSearchFilterLoading,
272
+ setTableRefreshing,
273
+ setTreeIsLoading,
274
+ sorter,
275
+ treeView,
276
+ ]
277
+ );
277
278
 
278
279
  const changeSort = useCallback(
279
280
  (newSorter: any) => {
@@ -292,22 +293,19 @@ export const useSearch = (opts: UseSearchOpts) => {
292
293
  );
293
294
 
294
295
  const submit = useCallback(
295
- ({
296
- params: newParams,
297
- limit: newLimit,
298
- offset: newOffset,
299
- searchValues,
300
- }: {
296
+ (opts: {
301
297
  params: any;
302
298
  limit: number;
303
299
  offset: number;
304
300
  searchValues: any;
305
301
  }) => {
302
+ const { params, searchValues, limit: newLimit, offset: newOffset } = opts;
303
+
306
304
  if (tableRefreshing) return;
307
305
  setSearchTreeNameSearch?.(undefined);
308
306
  setSelectedRowItems?.([]);
309
307
  setSearchValues?.(searchValues);
310
- setSearchParams?.(newParams);
308
+ setSearchParams?.(params);
311
309
  setSearchVisible?.(false);
312
310
  setSearchFilterLoading(true);
313
311
  setSearchError(undefined);
@@ -315,7 +313,10 @@ export const useSearch = (opts: UseSearchOpts) => {
315
313
  internalLimit.current = newLimit;
316
314
  if (newLimit) setLimit?.(newLimit);
317
315
  if (newOffset) setOffset(newOffset);
318
- fetchResults();
316
+ fetchResults({
317
+ params,
318
+ newOffset,
319
+ });
319
320
  },
320
321
  [
321
322
  tableRefreshing,
@@ -1,7 +1,7 @@
1
1
  import GraphActionBar from "@/actionbar/GraphActionBar";
2
2
  import TitleHeader from "@/ui/TitleHeader";
3
3
  import { Graph } from "@/widgets/views/Graph/Graph";
4
- import React, { useContext, useRef } from "react";
4
+ import React, { useContext, useEffect, useRef, useState } from "react";
5
5
  import {
6
6
  ActionViewContext,
7
7
  ActionViewContextType,
@@ -11,7 +11,7 @@ import { mergeSearchFields } from "@/helpers/formHelper";
11
11
  import { useSearch } from "@/hooks/useSearch";
12
12
  import SearchFilter from "@/widgets/views/searchFilter/SearchFilter";
13
13
  import { Spin } from "antd";
14
- import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
14
+ import { mergeParams } from "@/helpers/searchHelper";
15
15
 
16
16
  export type GraphActionViewProps = {
17
17
  viewData: any;
@@ -47,43 +47,48 @@ export const GraphActionView = (props: GraphActionViewProps) => {
47
47
  setTreeIsLoading = undefined,
48
48
  limit,
49
49
  setLimit,
50
+ searchParams,
51
+ searchValues,
52
+ setSearchValues,
53
+ currentView,
50
54
  } = actionViewContext || {};
51
55
 
52
- const { searchParams, searchValues, setSearchValues } = useContext(
53
- ActionViewContext
54
- ) as ActionViewContextType;
55
- const { t } = useContext(LocaleContext) as LocaleContextType;
56
+ const [applyLimit, setApplyLimit] = useState(true);
56
57
 
57
- const {
58
- submit,
59
- clear,
60
- searchFilterLoading,
61
- searchError,
62
- offset,
63
- tableRefreshing,
64
- } = useSearch({
65
- model,
66
- setSearchTreeNameSearch,
67
- setSelectedRowItems,
68
- searchParams,
69
- setSearchValues,
70
- setSearchParams,
71
- setSearchVisible,
72
- setTreeIsLoading,
73
- context,
74
- formView: formView!,
75
- treeView: treeView!,
76
- sorter,
77
- setSorter,
78
- setCurrentItemIndex,
79
- setResultsActionView,
80
- resultsActionView,
81
- domain,
82
- currentId,
83
- setActionViewTotalItems,
84
- limit,
85
- setLimit,
86
- });
58
+ useEffect(() => {
59
+ (graphRef.current as any)?.refresh();
60
+ }, [searchParams]);
61
+
62
+ useEffect(() => {
63
+ if (viewData.view_id !== currentView.view_id) {
64
+ setApplyLimit(true);
65
+ }
66
+ }, [currentView]);
67
+
68
+ const { clear, searchFilterLoading, searchError, offset, tableRefreshing } =
69
+ useSearch({
70
+ model,
71
+ setSearchTreeNameSearch,
72
+ setSelectedRowItems,
73
+ searchParams,
74
+ setSearchValues,
75
+ setSearchParams,
76
+ setSearchVisible,
77
+ setTreeIsLoading,
78
+ context,
79
+ formView: formView!,
80
+ treeView: treeView!,
81
+ sorter,
82
+ setSorter,
83
+ setCurrentItemIndex,
84
+ setResultsActionView,
85
+ resultsActionView,
86
+ domain,
87
+ currentId,
88
+ setActionViewTotalItems,
89
+ limit,
90
+ setLimit,
91
+ });
87
92
 
88
93
  if (!visible) {
89
94
  return null;
@@ -112,27 +117,32 @@ export const GraphActionView = (props: GraphActionViewProps) => {
112
117
  onClear={clear}
113
118
  offset={offset}
114
119
  isSearching={searchFilterLoading}
115
- onSubmit={submit}
120
+ onSubmit={(opts: {
121
+ params: any;
122
+ limit: number;
123
+ offset: number;
124
+ searchValues: any;
125
+ }) => {
126
+ setApplyLimit(false);
127
+ setSearchParams?.(opts.params);
128
+ setSearchVisible?.(false);
129
+ }}
116
130
  searchError={searchError}
117
131
  searchVisible={searchVisible}
118
132
  searchValues={searchValues}
133
+ showLimitOptions={false}
119
134
  />
120
135
  {tableRefreshing ? (
121
136
  <Spin />
122
137
  ) : (
123
- <>
124
- <p style={{ textAlign: "right" }}>
125
- {`${t("totalRegisters")} ${resultsActionView?.length}`}
126
- </p>
127
- <Graph
128
- ref={graphRef}
129
- view_id={viewData.view_id}
130
- model={model}
131
- context={context}
132
- domain={searchParams || domain}
133
- limit={limit}
134
- />
135
- </>
138
+ <Graph
139
+ ref={graphRef}
140
+ view_id={viewData.view_id}
141
+ model={model}
142
+ context={context}
143
+ domain={mergeParams(searchParams || [], domain)}
144
+ limit={applyLimit ? limit : undefined}
145
+ />
136
146
  )}
137
147
  </>
138
148
  );
@@ -36,7 +36,6 @@ export const TreeActionView = (props: TreeActionViewProps) => {
36
36
  setCurrentView,
37
37
  availableViews,
38
38
  searchTreeNameSearch,
39
- limit,
40
39
  } = props;
41
40
 
42
41
  if (!visible) {
@@ -6,6 +6,7 @@ import { FormView, TreeView } from "@/types/index";
6
6
  import ConnectionProvider from "@/ConnectionProvider";
7
7
 
8
8
  import { getColorMap, getTree, sortResults } from "@/helpers/treeHelper";
9
+ import { mergeParams } from "@/helpers/searchHelper";
9
10
 
10
11
  const DEFAULT_SEARCH_LIMIT = 80;
11
12
 
@@ -67,33 +68,6 @@ function DashboardTree(props: Props) {
67
68
  setOffset((page - 1) * limitRef.current!);
68
69
  };
69
70
 
70
- const getUniqueFieldsForParams = (params: any[]) => {
71
- const uniqueFields: any = {};
72
-
73
- params.forEach((param) => {
74
- if (Array.isArray(param) && param[0]) {
75
- uniqueFields[param[0]] = true;
76
- }
77
- });
78
-
79
- return Object.keys(uniqueFields);
80
- };
81
-
82
- const mergeParams = (searchParams: any[], domainParams: any[]) => {
83
- const finalParams = searchParams;
84
- const uniqueParams = getUniqueFieldsForParams(searchParams);
85
-
86
- domainParams.forEach((element) => {
87
- if (Array.isArray(element) && element[0]) {
88
- if (!uniqueParams.includes(element[0])) {
89
- finalParams.push(element);
90
- }
91
- }
92
- });
93
-
94
- return finalParams;
95
- };
96
-
97
71
  const searchResults = async () => {
98
72
  const domainParams =
99
73
  actionDomain.current.length > 0 ? actionDomain.current : domain;
@@ -23,7 +23,7 @@ export const GraphChart = (props: GraphChartProps) => {
23
23
  const { model, domain, context, xml, limit } = props;
24
24
  const { t } = useContext(LocaleContext) as LocaleContextType;
25
25
 
26
- const { error, loading, values, type } = useGraphData({
26
+ const { error, loading, values, type, evaluatedEntries } = useGraphData({
27
27
  model,
28
28
  xml,
29
29
  limit,
@@ -54,6 +54,9 @@ export const GraphChart = (props: GraphChartProps) => {
54
54
 
55
55
  return (
56
56
  <div style={{ padding: "1rem" }}>
57
+ <p style={{ textAlign: "right" }}>
58
+ {`${t("totalRegisters")} ${evaluatedEntries?.length}`}
59
+ </p>
57
60
  <Chart
58
61
  {...getGraphProps({
59
62
  type,
@@ -36,6 +36,7 @@ export const useGraphData = (opts: GraphDataOpts) => {
36
36
  const [loading, setLoading] = useState(false);
37
37
  const [error, setError] = useState<any>();
38
38
  const [processedValues, setProcessedValues] = useState<any>();
39
+ const [evaluatedEntries, setEvaluatedEntries] = useState<any[]>();
39
40
  const [type, setType] = useState<GraphType>("line");
40
41
 
41
42
  useDeepCompareEffect(() => {
@@ -74,6 +75,7 @@ export const useGraphData = (opts: GraphDataOpts) => {
74
75
  return;
75
76
  }
76
77
 
78
+ setEvaluatedEntries(values);
77
79
  const _processedValues = processGraphData({
78
80
  ooui,
79
81
  values,
@@ -93,7 +95,13 @@ export const useGraphData = (opts: GraphDataOpts) => {
93
95
  })();
94
96
  }, [xml, model, limit, context, domain]);
95
97
 
96
- return { loading, error, type, values: processedValues };
98
+ return {
99
+ loading,
100
+ error,
101
+ type,
102
+ values: processedValues,
103
+ evaluatedEntries,
104
+ };
97
105
  };
98
106
 
99
107
  async function getFieldsForModel({
@@ -29,6 +29,7 @@ type Props = {
29
29
  setSearchFilterHeight?: (height: number) => void;
30
30
  searchError?: string;
31
31
  searchValues?: any;
32
+ showLimitOptions?: boolean;
32
33
  };
33
34
 
34
35
  function SearchFilter(props: Props) {
@@ -45,6 +46,7 @@ function SearchFilter(props: Props) {
45
46
  setSearchFilterHeight,
46
47
  searchError,
47
48
  searchValues,
49
+ showLimitOptions = true,
48
50
  } = props;
49
51
 
50
52
  const [simpleSearchFields, setSimpleSearchFields] = useState<Container>();
@@ -116,7 +118,9 @@ function SearchFilter(props: Props) {
116
118
  initialValues={{ offset, limit }}
117
119
  >
118
120
  {rows}
119
- {advancedFilter && <SearchParams onLimitChange={onLimitChange} />}
121
+ {advancedFilter && showLimitOptions && (
122
+ <SearchParams onLimitChange={onLimitChange} />
123
+ )}
120
124
  <SearchBottomBar
121
125
  advancedFilter={advancedFilter}
122
126
  onAdvancedFilterToggle={() => {