@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
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import GraphActionBar from "@/actionbar/GraphActionBar";
|
|
2
|
+
import TitleHeader from "@/ui/TitleHeader";
|
|
3
|
+
import { Graph } from "@/widgets/views/Graph/Graph";
|
|
4
|
+
import React, { useContext, useRef } from "react";
|
|
5
|
+
import {
|
|
6
|
+
ActionViewContext,
|
|
7
|
+
ActionViewContextType,
|
|
8
|
+
} from "@/context/ActionViewContext";
|
|
9
|
+
import { FormView, TreeView } from "@/types";
|
|
10
|
+
import { mergeSearchFields } from "@/helpers/formHelper";
|
|
11
|
+
import { useSearch } from "@/hooks/useSearch";
|
|
12
|
+
import SearchFilter from "@/widgets/views/searchFilter/SearchFilter";
|
|
13
|
+
import { Spin } from "antd";
|
|
14
|
+
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
15
|
+
|
|
16
|
+
export type GraphActionViewProps = {
|
|
17
|
+
viewData: any;
|
|
18
|
+
visible: boolean;
|
|
19
|
+
model: string;
|
|
20
|
+
context: any;
|
|
21
|
+
domain: any;
|
|
22
|
+
formView: FormView;
|
|
23
|
+
treeView: TreeView;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const GraphActionView = (props: GraphActionViewProps) => {
|
|
27
|
+
const { viewData, visible, model, context, domain, formView, treeView } =
|
|
28
|
+
props;
|
|
29
|
+
const graphRef = useRef();
|
|
30
|
+
|
|
31
|
+
const actionViewContext = useContext(
|
|
32
|
+
ActionViewContext
|
|
33
|
+
) as ActionViewContextType;
|
|
34
|
+
const {
|
|
35
|
+
setResults: setResultsActionView = undefined,
|
|
36
|
+
setCurrentItemIndex = undefined,
|
|
37
|
+
currentId = undefined,
|
|
38
|
+
results: resultsActionView = undefined,
|
|
39
|
+
setSelectedRowItems = undefined,
|
|
40
|
+
setSearchParams = undefined,
|
|
41
|
+
searchVisible = true,
|
|
42
|
+
setSearchVisible = undefined,
|
|
43
|
+
sorter = undefined,
|
|
44
|
+
setSorter = undefined,
|
|
45
|
+
setTotalItems: setActionViewTotalItems = undefined,
|
|
46
|
+
setSearchTreeNameSearch = undefined,
|
|
47
|
+
setTreeIsLoading = undefined,
|
|
48
|
+
results = undefined,
|
|
49
|
+
} = actionViewContext || {};
|
|
50
|
+
|
|
51
|
+
const { searchParams, searchValues, setSearchValues } = useContext(
|
|
52
|
+
ActionViewContext
|
|
53
|
+
) as ActionViewContextType;
|
|
54
|
+
const { t } = useContext(LocaleContext) as LocaleContextType;
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
submit,
|
|
58
|
+
clear,
|
|
59
|
+
searchFilterLoading,
|
|
60
|
+
searchError,
|
|
61
|
+
offset,
|
|
62
|
+
limit,
|
|
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
|
+
});
|
|
85
|
+
|
|
86
|
+
if (!visible) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!viewData) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<>
|
|
96
|
+
<TitleHeader title={viewData.name}>
|
|
97
|
+
<GraphActionBar
|
|
98
|
+
refreshGraph={() => {
|
|
99
|
+
(graphRef.current as any).refresh();
|
|
100
|
+
}}
|
|
101
|
+
/>
|
|
102
|
+
</TitleHeader>
|
|
103
|
+
<SearchFilter
|
|
104
|
+
fields={{ ...treeView.fields, ...formView.fields }}
|
|
105
|
+
searchFields={mergeSearchFields([
|
|
106
|
+
formView.search_fields,
|
|
107
|
+
treeView.search_fields,
|
|
108
|
+
])}
|
|
109
|
+
limit={limit!}
|
|
110
|
+
onClear={clear}
|
|
111
|
+
offset={offset}
|
|
112
|
+
isSearching={searchFilterLoading}
|
|
113
|
+
onSubmit={submit}
|
|
114
|
+
searchError={searchError}
|
|
115
|
+
searchVisible={searchVisible}
|
|
116
|
+
searchValues={searchValues}
|
|
117
|
+
/>
|
|
118
|
+
{tableRefreshing ? (
|
|
119
|
+
<Spin />
|
|
120
|
+
) : (
|
|
121
|
+
<>
|
|
122
|
+
<p style={{ textAlign: "right" }}>
|
|
123
|
+
{`${t("totalRegisters")} ${results?.length}`}
|
|
124
|
+
</p>
|
|
125
|
+
<Graph
|
|
126
|
+
ref={graphRef}
|
|
127
|
+
view_id={viewData.view_id}
|
|
128
|
+
model={model}
|
|
129
|
+
context={context}
|
|
130
|
+
domain={searchParams || domain}
|
|
131
|
+
/>
|
|
132
|
+
</>
|
|
133
|
+
)}
|
|
134
|
+
</>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import TreeActionBar from "@/actionbar/TreeActionBar";
|
|
2
|
+
import { FormView, TreeView, View } from "@/types";
|
|
3
|
+
import TitleHeader from "@/ui/TitleHeader";
|
|
4
|
+
import SearchTree from "@/widgets/views/SearchTree";
|
|
5
|
+
import React from "react";
|
|
6
|
+
|
|
7
|
+
export type TreeActionViewProps = {
|
|
8
|
+
formView?: FormView;
|
|
9
|
+
treeView?: TreeView;
|
|
10
|
+
visible: boolean;
|
|
11
|
+
searchTreeRef: any;
|
|
12
|
+
model: string;
|
|
13
|
+
domain: any;
|
|
14
|
+
context: any;
|
|
15
|
+
results: any[];
|
|
16
|
+
setCurrentItemIndex: (value?: number) => void;
|
|
17
|
+
setCurrentId: (id?: number) => void;
|
|
18
|
+
setCurrentView: (view: View) => void;
|
|
19
|
+
availableViews: View[];
|
|
20
|
+
searchTreeNameSearch?: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const TreeActionView = (props: TreeActionViewProps) => {
|
|
24
|
+
const {
|
|
25
|
+
visible,
|
|
26
|
+
searchTreeRef,
|
|
27
|
+
model,
|
|
28
|
+
context,
|
|
29
|
+
formView,
|
|
30
|
+
treeView,
|
|
31
|
+
domain,
|
|
32
|
+
setCurrentItemIndex,
|
|
33
|
+
results,
|
|
34
|
+
setCurrentId,
|
|
35
|
+
setCurrentView,
|
|
36
|
+
availableViews,
|
|
37
|
+
searchTreeNameSearch,
|
|
38
|
+
} = props;
|
|
39
|
+
|
|
40
|
+
if (!visible) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<TitleHeader>
|
|
47
|
+
<TreeActionBar
|
|
48
|
+
toolbar={formView?.toolbar}
|
|
49
|
+
parentContext={context}
|
|
50
|
+
treeExpandable={treeView?.isExpandable || false}
|
|
51
|
+
/>
|
|
52
|
+
</TitleHeader>
|
|
53
|
+
<SearchTree
|
|
54
|
+
ref={searchTreeRef}
|
|
55
|
+
rootTree={true}
|
|
56
|
+
model={model}
|
|
57
|
+
parentContext={context}
|
|
58
|
+
nameSearch={searchTreeNameSearch}
|
|
59
|
+
formView={formView}
|
|
60
|
+
treeView={treeView}
|
|
61
|
+
domain={domain}
|
|
62
|
+
onRowClicked={(event: any) => {
|
|
63
|
+
const { id } = event;
|
|
64
|
+
setCurrentId(id);
|
|
65
|
+
const itemIndex = results.findIndex((item: any) => {
|
|
66
|
+
return item.id === id;
|
|
67
|
+
});
|
|
68
|
+
setCurrentItemIndex(itemIndex);
|
|
69
|
+
const formView = availableViews.find(
|
|
70
|
+
(v) => v.type === "form"
|
|
71
|
+
) as FormView;
|
|
72
|
+
setCurrentView(formView);
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
</>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
@@ -53,7 +53,7 @@ export const Button = (props: Props) => {
|
|
|
53
53
|
function getButtonIcon() {
|
|
54
54
|
if (isRunning) return <LoadingOutlined />;
|
|
55
55
|
if (icon) {
|
|
56
|
-
const Icon: React.ElementType = iconMapper(icon);
|
|
56
|
+
const Icon: React.ElementType = iconMapper(icon) as any;
|
|
57
57
|
return Icon && <Icon />;
|
|
58
58
|
}
|
|
59
59
|
return undefined;
|
|
@@ -2,7 +2,7 @@ import React, { useContext, useState } from "react";
|
|
|
2
2
|
import { One2many as One2manyOoui } from "@gisce/ooui";
|
|
3
3
|
import Field from "@/common/Field";
|
|
4
4
|
import { Spin, Alert } from "antd";
|
|
5
|
-
import { Views } from "@/types";
|
|
5
|
+
import { Views, ViewType } from "@/types";
|
|
6
6
|
import ConnectionProvider from "@/ConnectionProvider";
|
|
7
7
|
import One2manyProvider from "@/context/One2manyContext";
|
|
8
8
|
import { One2manyInput } from "@/widgets/base/one2many/One2manyInput";
|
|
@@ -13,13 +13,11 @@ type Props = {
|
|
|
13
13
|
ooui: One2manyOoui;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export type ViewModes = "tree" | "form" | "graph";
|
|
17
|
-
|
|
18
16
|
export const One2many = (props: Props) => {
|
|
19
17
|
const { ooui } = props;
|
|
20
18
|
const { mode, relation, views: oouiViews, required, context } = ooui;
|
|
21
19
|
|
|
22
|
-
let initialView:
|
|
20
|
+
let initialView: ViewType;
|
|
23
21
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
|
24
22
|
const [error, setError] = useState<string>();
|
|
25
23
|
const [views, setViews] = useState<Views>(new Map<string, any>());
|
|
@@ -30,7 +28,7 @@ export const One2many = (props: Props) => {
|
|
|
30
28
|
fetchData();
|
|
31
29
|
}, [ooui]);
|
|
32
30
|
|
|
33
|
-
const getViewData = async (type:
|
|
31
|
+
const getViewData = async (type: ViewType) => {
|
|
34
32
|
if (oouiViews && oouiViews[type]) {
|
|
35
33
|
return oouiViews[type];
|
|
36
34
|
}
|
|
@@ -47,7 +45,7 @@ export const One2many = (props: Props) => {
|
|
|
47
45
|
|
|
48
46
|
try {
|
|
49
47
|
if (mode && mode.length > 0) {
|
|
50
|
-
for (const m of mode as
|
|
48
|
+
for (const m of mode as ViewType[]) {
|
|
51
49
|
const v = await getViewData(m);
|
|
52
50
|
views.set(m, v)
|
|
53
51
|
}
|
|
@@ -67,7 +65,7 @@ export const One2many = (props: Props) => {
|
|
|
67
65
|
};
|
|
68
66
|
|
|
69
67
|
if (mode && mode.length > 0) {
|
|
70
|
-
initialView = mode[0] as
|
|
68
|
+
initialView = mode[0] as ViewType;
|
|
71
69
|
} else {
|
|
72
70
|
initialView = "tree";
|
|
73
71
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
parseGraph,
|
|
11
11
|
transformDomainForChildWidget,
|
|
12
12
|
} from "@gisce/ooui";
|
|
13
|
-
import { Views } from "@/types";
|
|
13
|
+
import { Views, ViewType } from "@/types";
|
|
14
14
|
import ConnectionProvider from "@/ConnectionProvider";
|
|
15
15
|
import { FormModal } from "@/widgets/modals/FormModal";
|
|
16
16
|
import showUnsavedChangesDialog from "@/ui/UnsavedChangesDialog";
|
|
@@ -25,7 +25,6 @@ import { One2manyTopBar } from "@/widgets/base/one2many/One2manyTopBar";
|
|
|
25
25
|
import { readObjectValues, getNextPendingId } from "@/helpers/one2manyHelper";
|
|
26
26
|
import { SearchModal } from "@/widgets/modals/SearchModal";
|
|
27
27
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
28
|
-
import { ViewModes } from "@/widgets/base/one2many/One2many";
|
|
29
28
|
import { sortResults, sortResultsWithOrder } from "@/helpers/treeHelper";
|
|
30
29
|
|
|
31
30
|
type One2manyValue = {
|
|
@@ -90,9 +89,8 @@ const One2manyInput: React.FC<One2manyInputProps> = (
|
|
|
90
89
|
const [showSearchModal, setShowSearchModal] = useState<boolean>(false);
|
|
91
90
|
const [modalItem, setModalItem] = useState<One2manyItem>();
|
|
92
91
|
const [selectedRowKeys, setSelectedRowKeys] = useState<any[]>([]);
|
|
93
|
-
const [continuousEntryMode, setContinuousEntryMode] =
|
|
94
|
-
false
|
|
95
|
-
);
|
|
92
|
+
const [continuousEntryMode, setContinuousEntryMode] =
|
|
93
|
+
useState<boolean>(false);
|
|
96
94
|
const transformedDomain = useRef<any[]>([]);
|
|
97
95
|
const [sorter, setSorter] = useState<any>();
|
|
98
96
|
const originalSortItemIds = useRef<number[]>();
|
|
@@ -185,7 +183,7 @@ const One2manyInput: React.FC<One2manyInputProps> = (
|
|
|
185
183
|
const keys = Array.from(views.keys());
|
|
186
184
|
const nextView = keys[
|
|
187
185
|
(keys.indexOf(currentView) + 1) % keys.length
|
|
188
|
-
] as
|
|
186
|
+
] as ViewType;
|
|
189
187
|
if (currentView === "form") {
|
|
190
188
|
showFormChangesDialogIfNeeded(() => {
|
|
191
189
|
setCurrentView(nextView);
|
|
@@ -486,7 +484,7 @@ const One2manyInput: React.FC<One2manyInputProps> = (
|
|
|
486
484
|
|
|
487
485
|
// TODO: improve this. Do we really have to parse the entire object just to get the title?
|
|
488
486
|
function getTitle() {
|
|
489
|
-
const ViewType: any = ViewObjects[currentView];
|
|
487
|
+
const ViewType: any = (ViewObjects as any)[currentView];
|
|
490
488
|
if (currentView === "graph") {
|
|
491
489
|
const parsedGraph = parseGraph(views.get("graph").arch);
|
|
492
490
|
return parsedGraph.string!;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ButtonWithTooltip from "@/common/ButtonWithTooltip";
|
|
3
|
-
import { ViewModes } from "@/widgets/base/one2many/One2many";
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
5
|
FileAddOutlined,
|
|
@@ -11,10 +10,11 @@ import {
|
|
|
11
10
|
SearchOutlined,
|
|
12
11
|
ApiOutlined,
|
|
13
12
|
} from "@ant-design/icons";
|
|
13
|
+
import { ViewType } from "@/types";
|
|
14
14
|
|
|
15
15
|
type One2manyTopBarProps = {
|
|
16
16
|
title: string;
|
|
17
|
-
mode:
|
|
17
|
+
mode: ViewType;
|
|
18
18
|
isMany2Many: boolean;
|
|
19
19
|
readOnly: boolean;
|
|
20
20
|
formHasChanges: boolean;
|
|
@@ -56,8 +56,8 @@ export const One2manyTopBar = (props: One2manyTopBarProps) => {
|
|
|
56
56
|
|
|
57
57
|
function title() {
|
|
58
58
|
return (
|
|
59
|
-
<div className="
|
|
60
|
-
<div className="
|
|
59
|
+
<div className="flex flex-grow h-8 text-gray-200 bg-gray-700">
|
|
60
|
+
<div className="flex flex-col items-center justify-center h-full">
|
|
61
61
|
<span className="pl-2 font-bold">{titleString}</span>
|
|
62
62
|
</div>
|
|
63
63
|
</div>
|
|
@@ -115,7 +115,7 @@ export const One2manyTopBar = (props: One2manyTopBarProps) => {
|
|
|
115
115
|
return (
|
|
116
116
|
<div className="flex mb-2">
|
|
117
117
|
{title()}
|
|
118
|
-
<div className="h-8
|
|
118
|
+
<div className="flex-none h-8 pl-2">
|
|
119
119
|
{mode !== "graph" && showCreateButton && (
|
|
120
120
|
<ButtonWithTooltip
|
|
121
121
|
tooltip={"Create new item"}
|
|
@@ -56,7 +56,7 @@ const Container = (props: Props): React.ReactElement => {
|
|
|
56
56
|
firstRow = firstRow.concat(rowWithEmptiesToFit);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
return rowWithEmptiesToFit.map((item: Widget
|
|
59
|
+
return rowWithEmptiesToFit.map((item: Widget) => {
|
|
60
60
|
// We check if we have any label+field inside the container.
|
|
61
61
|
// In this scenario, we must format the grid accordingly
|
|
62
62
|
// Otherwise, the grid will divide uniformly
|
|
@@ -64,11 +64,9 @@ const Container = (props: Props): React.ReactElement => {
|
|
|
64
64
|
fieldInRows = true;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const itemRowIndex = row.indexOf(item);
|
|
68
|
-
|
|
69
67
|
return (
|
|
70
68
|
<div
|
|
71
|
-
key={
|
|
69
|
+
key={item.key}
|
|
72
70
|
style={{
|
|
73
71
|
...getSpanStyleForItem({ item, responsiveBehaviour }),
|
|
74
72
|
minWidth: 0,
|
|
@@ -17,7 +17,7 @@ function Notebook(props: Props): React.ReactElement {
|
|
|
17
17
|
|
|
18
18
|
function getPageIcon(icon: string) {
|
|
19
19
|
if (icon) {
|
|
20
|
-
const Icon: React.ElementType = iconMapper(icon);
|
|
20
|
+
const Icon: React.ElementType = iconMapper(icon) as any;
|
|
21
21
|
return Icon && <Icon />;
|
|
22
22
|
}
|
|
23
23
|
return undefined;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import React, { useContext, useState } from "react";
|
|
2
2
|
import Field from "@/common/Field";
|
|
3
|
-
import { DownOutlined } from
|
|
3
|
+
import { DownOutlined } from "@ant-design/icons";
|
|
4
4
|
import { Dropdown, Menu } from "antd";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ButtonGroup as ButtonGroupOoui,
|
|
7
|
+
Button as ButtonOoui,
|
|
8
|
+
Field as FieldOoui,
|
|
9
|
+
} from "@gisce/ooui";
|
|
6
10
|
import showConfirmDialog from "@/ui/ConfirmDialog";
|
|
7
11
|
import { FormContext, FormContextType } from "@/context/FormContext";
|
|
8
12
|
import { LoadingOutlined } from "@ant-design/icons";
|
|
@@ -41,7 +45,7 @@ export const ButtonGroup = (props: ButtonGroupProps) => {
|
|
|
41
45
|
function getButtonIcon() {
|
|
42
46
|
if (isRunning) return <LoadingOutlined />;
|
|
43
47
|
if (icon) {
|
|
44
|
-
const Icon: React.ElementType = iconMapper(icon);
|
|
48
|
+
const Icon: React.ElementType = iconMapper(icon) as any;
|
|
45
49
|
return Icon && <Icon />;
|
|
46
50
|
}
|
|
47
51
|
return undefined;
|
|
@@ -71,21 +75,22 @@ export const ButtonGroup = (props: ButtonGroupProps) => {
|
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
return (
|
|
74
|
-
<Field ooui={new FieldOoui({...{ooui}})}>
|
|
78
|
+
<Field ooui={new FieldOoui({ ...{ ooui } })}>
|
|
75
79
|
<Dropdown.Button
|
|
76
80
|
disabled={!activated || readOnly}
|
|
77
81
|
onClick={onClick}
|
|
78
|
-
icon={<DownOutlined/>}
|
|
82
|
+
icon={<DownOutlined />}
|
|
79
83
|
type={primary ? "primary" : undefined}
|
|
80
84
|
//danger={danger ? true : undefined} This works but typescript
|
|
81
85
|
// doesn't accept
|
|
82
86
|
overlay={<Items ooui={secondaryButtons} />}
|
|
83
87
|
>
|
|
84
|
-
|
|
88
|
+
{getButtonIcon()}
|
|
89
|
+
{caption}
|
|
85
90
|
</Dropdown.Button>
|
|
86
91
|
</Field>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
92
|
+
);
|
|
93
|
+
};
|
|
89
94
|
|
|
90
95
|
const Items = (props: ItemsProps) => {
|
|
91
96
|
const { ooui } = props;
|
|
@@ -130,7 +135,7 @@ const Items = (props: ItemsProps) => {
|
|
|
130
135
|
function getButtonIcon() {
|
|
131
136
|
if (isRunning) return <LoadingOutlined />;
|
|
132
137
|
if (icon) {
|
|
133
|
-
const Icon: React.ElementType = iconMapper(icon);
|
|
138
|
+
const Icon: React.ElementType = iconMapper(icon) as any;
|
|
134
139
|
return Icon && <Icon />;
|
|
135
140
|
}
|
|
136
141
|
return undefined;
|
|
@@ -147,9 +152,5 @@ const Items = (props: ItemsProps) => {
|
|
|
147
152
|
</Menu.Item>
|
|
148
153
|
);
|
|
149
154
|
});
|
|
150
|
-
return
|
|
151
|
-
<Menu>
|
|
152
|
-
{items}
|
|
153
|
-
</Menu>
|
|
154
|
-
)
|
|
155
|
+
return <Menu>{items}</Menu>;
|
|
155
156
|
};
|
|
@@ -34,12 +34,12 @@ const IndicatorInput = (props: IndicatorInputProps) => {
|
|
|
34
34
|
<span>{ooui.label} </span>
|
|
35
35
|
{ooui.tooltip &&
|
|
36
36
|
<Tooltip title={ooui.tooltip}>
|
|
37
|
-
<QuestionCircleOutlined className="text-xs text-blue-400
|
|
37
|
+
<QuestionCircleOutlined className="pr-1 text-xs text-blue-400"/>
|
|
38
38
|
</Tooltip>
|
|
39
39
|
}
|
|
40
40
|
</>
|
|
41
41
|
);
|
|
42
|
-
const Icon: React.ElementType = iconMapper(ooui.icon);
|
|
42
|
+
const Icon: React.ElementType = iconMapper(ooui.icon) as any;
|
|
43
43
|
let formattedValue = value;
|
|
44
44
|
if (ooui.selectionValues.size) {
|
|
45
45
|
formattedValue = ooui.selectionValues.get(value);
|
|
@@ -7,14 +7,13 @@ import React, {
|
|
|
7
7
|
useState,
|
|
8
8
|
} from "react";
|
|
9
9
|
import ActionView from "@/views/ActionView";
|
|
10
|
-
import { DashboardProps } from "./Dashboard.types";
|
|
11
10
|
import { fetchAction } from "./dashboardHelper";
|
|
12
11
|
import "react-resizable/css/styles.css";
|
|
13
12
|
import "react-grid-layout/css/styles.css";
|
|
14
13
|
import { Graph } from "../Graph/Graph";
|
|
15
14
|
import { DashboardGrid, DashboardGridItem } from "../DashboardGrid";
|
|
16
15
|
import ConnectionProvider from "@/ConnectionProvider";
|
|
17
|
-
import { FormView } from "@/types";
|
|
16
|
+
import { DashboardProps, FormView } from "@/types";
|
|
18
17
|
import { One2manyItem } from "@/index";
|
|
19
18
|
import { readObjectValues } from "@/helpers/one2manyHelper";
|
|
20
19
|
import { LoadingOutlined } from "@ant-design/icons";
|
|
@@ -60,7 +59,7 @@ function Dashboard(props: DashboardProps, ref: any) {
|
|
|
60
59
|
setError(undefined);
|
|
61
60
|
|
|
62
61
|
try {
|
|
63
|
-
const view = await fetchView();
|
|
62
|
+
const view: FormView = (await fetchView()) as FormView;
|
|
64
63
|
const values = await fetchValues(view);
|
|
65
64
|
const model = view.fields[itemsField].relation;
|
|
66
65
|
const items: One2manyItem[] = values[itemsField].items;
|
|
@@ -99,11 +98,11 @@ function Dashboard(props: DashboardProps, ref: any) {
|
|
|
99
98
|
context: any;
|
|
100
99
|
}) {
|
|
101
100
|
itemsFields.current = (
|
|
102
|
-
await ConnectionProvider.getHandler().getView({
|
|
101
|
+
(await ConnectionProvider.getHandler().getView({
|
|
103
102
|
model,
|
|
104
103
|
type: "form",
|
|
105
104
|
context,
|
|
106
|
-
})
|
|
105
|
+
})) as FormView
|
|
107
106
|
).fields;
|
|
108
107
|
|
|
109
108
|
return await readObjectValues({
|
|
@@ -101,20 +101,18 @@ function DashboardTree(props: Props) {
|
|
|
101
101
|
const searchParams = mergeParams(paramsRef.current, domainParams);
|
|
102
102
|
const { colors } = getTree(treeView!);
|
|
103
103
|
|
|
104
|
-
const {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
setTotalItems(totalItems);
|
|
104
|
+
const { totalItems, results, attrsEvaluated } =
|
|
105
|
+
await ConnectionProvider.getHandler().searchForTree({
|
|
106
|
+
params: searchParams,
|
|
107
|
+
limit: limitRef.current,
|
|
108
|
+
offset,
|
|
109
|
+
model: currentModel!,
|
|
110
|
+
fields: treeView!.fields,
|
|
111
|
+
context: parentContext,
|
|
112
|
+
attrs: colors && { colors },
|
|
113
|
+
});
|
|
114
|
+
const totalItemsResult = await totalItems;
|
|
115
|
+
setTotalItems(totalItemsResult);
|
|
118
116
|
setColorsForResults(getColorMap(attrsEvaluated));
|
|
119
117
|
|
|
120
118
|
const resultsSorted = sortResults({
|
|
@@ -167,12 +165,11 @@ function DashboardTree(props: Props) {
|
|
|
167
165
|
};
|
|
168
166
|
|
|
169
167
|
const fetchActionData = async () => {
|
|
170
|
-
const dataForAction =
|
|
171
|
-
{
|
|
168
|
+
const dataForAction =
|
|
169
|
+
await ConnectionProvider.getHandler().getViewsForAction({
|
|
172
170
|
action: action!,
|
|
173
171
|
context: parentContext,
|
|
174
|
-
}
|
|
175
|
-
);
|
|
172
|
+
});
|
|
176
173
|
actionDomain.current = dataForAction.domain;
|
|
177
174
|
setFormView(dataForAction.views.get("form"));
|
|
178
175
|
setTreeView(dataForAction.views.get("tree"));
|