Skip to content

Commit

Permalink
Fix chart editor
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Jan 11, 2020
1 parent c35dbeb commit 0f2f2a9
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 57 deletions.
116 changes: 61 additions & 55 deletions src/EmbedChartBlock/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,72 @@ import PickVisualization from '../PickVisualization';
import ConnectedChart from '../ConnectedChart';

class EmbedChartBlockEdit extends Component {
constructor(props) {
super(props);
this.state = {
textEditorSelected: false,
};
}
componentDidMount() {
this.props.changeSidebarState(true);
}

render() {
console.log(this.props);
return (
<div className="block selected">
{this.props.selected && (
<SidebarPortal selected={true}>
<Segment.Group raised>
<header className="header pulled">
<h2>Edit chart options</h2>
</header>
<Segment className="form sidebar-image-data">
<PickVisualization
onLoadChartData={chartData =>
this.props.onChangeBlock(this.props.block, {
...this.props.data,
chartData,
})
}
currentChartData={this.props.data?.chartData}
onChange={url =>
this.props.onChangeBlock(this.props.block, {
...this.props.data,
vis_url: url,
})
}
value={this.props.data?.vis_url || ''}
/>
<Field
title="Source"
id="chart-source"
type="text"
value={this.props.data.chart_source || ''}
required={false}
onChange={(e, d) =>
this.props.onChangeBlock(this.props.block, {
...this.props.data,
chart_source: d,
})
}
/>
<Field
title="Source Link"
id="chart-source-link"
type="text"
value={this.props.data.chart_source_link || ''}
required={false}
onChange={(e, d) =>
this.props.onChangeBlock(this.props.block, {
...this.props.data,
chart_source_link: d,
})
}
/>
</Segment>
</Segment.Group>
</SidebarPortal>
)}
<SidebarPortal selected={this.props.selected}>
<Segment.Group raised>
<header className="header pulled">
<h2>Edit chart options</h2>
</header>
<Segment className="form sidebar-image-data">
<PickVisualization
id={`vis-${this.props.block}`}
onLoadChartData={chartData =>
this.props.onChangeBlock(this.props.block, {
...this.props.data,
chartData,
})
}
currentChartData={this.props.data?.chartData}
onChange={url =>
this.props.onChangeBlock(this.props.block, {
...this.props.data,
vis_url: url,
})
}
value={this.props.data?.vis_url || ''}
/>
<Field
title="Source"
id="chart-source"
type="text"
value={this.props.data.chart_source || ''}
required={false}
onChange={(e, d) =>
this.props.onChangeBlock(this.props.block, {
...this.props.data,
chart_source: d,
})
}
/>
<Field
title="Source Link"
id="chart-source-link"
type="text"
value={this.props.data.chart_source_link || ''}
required={false}
onChange={(e, d) =>
this.props.onChangeBlock(this.props.block, {
...this.props.data,
chart_source_link: d,
})
}
/>
</Segment>
</Segment.Group>
</SidebarPortal>

<div className="block-inner-wrapper">
<Grid columns={2} divided>
Expand All @@ -85,7 +91,7 @@ class EmbedChartBlockEdit extends Component {
<Editor
index={this.props.index}
detached={true}
selected={this.props.selected}
selected={this.state.textEditorSelected}
block={this.props.block}
onAddBlock={this.nop}
onChangeBlock={(id, { text }) => {
Expand All @@ -99,7 +105,7 @@ class EmbedChartBlockEdit extends Component {
onFocusNextBlock={this.nop}
onSelectBlock={this.nop}
onMutateBlock={this.nop}
data={this.props.data.text}
data={this.props.data}
blockNode={this.props.blockNode}
/>
</UiForm>
Expand Down
4 changes: 2 additions & 2 deletions src/PickVisualization/PickVisualization.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PickVisualization extends Component {
// object_provides: 'forests.content.interfaces.IDataVisualization',
portal_type: 'visualization',
},
'getVisualizations',
this.props.id,
);
};

Expand Down Expand Up @@ -59,7 +59,7 @@ export default connect(
(state, props) => {
// const chartData = state.data_providers ? state.data_providers.item : {};
let visualizations = state.search
? state.search.subrequests?.getVisualizations?.items || []
? state.search.subrequests?.[props.id]?.items || []
: [];
visualizations = visualizations.map(el => [el['@id'], el.title]);
return {
Expand Down

0 comments on commit 0f2f2a9

Please sign in to comment.