@gisce/react-ooui 2.0.0-alpha.53 → 2.0.0-alpha.55
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/helpers/treeHelper.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/react-ooui.es.js +3164 -3034
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/ui/TitleHeader.d.ts.map +1 -1
- package/dist/widgets/views/{Tree.d.ts → Tree/Tree.d.ts} +4 -4
- package/dist/widgets/views/Tree/Tree.d.ts.map +1 -0
- package/dist/widgets/views/Tree/index.d.ts +2 -0
- package/dist/widgets/views/Tree/index.d.ts.map +1 -0
- package/dist/widgets/views/Tree/treeComponents.d.ts +131 -0
- package/dist/widgets/views/Tree/treeComponents.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/helpers/{treeHelper.ts → treeHelper.tsx} +25 -4
- package/src/index.ts +1 -1
- package/src/ui/TitleHeader.tsx +10 -1
- package/src/widgets/views/Dashboard/DashboardTree.tsx +1 -1
- package/src/widgets/views/Graph/GraphDefaults.ts +1 -1
- package/src/widgets/views/SearchTree.tsx +2 -2
- package/src/widgets/views/{Tree.tsx → Tree/Tree.tsx} +74 -188
- package/src/widgets/views/Tree/index.ts +1 -0
- package/src/widgets/views/Tree/treeComponents.tsx +276 -0
- package/dist/widgets/views/Tree.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TitleHeader.d.ts","sourceRoot":"","sources":["../../src/ui/TitleHeader.tsx"],"names":[],"mappings":"AAaA,KAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AAEF,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"TitleHeader.d.ts","sourceRoot":"","sources":["../../src/ui/TitleHeader.tsx"],"names":[],"mappings":"AAaA,KAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB,CAAC;AAEF,iBAAS,WAAW,CAAC,KAAK,EAAE,KAAK,2CAkGhC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { TreeView } from '
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TreeView } from '../../../*/types';
|
|
3
3
|
type Props = {
|
|
4
4
|
total?: number;
|
|
5
5
|
limit: number;
|
|
@@ -27,6 +27,6 @@ type Props = {
|
|
|
27
27
|
readonly?: boolean;
|
|
28
28
|
onSelectAllRecords?: () => Promise<void>;
|
|
29
29
|
};
|
|
30
|
-
declare
|
|
31
|
-
export
|
|
30
|
+
export declare const Tree: import("react").MemoExoticComponent<(props: Props) => import("react/jsx-runtime").JSX.Element>;
|
|
31
|
+
export {};
|
|
32
32
|
//# sourceMappingURL=Tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["../../../../src/widgets/views/Tree/Tree.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAiBnC,KAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACtC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,wBAAwB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C,CAAC;AACF,eAAO,MAAM,IAAI,8CAAgB,KAAK,6CAsPpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/widgets/views/Tree/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { ReactElement } from "react";
|
|
2
|
+
import { One2manyValue } from "../../base/one2many/One2manyInput";
|
|
3
|
+
export declare const BooleanComponent: ({ value, }: {
|
|
4
|
+
value: boolean;
|
|
5
|
+
}) => ReactElement;
|
|
6
|
+
export declare const Many2OneComponent: ({ value }: {
|
|
7
|
+
value: any;
|
|
8
|
+
}) => ReactElement;
|
|
9
|
+
export declare const TextComponent: ({ value }: {
|
|
10
|
+
value: any;
|
|
11
|
+
}) => ReactElement;
|
|
12
|
+
export declare const DateComponent: ({ value }: {
|
|
13
|
+
value: any;
|
|
14
|
+
}) => ReactElement;
|
|
15
|
+
export declare const DateTimeComponent: ({ value }: {
|
|
16
|
+
value: any;
|
|
17
|
+
}) => ReactElement;
|
|
18
|
+
export declare const One2ManyComponent: ({ value, }: {
|
|
19
|
+
value: One2manyValue;
|
|
20
|
+
}) => ReactElement;
|
|
21
|
+
export declare const ProgressBarComponent: ({ value, }: {
|
|
22
|
+
value: any;
|
|
23
|
+
}) => ReactElement;
|
|
24
|
+
export declare const FloatTimeComponent: ({ value }: {
|
|
25
|
+
value: any;
|
|
26
|
+
}) => ReactElement;
|
|
27
|
+
export declare const NumberComponent: ({ value }: {
|
|
28
|
+
value: number;
|
|
29
|
+
}) => ReactElement;
|
|
30
|
+
export declare const ImageComponent: ({ value }: {
|
|
31
|
+
value: string;
|
|
32
|
+
}) => ReactElement;
|
|
33
|
+
export declare const TagComponent: ({ value, key, ooui, context, }: {
|
|
34
|
+
value: any;
|
|
35
|
+
key: string;
|
|
36
|
+
ooui: any;
|
|
37
|
+
context: any;
|
|
38
|
+
}) => ReactElement;
|
|
39
|
+
export declare const SelectionComponent: ({ value, key, ooui, context, }: {
|
|
40
|
+
value: any;
|
|
41
|
+
key: string;
|
|
42
|
+
ooui: any;
|
|
43
|
+
context: any;
|
|
44
|
+
}) => ReactElement;
|
|
45
|
+
export declare const ReferenceComponent: ({ value, key, ooui, context, }: {
|
|
46
|
+
value: any;
|
|
47
|
+
key: string;
|
|
48
|
+
ooui: any;
|
|
49
|
+
context: any;
|
|
50
|
+
}) => ReactElement;
|
|
51
|
+
export declare const AvatarComponent: ({ value, key, ooui, context, }: {
|
|
52
|
+
value: any;
|
|
53
|
+
key: string;
|
|
54
|
+
ooui: any;
|
|
55
|
+
context: any;
|
|
56
|
+
}) => ReactElement;
|
|
57
|
+
export declare const TagsComponent: ({ value, key, ooui, context, }: {
|
|
58
|
+
value: any;
|
|
59
|
+
key: string;
|
|
60
|
+
ooui: any;
|
|
61
|
+
context: any;
|
|
62
|
+
}) => ReactElement;
|
|
63
|
+
export declare const COLUMN_COMPONENTS: {
|
|
64
|
+
boolean: ({ value, }: {
|
|
65
|
+
value: boolean;
|
|
66
|
+
}) => ReactElement;
|
|
67
|
+
many2one: ({ value }: {
|
|
68
|
+
value: any;
|
|
69
|
+
}) => ReactElement;
|
|
70
|
+
text: ({ value }: {
|
|
71
|
+
value: any;
|
|
72
|
+
}) => ReactElement;
|
|
73
|
+
one2many: ({ value, }: {
|
|
74
|
+
value: One2manyValue;
|
|
75
|
+
}) => ReactElement;
|
|
76
|
+
many2many: ({ value, }: {
|
|
77
|
+
value: One2manyValue;
|
|
78
|
+
}) => ReactElement;
|
|
79
|
+
progressbar: ({ value, }: {
|
|
80
|
+
value: any;
|
|
81
|
+
}) => ReactElement;
|
|
82
|
+
float_time: ({ value }: {
|
|
83
|
+
value: any;
|
|
84
|
+
}) => ReactElement;
|
|
85
|
+
image: ({ value }: {
|
|
86
|
+
value: string;
|
|
87
|
+
}) => ReactElement;
|
|
88
|
+
integer: ({ value }: {
|
|
89
|
+
value: number;
|
|
90
|
+
}) => ReactElement;
|
|
91
|
+
float: ({ value }: {
|
|
92
|
+
value: number;
|
|
93
|
+
}) => ReactElement;
|
|
94
|
+
reference: ({ value, key, ooui, context, }: {
|
|
95
|
+
value: any;
|
|
96
|
+
key: string;
|
|
97
|
+
ooui: any;
|
|
98
|
+
context: any;
|
|
99
|
+
}) => ReactElement;
|
|
100
|
+
tag: ({ value, key, ooui, context, }: {
|
|
101
|
+
value: any;
|
|
102
|
+
key: string;
|
|
103
|
+
ooui: any;
|
|
104
|
+
context: any;
|
|
105
|
+
}) => ReactElement;
|
|
106
|
+
selection: ({ value, key, ooui, context, }: {
|
|
107
|
+
value: any;
|
|
108
|
+
key: string;
|
|
109
|
+
ooui: any;
|
|
110
|
+
context: any;
|
|
111
|
+
}) => ReactElement;
|
|
112
|
+
date: ({ value }: {
|
|
113
|
+
value: any;
|
|
114
|
+
}) => ReactElement;
|
|
115
|
+
datetime: ({ value }: {
|
|
116
|
+
value: any;
|
|
117
|
+
}) => ReactElement;
|
|
118
|
+
avatar: ({ value, key, ooui, context, }: {
|
|
119
|
+
value: any;
|
|
120
|
+
key: string;
|
|
121
|
+
ooui: any;
|
|
122
|
+
context: any;
|
|
123
|
+
}) => ReactElement;
|
|
124
|
+
tags: ({ value, key, ooui, context, }: {
|
|
125
|
+
value: any;
|
|
126
|
+
key: string;
|
|
127
|
+
ooui: any;
|
|
128
|
+
context: any;
|
|
129
|
+
}) => ReactElement;
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=treeComponents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeComponents.d.ts","sourceRoot":"","sources":["../../../../src/widgets/views/Tree/treeComponents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,OAAO,CAAC;AAIhF,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAWlE,eAAO,MAAM,gBAAgB;WAGpB,OAAO;MACZ,YAeH,CAAC;AAEF,eAAO,MAAM,iBAAiB;WAAwB,GAAG;MAAK,YAE7D,CAAC;AAEF,eAAO,MAAM,aAAa;WAAwB,GAAG;MAAK,YASzD,CAAC;AAEF,eAAO,MAAM,aAAa;WAAwB,GAAG;MAAK,YAUzD,CAAC;AAEF,eAAO,MAAM,iBAAiB;WAAwB,GAAG;MAAK,YAS7D,CAAC;AAEF,eAAO,MAAM,iBAAiB;WAGrB,aAAa;MAClB,YAKH,CAAC;AAEF,eAAO,MAAM,oBAAoB;WAGxB,GAAG;MACR,YAEH,CAAC;AAEF,eAAO,MAAM,kBAAkB;WAAwB,GAAG;MAAK,YAE9D,CAAC;AAEF,eAAO,MAAM,eAAe;WAAwB,MAAM;MAAK,YAK9D,CAAC;AAEF,eAAO,MAAM,cAAc;WAAwB,MAAM;MAAK,YAU7D,CAAC;AAEF,eAAO,MAAM,YAAY;WAMhB,GAAG;SACL,MAAM;UACL,GAAG;aACA,GAAG;MACV,YAEH,CAAC;AAEF,eAAO,MAAM,kBAAkB;WAMtB,GAAG;SACL,MAAM;UACL,GAAG;aACA,GAAG;MACV,YAEH,CAAC;AAEF,eAAO,MAAM,kBAAkB;WAMtB,GAAG;SACL,MAAM;UACL,GAAG;aACA,GAAG;MACV,YAWH,CAAC;AAEF,eAAO,MAAM,eAAe;WAMnB,GAAG;SACL,MAAM;UACL,GAAG;aACA,GAAG;MACV,YAEH,CAAC;AAEF,eAAO,MAAM,aAAa;WAMjB,GAAG;SACL,MAAM;UACL,GAAG;aACA,GAAG;MACV,YAgEH,CAAC;AAEF,eAAO,MAAM,iBAAiB;;eA/OrB,OAAO;UACZ,YAAY;;eAiBsC,GAAG;UAAK,YAAY;;eAIxB,GAAG;UAAK,YAAY;;eAqC7D,aAAa;UAClB,YAAY;;eADP,aAAa;UAClB,YAAY;;eAUP,GAAG;UACR,YAAY;;eAIuC,GAAG;UAAK,YAAY;;eAWxB,MAAM;UAAK,YAAY;;eAPtB,MAAM;UAAK,YAAY;;eAAvB,MAAM;UAAK,YAAY;;eAqDlE,GAAG;aACL,MAAM;cACL,GAAG;iBACA,GAAG;UACV,YAAY;;eAhCP,GAAG;aACL,MAAM;cACL,GAAG;iBACA,GAAG;UACV,YAAY;;eAUP,GAAG;aACL,MAAM;cACL,GAAG;iBACA,GAAG;UACV,YAAY;;eAzFkC,GAAG;UAAK,YAAY;;eAYhB,GAAG;UAAK,YAAY;;eA8GjE,GAAG;aACL,MAAM;cACL,GAAG;iBACA,GAAG;UACV,YAAY;;eAUP,GAAG;aACL,MAAM;cACL,GAAG;iBACA,GAAG;UACV,YAAY;CAoFf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gisce/react-ooui",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.55",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": "20.5.0"
|
|
6
6
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@gisce/fiber-diagram": "^1.1.0-rc.3",
|
|
37
37
|
"@gisce/ooui": "1.0.0-alpha.21",
|
|
38
38
|
"@gisce/react-formiga-components": "^1.0.9-rc.21",
|
|
39
|
-
"@gisce/react-formiga-table": "1.0.0-alpha.
|
|
39
|
+
"@gisce/react-formiga-table": "1.0.0-alpha.11",
|
|
40
40
|
"@monaco-editor/react": "^4.4.5",
|
|
41
41
|
"@tabler/icons-react": "^2.11.0",
|
|
42
42
|
"antd": "^5.5.2",
|
|
@@ -15,6 +15,15 @@ const getTree = (treeView: TreeView): TreeOoui => {
|
|
|
15
15
|
return tree;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
+
function isPrimitive(value: any): boolean {
|
|
19
|
+
return (
|
|
20
|
+
typeof value === "number" ||
|
|
21
|
+
typeof value === "string" ||
|
|
22
|
+
typeof value === "boolean" ||
|
|
23
|
+
value === null
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
18
27
|
const getTableColumns = (
|
|
19
28
|
tree: TreeOoui,
|
|
20
29
|
components: any,
|
|
@@ -27,8 +36,21 @@ const getTableColumns = (
|
|
|
27
36
|
let render;
|
|
28
37
|
|
|
29
38
|
if (component) {
|
|
30
|
-
render = (
|
|
31
|
-
return component(
|
|
39
|
+
render = (value: any) => {
|
|
40
|
+
return component({ value, key, ooui: column, context });
|
|
41
|
+
};
|
|
42
|
+
} else {
|
|
43
|
+
render = (value: any) => {
|
|
44
|
+
return isPrimitive(value) ? (
|
|
45
|
+
value
|
|
46
|
+
) : (
|
|
47
|
+
<p style={{ color: "red" }}>
|
|
48
|
+
Unsupported widget type for a Tree cell:
|
|
49
|
+
<pre>
|
|
50
|
+
<strong>{type}:</strong>
|
|
51
|
+
</pre>
|
|
52
|
+
</p>
|
|
53
|
+
);
|
|
32
54
|
};
|
|
33
55
|
}
|
|
34
56
|
|
|
@@ -58,7 +80,7 @@ const getTableColumns = (
|
|
|
58
80
|
const getTableItems = (treeOoui: TreeOoui, results: any[]): any[] => {
|
|
59
81
|
const tableItems = results.map((item: any) => {
|
|
60
82
|
const parsedItem: any = {};
|
|
61
|
-
Object.keys(item).
|
|
83
|
+
Object.keys(item).forEach((key) => {
|
|
62
84
|
if (key === "id") {
|
|
63
85
|
parsedItem[key] = item[key];
|
|
64
86
|
} else {
|
|
@@ -67,7 +89,6 @@ const getTableItems = (treeOoui: TreeOoui, results: any[]): any[] => {
|
|
|
67
89
|
if (widget instanceof Reference) {
|
|
68
90
|
parsedItem[key] = item[key];
|
|
69
91
|
} else if (widget instanceof Selection) {
|
|
70
|
-
const selection = widget;
|
|
71
92
|
parsedItem[key] = item[key];
|
|
72
93
|
} else if (widget instanceof Many2one) {
|
|
73
94
|
parsedItem[key] = item[key] &&
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Selection } from "@/widgets/base/Selection";
|
|
|
5
5
|
import { Boolean } from "@/widgets/base/Boolean";
|
|
6
6
|
import { Many2one } from "@/widgets/base/many2one/Many2one";
|
|
7
7
|
import { One2many } from "@/widgets/base/one2many/One2many";
|
|
8
|
-
import Tree from "@/widgets/views/Tree";
|
|
8
|
+
import { Tree } from "@/widgets/views/Tree";
|
|
9
9
|
import { Float } from "@/widgets/base/Float";
|
|
10
10
|
import { ProgressBar } from "@/widgets/base/ProgressBar";
|
|
11
11
|
import { FloatTime } from "@/widgets/base/FloatTime";
|
package/src/ui/TitleHeader.tsx
CHANGED
|
@@ -82,13 +82,22 @@ function TitleHeader(props: Props) {
|
|
|
82
82
|
return null;
|
|
83
83
|
}
|
|
84
84
|
return (
|
|
85
|
-
<div
|
|
85
|
+
<div
|
|
86
|
+
style={{
|
|
87
|
+
position: "sticky",
|
|
88
|
+
top: 80,
|
|
89
|
+
zIndex: 3,
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
86
92
|
<Row
|
|
87
93
|
className="shadow-md"
|
|
88
94
|
style={{
|
|
89
95
|
padding: "1em",
|
|
90
96
|
borderRadius: token.borderRadius,
|
|
91
97
|
backgroundColor: token.colorPrimaryBg,
|
|
98
|
+
height: "82px",
|
|
99
|
+
minHeight: "82px",
|
|
100
|
+
maxHeight: "82px",
|
|
92
101
|
}}
|
|
93
102
|
align="middle"
|
|
94
103
|
>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState, useRef } from "react";
|
|
2
2
|
import { Alert, Spin } from "antd";
|
|
3
3
|
|
|
4
|
-
import Tree from "@/widgets/views/Tree";
|
|
4
|
+
import { Tree } from "@/widgets/views/Tree";
|
|
5
5
|
import { FormView, TreeView } from "@/types/index";
|
|
6
6
|
import ConnectionProvider from "@/ConnectionProvider";
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ import React, {
|
|
|
9
9
|
import { Alert, Spin } from "antd";
|
|
10
10
|
|
|
11
11
|
import SearchFilter from "@/widgets/views/searchFilter/SearchFilter";
|
|
12
|
-
import Tree from "@/widgets/views/Tree";
|
|
12
|
+
import { Tree } from "@/widgets/views/Tree";
|
|
13
13
|
import { FormView, TreeView } from "@/types/index";
|
|
14
14
|
import ConnectionProvider from "@/ConnectionProvider";
|
|
15
15
|
|
|
@@ -284,7 +284,7 @@ function SearchTree(props: Props, ref: any) {
|
|
|
284
284
|
if (treeView?.isExpandable) {
|
|
285
285
|
return height - 160;
|
|
286
286
|
}
|
|
287
|
-
return height - (searchFilterHeight +
|
|
287
|
+
return height - (searchFilterHeight + 240);
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
const content = () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Pagination
|
|
1
|
+
import { memo, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Pagination as AntPagination, Row, Col, Spin, Badge } from "antd";
|
|
3
3
|
import {
|
|
4
4
|
getTree,
|
|
5
5
|
getTableColumns,
|
|
@@ -7,31 +7,22 @@ import {
|
|
|
7
7
|
hasActualValues,
|
|
8
8
|
} from "@/helpers/treeHelper";
|
|
9
9
|
import { Tree as TreeOoui } from "@gisce/ooui";
|
|
10
|
-
|
|
11
|
-
import { TreeView, Column } from "@/types";
|
|
10
|
+
import { TreeView } from "@/types";
|
|
12
11
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
13
12
|
import { calculateColumnsWidth } from "@/helpers/dynamicColumnsHelper";
|
|
14
|
-
import { parseFloatToString } from "@/helpers/timeHelper";
|
|
15
|
-
import { ProgressBarInput } from "../base/ProgressBar";
|
|
16
13
|
import { Table as GisceTable } from "@gisce/react-formiga-table";
|
|
17
14
|
import {
|
|
18
15
|
PlusSquareOutlined,
|
|
19
16
|
MinusSquareOutlined,
|
|
20
17
|
LoadingOutlined,
|
|
21
18
|
} from "@ant-design/icons";
|
|
22
|
-
import { One2manyValue } from "../base/one2many/One2manyInput";
|
|
23
|
-
import { Interweave } from "interweave";
|
|
24
19
|
import {
|
|
25
20
|
ActionViewContext,
|
|
26
21
|
ActionViewContextType,
|
|
27
22
|
} from "@/context/ActionViewContext";
|
|
28
|
-
import { Many2oneTree } from "../base/many2one/Many2oneTree";
|
|
29
|
-
import { ReferenceTree } from "../base/ReferenceTree";
|
|
30
|
-
import dayjs from "dayjs";
|
|
31
|
-
import Avatar from "../custom/Avatar";
|
|
32
|
-
import { TagInput } from "../custom/Tag";
|
|
33
|
-
import { DatePickerConfig } from "@/common/DatePicker";
|
|
34
23
|
import { SelectAllRecordsRow } from "@/common/SelectAllRecordsRow";
|
|
24
|
+
import { COLUMN_COMPONENTS } from "./treeComponents";
|
|
25
|
+
import ErrorBoundary from "antd/es/alert/ErrorBoundary";
|
|
35
26
|
|
|
36
27
|
type Props = {
|
|
37
28
|
total?: number;
|
|
@@ -56,121 +47,7 @@ type Props = {
|
|
|
56
47
|
readonly?: boolean;
|
|
57
48
|
onSelectAllRecords?: () => Promise<void>;
|
|
58
49
|
};
|
|
59
|
-
|
|
60
|
-
const booleanComponentFn = (value: boolean): React.ReactElement => {
|
|
61
|
-
return (
|
|
62
|
-
<div
|
|
63
|
-
style={{
|
|
64
|
-
display: "flex",
|
|
65
|
-
justifyContent: "center",
|
|
66
|
-
alignContent: "center",
|
|
67
|
-
}}
|
|
68
|
-
>
|
|
69
|
-
<Checkbox checked={value} disabled />
|
|
70
|
-
</div>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const many2OneComponentFn = (m2oField: any): React.ReactElement => {
|
|
75
|
-
return <Many2oneTree m2oField={m2oField} />;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const textComponentFn = (value: any): React.ReactElement => {
|
|
79
|
-
return (
|
|
80
|
-
<Interweave
|
|
81
|
-
content={value?.toString().replace(/(?:\r\n|\r|\n)/g, "<br>")}
|
|
82
|
-
/>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const dateComponentFn = (value: any): React.ReactElement => {
|
|
87
|
-
if (!value || (value && value.length === 0)) return <></>;
|
|
88
|
-
|
|
89
|
-
const formattedValue = dayjs(
|
|
90
|
-
value,
|
|
91
|
-
DatePickerConfig.date.dateInternalFormat,
|
|
92
|
-
).format(DatePickerConfig.date.dateDisplayFormat);
|
|
93
|
-
return <>{formattedValue}</>;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const dateTimeComponentFn = (value: any): React.ReactElement => {
|
|
97
|
-
if (!value || (value && value.length === 0)) return <></>;
|
|
98
|
-
const formattedValue = dayjs(
|
|
99
|
-
value,
|
|
100
|
-
DatePickerConfig.time.dateInternalFormat,
|
|
101
|
-
).format(DatePickerConfig.time.dateDisplayFormat);
|
|
102
|
-
return <>{formattedValue}</>;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const one2ManyComponentFn = (value: One2manyValue): React.ReactElement => {
|
|
106
|
-
const length = Array.isArray(value?.items) ? value?.items.length : 0;
|
|
107
|
-
return <>{`( ${length} )`}</>;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const progressBarComponentFn = (value: any): React.ReactElement => {
|
|
111
|
-
return <ProgressBarInput value={value} />;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const floatTimeComponent = (value: number): React.ReactElement => {
|
|
115
|
-
return <>{parseFloatToString(value)}</>;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const numberComponent = (value: number): React.ReactElement => {
|
|
119
|
-
return <div style={{ textAlign: "right" }}>{value}</div>;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const imageComponent = (value: string): React.ReactElement => {
|
|
123
|
-
return (
|
|
124
|
-
<img
|
|
125
|
-
src={`data:image/*;base64,${value}`}
|
|
126
|
-
style={{ maxWidth: "50px", padding: "5px" }}
|
|
127
|
-
/>
|
|
128
|
-
);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const TagComponent = (
|
|
132
|
-
value: any,
|
|
133
|
-
key: string,
|
|
134
|
-
ooui: any,
|
|
135
|
-
context: any,
|
|
136
|
-
): React.ReactElement => {
|
|
137
|
-
return <TagInput ooui={ooui} value={value} />;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const SelectionComponent = (
|
|
141
|
-
value: any,
|
|
142
|
-
key: string,
|
|
143
|
-
ooui: any,
|
|
144
|
-
context: any,
|
|
145
|
-
): React.ReactElement => {
|
|
146
|
-
return <>{ooui.selectionValues.get(value)}</>;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const referenceComponent = (
|
|
150
|
-
value: any,
|
|
151
|
-
key: string,
|
|
152
|
-
ooui: any,
|
|
153
|
-
context: any,
|
|
154
|
-
): React.ReactElement => {
|
|
155
|
-
return (
|
|
156
|
-
<>
|
|
157
|
-
<ReferenceTree
|
|
158
|
-
value={value}
|
|
159
|
-
selectionValues={ooui.selectionValues}
|
|
160
|
-
context={context}
|
|
161
|
-
/>
|
|
162
|
-
</>
|
|
163
|
-
);
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
const AvatarFn = (
|
|
167
|
-
value: any,
|
|
168
|
-
key: string,
|
|
169
|
-
ooui: any,
|
|
170
|
-
context: any,
|
|
171
|
-
): React.ReactElement => <Avatar ooui={ooui} value={value} />;
|
|
172
|
-
|
|
173
|
-
function Tree(props: Props): React.ReactElement {
|
|
50
|
+
export const Tree = memo((props: Props) => {
|
|
174
51
|
const {
|
|
175
52
|
page = 1,
|
|
176
53
|
limit,
|
|
@@ -196,11 +73,10 @@ function Tree(props: Props): React.ReactElement {
|
|
|
196
73
|
} = props;
|
|
197
74
|
|
|
198
75
|
const [items, setItems] = useState<any[]>([]);
|
|
199
|
-
const [columns, setColumns] = useState<Column[]>([]);
|
|
200
76
|
|
|
201
77
|
const errorInParseColors = useRef<boolean>(false);
|
|
202
78
|
|
|
203
|
-
const treeOoui =
|
|
79
|
+
const [treeOoui, setTreeOoui] = useState<TreeOoui>();
|
|
204
80
|
|
|
205
81
|
const { t } = useContext(LocaleContext) as LocaleContextType;
|
|
206
82
|
const internalLimit = useRef(limit);
|
|
@@ -211,46 +87,43 @@ function Tree(props: Props): React.ReactElement {
|
|
|
211
87
|
const { title = undefined, setTitle = undefined } =
|
|
212
88
|
(rootTree ? actionViewContext : {}) || {};
|
|
213
89
|
|
|
214
|
-
|
|
215
|
-
|
|
90
|
+
const columns = useMemo(() => {
|
|
91
|
+
if (!treeOoui) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
216
94
|
|
|
217
|
-
|
|
218
|
-
treeOoui
|
|
95
|
+
return getTableColumns(
|
|
96
|
+
treeOoui,
|
|
219
97
|
{
|
|
220
|
-
|
|
221
|
-
many2one: many2OneComponentFn,
|
|
222
|
-
text: textComponentFn,
|
|
223
|
-
one2many: one2ManyComponentFn,
|
|
224
|
-
many2many: one2ManyComponentFn,
|
|
225
|
-
progressbar: progressBarComponentFn,
|
|
226
|
-
float_time: floatTimeComponent,
|
|
227
|
-
image: imageComponent,
|
|
228
|
-
integer: numberComponent,
|
|
229
|
-
float: numberComponent,
|
|
230
|
-
reference: referenceComponent,
|
|
231
|
-
tag: TagComponent,
|
|
232
|
-
selection: SelectionComponent,
|
|
233
|
-
date: dateComponentFn,
|
|
234
|
-
datetime: dateTimeComponentFn,
|
|
235
|
-
avatar: AvatarFn,
|
|
98
|
+
...COLUMN_COMPONENTS,
|
|
236
99
|
},
|
|
237
100
|
context,
|
|
238
101
|
);
|
|
102
|
+
}, [context, treeOoui]);
|
|
239
103
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
const treeOoui = getTree(treeView);
|
|
106
|
+
setTreeOoui(treeOoui);
|
|
107
|
+
if (treeOoui.string && title !== treeOoui.string) {
|
|
108
|
+
setTitle?.(treeOoui.string);
|
|
244
109
|
}
|
|
245
|
-
|
|
110
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
|
+
}, [treeView, title]);
|
|
246
112
|
|
|
247
113
|
useEffect(() => {
|
|
114
|
+
if (!treeOoui) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
248
117
|
errorInParseColors.current = false;
|
|
249
|
-
const items = getTableItems(treeOoui
|
|
118
|
+
const items = getTableItems(treeOoui, results);
|
|
250
119
|
setItems(items);
|
|
251
|
-
|
|
120
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
252
121
|
}, [results]);
|
|
253
122
|
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
internalLimit.current = limit;
|
|
125
|
+
}, [limit]);
|
|
126
|
+
|
|
254
127
|
const from = (page - 1) * internalLimit.current + 1;
|
|
255
128
|
const to = from - 1 + items.length;
|
|
256
129
|
const summary =
|
|
@@ -263,7 +136,7 @@ function Tree(props: Props): React.ReactElement {
|
|
|
263
136
|
.replace("{to}", to?.toString())
|
|
264
137
|
.replace("{total}", total?.toString());
|
|
265
138
|
|
|
266
|
-
const pagination = () => {
|
|
139
|
+
const pagination = useMemo(() => {
|
|
267
140
|
if (!showPagination || treeView.isExpandable) {
|
|
268
141
|
return null;
|
|
269
142
|
}
|
|
@@ -279,7 +152,7 @@ function Tree(props: Props): React.ReactElement {
|
|
|
279
152
|
) : (
|
|
280
153
|
<Row align="bottom" className="pb-4">
|
|
281
154
|
<Col span={onSelectAllRecords ? 8 : 12}>
|
|
282
|
-
<
|
|
155
|
+
<AntPagination
|
|
283
156
|
total={total}
|
|
284
157
|
pageSize={
|
|
285
158
|
internalLimit.current === 0 ? total : internalLimit.current
|
|
@@ -307,12 +180,24 @@ function Tree(props: Props): React.ReactElement {
|
|
|
307
180
|
</Col>
|
|
308
181
|
</Row>
|
|
309
182
|
);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
183
|
+
}, [
|
|
184
|
+
items,
|
|
185
|
+
loading,
|
|
186
|
+
onRequestPageChange,
|
|
187
|
+
onSelectAllRecords,
|
|
188
|
+
page,
|
|
189
|
+
rowSelection?.selectedRowKeys,
|
|
190
|
+
showPagination,
|
|
191
|
+
summary,
|
|
192
|
+
total,
|
|
193
|
+
treeView.isExpandable,
|
|
194
|
+
]);
|
|
314
195
|
|
|
315
|
-
|
|
196
|
+
const sums = useMemo(() => {
|
|
197
|
+
if (!treeOoui) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
const sumFields = treeOoui.columns
|
|
316
201
|
.filter((it) => it.sum !== undefined)
|
|
317
202
|
.map((it) => {
|
|
318
203
|
return { label: it.sum, field: it.id };
|
|
@@ -341,29 +226,30 @@ function Tree(props: Props): React.ReactElement {
|
|
|
341
226
|
});
|
|
342
227
|
|
|
343
228
|
return <div className="p-1 pb-0 pl-2 mt-2 ">{summary.join(", ")}</div>;
|
|
344
|
-
}
|
|
229
|
+
}, [items, rowSelection?.selectedRowKeys, treeOoui]);
|
|
345
230
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
dataTable = calculateColumnsWidth(columns, items, maxWidthPerCell);
|
|
354
|
-
const tree = treeOoui.current as TreeOoui;
|
|
231
|
+
const dataTable = useMemo(() => {
|
|
232
|
+
if (treeOoui !== null && columns && columns.length > 0) {
|
|
233
|
+
const maxWidthPerCell = 600;
|
|
234
|
+
return calculateColumnsWidth(columns, items, maxWidthPerCell);
|
|
235
|
+
}
|
|
236
|
+
return undefined;
|
|
237
|
+
}, [columns, items, treeOoui]);
|
|
355
238
|
|
|
356
|
-
|
|
357
|
-
|
|
239
|
+
const adjustedHeight = useMemo(() => {
|
|
240
|
+
if (scrollY && treeOoui?.columns.some((it: any) => it.sum !== undefined)) {
|
|
241
|
+
return scrollY - 30;
|
|
358
242
|
}
|
|
243
|
+
return scrollY;
|
|
244
|
+
}, [scrollY, treeOoui?.columns]);
|
|
245
|
+
|
|
246
|
+
if (treeOoui === null || !dataTable || dataTable?.columns?.length === 0) {
|
|
247
|
+
return <Spin style={{ padding: "2rem" }} />;
|
|
359
248
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
) : (
|
|
365
|
-
<div>
|
|
366
|
-
{pagination()}
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<ErrorBoundary>
|
|
252
|
+
{pagination}
|
|
367
253
|
<GisceTable
|
|
368
254
|
height={adjustedHeight!}
|
|
369
255
|
columns={dataTable.columns}
|
|
@@ -404,9 +290,9 @@ function Tree(props: Props): React.ReactElement {
|
|
|
404
290
|
: undefined
|
|
405
291
|
}
|
|
406
292
|
/>
|
|
407
|
-
{
|
|
408
|
-
</
|
|
293
|
+
{sums}
|
|
294
|
+
</ErrorBoundary>
|
|
409
295
|
);
|
|
410
|
-
}
|
|
296
|
+
});
|
|
411
297
|
|
|
412
|
-
|
|
298
|
+
Tree.displayName = "Tree";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Tree";
|