From 1182681e1eccbaf712bef02d38795a8458320bb1 Mon Sep 17 00:00:00 2001 From: Mihai Macaneata Date: Mon, 27 Jan 2020 17:52:50 +0200 Subject: [PATCH] multiple sources --- src/ChartBlock/Edit.jsx | 65 ++++++++++++++++++++++++++++++++++++ src/ChartBlock/View.jsx | 15 ++++----- src/EmbedChartBlock/Edit.jsx | 63 ++++++++++++++++++++++++++++++++++ src/EmbedChartBlock/View.jsx | 14 ++++---- 4 files changed, 140 insertions(+), 17 deletions(-) diff --git a/src/ChartBlock/Edit.jsx b/src/ChartBlock/Edit.jsx index 4fa5f0e0..5b1e81cb 100644 --- a/src/ChartBlock/Edit.jsx +++ b/src/ChartBlock/Edit.jsx @@ -5,6 +5,8 @@ import { Field } from '@plone/volto/components'; // EditBlock import { Segment } from 'semantic-ui-react'; // , Dropdown import 'react-chart-editor/lib/react-chart-editor.css'; +import { TextWidget } from '@plone/volto/components'; +import { Button } from 'semantic-ui-react'; import { SidebarPortal } from '@plone/volto/components'; @@ -150,6 +152,69 @@ class Edit extends Component { }) } /> + {this.props.data.chartSources && + this.props.data.chartSources.length + ? this.props.data.chartSources.map((item, index) => ( + + { + const dataClone = JSON.parse( + JSON.stringify(this.props.data.chartSources), + ); + dataClone[index].chart_source = d; + this.props.onChangeBlock(this.props.block, { + ...this.props.data, + chartSources: dataClone, + }); + }} + /> + { + const dataClone = JSON.parse( + JSON.stringify(this.props.data.chartSources), + ); + dataClone[index].chart_source_link = d; + this.props.onChangeBlock(this.props.block, { + ...this.props.data, + chartSources: dataClone, + }); + }} + /> + + )) + : ''} + diff --git a/src/ChartBlock/View.jsx b/src/ChartBlock/View.jsx index 5c5ccc55..e1f7e4db 100644 --- a/src/ChartBlock/View.jsx +++ b/src/ChartBlock/View.jsx @@ -1,20 +1,17 @@ import React from 'react'; import ConnectedChart from '../ConnectedChart'; - +import SourceView from '~/components/theme/Blocks/SourceView'; const ChartView = props => { return (
- - {props.data.chart_source} - +
diff --git a/src/EmbedChartBlock/Edit.jsx b/src/EmbedChartBlock/Edit.jsx index 03e64930..8f48d960 100644 --- a/src/EmbedChartBlock/Edit.jsx +++ b/src/EmbedChartBlock/Edit.jsx @@ -17,6 +17,8 @@ import MultiValuesEdit from 'volto-datablocks/DataConnectedBlock/MultiValuesEdit import PickVisualization from '../PickVisualization'; import ConnectedChart from '../ConnectedChart'; import { v4 as uuid } from 'uuid'; +import { Button } from 'semantic-ui-react'; +import { TextWidget } from '@plone/volto/components'; const toolbarId = uuid(); @@ -114,6 +116,67 @@ class EmbedChartBlockEdit extends Component { }) } /> + {this.props.data.chartSources && + this.props.data.chartSources.length + ? this.props.data.chartSources.map((item, index) => ( + + { + const dataClone = JSON.parse( + JSON.stringify(this.props.data.chartSources), + ); + dataClone[index].chart_source = d; + this.props.onChangeBlock(this.props.block, { + ...this.props.data, + chartSources: dataClone, + }); + }} + /> + { + const dataClone = JSON.parse( + JSON.stringify(this.props.data.chartSources), + ); + dataClone[index].chart_source_link = d; + this.props.onChangeBlock(this.props.block, { + ...this.props.data, + chartSources: dataClone, + }); + }} + /> + + )) + : ''} + diff --git a/src/EmbedChartBlock/View.jsx b/src/EmbedChartBlock/View.jsx index 7d2f174d..829e68bb 100644 --- a/src/EmbedChartBlock/View.jsx +++ b/src/EmbedChartBlock/View.jsx @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { Grid } from 'semantic-ui-react'; import ConnectedChart from '../ConnectedChart'; import ViewText from '@plone/volto/components/manage/Blocks/Text/View'; +import SourceView from '~/components/theme/Blocks/SourceView'; const EmbedChartView = props => { const hasText = @@ -45,14 +46,11 @@ const EmbedChartView = props => {
- - {props.data.chart_source} - +