@gisce/react-ooui 1.2.0-rc.4 → 1.2.0-rc.41
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/FormActionBar.d.ts.map +1 -1
- package/dist/actionbar/TreeActionBar.d.ts.map +1 -1
- package/dist/context/ActionViewContext.d.ts +5 -1
- package/dist/context/ActionViewContext.d.ts.map +1 -1
- package/dist/context/ContentRootContext.d.ts.map +1 -1
- package/dist/context/FormContext.d.ts +4 -1
- package/dist/context/FormContext.d.ts.map +1 -1
- package/dist/helpers/formHelper.d.ts +5 -3
- package/dist/helpers/formHelper.d.ts.map +1 -1
- package/dist/helpers/iconMapper.d.ts +5 -1
- package/dist/helpers/iconMapper.d.ts.map +1 -1
- package/dist/helpers/one2manyHelper.d.ts +2 -1
- package/dist/helpers/one2manyHelper.d.ts.map +1 -1
- package/dist/helpers/treeHelper.d.ts +1 -1
- package/dist/helpers/treeHelper.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/locales/ca_ES.d.ts +4 -0
- package/dist/locales/ca_ES.d.ts.map +1 -1
- package/dist/locales/en_US.d.ts +4 -0
- package/dist/locales/en_US.d.ts.map +1 -1
- package/dist/locales/es_ES.d.ts +4 -0
- package/dist/locales/es_ES.d.ts.map +1 -1
- package/dist/react-ooui.es.js +16980 -18378
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +78 -51
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/views/ActionView.d.ts.map +1 -1
- package/dist/views/RootView.d.ts.map +1 -1
- package/dist/views/actionViews/TreeActionView.d.ts.map +1 -1
- package/dist/widgets/WidgetFactory.d.ts.map +1 -1
- package/dist/widgets/base/Integer.d.ts.map +1 -1
- package/dist/widgets/base/Label.d.ts.map +1 -1
- package/dist/widgets/base/ReferenceTree.d.ts +8 -0
- package/dist/widgets/base/ReferenceTree.d.ts.map +1 -0
- package/dist/widgets/base/many2one/Many2one.d.ts.map +1 -1
- package/dist/widgets/base/many2one/Many2oneTree.d.ts +6 -0
- package/dist/widgets/base/many2one/Many2oneTree.d.ts.map +1 -0
- package/dist/widgets/base/one2many/One2manyInput.d.ts.map +1 -1
- package/dist/widgets/custom/MultiCheckbox.d.ts.map +1 -1
- package/dist/widgets/custom/Tag.d.ts +5 -0
- package/dist/widgets/custom/Tag.d.ts.map +1 -0
- package/dist/widgets/custom/Tags.d.ts.map +1 -1
- package/dist/widgets/modals/ExportModal.d.ts +2 -2
- package/dist/widgets/modals/ExportModal.d.ts.map +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/SearchTree.d.ts.map +1 -1
- package/dist/widgets/views/Tree.d.ts +2 -0
- package/dist/widgets/views/Tree.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/__tests__/iconMapper.test.ts +20 -5
- package/src/actionbar/ChangeViewButton.tsx +2 -2
- package/src/actionbar/FormActionBar.tsx +94 -11
- package/src/actionbar/TreeActionBar.tsx +86 -69
- package/src/context/ActionViewContext.tsx +7 -4
- package/src/context/ContentRootContext.tsx +15 -7
- package/src/context/FormContext.tsx +1 -1
- package/src/helpers/formHelper.ts +26 -5
- package/src/helpers/iconMapper.ts +134 -107
- package/src/helpers/one2manyHelper.ts +27 -9
- package/src/helpers/treeHelper.ts +17 -5
- package/src/index.ts +2 -0
- package/src/locales/ca_ES.tsx +4 -0
- package/src/locales/en_US.tsx +4 -0
- package/src/locales/es_ES.tsx +4 -0
- package/src/stories/Label.stories.tsx +7 -8
- package/src/stories/containers/Notebook.stories.tsx +27 -0
- package/src/stories/custom/Tag.stories.tsx +57 -0
- package/src/stories/mocks/models/crm_case.ts +7 -10
- package/src/stories/views/Tree.stories.jsx +5 -5
- package/src/types/index.ts +1 -0
- package/src/views/ActionView.tsx +15 -4
- package/src/views/RootView.tsx +7 -1
- package/src/views/actionViews/TreeActionView.tsx +10 -1
- package/src/widgets/WidgetFactory.tsx +3 -0
- package/src/widgets/base/Integer.tsx +1 -0
- package/src/widgets/base/Label.tsx +5 -9
- package/src/widgets/base/ReferenceTree.tsx +62 -0
- package/src/widgets/base/many2one/Many2one.tsx +8 -9
- package/src/widgets/base/many2one/Many2oneTree.tsx +18 -0
- package/src/widgets/base/one2many/One2manyInput.tsx +2 -0
- package/src/widgets/containers/Group.tsx +3 -3
- package/src/widgets/custom/ButtonGroup.tsx +1 -1
- package/src/widgets/custom/MultiCheckbox.tsx +1 -0
- package/src/widgets/custom/Tag.tsx +24 -0
- package/src/widgets/custom/Tags.tsx +27 -28
- package/src/widgets/modals/ExportModal.tsx +53 -15
- package/src/widgets/views/Dashboard/Dashboard.tsx +5 -1
- package/src/widgets/views/Dashboard/DashboardTree.tsx +1 -0
- package/src/widgets/views/Form.tsx +35 -24
- package/src/widgets/views/SearchTree.tsx +2 -0
- package/src/widgets/views/Tree.tsx +88 -25
- package/dist/helpers/icons/antd_icons.d.ts +0 -4
- package/dist/helpers/icons/antd_icons.d.ts.map +0 -1
- package/dist/helpers/icons/tabler_icons.d.ts +0 -4
- package/dist/helpers/icons/tabler_icons.d.ts.map +0 -1
- package/dist/ui/Fieldset.d.ts +0 -8
- package/dist/ui/Fieldset.d.ts.map +0 -1
- package/src/helpers/icons/antd_icons.ts +0 -1583
- package/src/helpers/icons/tabler_icons.ts +0 -5367
- package/src/ui/Fieldset.tsx +0 -31
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { Pagination, Checkbox, Space, Row, Col, Spin } from "antd";
|
|
2
|
+
import { Pagination, Checkbox, Space, Row, Col, Spin, Tag } from "antd";
|
|
3
3
|
import { getTree, getTableColumns, getTableItems } from "@/helpers/treeHelper";
|
|
4
4
|
import { Tree as TreeOoui } from "@gisce/ooui";
|
|
5
5
|
|
|
6
6
|
import { TreeView, Column } from "@/types";
|
|
7
7
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
8
|
-
import { Many2oneSuffix } from "../base/many2one/Many2oneSuffix";
|
|
9
8
|
import { calculateColumnsWidth } from "@/helpers/dynamicColumnsHelper";
|
|
10
9
|
import { parseFloatToString } from "@/helpers/timeHelper";
|
|
11
10
|
import { ProgressBarInput } from "../base/ProgressBar";
|
|
@@ -16,6 +15,13 @@ import {
|
|
|
16
15
|
LoadingOutlined,
|
|
17
16
|
} from "@ant-design/icons";
|
|
18
17
|
import { One2manyValue } from "../base/one2many/One2manyInput";
|
|
18
|
+
import { Interweave } from "interweave";
|
|
19
|
+
import {
|
|
20
|
+
ActionViewContext,
|
|
21
|
+
ActionViewContextType,
|
|
22
|
+
} from "@/context/ActionViewContext";
|
|
23
|
+
import { Many2oneTree } from "../base/many2one/Many2oneTree";
|
|
24
|
+
import { ReferenceTree } from "../base/ReferenceTree";
|
|
19
25
|
|
|
20
26
|
type Props = {
|
|
21
27
|
total?: number;
|
|
@@ -34,6 +40,8 @@ type Props = {
|
|
|
34
40
|
sorter?: any;
|
|
35
41
|
onFetchChildrenForRecord?: (item: any) => Promise<any[]>;
|
|
36
42
|
childField?: string;
|
|
43
|
+
rootTree?: boolean;
|
|
44
|
+
context?: any;
|
|
37
45
|
};
|
|
38
46
|
|
|
39
47
|
const booleanComponentFn = (value: boolean): React.ReactElement => {
|
|
@@ -51,18 +59,11 @@ const booleanComponentFn = (value: boolean): React.ReactElement => {
|
|
|
51
59
|
};
|
|
52
60
|
|
|
53
61
|
const many2OneComponentFn = (m2oField: any): React.ReactElement => {
|
|
54
|
-
|
|
55
|
-
return <></>;
|
|
56
|
-
}
|
|
57
|
-
return (
|
|
58
|
-
<Space>
|
|
59
|
-
<>{m2oField.value}</>
|
|
60
|
-
<Many2oneSuffix id={m2oField.id} model={m2oField.model} />
|
|
61
|
-
</Space>
|
|
62
|
-
);
|
|
62
|
+
return <Many2oneTree m2oField={m2oField} />;
|
|
63
63
|
};
|
|
64
|
+
|
|
64
65
|
const textComponentFn = (value: any): React.ReactElement => {
|
|
65
|
-
return <
|
|
66
|
+
return <Interweave content={value?.replace(/(?:\r\n|\r|\n)/g, "<br>")} />;
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
const one2ManyComponentFn = (value: One2manyValue): React.ReactElement => {
|
|
@@ -91,6 +92,47 @@ const imageComponent = (value: string): React.ReactElement => {
|
|
|
91
92
|
);
|
|
92
93
|
};
|
|
93
94
|
|
|
95
|
+
const TagComponent = (
|
|
96
|
+
value: any,
|
|
97
|
+
key: string,
|
|
98
|
+
ooui: any,
|
|
99
|
+
context: any
|
|
100
|
+
): React.ReactElement => {
|
|
101
|
+
return (
|
|
102
|
+
<>
|
|
103
|
+
{value ? <Tag color={ooui.colors[value]}>{ooui.selectionValues.get(value)}</Tag> : null}
|
|
104
|
+
</>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const SelectionComponent = (
|
|
109
|
+
value: any,
|
|
110
|
+
key: string,
|
|
111
|
+
ooui: any,
|
|
112
|
+
context: any
|
|
113
|
+
): React.ReactElement => {
|
|
114
|
+
return (
|
|
115
|
+
<>{ooui.selectionValues.get(value)}</>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const referenceComponent = (
|
|
120
|
+
value: any,
|
|
121
|
+
key: string,
|
|
122
|
+
ooui: any,
|
|
123
|
+
context: any
|
|
124
|
+
): React.ReactElement => {
|
|
125
|
+
return (
|
|
126
|
+
<>
|
|
127
|
+
<ReferenceTree
|
|
128
|
+
value={value}
|
|
129
|
+
selectionValues={ooui.selectionValues}
|
|
130
|
+
context={context}
|
|
131
|
+
/>
|
|
132
|
+
</>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
94
136
|
function Tree(props: Props): React.ReactElement {
|
|
95
137
|
const {
|
|
96
138
|
page = 1,
|
|
@@ -109,6 +151,8 @@ function Tree(props: Props): React.ReactElement {
|
|
|
109
151
|
sorter,
|
|
110
152
|
onFetchChildrenForRecord,
|
|
111
153
|
childField,
|
|
154
|
+
rootTree = false,
|
|
155
|
+
context,
|
|
112
156
|
} = props;
|
|
113
157
|
|
|
114
158
|
const [items, setItems] = useState<Array<any>>([]);
|
|
@@ -121,23 +165,40 @@ function Tree(props: Props): React.ReactElement {
|
|
|
121
165
|
const { t } = useContext(LocaleContext) as LocaleContextType;
|
|
122
166
|
const internalLimit = useRef(limit);
|
|
123
167
|
|
|
168
|
+
const actionViewContext = useContext(
|
|
169
|
+
ActionViewContext
|
|
170
|
+
) as ActionViewContextType;
|
|
171
|
+
const { title = undefined, setTitle = undefined } =
|
|
172
|
+
(rootTree ? actionViewContext : {}) || {};
|
|
173
|
+
|
|
124
174
|
useEffect(() => {
|
|
125
175
|
treeOoui.current = getTree(treeView);
|
|
126
176
|
|
|
127
|
-
const columns = getTableColumns(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
177
|
+
const columns = getTableColumns(
|
|
178
|
+
treeOoui.current,
|
|
179
|
+
{
|
|
180
|
+
boolean: booleanComponentFn,
|
|
181
|
+
many2one: many2OneComponentFn,
|
|
182
|
+
text: textComponentFn,
|
|
183
|
+
one2many: one2ManyComponentFn,
|
|
184
|
+
many2many: one2ManyComponentFn,
|
|
185
|
+
progressbar: progressBarComponentFn,
|
|
186
|
+
float_time: floatTimeComponent,
|
|
187
|
+
image: imageComponent,
|
|
188
|
+
integer: numberComponent,
|
|
189
|
+
float: numberComponent,
|
|
190
|
+
reference: referenceComponent,
|
|
191
|
+
tag: TagComponent,
|
|
192
|
+
selection: SelectionComponent,
|
|
193
|
+
},
|
|
194
|
+
context
|
|
195
|
+
);
|
|
139
196
|
|
|
140
197
|
setColumns(columns);
|
|
198
|
+
|
|
199
|
+
if (treeOoui.current.string && title !== treeOoui.current.string) {
|
|
200
|
+
setTitle?.(treeOoui.current.string);
|
|
201
|
+
}
|
|
141
202
|
}, [treeView]);
|
|
142
203
|
|
|
143
204
|
useEffect(() => {
|
|
@@ -171,7 +232,9 @@ function Tree(props: Props): React.ReactElement {
|
|
|
171
232
|
<Col span={12}>
|
|
172
233
|
<Pagination
|
|
173
234
|
total={total}
|
|
174
|
-
pageSize={
|
|
235
|
+
pageSize={
|
|
236
|
+
internalLimit.current === 0 ? total : internalLimit.current
|
|
237
|
+
}
|
|
175
238
|
current={page}
|
|
176
239
|
showSizeChanger={false}
|
|
177
240
|
onChange={onRequestPageChange}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"antd_icons.d.ts","sourceRoot":"","sources":["antd_icons.ts"],"names":[],"mappings":"AAwxBA,eAAO,MAAM,QAAQ,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAsxB1C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tabler_icons.d.ts","sourceRoot":"","sources":["tabler_icons.ts"],"names":[],"mappings":"AA4nFA,eAAO,MAAM,WAAW,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CA0nF7C,CAAC"}
|
package/dist/ui/Fieldset.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Fieldset.d.ts","sourceRoot":"","sources":["Fieldset.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,aAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,GAAG,CAAC;CACf,CAAC;AAEF,QAAA,MAAM,QAAQ,UAAW,KAAK,KAAG,MAAM,YAqBtC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|