@gisce/react-ooui 1.4.17-rc.1 → 1.4.17
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/common/SelectAllRecordsRow.d.ts +10 -0
- package/dist/common/SelectAllRecordsRow.d.ts.map +1 -0
- package/dist/react-ooui.es.js +1806 -1761
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +16 -12
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/widgets/views/Tree.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/SelectAllRecordsRow.tsx +91 -0
- package/src/widgets/views/Tree.tsx +21 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["Tree.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAUvE,OAAO,EAAE,QAAQ,EAAU,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["Tree.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAUvE,OAAO,EAAE,QAAQ,EAAU,MAAM,SAAS,CAAC;AAyB3C,aAAK,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,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,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;AAmHF,iBAAS,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CA2O9C;AAED,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gisce/react-ooui",
|
|
3
|
-
"version": "1.4.17
|
|
3
|
+
"version": "1.4.17",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"src",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@gisce/fiber-diagram": "^1.1.0-rc.3",
|
|
36
36
|
"@gisce/ooui": "^0.22.3",
|
|
37
37
|
"@gisce/react-formiga-components": "^1.0.9-rc.21",
|
|
38
|
-
"@gisce/react-formiga-table": "^0.8.
|
|
38
|
+
"@gisce/react-formiga-table": "^0.8.6",
|
|
39
39
|
"@monaco-editor/react": "^4.4.5",
|
|
40
40
|
"@tabler/icons-react": "^2.11.0",
|
|
41
41
|
"antd": "^5.5.2",
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import { useContext, useState } from "react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Spin } from "antd";
|
|
5
|
+
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
6
|
+
import Link from "antd/es/typography/Link";
|
|
7
|
+
|
|
8
|
+
export const Container = styled.div`
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const SelectAllRecordsRow = ({
|
|
15
|
+
numberOfVisibleSelectedRows,
|
|
16
|
+
totalRecords,
|
|
17
|
+
numberOfTotalRows,
|
|
18
|
+
onSelectAllRecords,
|
|
19
|
+
numberOfRealSelectedRows,
|
|
20
|
+
}: {
|
|
21
|
+
numberOfVisibleSelectedRows: number;
|
|
22
|
+
totalRecords: number;
|
|
23
|
+
numberOfTotalRows: number;
|
|
24
|
+
numberOfRealSelectedRows: number;
|
|
25
|
+
onSelectAllRecords: () => Promise<void>;
|
|
26
|
+
}) => {
|
|
27
|
+
const [loading, setLoading] = useState(false);
|
|
28
|
+
const { t } = useContext(LocaleContext) as LocaleContextType;
|
|
29
|
+
|
|
30
|
+
const translations = {
|
|
31
|
+
recordsSelected: t("recordsSelected"),
|
|
32
|
+
selectAllRecords: t("selectAllRecords"),
|
|
33
|
+
allRecordsSelected: t("allRecordsSelected"),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (numberOfTotalRows === 0) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (
|
|
41
|
+
numberOfVisibleSelectedRows < numberOfTotalRows &&
|
|
42
|
+
numberOfRealSelectedRows <= numberOfTotalRows
|
|
43
|
+
) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const handleClick = async (event: any) => {
|
|
48
|
+
event.preventDefault(); // prevent the default action (navigation) from happening
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
setLoading(true);
|
|
51
|
+
await onSelectAllRecords();
|
|
52
|
+
setLoading(false);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const selectRowsComponent = (
|
|
56
|
+
<span>
|
|
57
|
+
{translations.recordsSelected.replace(
|
|
58
|
+
"{numberOfSelectedRows}",
|
|
59
|
+
numberOfVisibleSelectedRows.toString()
|
|
60
|
+
) + " "}
|
|
61
|
+
|
|
62
|
+
{loading ? (
|
|
63
|
+
<Spin />
|
|
64
|
+
) : (
|
|
65
|
+
<Link onClick={handleClick} style={{ fontWeight: 600 }}>
|
|
66
|
+
{translations.selectAllRecords.replace(
|
|
67
|
+
"{totalRecords}",
|
|
68
|
+
totalRecords.toString()
|
|
69
|
+
)}
|
|
70
|
+
</Link>
|
|
71
|
+
)}
|
|
72
|
+
</span>
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const allRowsAreSelected = (
|
|
76
|
+
<span style={{ fontWeight: 600 }}>
|
|
77
|
+
{translations.allRecordsSelected.replace(
|
|
78
|
+
"{totalRecords}",
|
|
79
|
+
numberOfRealSelectedRows.toString()
|
|
80
|
+
) + " "}
|
|
81
|
+
</span>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<Container>
|
|
86
|
+
{numberOfRealSelectedRows > numberOfTotalRows
|
|
87
|
+
? allRowsAreSelected
|
|
88
|
+
: selectRowsComponent}
|
|
89
|
+
</Container>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
@@ -31,6 +31,7 @@ import dayjs from "dayjs";
|
|
|
31
31
|
import Avatar from "../custom/Avatar";
|
|
32
32
|
import { TagInput } from "../custom/Tag";
|
|
33
33
|
import { DatePickerConfig } from "@/common/DatePicker";
|
|
34
|
+
import { SelectAllRecordsRow } from "@/common/SelectAllRecordsRow";
|
|
34
35
|
|
|
35
36
|
type Props = {
|
|
36
37
|
total?: number;
|
|
@@ -271,7 +272,7 @@ function Tree(props: Props): React.ReactElement {
|
|
|
271
272
|
<Spin className="pb-4" />
|
|
272
273
|
) : (
|
|
273
274
|
<Row align="bottom" className="pb-4">
|
|
274
|
-
<Col span={
|
|
275
|
+
<Col span={8}>
|
|
275
276
|
<Pagination
|
|
276
277
|
total={total}
|
|
277
278
|
pageSize={
|
|
@@ -282,7 +283,18 @@ function Tree(props: Props): React.ReactElement {
|
|
|
282
283
|
onChange={onRequestPageChange}
|
|
283
284
|
/>
|
|
284
285
|
</Col>
|
|
285
|
-
<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">
|
|
286
298
|
{summary}
|
|
287
299
|
</Col>
|
|
288
300
|
</Row>
|
|
@@ -338,7 +350,13 @@ function Tree(props: Props): React.ReactElement {
|
|
|
338
350
|
}
|
|
339
351
|
}
|
|
340
352
|
|
|
341
|
-
|
|
353
|
+
const numberOfVisibleSelectedRows = items.filter((entry) =>
|
|
354
|
+
rowSelection?.selectedRowKeys.includes(entry.id)
|
|
355
|
+
).length;
|
|
356
|
+
|
|
357
|
+
return treeOoui.current === null ||
|
|
358
|
+
!dataTable ||
|
|
359
|
+
dataTable.columns?.length === 0 ? (
|
|
342
360
|
<Spin style={{ padding: "2rem" }} />
|
|
343
361
|
) : (
|
|
344
362
|
<div>
|
|
@@ -383,13 +401,6 @@ function Tree(props: Props): React.ReactElement {
|
|
|
383
401
|
}
|
|
384
402
|
: undefined
|
|
385
403
|
}
|
|
386
|
-
onSelectAllRecords={onSelectAllRecords}
|
|
387
|
-
totalItems={total || 0}
|
|
388
|
-
translations={{
|
|
389
|
-
recordsSelected: t("recordsSelected"),
|
|
390
|
-
selectAllRecords: t("selectAllRecords"),
|
|
391
|
-
allRecordsSelected: t("allRecordsSelected"),
|
|
392
|
-
}}
|
|
393
404
|
/>
|
|
394
405
|
{getSums()}
|
|
395
406
|
</div>
|