@gisce/react-ooui 2.0.0-rc.0 → 2.0.0-rc.11
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/TreeActionBar.d.ts.map +1 -1
- package/dist/common/SelectAllRecordsRow.d.ts +10 -0
- package/dist/common/SelectAllRecordsRow.d.ts.map +1 -0
- package/dist/context/ContentRootContext.d.ts.map +1 -1
- package/dist/helpers/dynamicColumnsHelper.d.ts +9 -1
- package/dist/helpers/dynamicColumnsHelper.d.ts.map +1 -1
- package/dist/helpers/formHelper.d.ts +1 -0
- package/dist/helpers/formHelper.d.ts.map +1 -1
- package/dist/helpers/treeHelper.d.ts +2 -1
- package/dist/helpers/treeHelper.d.ts.map +1 -1
- package/dist/hooks/useSearch.d.ts +1 -0
- package/dist/hooks/useSearch.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 +5621 -5204
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +19 -14
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/types/index.d.ts +30 -29
- package/dist/types/index.d.ts.map +1 -1
- package/dist/views/actionViews/GraphActionView.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/many2one/Many2oneSuffix.d.ts.map +1 -1
- package/dist/widgets/base/one2many/One2manyInput.d.ts.map +1 -1
- package/dist/widgets/custom/Avatar.d.ts.map +1 -1
- package/dist/widgets/custom/Comments.d.ts +35 -0
- package/dist/widgets/custom/Comments.d.ts.map +1 -0
- package/dist/widgets/views/Form.d.ts +2 -2
- 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 +1 -0
- package/dist/widgets/views/Tree.d.ts.map +1 -1
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts +0 -1
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts.map +1 -1
- package/package.json +5 -3
- package/src/actionbar/FormActionBar.tsx +1 -1
- package/src/actionbar/TreeActionBar.tsx +84 -82
- package/src/common/SelectAllRecordsRow.tsx +95 -0
- package/src/context/ContentRootContext.tsx +5 -3
- package/src/helpers/dynamicColumnsHelper.ts +1 -1
- package/src/helpers/formHelper.ts +5 -0
- package/src/helpers/iconMapper.ts +1 -2
- package/src/helpers/treeHelper.ts +14 -3
- package/src/hooks/useExport.ts +2 -3
- package/src/hooks/useSearch.ts +16 -3
- package/src/index.ts +2 -0
- package/src/locales/ca_ES.tsx +5 -0
- package/src/locales/en_US.tsx +5 -0
- package/src/locales/es_ES.tsx +5 -0
- package/src/stories/custom/Comments.stories.tsx +190 -0
- package/src/stories/dashboard/DashboardGrid.stories.tsx +13 -0
- package/src/stories/mocks/models/cups.ts +16 -3
- package/src/types/index.ts +92 -41
- package/src/views/actionViews/GraphActionView.tsx +0 -1
- package/src/widgets/WidgetFactory.tsx +3 -0
- package/src/widgets/base/Integer.tsx +14 -1
- package/src/widgets/base/many2one/Many2oneSuffix.tsx +24 -12
- package/src/widgets/base/one2many/One2manyInput.tsx +11 -3
- package/src/widgets/custom/Avatar.tsx +0 -1
- package/src/widgets/custom/Comments.tsx +144 -0
- package/src/widgets/views/Form.tsx +83 -9
- package/src/widgets/views/Graph/GraphIndicator.tsx +3 -3
- package/src/widgets/views/SearchTree.tsx +12 -8
- package/src/widgets/views/Tree.tsx +62 -48
- package/src/widgets/views/searchFilter/SearchFilter.tsx +1 -3
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useCallback,
|
|
3
|
-
useContext,
|
|
4
|
-
useEffect,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
} from "react";
|
|
1
|
+
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
8
2
|
import { Pagination, Checkbox, Space, Row, Col, Spin, Tag, Badge } from "antd";
|
|
9
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
getTree,
|
|
5
|
+
getTableColumns,
|
|
6
|
+
getTableItems,
|
|
7
|
+
hasActualValues,
|
|
8
|
+
} from "@/helpers/treeHelper";
|
|
10
9
|
import { Tree as TreeOoui } from "@gisce/ooui";
|
|
11
10
|
|
|
12
11
|
import { TreeView, Column } from "@/types";
|
|
@@ -32,6 +31,7 @@ import dayjs from "dayjs";
|
|
|
32
31
|
import Avatar from "../custom/Avatar";
|
|
33
32
|
import { TagInput } from "../custom/Tag";
|
|
34
33
|
import { DatePickerConfig } from "@/common/DatePicker";
|
|
34
|
+
import { SelectAllRecordsRow } from "@/common/SelectAllRecordsRow";
|
|
35
35
|
|
|
36
36
|
type Props = {
|
|
37
37
|
total?: number;
|
|
@@ -54,6 +54,7 @@ type Props = {
|
|
|
54
54
|
rootTree?: boolean;
|
|
55
55
|
context?: any;
|
|
56
56
|
readonly?: boolean;
|
|
57
|
+
onSelectAllRecords?: () => Promise<void>;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
const booleanComponentFn = (value: boolean): React.ReactElement => {
|
|
@@ -114,8 +115,8 @@ const floatTimeComponent = (value: number): React.ReactElement => {
|
|
|
114
115
|
return <>{parseFloatToString(value)}</>;
|
|
115
116
|
};
|
|
116
117
|
|
|
117
|
-
const numberComponent = (value:
|
|
118
|
-
return <div style={{ textAlign: "right" }}>{
|
|
118
|
+
const numberComponent = (value: number): React.ReactElement => {
|
|
119
|
+
return <div style={{ textAlign: "right" }}>{value}</div>;
|
|
119
120
|
};
|
|
120
121
|
|
|
121
122
|
const imageComponent = (value: string): React.ReactElement => {
|
|
@@ -191,6 +192,7 @@ function Tree(props: Props): React.ReactElement {
|
|
|
191
192
|
rootTree = false,
|
|
192
193
|
context,
|
|
193
194
|
readonly,
|
|
195
|
+
onSelectAllRecords,
|
|
194
196
|
} = props;
|
|
195
197
|
|
|
196
198
|
const [items, setItems] = useState<Array<any>>([]);
|
|
@@ -215,22 +217,22 @@ function Tree(props: Props): React.ReactElement {
|
|
|
215
217
|
const columns = getTableColumns(
|
|
216
218
|
treeOoui.current,
|
|
217
219
|
{
|
|
218
|
-
boolean:
|
|
219
|
-
many2one:
|
|
220
|
-
text:
|
|
221
|
-
one2many:
|
|
222
|
-
many2many:
|
|
223
|
-
progressbar:
|
|
224
|
-
float_time:
|
|
225
|
-
image:
|
|
220
|
+
boolean: booleanComponentFn,
|
|
221
|
+
many2one: many2OneComponentFn,
|
|
222
|
+
text: textComponentFn,
|
|
223
|
+
one2many: one2ManyComponentFn,
|
|
224
|
+
many2many: one2ManyComponentFn,
|
|
225
|
+
progressbar: progressBarComponentFn,
|
|
226
|
+
float_time: floatTimeComponent,
|
|
227
|
+
image: imageComponent,
|
|
226
228
|
integer: numberComponent,
|
|
227
229
|
float: numberComponent,
|
|
228
|
-
reference:
|
|
229
|
-
tag:
|
|
230
|
-
selection:
|
|
231
|
-
date:
|
|
232
|
-
datetime:
|
|
233
|
-
avatar:
|
|
230
|
+
reference: referenceComponent,
|
|
231
|
+
tag: TagComponent,
|
|
232
|
+
selection: SelectionComponent,
|
|
233
|
+
date: dateComponentFn,
|
|
234
|
+
datetime: dateTimeComponentFn,
|
|
235
|
+
avatar: AvatarFn,
|
|
234
236
|
},
|
|
235
237
|
context
|
|
236
238
|
);
|
|
@@ -270,7 +272,7 @@ function Tree(props: Props): React.ReactElement {
|
|
|
270
272
|
<Spin className="pb-4" />
|
|
271
273
|
) : (
|
|
272
274
|
<Row align="bottom" className="pb-4">
|
|
273
|
-
<Col span={
|
|
275
|
+
<Col span={8}>
|
|
274
276
|
<Pagination
|
|
275
277
|
total={total}
|
|
276
278
|
pageSize={
|
|
@@ -281,7 +283,18 @@ function Tree(props: Props): React.ReactElement {
|
|
|
281
283
|
onChange={onRequestPageChange}
|
|
282
284
|
/>
|
|
283
285
|
</Col>
|
|
284
|
-
<Col span={
|
|
286
|
+
<Col span={8} className="text-center">
|
|
287
|
+
{onSelectAllRecords && (
|
|
288
|
+
<SelectAllRecordsRow
|
|
289
|
+
numberOfVisibleSelectedRows={numberOfVisibleSelectedRows}
|
|
290
|
+
numberOfRealSelectedRows={rowSelection?.selectedRowKeys.length}
|
|
291
|
+
numberOfTotalRows={items.length}
|
|
292
|
+
totalRecords={total || 0}
|
|
293
|
+
onSelectAllRecords={onSelectAllRecords}
|
|
294
|
+
/>
|
|
295
|
+
)}
|
|
296
|
+
</Col>
|
|
297
|
+
<Col span={8} className="text-right">
|
|
285
298
|
{summary}
|
|
286
299
|
</Col>
|
|
287
300
|
</Row>
|
|
@@ -337,27 +350,13 @@ function Tree(props: Props): React.ReactElement {
|
|
|
337
350
|
}
|
|
338
351
|
}
|
|
339
352
|
|
|
340
|
-
const
|
|
341
|
-
(
|
|
342
|
-
|
|
343
|
-
return { color: colorsForResults![record.id] };
|
|
344
|
-
}
|
|
345
|
-
return undefined;
|
|
346
|
-
},
|
|
347
|
-
[colorsForResults]
|
|
348
|
-
);
|
|
349
|
-
|
|
350
|
-
const onRowStatus = useCallback(
|
|
351
|
-
(record: any) => {
|
|
352
|
-
if (statusForResults![record.id]) {
|
|
353
|
-
return <Badge color={statusForResults[record.id]} />;
|
|
354
|
-
}
|
|
355
|
-
return undefined;
|
|
356
|
-
},
|
|
357
|
-
[statusForResults]
|
|
358
|
-
);
|
|
353
|
+
const numberOfVisibleSelectedRows = items.filter((entry) =>
|
|
354
|
+
rowSelection?.selectedRowKeys.includes(entry.id)
|
|
355
|
+
).length;
|
|
359
356
|
|
|
360
|
-
return treeOoui.current === null
|
|
357
|
+
return treeOoui.current === null ||
|
|
358
|
+
!dataTable ||
|
|
359
|
+
dataTable.columns?.length === 0 ? (
|
|
361
360
|
<Spin style={{ padding: "2rem" }} />
|
|
362
361
|
) : (
|
|
363
362
|
<div>
|
|
@@ -368,9 +367,24 @@ function Tree(props: Props): React.ReactElement {
|
|
|
368
367
|
dataSource={items}
|
|
369
368
|
loading={loading}
|
|
370
369
|
loadingComponent={<Spin />}
|
|
371
|
-
onRowStyle={
|
|
372
|
-
|
|
370
|
+
onRowStyle={(record: any) => {
|
|
371
|
+
if (colorsForResults![record.id]) {
|
|
372
|
+
return { color: colorsForResults![record.id] };
|
|
373
|
+
}
|
|
374
|
+
return undefined;
|
|
375
|
+
}}
|
|
376
|
+
onRowStatus={
|
|
377
|
+
hasActualValues(statusForResults)
|
|
378
|
+
? (record: any) => {
|
|
379
|
+
if (statusForResults![record.id]) {
|
|
380
|
+
return <Badge color={statusForResults[record.id]} />;
|
|
381
|
+
}
|
|
382
|
+
return undefined;
|
|
383
|
+
}
|
|
384
|
+
: undefined
|
|
385
|
+
}
|
|
373
386
|
onRowDoubleClick={onRowClicked}
|
|
387
|
+
selectionRowKeys={rowSelection?.selectedRowKeys}
|
|
374
388
|
onRowSelectionChange={rowSelection?.onChange}
|
|
375
389
|
onChangeSort={onChangeSort}
|
|
376
390
|
sorter={sorter}
|
|
@@ -31,7 +31,6 @@ type Props = {
|
|
|
31
31
|
searchError?: string;
|
|
32
32
|
searchValues?: any;
|
|
33
33
|
showLimitOptions?: boolean;
|
|
34
|
-
formXml: string;
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
function SearchFilter(props: Props) {
|
|
@@ -49,7 +48,6 @@ function SearchFilter(props: Props) {
|
|
|
49
48
|
searchError,
|
|
50
49
|
searchValues,
|
|
51
50
|
showLimitOptions = true,
|
|
52
|
-
formXml,
|
|
53
51
|
} = props;
|
|
54
52
|
|
|
55
53
|
const [simpleSearchFields, setSimpleSearchFields] = useState<Container>();
|
|
@@ -89,7 +87,7 @@ function SearchFilter(props: Props) {
|
|
|
89
87
|
|
|
90
88
|
useDeepCompareEffect(() => {
|
|
91
89
|
setAdvancedFilter(false);
|
|
92
|
-
sfo.current = new SearchFilterOoui(searchFields, fields
|
|
90
|
+
sfo.current = new SearchFilterOoui(searchFields, fields);
|
|
93
91
|
sfo.current.parse();
|
|
94
92
|
setSimpleSearchFields(sfo.current._simpleSearchContainer);
|
|
95
93
|
setAdvancedSearchFields(sfo.current._advancedSearchContainer);
|