@eeacms/volto-tableau 3.0.5 → 3.0.6
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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [3.0.6](https://github.com/eea/volto-tableau/compare/3.0.5...3.0.6) - 30 January 2023
|
|
8
|
+
|
|
7
9
|
### [3.0.5](https://github.com/eea/volto-tableau/compare/3.0.4...3.0.5) - 26 January 2023
|
|
8
10
|
|
|
9
11
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -1,22 +1,64 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Popup, Button, Modal } from 'semantic-ui-react';
|
|
2
|
+
import { Popup, Button, Modal, Dropdown } from 'semantic-ui-react';
|
|
3
3
|
import { Icon } from '@plone/volto/components';
|
|
4
4
|
import downloadSVG from '@plone/volto/icons/download.svg';
|
|
5
5
|
|
|
6
6
|
const TableauDownload = (props) => {
|
|
7
|
-
const [open, setOpen] = React.useState(false);
|
|
8
7
|
const viz = props.viz || {};
|
|
9
8
|
|
|
9
|
+
const [open, setOpen] = React.useState(false);
|
|
10
|
+
const [
|
|
11
|
+
isSheetSelectorCsvVisible,
|
|
12
|
+
setIsSheetSelectorCsvVisible,
|
|
13
|
+
] = React.useState(false);
|
|
14
|
+
const [
|
|
15
|
+
isSheetSelectorExcelVisible,
|
|
16
|
+
setIsSheetSelectorExcelVisible,
|
|
17
|
+
] = React.useState(false);
|
|
18
|
+
const [availableSheets, setAvailableSheets] = React.useState([]);
|
|
19
|
+
|
|
20
|
+
const initializeDropdown = () => {
|
|
21
|
+
const sheets = viz
|
|
22
|
+
?.getWorkbook()
|
|
23
|
+
?.getActiveSheet()
|
|
24
|
+
?.getWorksheets()
|
|
25
|
+
.map((sheet, index) => ({
|
|
26
|
+
key: index,
|
|
27
|
+
text: sheet.getName(),
|
|
28
|
+
value: sheet.getName(),
|
|
29
|
+
}));
|
|
30
|
+
setAvailableSheets(sheets);
|
|
31
|
+
};
|
|
32
|
+
|
|
10
33
|
const exportImage = () => {
|
|
34
|
+
setIsSheetSelectorCsvVisible(false);
|
|
35
|
+
setIsSheetSelectorExcelVisible(false);
|
|
11
36
|
viz.showExportImageDialog();
|
|
12
37
|
};
|
|
13
38
|
|
|
14
39
|
const exportToCSV = () => {
|
|
15
|
-
|
|
40
|
+
setIsSheetSelectorExcelVisible(false);
|
|
41
|
+
initializeDropdown();
|
|
42
|
+
setIsSheetSelectorCsvVisible(true);
|
|
16
43
|
};
|
|
17
44
|
|
|
18
45
|
const exportToExcel = () => {
|
|
19
|
-
|
|
46
|
+
setIsSheetSelectorCsvVisible(false);
|
|
47
|
+
initializeDropdown();
|
|
48
|
+
setIsSheetSelectorExcelVisible(true);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const handleSheetSelectionCsvChange = (e, data) => {
|
|
52
|
+
viz.showExportCrossTabDialog(data.value);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const handleSheetSelectionExcelChange = (e, data) => {
|
|
56
|
+
viz.exportCrossTabToExcel(data.value);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const hideDropdowns = () => {
|
|
60
|
+
setIsSheetSelectorCsvVisible(false);
|
|
61
|
+
setIsSheetSelectorExcelVisible(false);
|
|
20
62
|
};
|
|
21
63
|
|
|
22
64
|
return (
|
|
@@ -28,7 +70,11 @@ const TableauDownload = (props) => {
|
|
|
28
70
|
on="click"
|
|
29
71
|
trigger={
|
|
30
72
|
<div className="toolbar-button-wrapper">
|
|
31
|
-
<Button
|
|
73
|
+
<Button
|
|
74
|
+
className="toolbar-button"
|
|
75
|
+
title="Download"
|
|
76
|
+
onClick={hideDropdowns}
|
|
77
|
+
>
|
|
32
78
|
<Icon name={downloadSVG} size="26px" />
|
|
33
79
|
</Button>
|
|
34
80
|
<span className="btn-text">Save</span>
|
|
@@ -40,7 +86,23 @@ const TableauDownload = (props) => {
|
|
|
40
86
|
<p>Select your file format.</p>
|
|
41
87
|
<Button onClick={exportImage}>Image</Button>
|
|
42
88
|
<Button onClick={exportToCSV}>CSV</Button>
|
|
89
|
+
{isSheetSelectorCsvVisible ? (
|
|
90
|
+
<Dropdown
|
|
91
|
+
placeholder="Sheet"
|
|
92
|
+
selection
|
|
93
|
+
options={availableSheets}
|
|
94
|
+
onChange={handleSheetSelectionCsvChange}
|
|
95
|
+
/>
|
|
96
|
+
) : null}
|
|
43
97
|
<Button onClick={exportToExcel}>Excel</Button>
|
|
98
|
+
{isSheetSelectorExcelVisible ? (
|
|
99
|
+
<Dropdown
|
|
100
|
+
placeholder="Sheet"
|
|
101
|
+
selection
|
|
102
|
+
options={availableSheets}
|
|
103
|
+
onChange={handleSheetSelectionExcelChange}
|
|
104
|
+
/>
|
|
105
|
+
) : null}
|
|
44
106
|
</Popup.Content>
|
|
45
107
|
</Popup>
|
|
46
108
|
|