@gisce/react-ooui 1.0.20 → 1.1.1
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 +4915 -4469
- 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/containers/Container.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/Form.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/stories/forms/ActivacioContracteForm.stories.tsx +25 -0
- package/src/stories/mocks/index.ts +2 -0
- package/src/stories/mocks/models/activacioContracte.ts +112 -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/Container.tsx +2 -4
- 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/Form.tsx +0 -1
- 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
package/src/views/ActionView.tsx
CHANGED
|
@@ -9,15 +9,18 @@ import React, {
|
|
|
9
9
|
|
|
10
10
|
import { Spin } from "antd";
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
DashboardView,
|
|
14
|
+
FormView,
|
|
15
|
+
GraphView,
|
|
16
|
+
InitialViewData,
|
|
17
|
+
TreeView,
|
|
18
|
+
View,
|
|
19
|
+
ViewType,
|
|
20
|
+
} from "@/types/index";
|
|
13
21
|
import ConnectionProvider from "@/ConnectionProvider";
|
|
14
|
-
import Form from "@/widgets/views/Form";
|
|
15
|
-
import SearchTree from "@/widgets/views/SearchTree";
|
|
16
22
|
|
|
17
23
|
import ActionViewProvider from "@/context/ActionViewContext";
|
|
18
|
-
import TitleHeader from "@/ui/TitleHeader";
|
|
19
|
-
import FormActionBar from "@/actionbar/FormActionBar";
|
|
20
|
-
import TreeActionBar from "@/actionbar/TreeActionBar";
|
|
21
24
|
import {
|
|
22
25
|
TabManagerContext,
|
|
23
26
|
TabManagerContextType,
|
|
@@ -26,20 +29,20 @@ import { useHotkeys } from "react-hotkeys-hook";
|
|
|
26
29
|
import { GoToResourceModal } from "@/ui/GoToResourceModal";
|
|
27
30
|
import showInfo from "@/ui/InfoDialog";
|
|
28
31
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import
|
|
32
|
-
import
|
|
32
|
+
import { GraphActionView } from "@/views/actionViews/GraphActionView";
|
|
33
|
+
import { FormActionView } from "./actionViews/FormActionView";
|
|
34
|
+
import { TreeActionView } from "./actionViews/TreeActionView";
|
|
35
|
+
import { DashboardActionView } from "./actionViews/DashboardActionView";
|
|
33
36
|
|
|
34
37
|
type Props = {
|
|
35
38
|
domain: any;
|
|
36
39
|
context: any;
|
|
37
40
|
model: string;
|
|
38
|
-
views: Array<
|
|
41
|
+
views: Array<[number, ViewType]>;
|
|
39
42
|
title: string;
|
|
40
43
|
tabKey: string;
|
|
41
44
|
setCanWeClose: (f: any) => void;
|
|
42
|
-
initialView:
|
|
45
|
+
initialView: InitialViewData;
|
|
43
46
|
formDefaultValues?: any;
|
|
44
47
|
formForcedValues?: any;
|
|
45
48
|
res_id?: number | boolean;
|
|
@@ -48,11 +51,6 @@ type Props = {
|
|
|
48
51
|
treeExpandable?: boolean;
|
|
49
52
|
};
|
|
50
53
|
|
|
51
|
-
export type View = {
|
|
52
|
-
id: number;
|
|
53
|
-
type: ViewType;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
54
|
function ActionView(props: Props, ref: any) {
|
|
57
55
|
const {
|
|
58
56
|
domain,
|
|
@@ -71,44 +69,36 @@ function ActionView(props: Props, ref: any) {
|
|
|
71
69
|
treeExpandable = false,
|
|
72
70
|
} = props;
|
|
73
71
|
const [currentView, setCurrentViewInternal] = useState<View>();
|
|
72
|
+
|
|
74
73
|
const [availableViews, setAvailableViews] = useState<View[]>([]);
|
|
75
74
|
|
|
76
|
-
const [treeView, setTreeView] = useState<TreeView>();
|
|
77
|
-
const [formView, setFormView] = useState<FormView>();
|
|
78
|
-
const [dashboardData, setDashboardData] = useState<DashboardProps>();
|
|
79
75
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
|
80
76
|
const res_id_parsed: number | undefined = res_id
|
|
81
77
|
? (res_id as number)
|
|
82
78
|
: undefined;
|
|
83
79
|
|
|
84
|
-
const [currentId, setCurrentIdInternal] =
|
|
85
|
-
res_id_parsed
|
|
86
|
-
);
|
|
80
|
+
const [currentId, setCurrentIdInternal] =
|
|
81
|
+
useState<number | undefined>(res_id_parsed);
|
|
87
82
|
const [selectedRowItems, setSelectedRowItems] = useState<any[]>([]);
|
|
88
83
|
const [currentItemIndex, setCurrentItemIndex] = useState<number>();
|
|
89
84
|
const [results, setResults] = useState<any>([]);
|
|
90
|
-
const [toolbar, setToolbar] = useState<any>();
|
|
91
85
|
const [sorter, setSorter] = useState<any>();
|
|
92
86
|
const [totalItems, setTotalItems] = useState<number>(0);
|
|
93
|
-
const [gtResourceModalVisible, setGtResourceModalVisible] =
|
|
94
|
-
false
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
false
|
|
98
|
-
);
|
|
87
|
+
const [gtResourceModalVisible, setGtResourceModalVisible] =
|
|
88
|
+
useState<boolean>(false);
|
|
89
|
+
const [searchingForResourceId, setSearchingForResourceId] =
|
|
90
|
+
useState<boolean>(false);
|
|
99
91
|
const [searchTreeNameSearch, setSearchTreeNameSearch] = useState<string>();
|
|
100
92
|
|
|
101
93
|
const { t } = useContext(LocaleContext) as LocaleContextType;
|
|
102
94
|
|
|
103
95
|
const formRef = useRef();
|
|
104
96
|
const searchTreeRef = useRef();
|
|
105
|
-
const dashboardRef = useRef();
|
|
106
97
|
|
|
107
98
|
const tabManagerContext = useContext(
|
|
108
99
|
TabManagerContext
|
|
109
100
|
) as TabManagerContextType;
|
|
110
101
|
const {
|
|
111
|
-
openShortcut,
|
|
112
102
|
setCurrentView: setCurrentViewTabContext,
|
|
113
103
|
setCurrentId: setCurrentIdTabContext,
|
|
114
104
|
tabs,
|
|
@@ -142,13 +132,32 @@ function ActionView(props: Props, ref: any) {
|
|
|
142
132
|
const fetchData = async () => {
|
|
143
133
|
setIsLoading(true);
|
|
144
134
|
|
|
145
|
-
const
|
|
135
|
+
const viewDataRetrieved: View[] = [];
|
|
146
136
|
|
|
147
137
|
for (const viewArray of views) {
|
|
148
138
|
const [id, viewType] = viewArray;
|
|
149
139
|
|
|
140
|
+
let viewInfo;
|
|
141
|
+
|
|
150
142
|
try {
|
|
151
|
-
if (viewType
|
|
143
|
+
if (viewType !== "dashboard") {
|
|
144
|
+
viewInfo = await ConnectionProvider.getHandler().getView({
|
|
145
|
+
model,
|
|
146
|
+
type: viewType,
|
|
147
|
+
id,
|
|
148
|
+
context,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
} catch (err) {
|
|
152
|
+
console.error(
|
|
153
|
+
`${model} - ${viewType} - ${JSON.stringify(err, null, 2)}`
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
switch (viewType) {
|
|
160
|
+
case "dashboard": {
|
|
152
161
|
const formView = views.find((view: any[]) => {
|
|
153
162
|
const [, type] = view;
|
|
154
163
|
return type === "form";
|
|
@@ -168,56 +177,70 @@ function ActionView(props: Props, ref: any) {
|
|
|
168
177
|
};
|
|
169
178
|
}
|
|
170
179
|
|
|
171
|
-
|
|
180
|
+
viewDataRetrieved.push({
|
|
181
|
+
type: "dashboard",
|
|
172
182
|
id: context["active_id"],
|
|
173
183
|
model,
|
|
174
184
|
context,
|
|
175
185
|
configAction,
|
|
176
186
|
});
|
|
177
|
-
|
|
187
|
+
break;
|
|
178
188
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
context,
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
if (viewType === "tree") {
|
|
188
|
-
setTreeView({ ...viewData, isExpandable: treeExpandable });
|
|
189
|
-
} else if (viewType === "form") {
|
|
190
|
-
setFormView(viewData);
|
|
191
|
-
setToolbar((viewData as any)?.toolbar);
|
|
189
|
+
case "form": {
|
|
190
|
+
viewDataRetrieved.push({
|
|
191
|
+
...(viewInfo as FormView),
|
|
192
|
+
});
|
|
193
|
+
break;
|
|
192
194
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
case "tree": {
|
|
196
|
+
viewDataRetrieved.push({
|
|
197
|
+
...(viewInfo as TreeView),
|
|
198
|
+
isExpandable: treeExpandable,
|
|
199
|
+
});
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
case "graph": {
|
|
203
|
+
viewDataRetrieved.push({
|
|
204
|
+
...(viewInfo as GraphView),
|
|
205
|
+
});
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
default:
|
|
209
|
+
break;
|
|
199
210
|
}
|
|
200
211
|
}
|
|
201
212
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
213
|
+
if (!initialView && viewDataRetrieved.find((v) => v.type === "tree")) {
|
|
214
|
+
const treeView: TreeView = viewDataRetrieved.find(
|
|
215
|
+
(v) => v.type === "tree"
|
|
216
|
+
) as TreeView;
|
|
217
|
+
setCurrentView(treeView);
|
|
205
218
|
} else if (!initialView) {
|
|
206
|
-
|
|
219
|
+
const formView: TreeView = viewDataRetrieved.find(
|
|
220
|
+
(v) => v.type === "form"
|
|
221
|
+
) as TreeView;
|
|
222
|
+
|
|
223
|
+
setCurrentView(formView);
|
|
207
224
|
} else {
|
|
208
|
-
|
|
225
|
+
const view = viewDataRetrieved.find(
|
|
226
|
+
(v) => v.type === initialView.type && v.view_id === initialView.id
|
|
227
|
+
);
|
|
228
|
+
setCurrentView(view);
|
|
209
229
|
}
|
|
210
230
|
|
|
211
|
-
setAvailableViews(
|
|
231
|
+
setAvailableViews(viewDataRetrieved);
|
|
212
232
|
setIsLoading(false);
|
|
213
233
|
};
|
|
214
234
|
|
|
215
235
|
setCanWeClose({ tabKey, canWeClose });
|
|
216
236
|
|
|
217
237
|
useEffect(() => {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
238
|
+
const treeView = availableViews.find((v) => v.type === "tree") as TreeView;
|
|
239
|
+
const initialViewWithData: View = availableViews.find(
|
|
240
|
+
(v) => v.type === initialView.type && v.view_id === initialView.id
|
|
241
|
+
) as View;
|
|
242
|
+
|
|
243
|
+
setCurrentView(initialViewWithData || treeView);
|
|
221
244
|
if (!res_id) {
|
|
222
245
|
setCurrentId(undefined);
|
|
223
246
|
setCurrentItemIndex(undefined);
|
|
@@ -300,7 +323,7 @@ function ActionView(props: Props, ref: any) {
|
|
|
300
323
|
views,
|
|
301
324
|
title,
|
|
302
325
|
target: "current",
|
|
303
|
-
initialView: { id: viewForm[0]
|
|
326
|
+
initialView: { id: viewForm?.[0]!, type: "form" },
|
|
304
327
|
action_id,
|
|
305
328
|
action_type,
|
|
306
329
|
res_id: id,
|
|
@@ -308,56 +331,86 @@ function ActionView(props: Props, ref: any) {
|
|
|
308
331
|
}
|
|
309
332
|
|
|
310
333
|
function content() {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
334
|
+
return availableViews.map((view) => {
|
|
335
|
+
switch (view.type) {
|
|
336
|
+
case "form": {
|
|
337
|
+
return (
|
|
338
|
+
<FormActionView
|
|
339
|
+
key={`${view.type}-${view.view_id}`}
|
|
340
|
+
formRef={formRef}
|
|
341
|
+
currentId={currentId}
|
|
342
|
+
visible={
|
|
343
|
+
currentView!.type === view.type &&
|
|
344
|
+
currentView!.view_id === view.view_id
|
|
345
|
+
}
|
|
346
|
+
formView={view as FormView}
|
|
347
|
+
model={model}
|
|
348
|
+
context={context}
|
|
349
|
+
domain={domain}
|
|
350
|
+
defaultValues={formDefaultValues}
|
|
351
|
+
forcedValues={formForcedValues}
|
|
352
|
+
results={results}
|
|
353
|
+
setResults={setResults}
|
|
354
|
+
setCurrentItemIndex={setCurrentItemIndex}
|
|
355
|
+
/>
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
case "tree": {
|
|
359
|
+
return (
|
|
360
|
+
<TreeActionView
|
|
361
|
+
key={`${view.type}-${view.view_id}`}
|
|
362
|
+
visible={
|
|
363
|
+
currentView!.type === view.type &&
|
|
364
|
+
currentView!.view_id === view.view_id
|
|
365
|
+
}
|
|
366
|
+
model={model}
|
|
367
|
+
context={context}
|
|
368
|
+
domain={domain}
|
|
369
|
+
formView={
|
|
370
|
+
availableViews.find((v) => v.type === "form") as FormView
|
|
371
|
+
}
|
|
372
|
+
treeView={view as TreeView}
|
|
373
|
+
searchTreeRef={searchTreeRef}
|
|
374
|
+
searchTreeNameSearch={searchTreeNameSearch}
|
|
375
|
+
availableViews={availableViews}
|
|
376
|
+
results={results}
|
|
377
|
+
setCurrentItemIndex={setCurrentItemIndex}
|
|
378
|
+
setCurrentId={setCurrentId}
|
|
379
|
+
setCurrentView={setCurrentView}
|
|
380
|
+
/>
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
case "graph": {
|
|
384
|
+
return (
|
|
385
|
+
<GraphActionView
|
|
386
|
+
key={`${view.type}-${view.view_id}`}
|
|
387
|
+
visible={
|
|
388
|
+
currentView!.type === view.type &&
|
|
389
|
+
currentView!.view_id === view.view_id
|
|
390
|
+
}
|
|
391
|
+
viewData={view as GraphView}
|
|
392
|
+
model={model}
|
|
393
|
+
context={context}
|
|
394
|
+
domain={domain}
|
|
395
|
+
treeView={
|
|
396
|
+
availableViews.find((v) => v.type === "tree") as TreeView
|
|
397
|
+
}
|
|
398
|
+
formView={
|
|
399
|
+
availableViews.find((v) => v.type === "form") as FormView
|
|
400
|
+
}
|
|
401
|
+
/>
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
case "dashboard": {
|
|
405
|
+
return (
|
|
406
|
+
<DashboardActionView
|
|
407
|
+
key={`${view.type}-${view.view_id}`}
|
|
408
|
+
dashboardData={view as DashboardView}
|
|
409
|
+
/>
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
});
|
|
361
414
|
}
|
|
362
415
|
|
|
363
416
|
function onNewClicked() {
|
|
@@ -365,64 +418,19 @@ function ActionView(props: Props, ref: any) {
|
|
|
365
418
|
(formRef.current as any).clearAndReload();
|
|
366
419
|
} else {
|
|
367
420
|
setCurrentId(undefined);
|
|
368
|
-
|
|
421
|
+
const formView: FormView = availableViews.find(
|
|
422
|
+
(v) => v.type === "form"
|
|
423
|
+
) as FormView;
|
|
424
|
+
setCurrentView(formView);
|
|
369
425
|
}
|
|
370
426
|
}
|
|
371
427
|
|
|
372
|
-
if (
|
|
373
|
-
return
|
|
428
|
+
if (isLoading) {
|
|
429
|
+
return <Spin />;
|
|
374
430
|
}
|
|
375
431
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if (!dashboardData) {
|
|
379
|
-
return null;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
return (
|
|
383
|
-
<DashboardActionProvider
|
|
384
|
-
dashboardRef={dashboardRef}
|
|
385
|
-
openAction={(action) => {
|
|
386
|
-
openShortcut(action!);
|
|
387
|
-
}}
|
|
388
|
-
>
|
|
389
|
-
<TitleHeader>
|
|
390
|
-
<DashboardActionBar />
|
|
391
|
-
</TitleHeader>
|
|
392
|
-
<Dashboard
|
|
393
|
-
ref={dashboardRef}
|
|
394
|
-
model={dashboardData!.model}
|
|
395
|
-
id={dashboardData!.id}
|
|
396
|
-
context={dashboardData?.context}
|
|
397
|
-
configAction={dashboardData?.configAction}
|
|
398
|
-
/>
|
|
399
|
-
</DashboardActionProvider>
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
return (
|
|
404
|
-
<>
|
|
405
|
-
<TitleHeader>
|
|
406
|
-
{currentView!.type === "form" ? (
|
|
407
|
-
<FormActionBar />
|
|
408
|
-
) : (
|
|
409
|
-
<TreeActionBar
|
|
410
|
-
parentContext={context}
|
|
411
|
-
treeExpandable={treeView?.isExpandable || false}
|
|
412
|
-
/>
|
|
413
|
-
)}
|
|
414
|
-
</TitleHeader>
|
|
415
|
-
{content()}
|
|
416
|
-
<GoToResourceModal
|
|
417
|
-
visible={gtResourceModalVisible}
|
|
418
|
-
onIdSubmitted={goToResourceId}
|
|
419
|
-
isSearching={searchingForResourceId}
|
|
420
|
-
onCancel={() => {
|
|
421
|
-
setGtResourceModalVisible(false);
|
|
422
|
-
}}
|
|
423
|
-
/>
|
|
424
|
-
</>
|
|
425
|
-
);
|
|
432
|
+
if (!currentView) {
|
|
433
|
+
return null;
|
|
426
434
|
}
|
|
427
435
|
|
|
428
436
|
return (
|
|
@@ -441,8 +449,6 @@ function ActionView(props: Props, ref: any) {
|
|
|
441
449
|
results={results}
|
|
442
450
|
setResults={setResults}
|
|
443
451
|
currentModel={model}
|
|
444
|
-
toolbar={toolbar}
|
|
445
|
-
setToolbar={setToolbar}
|
|
446
452
|
sorter={sorter}
|
|
447
453
|
setSorter={setSorter}
|
|
448
454
|
totalItems={totalItems}
|
|
@@ -453,7 +459,15 @@ function ActionView(props: Props, ref: any) {
|
|
|
453
459
|
searchTreeNameSearch={searchTreeNameSearch}
|
|
454
460
|
goToResourceId={goToResourceId}
|
|
455
461
|
>
|
|
456
|
-
{
|
|
462
|
+
{content()}
|
|
463
|
+
<GoToResourceModal
|
|
464
|
+
visible={gtResourceModalVisible}
|
|
465
|
+
onIdSubmitted={goToResourceId}
|
|
466
|
+
isSearching={searchingForResourceId}
|
|
467
|
+
onCancel={() => {
|
|
468
|
+
setGtResourceModalVisible(false);
|
|
469
|
+
}}
|
|
470
|
+
/>
|
|
457
471
|
</ActionViewProvider>
|
|
458
472
|
);
|
|
459
473
|
}
|
package/src/views/RootView.tsx
CHANGED
|
@@ -8,13 +8,13 @@ import { ConnectionProvider, ContentRootProvider, FormView } from "..";
|
|
|
8
8
|
import { v4 as uuidv4 } from "uuid";
|
|
9
9
|
import Welcome from "./Welcome";
|
|
10
10
|
import TabManagerProvider from "@/context/TabManagerContext";
|
|
11
|
-
import ActionView
|
|
11
|
+
import ActionView from "./ActionView";
|
|
12
12
|
import { parseContext } from "@gisce/ooui";
|
|
13
13
|
import LocaleContextProvider from "@/context/LocaleContext";
|
|
14
14
|
import { tForLang } from "@/context/LocaleContext";
|
|
15
15
|
import { ShortcutApi } from "@/ui/FavouriteButton";
|
|
16
16
|
import showErrorDialog from "@/ui/ActionErrorDialog";
|
|
17
|
-
import { ViewType } from "@/types";
|
|
17
|
+
import { InitialViewData, ViewType } from "@/types";
|
|
18
18
|
|
|
19
19
|
type RootViewProps = {
|
|
20
20
|
children: React.ReactNode;
|
|
@@ -361,9 +361,8 @@ function RootView(props: RootViewProps, ref: any) {
|
|
|
361
361
|
res_id?: number;
|
|
362
362
|
domain?: any;
|
|
363
363
|
}) {
|
|
364
|
-
const actionString =
|
|
365
|
-
model
|
|
366
|
-
);
|
|
364
|
+
const actionString =
|
|
365
|
+
await ConnectionProvider.getHandler().getActionStringForModel(model);
|
|
367
366
|
await retrieveAndOpenAction({
|
|
368
367
|
action: actionString,
|
|
369
368
|
values,
|
|
@@ -395,7 +394,7 @@ function RootView(props: RootViewProps, ref: any) {
|
|
|
395
394
|
views: Array<any>;
|
|
396
395
|
title: string;
|
|
397
396
|
target: string;
|
|
398
|
-
initialView:
|
|
397
|
+
initialView: InitialViewData;
|
|
399
398
|
action_id: number;
|
|
400
399
|
action_type: string;
|
|
401
400
|
res_id?: number | boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import DashboardActionBar from "@/actionbar/DashboardActionBar";
|
|
2
|
+
import DashboardActionProvider from "@/context/DashboardActionContext";
|
|
3
|
+
import TitleHeader from "@/ui/TitleHeader";
|
|
4
|
+
import Dashboard from "@/widgets/views/Dashboard/Dashboard";
|
|
5
|
+
import React, { useContext, useRef } from "react";
|
|
6
|
+
import {
|
|
7
|
+
TabManagerContext,
|
|
8
|
+
TabManagerContextType,
|
|
9
|
+
} from "@/context/TabManagerContext";
|
|
10
|
+
import { DashboardProps } from "@/types";
|
|
11
|
+
|
|
12
|
+
export type DashboardActionViewProps = {
|
|
13
|
+
dashboardData: DashboardProps;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const DashboardActionView = (props: DashboardActionViewProps) => {
|
|
17
|
+
const { dashboardData } = props;
|
|
18
|
+
const dashboardRef = useRef();
|
|
19
|
+
const tabManagerContext = useContext(
|
|
20
|
+
TabManagerContext
|
|
21
|
+
) as TabManagerContextType;
|
|
22
|
+
const { openShortcut } = tabManagerContext || {};
|
|
23
|
+
|
|
24
|
+
if (!dashboardData) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<DashboardActionProvider
|
|
30
|
+
dashboardRef={dashboardRef}
|
|
31
|
+
openAction={(action) => {
|
|
32
|
+
openShortcut(action!);
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<TitleHeader>
|
|
36
|
+
<DashboardActionBar />
|
|
37
|
+
</TitleHeader>
|
|
38
|
+
<Dashboard
|
|
39
|
+
ref={dashboardRef}
|
|
40
|
+
model={dashboardData!.model}
|
|
41
|
+
id={dashboardData!.id}
|
|
42
|
+
context={dashboardData?.context}
|
|
43
|
+
configAction={dashboardData?.configAction}
|
|
44
|
+
/>
|
|
45
|
+
</DashboardActionProvider>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import FormActionBar from "@/actionbar/FormActionBar";
|
|
2
|
+
import { FormView } from "@/types";
|
|
3
|
+
import TitleHeader from "@/ui/TitleHeader";
|
|
4
|
+
import Form from "@/widgets/views/Form";
|
|
5
|
+
import React from "react";
|
|
6
|
+
|
|
7
|
+
export type FormActionViewProps = {
|
|
8
|
+
formView?: FormView;
|
|
9
|
+
visible: boolean;
|
|
10
|
+
formRef: any;
|
|
11
|
+
model: string;
|
|
12
|
+
currentId?: number;
|
|
13
|
+
domain: any;
|
|
14
|
+
context: any;
|
|
15
|
+
defaultValues?: any;
|
|
16
|
+
forcedValues?: any;
|
|
17
|
+
results: any[];
|
|
18
|
+
setResults: (value: any[]) => void;
|
|
19
|
+
setCurrentItemIndex: (value?: number) => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const FormActionView = (props: FormActionViewProps) => {
|
|
23
|
+
const {
|
|
24
|
+
visible,
|
|
25
|
+
formRef,
|
|
26
|
+
model,
|
|
27
|
+
currentId,
|
|
28
|
+
domain,
|
|
29
|
+
formView,
|
|
30
|
+
context,
|
|
31
|
+
defaultValues,
|
|
32
|
+
forcedValues,
|
|
33
|
+
results,
|
|
34
|
+
setResults,
|
|
35
|
+
setCurrentItemIndex,
|
|
36
|
+
} = props;
|
|
37
|
+
|
|
38
|
+
if (!visible) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<TitleHeader>
|
|
45
|
+
<FormActionBar toolbar={formView?.toolbar} />
|
|
46
|
+
</TitleHeader>
|
|
47
|
+
<Form
|
|
48
|
+
rootForm={true}
|
|
49
|
+
ref={formRef}
|
|
50
|
+
model={model}
|
|
51
|
+
defaultValues={defaultValues}
|
|
52
|
+
forcedValues={forcedValues}
|
|
53
|
+
formView={formView}
|
|
54
|
+
actionDomain={domain}
|
|
55
|
+
id={currentId}
|
|
56
|
+
parentContext={context}
|
|
57
|
+
onSubmitSucceed={(id, values) => {
|
|
58
|
+
const itemIndex = results!.findIndex((item: any) => {
|
|
59
|
+
return item.id === id;
|
|
60
|
+
});
|
|
61
|
+
if (itemIndex === -1) {
|
|
62
|
+
results!.push(values);
|
|
63
|
+
setResults(results);
|
|
64
|
+
setCurrentItemIndex(results!.length - 1);
|
|
65
|
+
}
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
};
|