@gisce/react-ooui 1.2.0-rc.7 → 1.2.0-rc.71
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/common/DatePicker.d.ts +12 -0
- package/dist/common/DatePicker.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 -2
- 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 +12 -4
- package/dist/helpers/one2manyHelper.d.ts.map +1 -1
- package/dist/helpers/searchHelper.d.ts +1 -1
- package/dist/helpers/searchHelper.d.ts.map +1 -1
- package/dist/helpers/treeHelper.d.ts +1 -1
- package/dist/helpers/treeHelper.d.ts.map +1 -1
- package/dist/hooks/useExport.d.ts +44 -0
- package/dist/hooks/useExport.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/locales/ca_ES.d.ts +2 -0
- package/dist/locales/ca_ES.d.ts.map +1 -1
- package/dist/locales/en_US.d.ts +2 -0
- package/dist/locales/en_US.d.ts.map +1 -1
- package/dist/locales/es_ES.d.ts +2 -0
- package/dist/locales/es_ES.d.ts.map +1 -1
- package/dist/react-ooui.es.js +25403 -27411
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +46 -184
- 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/RootView.d.ts.map +1 -1
- package/dist/views/actionViews/GraphActionView.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/Reference.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/Separator.d.ts.map +1 -1
- 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/containers/Group.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/custom/Timeline.d.ts.map +1 -1
- package/dist/widgets/modals/ExportModal.d.ts +2 -1
- 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/Graph/GraphChart.d.ts.map +1 -1
- package/dist/widgets/views/Graph/GraphDefaults.d.ts +36 -0
- package/dist/widgets/views/Graph/GraphDefaults.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/dist/widgets/views/searchFilter/SearchFilter.d.ts +1 -0
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/__tests__/iconMapper.test.ts +20 -5
- package/src/actionbar/ChangeViewButton.tsx +2 -2
- package/src/actionbar/FormActionBar.tsx +82 -11
- package/src/actionbar/TreeActionBar.tsx +23 -28
- package/src/common/DatePicker.tsx +4 -3
- package/src/context/ActionViewContext.tsx +7 -4
- package/src/context/ContentRootContext.tsx +15 -7
- package/src/context/FormContext.tsx +1 -4
- package/src/helpers/formHelper.ts +26 -5
- package/src/helpers/iconMapper.ts +134 -107
- package/src/helpers/one2manyHelper.ts +94 -39
- package/src/helpers/searchHelper.ts +8 -7
- package/src/helpers/treeHelper.ts +17 -5
- package/src/hooks/useExport.ts +439 -0
- package/src/index.ts +2 -0
- package/src/locales/ca_ES.tsx +2 -0
- package/src/locales/en_US.tsx +2 -0
- package/src/locales/es_ES.tsx +2 -0
- package/src/stories/Label.stories.tsx +7 -8
- package/src/stories/Separator.stories.tsx +33 -0
- package/src/stories/containers/Group.stories.tsx +24 -0
- 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/ui/FavouriteButton.tsx +4 -4
- package/src/views/RootView.tsx +7 -1
- package/src/views/actionViews/GraphActionView.tsx +1 -0
- 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/Reference.tsx +13 -3
- package/src/widgets/base/ReferenceTree.tsx +62 -0
- package/src/widgets/base/Separator.tsx +11 -3
- package/src/widgets/base/many2one/Many2one.tsx +10 -19
- package/src/widgets/base/many2one/Many2oneTree.tsx +18 -0
- package/src/widgets/base/one2many/One2manyInput.tsx +79 -23
- package/src/widgets/containers/Group.tsx +7 -4
- 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/custom/Timeline.tsx +9 -3
- package/src/widgets/modals/ExportModal.tsx +33 -134
- package/src/widgets/views/Dashboard/Dashboard.tsx +15 -4
- package/src/widgets/views/Dashboard/DashboardTree.tsx +1 -0
- package/src/widgets/views/Form.tsx +38 -31
- package/src/widgets/views/Graph/GraphChart.tsx +6 -1
- package/src/widgets/views/Graph/GraphDefaults.ts +113 -0
- package/src/widgets/views/Graph/GraphIndicator.tsx +17 -3
- package/src/widgets/views/SearchTree.tsx +3 -0
- package/src/widgets/views/Tree.tsx +111 -25
- package/src/widgets/views/searchFilter/SearchFilter.tsx +12 -6
- 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,15 @@ 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";
|
|
25
|
+
import moment from "moment";
|
|
26
|
+
import { DatePickerConfig } from "@/common/DatePicker";
|
|
19
27
|
|
|
20
28
|
type Props = {
|
|
21
29
|
total?: number;
|
|
@@ -34,6 +42,8 @@ type Props = {
|
|
|
34
42
|
sorter?: any;
|
|
35
43
|
onFetchChildrenForRecord?: (item: any) => Promise<any[]>;
|
|
36
44
|
childField?: string;
|
|
45
|
+
rootTree?: boolean;
|
|
46
|
+
context?: any;
|
|
37
47
|
};
|
|
38
48
|
|
|
39
49
|
const booleanComponentFn = (value: boolean): React.ReactElement => {
|
|
@@ -51,18 +61,30 @@ const booleanComponentFn = (value: boolean): React.ReactElement => {
|
|
|
51
61
|
};
|
|
52
62
|
|
|
53
63
|
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
|
-
);
|
|
64
|
+
return <Many2oneTree m2oField={m2oField} />;
|
|
63
65
|
};
|
|
66
|
+
|
|
64
67
|
const textComponentFn = (value: any): React.ReactElement => {
|
|
65
|
-
return <
|
|
68
|
+
return <Interweave content={value?.replace(/(?:\r\n|\r|\n)/g, "<br>")} />;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const dateComponentFn = (value: any): React.ReactElement => {
|
|
72
|
+
if (!value || (value && value.length === 0)) return <></>;
|
|
73
|
+
|
|
74
|
+
const formattedValue = moment(
|
|
75
|
+
value,
|
|
76
|
+
DatePickerConfig.date.dateInternalFormat
|
|
77
|
+
).format(DatePickerConfig.date.dateDisplayFormat);
|
|
78
|
+
return <>{formattedValue}</>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const dateTimeComponentFn = (value: any): React.ReactElement => {
|
|
82
|
+
if (!value || (value && value.length === 0)) return <></>;
|
|
83
|
+
const formattedValue = moment(
|
|
84
|
+
value,
|
|
85
|
+
DatePickerConfig.time.dateInternalFormat
|
|
86
|
+
).format(DatePickerConfig.time.dateDisplayFormat);
|
|
87
|
+
return <>{formattedValue}</>;
|
|
66
88
|
};
|
|
67
89
|
|
|
68
90
|
const one2ManyComponentFn = (value: One2manyValue): React.ReactElement => {
|
|
@@ -91,6 +113,47 @@ const imageComponent = (value: string): React.ReactElement => {
|
|
|
91
113
|
);
|
|
92
114
|
};
|
|
93
115
|
|
|
116
|
+
const TagComponent = (
|
|
117
|
+
value: any,
|
|
118
|
+
key: string,
|
|
119
|
+
ooui: any,
|
|
120
|
+
context: any
|
|
121
|
+
): React.ReactElement => {
|
|
122
|
+
return (
|
|
123
|
+
<>
|
|
124
|
+
{value ? <Tag color={ooui.colors[value]}>{ooui.selectionValues.get(value)}</Tag> : null}
|
|
125
|
+
</>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const SelectionComponent = (
|
|
130
|
+
value: any,
|
|
131
|
+
key: string,
|
|
132
|
+
ooui: any,
|
|
133
|
+
context: any
|
|
134
|
+
): React.ReactElement => {
|
|
135
|
+
return (
|
|
136
|
+
<>{ooui.selectionValues.get(value)}</>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const referenceComponent = (
|
|
141
|
+
value: any,
|
|
142
|
+
key: string,
|
|
143
|
+
ooui: any,
|
|
144
|
+
context: any
|
|
145
|
+
): React.ReactElement => {
|
|
146
|
+
return (
|
|
147
|
+
<>
|
|
148
|
+
<ReferenceTree
|
|
149
|
+
value={value}
|
|
150
|
+
selectionValues={ooui.selectionValues}
|
|
151
|
+
context={context}
|
|
152
|
+
/>
|
|
153
|
+
</>
|
|
154
|
+
);
|
|
155
|
+
};
|
|
156
|
+
|
|
94
157
|
function Tree(props: Props): React.ReactElement {
|
|
95
158
|
const {
|
|
96
159
|
page = 1,
|
|
@@ -109,6 +172,8 @@ function Tree(props: Props): React.ReactElement {
|
|
|
109
172
|
sorter,
|
|
110
173
|
onFetchChildrenForRecord,
|
|
111
174
|
childField,
|
|
175
|
+
rootTree = false,
|
|
176
|
+
context,
|
|
112
177
|
} = props;
|
|
113
178
|
|
|
114
179
|
const [items, setItems] = useState<Array<any>>([]);
|
|
@@ -121,23 +186,42 @@ function Tree(props: Props): React.ReactElement {
|
|
|
121
186
|
const { t } = useContext(LocaleContext) as LocaleContextType;
|
|
122
187
|
const internalLimit = useRef(limit);
|
|
123
188
|
|
|
189
|
+
const actionViewContext = useContext(
|
|
190
|
+
ActionViewContext
|
|
191
|
+
) as ActionViewContextType;
|
|
192
|
+
const { title = undefined, setTitle = undefined } =
|
|
193
|
+
(rootTree ? actionViewContext : {}) || {};
|
|
194
|
+
|
|
124
195
|
useEffect(() => {
|
|
125
196
|
treeOoui.current = getTree(treeView);
|
|
126
197
|
|
|
127
|
-
const columns = getTableColumns(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
198
|
+
const columns = getTableColumns(
|
|
199
|
+
treeOoui.current,
|
|
200
|
+
{
|
|
201
|
+
boolean: booleanComponentFn,
|
|
202
|
+
many2one: many2OneComponentFn,
|
|
203
|
+
text: textComponentFn,
|
|
204
|
+
one2many: one2ManyComponentFn,
|
|
205
|
+
many2many: one2ManyComponentFn,
|
|
206
|
+
progressbar: progressBarComponentFn,
|
|
207
|
+
float_time: floatTimeComponent,
|
|
208
|
+
image: imageComponent,
|
|
209
|
+
integer: numberComponent,
|
|
210
|
+
float: numberComponent,
|
|
211
|
+
reference: referenceComponent,
|
|
212
|
+
tag: TagComponent,
|
|
213
|
+
selection: SelectionComponent,
|
|
214
|
+
date: dateComponentFn,
|
|
215
|
+
datetime: dateTimeComponentFn,
|
|
216
|
+
},
|
|
217
|
+
context
|
|
218
|
+
);
|
|
139
219
|
|
|
140
220
|
setColumns(columns);
|
|
221
|
+
|
|
222
|
+
if (treeOoui.current.string && title !== treeOoui.current.string) {
|
|
223
|
+
setTitle?.(treeOoui.current.string);
|
|
224
|
+
}
|
|
141
225
|
}, [treeView]);
|
|
142
226
|
|
|
143
227
|
useEffect(() => {
|
|
@@ -171,7 +255,9 @@ function Tree(props: Props): React.ReactElement {
|
|
|
171
255
|
<Col span={12}>
|
|
172
256
|
<Pagination
|
|
173
257
|
total={total}
|
|
174
|
-
pageSize={
|
|
258
|
+
pageSize={
|
|
259
|
+
internalLimit.current === 0 ? total : internalLimit.current
|
|
260
|
+
}
|
|
175
261
|
current={page}
|
|
176
262
|
showSizeChanger={false}
|
|
177
263
|
onChange={onRequestPageChange}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
2
2
|
import { Form, Row, Col, Alert } from "antd";
|
|
3
3
|
import useDeepCompareEffect from "use-deep-compare-effect";
|
|
4
4
|
|
|
@@ -30,6 +30,7 @@ type Props = {
|
|
|
30
30
|
searchError?: string;
|
|
31
31
|
searchValues?: any;
|
|
32
32
|
showLimitOptions?: boolean;
|
|
33
|
+
formXml: string;
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
function SearchFilter(props: Props) {
|
|
@@ -47,11 +48,13 @@ function SearchFilter(props: Props) {
|
|
|
47
48
|
searchError,
|
|
48
49
|
searchValues,
|
|
49
50
|
showLimitOptions = true,
|
|
51
|
+
formXml,
|
|
50
52
|
} = props;
|
|
51
53
|
|
|
52
54
|
const [simpleSearchFields, setSimpleSearchFields] = useState<Container>();
|
|
53
55
|
const [advancedSearchFields, setAdvancedSearchFields] = useState<Container>();
|
|
54
56
|
const [advancedFilter, setAdvancedFilter] = useState(false);
|
|
57
|
+
const sfo = useRef<SearchFilterOoui>();
|
|
55
58
|
|
|
56
59
|
const [form] = Form.useForm();
|
|
57
60
|
|
|
@@ -84,10 +87,10 @@ function SearchFilter(props: Props) {
|
|
|
84
87
|
|
|
85
88
|
useDeepCompareEffect(() => {
|
|
86
89
|
setAdvancedFilter(false);
|
|
87
|
-
|
|
88
|
-
sfo.parse();
|
|
89
|
-
setSimpleSearchFields(sfo._simpleSearchContainer);
|
|
90
|
-
setAdvancedSearchFields(sfo._advancedSearchContainer);
|
|
90
|
+
sfo.current = new SearchFilterOoui(searchFields, fields, formXml);
|
|
91
|
+
sfo.current.parse();
|
|
92
|
+
setSimpleSearchFields(sfo.current._simpleSearchContainer);
|
|
93
|
+
setAdvancedSearchFields(sfo.current._advancedSearchContainer);
|
|
91
94
|
}, [fields, searchFields]);
|
|
92
95
|
|
|
93
96
|
const rows = getRowsAndCols();
|
|
@@ -96,7 +99,10 @@ function SearchFilter(props: Props) {
|
|
|
96
99
|
const { limit, offset } = values;
|
|
97
100
|
delete values.offset;
|
|
98
101
|
delete values.limit;
|
|
99
|
-
const newParams = getParamsForFields(
|
|
102
|
+
const newParams = getParamsForFields(
|
|
103
|
+
values,
|
|
104
|
+
sfo.current?._advancedSearchContainer
|
|
105
|
+
);
|
|
100
106
|
|
|
101
107
|
onSubmit({ params: newParams, offset, limit, searchValues: values });
|
|
102
108
|
};
|
|
@@ -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"}
|