diff --git a/src/Blocks/EmbedVisualization/Edit.jsx b/src/Blocks/EmbedVisualization/Edit.jsx
index ac40afed..9c6ba921 100644
--- a/src/Blocks/EmbedVisualization/Edit.jsx
+++ b/src/Blocks/EmbedVisualization/Edit.jsx
@@ -1,27 +1,84 @@
import React from 'react';
+import { v4 as uuid } from 'uuid';
+import { Segment, Form } from 'semantic-ui-react';
import { SidebarPortal } from '@plone/volto/components';
+import Editor from '@plone/volto/components/manage/Blocks/Text/Edit';
import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
+import ConnectedChart from '@eeacms/volto-plotlycharts/ConnectedChart';
import schema from './schema';
-import View from './View';
-const Edit = (props) => (
- <>
-
+import '@eeacms/volto-plotlycharts/less/visualization.less';
-
- {
- props.onChangeBlock(props.block, {
- ...props.data,
- [id]: value,
- });
- }}
- formData={props.data}
- />
-
- >
-);
+const nope = () => {};
+
+const toolbarId = uuid();
+
+const Edit = (props) => {
+ const { data, block, selected } = props;
+ return (
+ <>
+
+
+
+ {
+ props.onChangeBlock(props.block, {
+ ...props.data,
+ [id]: value,
+ });
+ }}
+ formData={props.data}
+ />
+
+ >
+ );
+};
export default Edit;
diff --git a/src/Blocks/EmbedVisualization/View.jsx b/src/Blocks/EmbedVisualization/View.jsx
index 49072e3f..2e576d6f 100644
--- a/src/Blocks/EmbedVisualization/View.jsx
+++ b/src/Blocks/EmbedVisualization/View.jsx
@@ -1,4 +1,6 @@
import React from 'react';
+import { Grid } from 'semantic-ui-react';
+import ViewText from '@plone/volto/components/manage/Blocks/Text/View';
import ConnectedChart from '@eeacms/volto-plotlycharts/ConnectedChart';
import '@eeacms/volto-plotlycharts/less/visualization.less';
@@ -6,24 +8,65 @@ import '@eeacms/volto-plotlycharts/less/visualization.less';
const View = (props) => {
const { data = {} } = props;
+ const hasText =
+ (data.text?.blocks?.length > 1 && data.text?.blocks) ||
+ (data.text?.blocks?.length === 1 && data.text?.blocks?.[0].text);
+
+ const grid = {
+ text_column: {
+ mobile: 12,
+ tablet: 12,
+ computer: 4,
+ },
+ chart_column: {
+ mobile: 12,
+ tablet: 12,
+ computer: hasText ? 8 : 12,
+ },
+ };
+
return (
-
+ {data.block_title ?
{data.block_title}
: ''}
+
+
+ {hasText ? (
+
+
+
+
+
+ ) : (
+ ''
+ )}
+
+
+
+
+
);
};
diff --git a/src/Blocks/PlotlyChart/Edit.jsx b/src/Blocks/PlotlyChart/Edit.jsx
index 984c5d3d..339199ae 100644
--- a/src/Blocks/PlotlyChart/Edit.jsx
+++ b/src/Blocks/PlotlyChart/Edit.jsx
@@ -5,11 +5,10 @@ import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
import { PickObjectWidget } from '@eeacms/volto-datablocks/components';
import ChartEditor from '@eeacms/volto-plotlycharts/ChartEditor';
-// import ConnectedChart from '@eeacms/volto-plotlycharts/ConnectedChart';
-
import schema from './schema';
import View from './View';
+import '@eeacms/volto-plotlycharts/less/plotly.less';
class PlotlyEditorModal extends Component {
constructor(props) {
super(props);
diff --git a/src/Blocks/PlotlyChart/View.jsx b/src/Blocks/PlotlyChart/View.jsx
index 5069f7dd..471fec0e 100644
--- a/src/Blocks/PlotlyChart/View.jsx
+++ b/src/Blocks/PlotlyChart/View.jsx
@@ -1,7 +1,7 @@
import React from 'react';
import ConnectedChart from '@eeacms/volto-plotlycharts/ConnectedChart';
-import '@eeacms/volto-plotlycharts/less/visualization.less';
+import '@eeacms/volto-plotlycharts/less/plotly.less';
const View = (props) => {
const { data = {} } = props;
diff --git a/src/ConnectedChart/ConnectedChart.jsx b/src/ConnectedChart/ConnectedChart.jsx
index 719199c3..d48b8aae 100644
--- a/src/ConnectedChart/ConnectedChart.jsx
+++ b/src/ConnectedChart/ConnectedChart.jsx
@@ -20,8 +20,10 @@ const LoadablePlotly = loadable(() => import('react-plotly.js'));
function ConnectedChart(props) {
const {
hoverFormatXY,
+ loadingProviderData,
loadingVisualizationData,
provider_data,
+ provider_metadata,
visualization,
visualization_data,
width,
@@ -107,11 +109,9 @@ function ConnectedChart(props) {
) : (
@@ -122,7 +122,10 @@ function ConnectedChart(props) {
}
export default compose(
- connectBlockToVisualization,
+ connectBlockToVisualization((props) => ({
+ vis_url: props.data?.vis_url || null,
+ use_live_data: props.data?.use_live_data ?? true,
+ })),
connectToProviderData((props) => {
const use_live_data = props.data?.use_live_data ?? true;
if (!use_live_data) return {};
diff --git a/src/hocs/connectBlockToVisualization.js b/src/hocs/connectBlockToVisualization.js
index e8e32322..63a4537a 100644
--- a/src/hocs/connectBlockToVisualization.js
+++ b/src/hocs/connectBlockToVisualization.js
@@ -1,4 +1,4 @@
-import React, { useEffect } from 'react';
+import React, { useEffect, useMemo } from 'react';
import { withRouter } from 'react-router';
import { connect, useDispatch } from 'react-redux';
import {
@@ -11,52 +11,58 @@ import {
*
* @param {} WrappedComponent
*/
-export function connectBlockToVisualization(WrappedComponent) {
- return connect((state) => ({
- data_visualizations: state.data_visualizations,
- }))(
- withRouter((props) => {
- const dispatch = useDispatch();
-
- const { vis_url = null, use_live_data = true } = props.data || {};
-
- const isPending = vis_url
- ? props.data_visualizations?.pendingVisualizations?.[vis_url]
- : false;
-
- const isFailed = vis_url
- ? props.data_visualizations?.failedVisualizations?.[vis_url]
- : false;
-
- const visualization_data = vis_url
- ? props.data_visualizations?.data?.[vis_url]
- : null;
-
- const readyToDispatch =
- vis_url && !visualization_data && !isPending && !isFailed;
-
- useEffect(() => {
- if (visualization_data) {
- dispatch(removeVisualization(vis_url));
- }
- /* eslint-disable-next-line */
- }, [use_live_data]);
-
- useEffect(() => {
- if (readyToDispatch) {
- dispatch(getVisualization(vis_url, use_live_data));
- }
- });
-
- return (
-
- );
- }),
- );
+function connectBlockToVisualization(getConfig = () => ({})) {
+ return (WrappedComponent) => {
+ return connect((state) => ({
+ data_visualizations: state.data_visualizations,
+ }))(
+ withRouter((props) => {
+ const dispatch = useDispatch();
+ const config = useMemo(() => getConfig(props), [props]);
+
+ const vis_url = useMemo(() => config.vis_url, [config.vis_url]);
+ const use_live_data = useMemo(() => config.use_live_data ?? true, [
+ config.use_live_data,
+ ]);
+
+ const isPending = vis_url
+ ? props.data_visualizations?.pendingVisualizations?.[vis_url]
+ : false;
+
+ const isFailed = vis_url
+ ? props.data_visualizations?.failedVisualizations?.[vis_url]
+ : false;
+
+ const visualization_data = vis_url
+ ? props.data_visualizations?.data?.[vis_url]
+ : null;
+
+ const readyToDispatch =
+ vis_url && !visualization_data && !isPending && !isFailed;
+
+ useEffect(() => {
+ if (visualization_data) {
+ dispatch(removeVisualization(vis_url));
+ }
+ /* eslint-disable-next-line */
+ }, [use_live_data]);
+
+ useEffect(() => {
+ if (readyToDispatch) {
+ dispatch(getVisualization(vis_url, use_live_data));
+ }
+ });
+
+ return (
+
+ );
+ }),
+ );
+ };
}
export default connectBlockToVisualization;
diff --git a/src/less/visualization.less b/src/less/visualization.less
index e69de29b..2a4287e6 100644
--- a/src/less/visualization.less
+++ b/src/less/visualization.less
@@ -0,0 +1,5 @@
+.embed-visualization {
+ .text-content {
+ margin-top: 1rem;
+ }
+}
\ No newline at end of file