@eeacms/volto-tableau 4.0.0 → 4.1.0
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 +7 -1
- package/package.json +1 -1
- package/src/Blocks/EmbedTableauVisualization/View.jsx +8 -5
- package/src/Blocks/EmbedTableauVisualization/index.js +3 -3
- package/src/Blocks/EmbedTableauVisualization/schema.js +3 -0
- package/src/Blocks/TableauBlock/Edit.jsx +11 -2
- package/src/Blocks/TableauBlock/View.jsx +47 -44
- package/src/Blocks/TableauBlock/index.js +3 -3
- package/src/Blocks/TableauBlock/schema.js +158 -106
- package/src/Tableau/Tableau.jsx +257 -90
- package/src/Tableau/helpers.js +41 -0
- package/src/Utils/Download/Download.jsx +4 -4
- package/src/Utils/JsonCodeSnippet/JsonCodeSnippet.jsx +48 -0
- package/src/Views/VisualizationView.jsx +10 -4
- package/src/Widgets/VisualizationWidget.jsx +38 -4
- package/src/Widgets/schema.js +115 -73
- package/src/less/tableau.less +46 -3
- package/src/less/tableau.variables +2 -1
|
@@ -8,10 +8,29 @@ import getSchema from './schema';
|
|
|
8
8
|
import '@eeacms/volto-tableau/less/tableau.less';
|
|
9
9
|
|
|
10
10
|
const VisualizationWidget = (props) => {
|
|
11
|
+
const viz = React.useRef();
|
|
12
|
+
const [vizState, setVizState] = React.useState({
|
|
13
|
+
loaded: false,
|
|
14
|
+
loading: false,
|
|
15
|
+
error: null,
|
|
16
|
+
});
|
|
11
17
|
const [open, setOpen] = React.useState(false);
|
|
12
|
-
const [schema] = React.useState(getSchema(config));
|
|
13
18
|
const [value, setValue] = React.useState(props.value);
|
|
14
19
|
|
|
20
|
+
const schema = React.useMemo(() => getSchema(config, viz.current, vizState), [
|
|
21
|
+
vizState,
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const extraOptions = React.useMemo(() => {
|
|
25
|
+
const options = {};
|
|
26
|
+
(value.staticParameters || []).forEach((parameter) => {
|
|
27
|
+
if (parameter.field) {
|
|
28
|
+
options[parameter.field] = parameter.value;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return options;
|
|
32
|
+
}, [value]);
|
|
33
|
+
|
|
15
34
|
const handleApplyChanges = () => {
|
|
16
35
|
props.onChange(props.id, value);
|
|
17
36
|
setOpen(false);
|
|
@@ -52,12 +71,18 @@ const VisualizationWidget = (props) => {
|
|
|
52
71
|
className="tableau-visualization-column"
|
|
53
72
|
>
|
|
54
73
|
<Tableau
|
|
74
|
+
ref={viz}
|
|
55
75
|
data={value}
|
|
76
|
+
mode="edit"
|
|
77
|
+
breakpoints={
|
|
78
|
+
config.blocks.blocksConfig.embed_tableau_visualization
|
|
79
|
+
.breakpoints
|
|
80
|
+
}
|
|
81
|
+
extraOptions={extraOptions}
|
|
82
|
+
setVizState={setVizState}
|
|
56
83
|
onChangeBlock={(_, newValue) => {
|
|
57
84
|
setValue(newValue);
|
|
58
85
|
}}
|
|
59
|
-
mode="edit"
|
|
60
|
-
noSizeUpdate
|
|
61
86
|
/>
|
|
62
87
|
</Grid.Column>
|
|
63
88
|
</Grid>
|
|
@@ -87,7 +112,16 @@ const VisualizationWidget = (props) => {
|
|
|
87
112
|
Open Tableau Editor
|
|
88
113
|
</Button>
|
|
89
114
|
</div>
|
|
90
|
-
<Tableau
|
|
115
|
+
<Tableau
|
|
116
|
+
data={{
|
|
117
|
+
...props.value,
|
|
118
|
+
autoScale: true,
|
|
119
|
+
}}
|
|
120
|
+
breakpoints={
|
|
121
|
+
config.blocks.blocksConfig.embed_tableau_visualization.breakpoints
|
|
122
|
+
}
|
|
123
|
+
extraOptions={extraOptions}
|
|
124
|
+
/>
|
|
91
125
|
</FormFieldWrapper>
|
|
92
126
|
);
|
|
93
127
|
};
|
package/src/Widgets/schema.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSheetnamesChoices,
|
|
3
|
+
canChangeVizData,
|
|
4
|
+
} from '@eeacms/volto-tableau/Tableau/helpers';
|
|
5
|
+
|
|
1
6
|
const urlParametersSchema = {
|
|
2
7
|
title: 'Parameter',
|
|
3
8
|
fieldsets: [
|
|
@@ -16,6 +21,22 @@ const urlParametersSchema = {
|
|
|
16
21
|
required: [],
|
|
17
22
|
};
|
|
18
23
|
|
|
24
|
+
const staticParameters = {
|
|
25
|
+
title: 'Parameter',
|
|
26
|
+
fieldsets: [{ id: 'default', title: 'Default', fields: ['field', 'value'] }],
|
|
27
|
+
properties: {
|
|
28
|
+
field: {
|
|
29
|
+
title: 'Tableau fieldname',
|
|
30
|
+
type: 'text',
|
|
31
|
+
},
|
|
32
|
+
value: {
|
|
33
|
+
title: 'Value',
|
|
34
|
+
type: 'text',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
required: [],
|
|
38
|
+
};
|
|
39
|
+
|
|
19
40
|
const breakpointUrlSchema = (config) => {
|
|
20
41
|
const breakpoints = config.blocks.blocksConfig.tableau_block.breakpoints;
|
|
21
42
|
|
|
@@ -25,7 +46,6 @@ const breakpointUrlSchema = (config) => {
|
|
|
25
46
|
properties: {
|
|
26
47
|
device: {
|
|
27
48
|
title: 'Device',
|
|
28
|
-
type: 'array',
|
|
29
49
|
choices: Object.keys(breakpoints).map((breakpoint) => [
|
|
30
50
|
breakpoint,
|
|
31
51
|
breakpoint,
|
|
@@ -40,76 +60,98 @@ const breakpointUrlSchema = (config) => {
|
|
|
40
60
|
};
|
|
41
61
|
};
|
|
42
62
|
|
|
43
|
-
export default (config) =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
63
|
+
export default (config, viz, vizState) => {
|
|
64
|
+
const isDisabled = !canChangeVizData(viz, vizState);
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
title: 'Tableau',
|
|
68
|
+
fieldsets: [
|
|
69
|
+
{
|
|
70
|
+
id: 'default',
|
|
71
|
+
title: 'Default',
|
|
72
|
+
fields: ['url'],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 'options',
|
|
76
|
+
title: 'Options',
|
|
77
|
+
fields: [
|
|
78
|
+
'sheetname',
|
|
79
|
+
'hideTabs',
|
|
80
|
+
'hideToolbar',
|
|
81
|
+
'autoScale',
|
|
82
|
+
'toolbarPosition',
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'extra_options',
|
|
87
|
+
title: 'Extra options',
|
|
88
|
+
fields: ['urlParameters', 'staticParameters', 'breakpointUrls'],
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
properties: {
|
|
92
|
+
url: {
|
|
93
|
+
title: 'Url',
|
|
94
|
+
widget: 'textarea',
|
|
95
|
+
isDisabled,
|
|
96
|
+
},
|
|
97
|
+
sheetname: {
|
|
98
|
+
title: 'Sheetname',
|
|
99
|
+
choices: getSheetnamesChoices(viz),
|
|
100
|
+
isDisabled,
|
|
101
|
+
},
|
|
102
|
+
hideTabs: {
|
|
103
|
+
title: 'Hide tabs',
|
|
104
|
+
type: 'boolean',
|
|
105
|
+
isDisabled,
|
|
106
|
+
},
|
|
107
|
+
hideToolbar: {
|
|
108
|
+
title: 'Hide toolbar',
|
|
109
|
+
type: 'boolean',
|
|
110
|
+
isDisabled,
|
|
111
|
+
},
|
|
112
|
+
autoScale: {
|
|
113
|
+
title: 'Auto scale',
|
|
114
|
+
type: 'boolean',
|
|
115
|
+
description: 'Scale down tableau according to width',
|
|
116
|
+
isDisabled,
|
|
117
|
+
},
|
|
118
|
+
toolbarPosition: {
|
|
119
|
+
title: 'Toolbar position',
|
|
120
|
+
choices: [
|
|
121
|
+
['Top', 'Top'],
|
|
122
|
+
['Bottom', 'Bottom'],
|
|
123
|
+
],
|
|
124
|
+
default: 'Top',
|
|
125
|
+
isDisabled,
|
|
126
|
+
},
|
|
127
|
+
urlParameters: {
|
|
128
|
+
title: 'URL parameters',
|
|
129
|
+
widget: 'object_list',
|
|
130
|
+
schema: urlParametersSchema,
|
|
131
|
+
description: 'Set a list of url parameters to filter the tableau',
|
|
132
|
+
isDisabled,
|
|
133
|
+
},
|
|
134
|
+
staticParameters: {
|
|
135
|
+
title: 'Static parameters',
|
|
136
|
+
widget: 'object_list',
|
|
137
|
+
schema: staticParameters,
|
|
138
|
+
description: (
|
|
139
|
+
<>
|
|
140
|
+
Set a list of static parameters.
|
|
141
|
+
<br />
|
|
142
|
+
<b>NOTE: You need to trigger a refresh for this to take effect</b>
|
|
143
|
+
</>
|
|
144
|
+
),
|
|
145
|
+
isDisabled,
|
|
146
|
+
},
|
|
147
|
+
breakpointUrls: {
|
|
148
|
+
title: 'Breakpoint urls',
|
|
149
|
+
widget: 'object_list',
|
|
150
|
+
schema: breakpointUrlSchema(config),
|
|
151
|
+
description: 'Set different vizualization for specific breakpoint',
|
|
152
|
+
isDisabled,
|
|
153
|
+
},
|
|
112
154
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
155
|
+
required: ['url'],
|
|
156
|
+
};
|
|
157
|
+
};
|
package/src/less/tableau.less
CHANGED
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.tableau-wrapper {
|
|
20
|
-
overflow: auto;
|
|
21
20
|
padding: @tableauWrapperPadding;
|
|
21
|
+
margin: @tableauWrapperMargin;
|
|
22
22
|
background-color: @tableauWrapperBackground;
|
|
23
23
|
|
|
24
24
|
.tableau-debug {
|
|
@@ -30,10 +30,20 @@
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
.tableau-info {
|
|
33
|
-
margin: 0 auto
|
|
33
|
+
margin: 0 auto;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
.tableau {
|
|
37
|
+
margin-bottom: 1rem;
|
|
38
|
+
|
|
39
|
+
&:not(.tableau-autoscale) {
|
|
40
|
+
overflow: auto;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.tableau-autoscale {
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
iframe {
|
|
38
48
|
padding: @tableauIframePadding;
|
|
39
49
|
border: @tableauIframeBorder;
|
|
@@ -47,7 +57,7 @@
|
|
|
47
57
|
display: flex;
|
|
48
58
|
overflow: hidden;
|
|
49
59
|
width: 100%;
|
|
50
|
-
height:
|
|
60
|
+
height: auto;
|
|
51
61
|
align-items: center;
|
|
52
62
|
justify-content: center;
|
|
53
63
|
margin: 0 auto 1rem auto;
|
|
@@ -71,6 +81,39 @@
|
|
|
71
81
|
text-align: center;
|
|
72
82
|
}
|
|
73
83
|
}
|
|
84
|
+
|
|
85
|
+
.tableau-error {
|
|
86
|
+
color: @errorTextColor;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.reload-tableau {
|
|
90
|
+
position: absolute;
|
|
91
|
+
right: 1rem;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.json-snippet {
|
|
95
|
+
.key {
|
|
96
|
+
color: @secondaryColor;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.important-note {
|
|
101
|
+
color: @secondaryColor;
|
|
102
|
+
|
|
103
|
+
.clear-filter-button {
|
|
104
|
+
padding: 0;
|
|
105
|
+
border: none;
|
|
106
|
+
margin: 0;
|
|
107
|
+
background-color: transparent;
|
|
108
|
+
color: inherit;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
text-decoration: underline;
|
|
111
|
+
|
|
112
|
+
&:hover {
|
|
113
|
+
color: @primaryColor;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
74
117
|
}
|
|
75
118
|
|
|
76
119
|
// ========= Sources ==========
|